diff options
author | Mike Lockwood <lockwood@android.com> | 2009-08-04 17:03:15 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-08-04 17:03:15 -0400 |
commit | ea8b7d568ad640d464725d1e21efa0c9fd1de953 (patch) | |
tree | aab4d85272ceb7b1811d04f6c21a4e0cb865446d /services | |
parent | cd9e8d49071d10ad2d64530070a5c82fe2f49902 (diff) | |
download | frameworks_base-ea8b7d568ad640d464725d1e21efa0c9fd1de953.zip frameworks_base-ea8b7d568ad640d464725d1e21efa0c9fd1de953.tar.gz frameworks_base-ea8b7d568ad640d464725d1e21efa0c9fd1de953.tar.bz2 |
Use USB notification instead of battery notification for USB debugging warning.
Fixes a problem with false positives that occurred when connecting an AC charger slowly.
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/NotificationManagerService.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index aac7124..5dad8d0 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -96,7 +96,7 @@ class NotificationManagerService extends INotificationManager.Stub private Vibrator mVibrator = new Vibrator(); // adb - private int mBatteryPlugged; + private boolean mUsbConnected; private boolean mAdbEnabled = false; private boolean mAdbNotificationShown = false; private Notification mAdbNotification; @@ -310,8 +310,11 @@ class NotificationManagerService extends INotificationManager.Stub mBatteryFull = batteryFull; updateLights(); } - - mBatteryPlugged = intent.getIntExtra("plugged", 0); + } else if (action.equals(Intent.ACTION_UMS_CONNECTED)) { + mUsbConnected = true; + updateAdbNotification(); + } else if (action.equals(Intent.ACTION_UMS_DISCONNECTED)) { + mUsbConnected = false; updateAdbNotification(); } else if (action.equals(Intent.ACTION_PACKAGE_REMOVED) || action.equals(Intent.ACTION_PACKAGE_RESTARTED)) { @@ -380,6 +383,8 @@ class NotificationManagerService extends INotificationManager.Stub // register for battery changed notifications IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); + filter.addAction(Intent.ACTION_UMS_CONNECTED); + filter.addAction(Intent.ACTION_UMS_DISCONNECTED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_RESTARTED); mContext.registerReceiver(mIntentReceiver, filter); @@ -954,7 +959,7 @@ class NotificationManagerService extends INotificationManager.Stub // security feature that we don't want people customizing the platform // to accidentally lose. private void updateAdbNotification() { - if (mAdbEnabled && mBatteryPlugged == BatteryManager.BATTERY_PLUGGED_USB) { + if (mAdbEnabled && mUsbConnected) { if ("0".equals(SystemProperties.get("persist.adb.notify"))) { return; } |