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

Commit 68fe6755 authored by DvTonder's avatar DvTonder Committed by Ricardo Cerqueira
Browse files

Settings: Add Advanced reboot (1 of 2)

This commit adds a setting in Development settings for including options
in the power menu for rebooting into recovery or bootloader, defauled to
off.

When enabled, the Advanced reboot options will only be available once the
device is unlocked.

Change-Id: Ib77f0be178d15131b99adbe0abb6ba18b2b7c0b6
parent 81c443b9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -70,4 +70,9 @@ two in order to insert additional control points. \'Remove\' deletes the selecte
    <string name="auto_brightness_sensitivity_medium">Medium</string>
    <string name="auto_brightness_sensitivity_high">High</string>
    <string name="auto_brightness_sensitivity_veryhigh">Very high</string>

    <!-- Advanced reboot options -->
    <string name="advanced_reboot_title">Advanced reboot</string>
    <string name="advanced_reboot_summary">When unlocked, include options in the power menu for rebooting into recovery or bootloader</string>

</resources>
+0 −1
Original line number Diff line number Diff line
@@ -5065,5 +5065,4 @@
    <!-- Launches Dev Tools -->
    <string name="development_tools_title">Launch Tools</string>

    <!-- **** CYANOGENMOD ADDITIONS END **** -->
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@
                android:targetClass="com.android.development.Development" />
    </PreferenceScreen>

    <CheckBoxPreference
        android:key="advanced_reboot"
        android:title="@string/advanced_reboot_title"
        android:summary="@string/advanced_reboot_summary" />

    <com.android.settings.BugreportPreference
            android:key="bugreport"
            android:title="@*android:string/bugreport_title"
+26 −0
Original line number Diff line number Diff line
@@ -150,6 +150,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment

    private static final String DEVELOPMENT_TOOLS = "development_tools";

    private static final String ADVANCED_REBOOT_KEY = "advanced_reboot";

    private static final int RESULT_DEBUG_APP = 1000;

    private IWindowManager mWindowManager;
@@ -207,6 +209,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
    private Object mSelectedRootValue;
    private PreferenceScreen mDevelopmentTools;

    private CheckBoxPreference mAdvancedReboot;

    private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
    private final ArrayList<CheckBoxPreference> mResetCbPrefs
            = new ArrayList<CheckBoxPreference>();
@@ -266,12 +270,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
        mAllowMockLocation = findAndInitCheckboxPref(ALLOW_MOCK_LOCATION);
        mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
        mAllPrefs.add(mPassword);
        mAdvancedReboot = findAndInitCheckboxPref(ADVANCED_REBOOT_KEY);

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

        mDebugAppPref = findPreference(DEBUG_APP_KEY);
@@ -529,6 +535,23 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
        updateForceRtlOptions();
        updateWifiDisplayCertificationOptions();
        updateRootAccessOptions();
        updateAdvancedRebootOptions();
    }

    private void resetAdvancedRebootOptions() {
        Settings.Secure.putInt(getActivity().getContentResolver(),
                Settings.Secure.ADVANCED_REBOOT, 0);
    }

    private void writeAdvancedRebootOptions() {
        Settings.Secure.putInt(getActivity().getContentResolver(),
                Settings.Secure.ADVANCED_REBOOT,
                mAdvancedReboot.isChecked() ? 1 : 0);
    }

    private void updateAdvancedRebootOptions() {
        mAdvancedReboot.setChecked(Settings.Secure.getInt(getActivity().getContentResolver(),
                Settings.Secure.ADVANCED_REBOOT, 0) != 0);
    }

    private void resetDangerousOptions() {
@@ -542,6 +565,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
        }
        resetDebuggerOptions();
        resetRootAccessOptions();
        resetAdvancedRebootOptions();
        writeAnimationScaleOption(0, mWindowAnimationScale, null);
        writeAnimationScaleOption(1, mTransitionAnimationScale, null);
        writeAnimationScaleOption(2, mAnimatorDurationScale, null);
@@ -1315,6 +1339,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
            writeForceRtlOptions();
        } else if (preference == mWifiDisplayCertification) {
            writeWifiDisplayCertificationOptions();
        } else if (preference == mAdvancedReboot) {
            writeAdvancedRebootOptions();
        } else {
            return super.onPreferenceTreeClick(preferenceScreen, preference);
        }