Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea8b7d56 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

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: default avatarMike Lockwood <lockwood@android.com>
parent cd9e8d49
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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;
            }