diff options
Diffstat (limited to 'services/usb/java/com/android/server')
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbDeviceManager.java | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index 09e15a8..2beb669 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -330,6 +330,14 @@ public class UsbDeviceManager { mContentResolver.registerContentObserver( Settings.Global.getUriFor(Settings.Global.ADB_ENABLED), false, new AdbSettingsObserver()); + mContentResolver.registerContentObserver( + Settings.Secure.getUriFor(Settings.Secure.ADB_NOTIFY), + false, new ContentObserver(null) { + public void onChange(boolean selfChange) { + updateAdbNotification(); + } + } + ); // Watch for USB configuration changes mUEventObserver.startObserving(USB_STATE_MATCH); @@ -768,39 +776,40 @@ 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; - - if (!mAdbNotificationShown) { - Resources r = mContext.getResources(); - CharSequence title = r.getText(id); - CharSequence message = r.getText( - com.android.internal.R.string.adb_active_notification_message); - - Intent intent = Intent.makeRestartActivityTask( - new ComponentName("com.android.settings", - "com.android.settings.DevelopmentSettings")); - PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, - intent, 0, null, UserHandle.CURRENT); - - Notification notification = new Notification.Builder(mContext) - .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) - .setWhen(0) - .setOngoing(true) - .setTicker(title) - .setDefaults(0) // please be quiet - .setPriority(Notification.PRIORITY_LOW) - .setColor(mContext.getColor( - com.android.internal.R.color.system_notification_accent_color)) - .setContentTitle(title) - .setContentText(message) - .setContentIntent(pi) - .setVisibility(Notification.VISIBILITY_PUBLIC) - .build(); - mAdbNotificationShown = true; - mNotificationManager.notifyAsUser(null, id, notification, - UserHandle.ALL); - } + boolean hideNotification = "0".equals(SystemProperties.get("persist.adb.notify")) + || Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.ADB_NOTIFY, 1) == 0; + + if (mAdbEnabled && mConnected && !mAdbNotificationShown && !hideNotification) { + Resources r = mContext.getResources(); + CharSequence title = r.getText(id); + CharSequence message = r.getText( + com.android.internal.R.string.adb_active_notification_message); + + Intent intent = Intent.makeRestartActivityTask( + new ComponentName("com.android.settings", + "com.android.settings.DevelopmentSettings")); + PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, + intent, 0, null, UserHandle.CURRENT); + + Notification notification = new Notification.Builder(mContext) + .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) + .setWhen(0) + .setOngoing(true) + .setTicker(title) + .setDefaults(0) // please be quiet + .setPriority(Notification.PRIORITY_LOW) + .setColor(mContext.getColor( + com.android.internal.R.color.system_notification_accent_color)) + .setContentTitle(title) + .setContentText(message) + .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); |