Loading services/java/com/android/server/usb/UsbDeviceManager.java +23 −26 Original line number Original line Diff line number Diff line Loading @@ -322,8 +322,6 @@ public class UsbDeviceManager { String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim(); String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim(); updateState(state); updateState(state); mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB); mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB); mAudioSourceEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_AUDIO_SOURCE); // Upgrade step for previous versions that used persist.service.adb.enable // Upgrade step for previous versions that used persist.service.adb.enable String value = SystemProperties.get("persist.service.adb.enable", ""); String value = SystemProperties.get("persist.service.adb.enable", ""); Loading Loading @@ -537,7 +535,10 @@ public class UsbDeviceManager { mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent); } } private void updateAudioSourceFunction(boolean enabled) { private void updateAudioSourceFunction() { boolean enabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_AUDIO_SOURCE); if (enabled != mAudioSourceEnabled) { // send a sticky broadcast containing current USB state // send a sticky broadcast containing current USB state Intent intent = new Intent(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG); Intent intent = new Intent(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); Loading @@ -554,10 +555,10 @@ public class UsbDeviceManager { Slog.e(TAG, "could not open audio source PCM file", e); Slog.e(TAG, "could not open audio source PCM file", e); } } } } mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent); mAudioSourceEnabled = enabled; mAudioSourceEnabled = enabled; } } } @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { Loading @@ -578,11 +579,7 @@ public class UsbDeviceManager { } } if (mBootCompleted) { if (mBootCompleted) { updateUsbState(); updateUsbState(); boolean audioSourceEnabled = containsFunction(mCurrentFunctions, updateAudioSourceFunction(); UsbManager.USB_FUNCTION_AUDIO_SOURCE); if (audioSourceEnabled != mAudioSourceEnabled) { updateAudioSourceFunction(audioSourceEnabled); } } } break; break; case MSG_ENABLE_ADB: case MSG_ENABLE_ADB: Loading @@ -597,13 +594,13 @@ public class UsbDeviceManager { updateUsbNotification(); updateUsbNotification(); updateAdbNotification(); updateAdbNotification(); updateUsbState(); updateUsbState(); updateAudioSourceFunction(); break; break; case MSG_BOOT_COMPLETED: case MSG_BOOT_COMPLETED: mBootCompleted = true; mBootCompleted = true; if (mCurrentAccessory != null) { if (mCurrentAccessory != null) { mSettingsManager.accessoryAttached(mCurrentAccessory); mSettingsManager.accessoryAttached(mCurrentAccessory); } } updateAudioSourceFunction(mAudioSourceEnabled); break; break; } } } } Loading Loading
services/java/com/android/server/usb/UsbDeviceManager.java +23 −26 Original line number Original line Diff line number Diff line Loading @@ -322,8 +322,6 @@ public class UsbDeviceManager { String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim(); String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim(); updateState(state); updateState(state); mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB); mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB); mAudioSourceEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_AUDIO_SOURCE); // Upgrade step for previous versions that used persist.service.adb.enable // Upgrade step for previous versions that used persist.service.adb.enable String value = SystemProperties.get("persist.service.adb.enable", ""); String value = SystemProperties.get("persist.service.adb.enable", ""); Loading Loading @@ -537,7 +535,10 @@ public class UsbDeviceManager { mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent); } } private void updateAudioSourceFunction(boolean enabled) { private void updateAudioSourceFunction() { boolean enabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_AUDIO_SOURCE); if (enabled != mAudioSourceEnabled) { // send a sticky broadcast containing current USB state // send a sticky broadcast containing current USB state Intent intent = new Intent(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG); Intent intent = new Intent(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); Loading @@ -554,10 +555,10 @@ public class UsbDeviceManager { Slog.e(TAG, "could not open audio source PCM file", e); Slog.e(TAG, "could not open audio source PCM file", e); } } } } mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent); mAudioSourceEnabled = enabled; mAudioSourceEnabled = enabled; } } } @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { Loading @@ -578,11 +579,7 @@ public class UsbDeviceManager { } } if (mBootCompleted) { if (mBootCompleted) { updateUsbState(); updateUsbState(); boolean audioSourceEnabled = containsFunction(mCurrentFunctions, updateAudioSourceFunction(); UsbManager.USB_FUNCTION_AUDIO_SOURCE); if (audioSourceEnabled != mAudioSourceEnabled) { updateAudioSourceFunction(audioSourceEnabled); } } } break; break; case MSG_ENABLE_ADB: case MSG_ENABLE_ADB: Loading @@ -597,13 +594,13 @@ public class UsbDeviceManager { updateUsbNotification(); updateUsbNotification(); updateAdbNotification(); updateAdbNotification(); updateUsbState(); updateUsbState(); updateAudioSourceFunction(); break; break; case MSG_BOOT_COMPLETED: case MSG_BOOT_COMPLETED: mBootCompleted = true; mBootCompleted = true; if (mCurrentAccessory != null) { if (mCurrentAccessory != null) { mSettingsManager.accessoryAttached(mCurrentAccessory); mSettingsManager.accessoryAttached(mCurrentAccessory); } } updateAudioSourceFunction(mAudioSourceEnabled); break; break; } } } } Loading