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

Commit 99ea39bc authored by DvTonder's avatar DvTonder
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: I72d6df55bf5df251802b321410670646d26c54b0
parent baaf4407
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -5161,5 +5161,10 @@
    <string name="auto_brightness_menu_edit_lux">Ambient brightness range</string>
    <string name="auto_brightness_menu_split">Split</string>
    <string name="auto_brightness_menu_remove">Remove</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>

    <!-- **** CYANOGENMOD ADDITIONS END **** -->
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,11 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
        android:title="@string/development_settings_title">

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

    <PreferenceScreen
            android:key="development_tools"
            android:title="@string/development_tools_title"
+27 −1
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ public class DevelopmentSettings extends PreferenceFragment

    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;
@@ -204,6 +206,8 @@ public class DevelopmentSettings extends PreferenceFragment
    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>();
@@ -238,10 +242,12 @@ public class DevelopmentSettings extends PreferenceFragment
        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(mPassword);
            disableForUser(mAdvancedReboot);
        }

        mDebugAppPref = findPreference(DEBUG_APP_KEY);
@@ -488,6 +494,23 @@ public class DevelopmentSettings extends PreferenceFragment
        updateVerifyAppsOverUsbOptions();
        updateBugreportOptions();
        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 updateAdbOverNetwork() {
@@ -529,6 +552,7 @@ public class DevelopmentSettings extends PreferenceFragment
        }
        resetDebuggerOptions();
        resetRootAccessOptions();
        resetAdvancedRebootOptions();
        writeAnimationScaleOption(0, mWindowAnimationScale, null);
        writeAnimationScaleOption(1, mTransitionAnimationScale, null);
        writeAnimationScaleOption(2, mAnimatorDurationScale, null);
@@ -1242,6 +1266,8 @@ public class DevelopmentSettings extends PreferenceFragment
            writeDebugLayoutOptions();
        } else if (preference == mKillAppLongpressBack) {
            writeKillAppLongpressBackOptions();
        } else if (preference == mAdvancedReboot) {
            writeAdvancedRebootOptions();
        }

        return false;