diff options
author | Tanguy Pruvot <tanguy.pruvot@gmail.com> | 2012-11-27 14:09:18 -0500 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-25 21:49:35 -0700 |
commit | 277dd1c16851511431c34028d9e99dafa80b849e (patch) | |
tree | 2859ca4ecc29673bbed0c5b27f22b22ef4fbf76c | |
parent | b2dd57b05867e3b3ad54c480adb812b965796125 (diff) | |
download | frameworks_base-277dd1c16851511431c34028d9e99dafa80b849e.zip frameworks_base-277dd1c16851511431c34028d9e99dafa80b849e.tar.gz frameworks_base-277dd1c16851511431c34028d9e99dafa80b849e.tar.bz2 |
Port "Option to hide Adb notification icon (2/2)"
Change-Id: I5d40f5b0990fa3a1d02210ad4cc2ff5ada15e69c
-rw-r--r-- | core/java/android/provider/Settings.java | 6 | ||||
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbDeviceManager.java | 75 |
2 files changed, 48 insertions, 33 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 3075a62..32f1af5 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4695,6 +4695,12 @@ public final class Settings { public static final String ADB_ENABLED = Global.ADB_ENABLED; /** + * Whether to display the ADB notification. + * @hide + */ + public static final String ADB_NOTIFY = "adb_notify"; + + /** * Setting to allow mock locations and location provider status to be injected into the * LocationManager service for testing purposes during application development. These * locations and status values override actual location and status information generated 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); |