summaryrefslogtreecommitdiffstats
path: root/services/usb
diff options
context:
space:
mode:
authorTanguy Pruvot <tanguy.pruvot@gmail.com>2012-11-27 14:09:18 -0500
committerSteve Kondik <steve@cyngn.com>2015-10-25 21:49:35 -0700
commit277dd1c16851511431c34028d9e99dafa80b849e (patch)
tree2859ca4ecc29673bbed0c5b27f22b22ef4fbf76c /services/usb
parentb2dd57b05867e3b3ad54c480adb812b965796125 (diff)
downloadframeworks_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
Diffstat (limited to 'services/usb')
-rw-r--r--services/usb/java/com/android/server/usb/UsbDeviceManager.java75
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);