Skip to content

Implemented Voice Controlled Device#50

Open
gaurav123-4 wants to merge 1 commit into
A-Akhil:mainfrom
gaurav123-4:gsoc-2025Gaurav
Open

Implemented Voice Controlled Device#50
gaurav123-4 wants to merge 1 commit into
A-Akhil:mainfrom
gaurav123-4:gsoc-2025Gaurav

Conversation

@gaurav123-4

Copy link
Copy Markdown

@A-Akhil @Navdeep-lab Please Check

@Navdeep-lab

Copy link
Copy Markdown
Collaborator

@gaurav123-4 ...did you check all the bugs? and can you please send me the output you are obtaining so i can proceed with merging

@gaurav123-4

Copy link
Copy Markdown
Author

@gaurav123-4 ...did you check all the bugs? and can you please send me the output you are obtaining so i can proceed with merging

yes there are no bugs .i will provide you the output

@gaurav123-4

gaurav123-4 commented Jul 28, 2025

Copy link
Copy Markdown
Author

Output-> Task :app:assembleDebug
BUILD SUCCESSFUL in 15s
30 actionable tasks: 30 executed

Performing Streamed Install
Success

How to Check Voice Control Is Working
After launching the app:

Tap the microphone or command button (if available).

Speak a prompt like “What’s the weather today?” or “Schedule a meeting.”

You should see:

Transcribed input

AI-generated response on screen

@gaurav123-4

Copy link
Copy Markdown
Author

Issue #23 Please check

@A-Akhil A-Akhil requested a review from Copilot August 4, 2025 05:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements voice-controlled device management functionality for the AI Secretary app, enabling users to control system settings like brightness, volume, WiFi, and Bluetooth through voice commands.

  • Adds comprehensive device control system with voice command processing
  • Implements permission management for system-level access
  • Creates settings UI for device control configuration

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
DeviceControlSettingsFragment.kt New settings fragment for configuring device control permissions and features
ChatViewModel.kt Integrates device control processing into chat flow and adds device status monitoring
AppModule.kt Adds dependency injection for device control components
SettingsManager.kt Adds preferences for device control settings
MemoryManager.kt Adds device control command pattern recognition
DeviceVoiceProcessor.kt Processes voice commands for device operations
DeviceStatusMonitor.kt Monitors and reports device status
DevicePermissionManager.kt Manages device control permissions
DeviceControlManager.kt Core device control operations
AndroidManifest.xml Adds required permissions for device control
Comments suppressed due to low confidence (2)

app/src/main/kotlin/com/example/aisecretary/ui/chat/ChatViewModel.kt:182

  • DeviceControlManager is created in multiple places (here and in DeviceVoiceProcessor). Consider storing it as a class property to avoid multiple instances and ensure consistency.
                    }

app/src/main/kotlin/com/example/aisecretary/ai/device/DevicePermissionManager.kt:28

  • The WRITE_SETTINGS permission in AndroidManifest.xml has maxSdkVersion="22" which conflicts with the runtime check for Build.VERSION.SDK_INT >= Build.VERSION_CODES.M (API 23+). This could cause permission issues on newer devices.
     * Check if WRITE_SETTINGS permission is granted

// Device control components
private val deviceVoiceProcessor = AppModule.provideDeviceVoiceProcessor(getApplication())
private val devicePermissionManager = AppModule.provideDevicePermissionManager(getApplication())
private val deviceStatusMonitor = DeviceStatusMonitor(getApplication())

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deviceStatusMonitor is instantiated directly instead of using dependency injection like other components. Consider using AppModule.provideDeviceStatusMonitor() for consistency.

