Loading services/java/com/android/server/NotificationManagerService.java +29 −2 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ public class NotificationManagerService extends INotificationManager.Stub private boolean mGreenLightOn = false; // for adb connected notifications private boolean mUsbConnected = false; private boolean mAdbNotificationShown = false; private Notification mAdbNotification; Loading Loading @@ -405,10 +406,10 @@ public class NotificationManagerService extends INotificationManager.Stub } } else if (action.equals(Usb.ACTION_USB_STATE)) { Bundle extras = intent.getExtras(); boolean usbConnected = extras.getBoolean(Usb.USB_CONNECTED); mUsbConnected = extras.getBoolean(Usb.USB_CONNECTED); boolean adbEnabled = (Usb.USB_FUNCTION_ENABLED.equals( extras.getString(Usb.USB_FUNCTION_ADB))); updateAdbNotification(usbConnected && adbEnabled); updateAdbNotification(mUsbConnected && adbEnabled); } else if (action.equals(Usb.ACTION_USB_DISCONNECTED)) { updateAdbNotification(false); } else if (action.equals(Intent.ACTION_PACKAGE_REMOVED) Loading Loading @@ -549,6 +550,29 @@ public class NotificationManagerService extends INotificationManager.Stub } } class AdbNotifyObserver extends ContentObserver { AdbNotifyObserver(Handler handler) { super(handler); } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.ADB_ENABLED), false, this); resolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.ADB_NOTIFY), false, this); } @Override public void onChange(boolean selfChange) { ContentResolver resolver = mContext.getContentResolver(); boolean adbEnabled = Settings.Secure.getInt(resolver, Settings.Secure.ADB_ENABLED, 0) != 0; boolean notifyEnabled = Settings.Secure.getInt(resolver, Settings.Secure.ADB_NOTIFY, 1) != 0; updateAdbNotification(adbEnabled && notifyEnabled && mUsbConnected); } } NotificationManagerService(Context context, StatusBarManagerService statusBar, LightsService lights) { Loading Loading @@ -604,6 +628,9 @@ public class NotificationManagerService extends INotificationManager.Stub SettingsObserver observer = new SettingsObserver(mHandler); observer.observe(); AdbNotifyObserver notifyObserver = new AdbNotifyObserver(mHandler); notifyObserver.observe(); } void systemReady() { Loading Loading
services/java/com/android/server/NotificationManagerService.java +29 −2 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ public class NotificationManagerService extends INotificationManager.Stub private boolean mGreenLightOn = false; // for adb connected notifications private boolean mUsbConnected = false; private boolean mAdbNotificationShown = false; private Notification mAdbNotification; Loading Loading @@ -405,10 +406,10 @@ public class NotificationManagerService extends INotificationManager.Stub } } else if (action.equals(Usb.ACTION_USB_STATE)) { Bundle extras = intent.getExtras(); boolean usbConnected = extras.getBoolean(Usb.USB_CONNECTED); mUsbConnected = extras.getBoolean(Usb.USB_CONNECTED); boolean adbEnabled = (Usb.USB_FUNCTION_ENABLED.equals( extras.getString(Usb.USB_FUNCTION_ADB))); updateAdbNotification(usbConnected && adbEnabled); updateAdbNotification(mUsbConnected && adbEnabled); } else if (action.equals(Usb.ACTION_USB_DISCONNECTED)) { updateAdbNotification(false); } else if (action.equals(Intent.ACTION_PACKAGE_REMOVED) Loading Loading @@ -549,6 +550,29 @@ public class NotificationManagerService extends INotificationManager.Stub } } class AdbNotifyObserver extends ContentObserver { AdbNotifyObserver(Handler handler) { super(handler); } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.ADB_ENABLED), false, this); resolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.ADB_NOTIFY), false, this); } @Override public void onChange(boolean selfChange) { ContentResolver resolver = mContext.getContentResolver(); boolean adbEnabled = Settings.Secure.getInt(resolver, Settings.Secure.ADB_ENABLED, 0) != 0; boolean notifyEnabled = Settings.Secure.getInt(resolver, Settings.Secure.ADB_NOTIFY, 1) != 0; updateAdbNotification(adbEnabled && notifyEnabled && mUsbConnected); } } NotificationManagerService(Context context, StatusBarManagerService statusBar, LightsService lights) { Loading Loading @@ -604,6 +628,9 @@ public class NotificationManagerService extends INotificationManager.Stub SettingsObserver observer = new SettingsObserver(mHandler); observer.observe(); AdbNotifyObserver notifyObserver = new AdbNotifyObserver(mHandler); notifyObserver.observe(); } void systemReady() { Loading