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

Commit 277dd1c1 authored by Tanguy Pruvot's avatar Tanguy Pruvot Committed by Steve Kondik
Browse files

Port "Option to hide Adb notification icon (2/2)"

Change-Id: I5d40f5b0990fa3a1d02210ad4cc2ff5ada15e69c
parent b2dd57b0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4694,6 +4694,12 @@ public final class Settings {
        @Deprecated
        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
+42 −33
Original line number Diff line number Diff line
@@ -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,10 +776,11 @@ 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;
            boolean hideNotification = "0".equals(SystemProperties.get("persist.adb.notify"))
                    || Settings.Secure.getInt(mContext.getContentResolver(),
                            Settings.Secure.ADB_NOTIFY, 1) == 0;

                if (!mAdbNotificationShown) {
            if (mAdbEnabled && mConnected && !mAdbNotificationShown && !hideNotification) {
                Resources r = mContext.getResources();
                CharSequence title = r.getText(id);
                CharSequence message = r.getText(
@@ -797,10 +806,10 @@ public class UsbDeviceManager {
                        .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);