Suggested change
private val deviceStatusMonitor = DeviceStatusMonitor(getApplication())
private val deviceStatusMonitor = AppModule.provideDeviceStatusMonitor(getApplication())

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +16
class DeviceVoiceProcessor(private val context: Context) {

private val deviceControlManager = DeviceControlManager(context)

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeviceControlManager is instantiated directly instead of using the provided AppModule method. This creates inconsistency with other parts of the codebase that use dependency injection.

Suggested change
class DeviceVoiceProcessor(private val context: Context) {
private val deviceControlManager = DeviceControlManager(context)
class DeviceVoiceProcessor(
private val context: Context,
private val deviceControlManager: DeviceControlManager
) {

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +20
class DeviceStatusMonitor(private val context: Context) {

private val deviceControlManager = DeviceControlManager(context)

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeviceControlManager is instantiated directly instead of using the provided AppModule method. This creates inconsistency with dependency injection patterns used elsewhere.

Suggested change
class DeviceStatusMonitor(private val context: Context) {
private val deviceControlManager = DeviceControlManager(context)
class DeviceStatusMonitor(
private val context: Context,
private val deviceControlManager: DeviceControlManager
) {

Copilot uses AI. Check for mistakes.
private val _bluetoothStatus = MutableStateFlow(DeviceStatus.Bluetooth(isBluetoothEnabled()))

// Combined status flow
val deviceStatus: StateFlow<DeviceStatusSummary> = combine(

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combine operation creates a new StateFlow that recalculates whenever any of the component flows change. Consider adding a debounce or throttle mechanism to prevent excessive updates when multiple device states change rapidly.

Copilot uses AI. Check for mistakes.
/**
* Log audit event for security tracking
*/
private fun logAuditEvent(action: String, details: String) {

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The audit log is stored in plain text in internal storage without encryption. Consider encrypting sensitive audit information to protect user privacy.

Copilot uses AI. Check for mistakes.
if (bluetoothAdapter == null) {
return DeviceControlResult.Error("Bluetooth not available on this device")
}

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bluetooth enable/disable operations should check for appropriate permissions (BLUETOOTH_CONNECT on API 31+) before executing to prevent SecurityExceptions.

Suggested change
// Check BLUETOOTH_CONNECT permission on API 31+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val permission = android.Manifest.permission.BLUETOOTH_CONNECT
val hasPermission = ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED
if (!hasPermission) {
return DeviceControlResult.Error("Missing BLUETOOTH_CONNECT permission. Please grant permission to control Bluetooth.")
}
}

Copilot uses AI. Check for mistakes.
val instructions = devicePermissionManager.getPermissionRequestInstructions(permission)

val message = "$explanation\n\n$instructions"
Toast.makeText(requireContext(), message, Toast.LENGTH_LONG).show()

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using Toast for permission instructions may not provide the best user experience. Consider using a custom dialog or bottom sheet for better visibility and user interaction.

Suggested change
Toast.makeText(requireContext(), message, Toast.LENGTH_LONG).show()
AlertDialog.Builder(requireContext())
.setTitle("Permission Instructions")
.setMessage(message)
.setPositiveButton("OK", null)
.show()

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +122
// For Android 10+, we need to guide user to system settings
return DeviceControlResult.RequiresUserAction(
"Please enable/disable WiFi manually in system settings",
Intent(Settings.ACTION_WIFI_SETTINGS)
)
}

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecated setWifiEnabled method is used without checking if it's supported. For Android 10+, this method is deprecated and may not work. The code handles this with a version check but could be clearer about the limitation.

Suggested change
// For Android 10+, we need to guide user to system settings
return DeviceControlResult.RequiresUserAction(
"Please enable/disable WiFi manually in system settings",
Intent(Settings.ACTION_WIFI_SETTINGS)
)
}
// Programmatic WiFi enable/disable is not supported on Android 10+ (API 29+)
Log.w("DeviceControlManager", "setWifiEnabled: Programmatic WiFi control is not supported on Android 10+ (API 29+). Guiding user to system settings.")
return DeviceControlResult.RequiresUserAction(
"Please enable/disable WiFi manually in system settings",
Intent(Settings.ACTION_WIFI_SETTINGS)
)
}
// On Android 9 and below, programmatic WiFi control is allowed

Copilot uses AI. Check for mistakes.
@A-Akhil

A-Akhil commented Aug 4, 2025

Copy link
Copy Markdown
Owner

@AkshitTiwarii kindly review this comments by @copilot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants