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

Commit 48d000ee authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Disable USB debugging checkbox and backup password for secondary users

This prevents secondary users from turning on adb debugging, even if they
find a way to launch developer options. Similarly, don't let them add or
change the adb backup password.

Bug: 7637920
Change-Id: I297f0c515a276ede6a7f12d2add72faec4eeb384
parent 3236571f
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.MultiCheckPreference;
@@ -213,6 +214,11 @@ public class DevelopmentSettings extends PreferenceFragment
        mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
        mAllPrefs.add(mPassword);

        if (!android.os.Process.myUserHandle().equals(UserHandle.OWNER)) {
            disableForUser(mEnableAdb);
            disableForUser(mPassword);
        }

        mDebugAppPref = findPreference(DEBUG_APP_KEY);
        mAllPrefs.add(mDebugAppPref);
        mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY);
@@ -284,6 +290,13 @@ public class DevelopmentSettings extends PreferenceFragment
        removeHdcpOptionsForProduction();
    }

    private void disableForUser(Preference pref) {
        if (pref != null) {
            pref.setEnabled(false);
            mDisabledPrefs.add(pref);
        }
    }

    private CheckBoxPreference findAndInitCheckboxPref(String key) {
        CheckBoxPreference pref = (CheckBoxPreference) findPreference(key);
        if (pref == null) {