summaryrefslogtreecommitdiffstats
path: root/services/usb/java/com/android/server
diff options
context:
space:
mode:
Diffstat (limited to 'services/usb/java/com/android/server')
-rw-r--r--services/usb/java/com/android/server/usb/UsbAlsaManager.java2
-rw-r--r--services/usb/java/com/android/server/usb/UsbDeviceManager.java53
-rw-r--r--services/usb/java/com/android/server/usb/UsbSettingsManager.java2
3 files changed, 45 insertions, 12 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbAlsaManager.java b/services/usb/java/com/android/server/usb/UsbAlsaManager.java
index 31763e7..701272e 100644
--- a/services/usb/java/com/android/server/usb/UsbAlsaManager.java
+++ b/services/usb/java/com/android/server/usb/UsbAlsaManager.java
@@ -439,7 +439,7 @@ public final class UsbAlsaManager {
UsbAudioDevice audioDevice = mAudioDevices.remove(usbDevice);
if (audioDevice != null) {
- if (audioDevice.mHasPlayback || audioDevice.mHasPlayback) {
+ if (audioDevice.mHasPlayback || audioDevice.mHasCapture) {
notifyDeviceState(audioDevice, false);
// if there any external devices left, select one of them
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index a4a4d84..34a17a2 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -51,6 +51,7 @@ import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.FgThread;
+import cyanogenmod.providers.CMSettings;
import java.io.File;
import java.io.FileNotFoundException;
@@ -322,7 +323,7 @@ public class UsbDeviceManager {
private boolean mCurrentFunctionsApplied;
private UsbAccessory mCurrentAccessory;
private int mUsbNotificationId;
- private boolean mAdbNotificationShown;
+ private int mAdbNotificationId;
private int mCurrentUser = UserHandle.USER_NULL;
public UsbHandler(Looper looper) {
@@ -348,6 +349,20 @@ public class UsbDeviceManager {
Settings.Global.getUriFor(Settings.Global.ADB_ENABLED),
false, new AdbSettingsObserver());
+ ContentObserver adbNotificationObserver = new ContentObserver(null) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updateAdbNotification();
+ }
+ };
+
+ mContentResolver.registerContentObserver(
+ CMSettings.Secure.getUriFor(CMSettings.Secure.ADB_PORT),
+ false, adbNotificationObserver);
+ mContentResolver.registerContentObserver(
+ CMSettings.Secure.getUriFor(CMSettings.Secure.ADB_NOTIFY),
+ false, adbNotificationObserver);
+
// Watch for USB configuration changes
mUEventObserver.startObserving(USB_STATE_MATCH);
mUEventObserver.startObserving(ACCESSORY_START_MATCH);
@@ -794,15 +809,35 @@ public class UsbDeviceManager {
private void updateAdbNotification() {
if (mNotificationManager == null) return;
- final int id = com.android.internal.R.string.adb_active_notification_title;
- if (mAdbEnabled && mConnected) {
- if ("0".equals(SystemProperties.get("persist.adb.notify"))) return;
+ final int id;
+ boolean usbAdbActive = mAdbEnabled && mConnected;
+ boolean netAdbActive = mAdbEnabled &&
+ CMSettings.Secure.getInt(mContentResolver, CMSettings.Secure.ADB_PORT, -1) > 0;
+ boolean hideNotification = "0".equals(SystemProperties.get("persist.adb.notify"))
+ || CMSettings.Secure.getInt(mContext.getContentResolver(),
+ CMSettings.Secure.ADB_NOTIFY, 1) == 0;
+
+ if (hideNotification) {
+ id = 0;
+ } else if (usbAdbActive && netAdbActive) {
+ id = com.android.internal.R.string.adb_both_active_notification_title;
+ } else if (usbAdbActive) {
+ id = com.android.internal.R.string.adb_active_notification_title;
+ } else if (netAdbActive) {
+ id = com.android.internal.R.string.adb_net_active_notification_title;
+ } else {
+ id = 0;
+ }
- if (!mAdbNotificationShown) {
+ if (id != mAdbNotificationId) {
+ if (mAdbNotificationId != 0) {
+ mNotificationManager.cancelAsUser(null, mAdbNotificationId, UserHandle.ALL);
+ }
+ if (id != 0) {
Resources r = mContext.getResources();
CharSequence title = r.getText(id);
CharSequence message = r.getText(
- com.android.internal.R.string.adb_active_notification_message);
+ com.android.internal.R.string.adb_active_generic_notification_message);
Intent intent = Intent.makeRestartActivityTask(
new ComponentName("com.android.settings",
@@ -824,13 +859,11 @@ public class UsbDeviceManager {
.setContentIntent(pi)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.build();
- mAdbNotificationShown = true;
+
mNotificationManager.notifyAsUser(null, id, notification,
UserHandle.ALL);
}
- } else if (mAdbNotificationShown) {
- mAdbNotificationShown = false;
- mNotificationManager.cancelAsUser(null, id, UserHandle.ALL);
+ mAdbNotificationId = id;
}
}
diff --git a/services/usb/java/com/android/server/usb/UsbSettingsManager.java b/services/usb/java/com/android/server/usb/UsbSettingsManager.java
index 2cf42f0..674952c 100644
--- a/services/usb/java/com/android/server/usb/UsbSettingsManager.java
+++ b/services/usb/java/com/android/server/usb/UsbSettingsManager.java
@@ -739,7 +739,7 @@ class UsbSettingsManager {
}
// Send broadcast to running activity with registered intent
- mUserContext.sendBroadcast(intent);
+ mUserContext.sendBroadcastAsUser(intent, UserHandle.ALL);
// Start activity with registered intent
resolveActivity(intent, matches, defaultPackage, device, null);