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

Commit f098be99 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge changes from topic "adbwifi-base" am: 458a9a25 am: bdf898ab

Change-Id: I2c404b54c4f76507103cba3551f55b8cdea142b5
parents e6465942 bdf898ab
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -9781,10 +9781,16 @@ public final class Settings {
        private static final Validator BUGREPORT_IN_POWER_MENU_VALIDATOR = BOOLEAN_VALIDATOR;
        /**
         * Whether ADB is enabled.
         * Whether ADB over USB is enabled.
         */
        public static final String ADB_ENABLED = "adb_enabled";
        /**
         * Whether ADB over Wifi is enabled.
         * @hide
         */
        public static final String ADB_WIFI_ENABLED = "adb_wifi_enabled";
        /**
         * Whether Views are allowed to save their attribute data.
         * @hide
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class SettingsBackupTest {
                    Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED,
                    Settings.Global.ADB_ALLOWED_CONNECTION_TIME,
                    Settings.Global.ADB_ENABLED,
                    Settings.Global.ADB_WIFI_ENABLED,
                    Settings.Global.ADD_USERS_WHEN_LOCKED,
                    Settings.Global.AIRPLANE_MODE_ON,
                    Settings.Global.AIRPLANE_MODE_RADIOS,
+5 −0
Original line number Diff line number Diff line
@@ -1009,6 +1009,11 @@ public class SettingsProvider extends ContentProvider {
                        String value = setting != null ? setting.getValue() : null;
                        updateGlobalSetting(Settings.Global.ADB_ENABLED,
                                value, null, true, userId, true);

                        setting = getGlobalSetting(Settings.Global.ADB_WIFI_ENABLED);
                        value = setting != null ? setting.getValue() : null;
                        updateGlobalSetting(Settings.Global.ADB_WIFI_ENABLED,
                                value, null, true, userId, true);
                    }
                } finally {
                    Binder.restoreCallingIdentity(identity);
+16 −2
Original line number Diff line number Diff line
@@ -134,9 +134,13 @@ public class AdbService extends IAdbManager.Stub {
            mIsAdbWifiEnabled = false;

            // register observer to listen for settings changes
            mObserver = new AdbSettingsObserver();
            mContentResolver.registerContentObserver(
                    Settings.Global.getUriFor(Settings.Global.ADB_ENABLED),
                    false, new AdbSettingsObserver());
                    false, mObserver);
            mContentResolver.registerContentObserver(
                    Settings.Global.getUriFor(Settings.Global.ADB_WIFI_ENABLED),
                    false, mObserver);
        } catch (Exception e) {
            Slog.e(TAG, "Error in initAdbState", e);
        }
@@ -153,6 +157,7 @@ public class AdbService extends IAdbManager.Stub {

    private class AdbSettingsObserver extends ContentObserver {
        private final Uri mAdbUsbUri = Settings.Global.getUriFor(Settings.Global.ADB_ENABLED);
        private final Uri mAdbWifiUri = Settings.Global.getUriFor(Settings.Global.ADB_WIFI_ENABLED);

        AdbSettingsObserver() {
            super(null);
@@ -166,8 +171,13 @@ public class AdbService extends IAdbManager.Stub {
                FgThread.getHandler().sendMessage(obtainMessage(
                        AdbService::setAdbEnabled, AdbService.this, shouldEnable,
                            AdbTransportType.USB));
            } else if (mAdbWifiUri.equals(uri)) {
                boolean shouldEnable = (Settings.Global.getInt(mContentResolver,
                        Settings.Global.ADB_WIFI_ENABLED, 0) > 0);
                FgThread.getHandler().sendMessage(obtainMessage(
                        AdbService::setAdbEnabled, AdbService.this, shouldEnable,
                            AdbTransportType.WIFI));
            }
            // TODO(joshuaduong): Add condition for WIFI transport
        }
    }

@@ -188,6 +198,8 @@ public class AdbService extends IAdbManager.Stub {
    private boolean mIsAdbWifiEnabled;
    private AdbDebuggingManager mDebuggingManager;

    private ContentObserver mObserver;

    private AdbService(Context context) {
        mContext = context;
        mContentResolver = context.getContentResolver();
@@ -213,6 +225,8 @@ public class AdbService extends IAdbManager.Stub {
        try {
            Settings.Global.putInt(mContentResolver,
                    Settings.Global.ADB_ENABLED, mIsAdbUsbEnabled ? 1 : 0);
            Settings.Global.putInt(mContentResolver,
                    Settings.Global.ADB_WIFI_ENABLED, mIsAdbWifiEnabled ? 1 : 0);
        } catch (SecurityException e) {
            // If UserManager.DISALLOW_DEBUGGING_FEATURES is on, that this setting can't be changed.
            Slog.d(TAG, "ADB_ENABLED is restricted.");
+4 −0
Original line number Diff line number Diff line
@@ -562,6 +562,9 @@ public class UserRestrictionsUtils {
                            android.provider.Settings.Global.putStringForUser(cr,
                                    android.provider.Settings.Global.ADB_ENABLED, "0",
                                    userId);
                            android.provider.Settings.Global.putStringForUser(cr,
                                    android.provider.Settings.Global.ADB_WIFI_ENABLED, "0",
                                    userId);
                        }
                    }
                    break;
@@ -702,6 +705,7 @@ public class UserRestrictionsUtils {
                break;

            case android.provider.Settings.Global.ADB_ENABLED:
            case android.provider.Settings.Global.ADB_WIFI_ENABLED:
                if ("0".equals(value)) {
                    return false;
                }
Loading