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

Commit 28dfd93b authored by Tao Bao's avatar Tao Bao Committed by Android (Google) Code Review
Browse files

Merge "Add a Developer option of "Disable automatic update"." into nyc-dev

parents 7b54a815 45a2c163
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -7005,6 +7005,9 @@
    <!-- Toast message letting the user know the color temperature setting is not immediate -->
    <!-- Toast message letting the user know the color temperature setting is not immediate -->
    <string name="color_temperature_toast">To apply color change, turn off screen</string>
    <string name="color_temperature_toast">To apply color change, turn off screen</string>
    <!-- Name of the setting to disable the automatic update -->
    <string name="ota_disable_automatic_update">Automatic system updates</string>
    <!-- Label for category for data usage [CHAR LIMIT=30] -->
    <!-- Label for category for data usage [CHAR LIMIT=30] -->
    <string name="usage">Usage</string>
    <string name="usage">Usage</string>
+4 −0
Original line number Original line Diff line number Diff line
@@ -89,6 +89,10 @@
        android:title="@string/color_temperature"
        android:title="@string/color_temperature"
        android:summary="@string/color_temperature_desc" />
        android:summary="@string/color_temperature_desc" />


    <SwitchPreference
        android:key="ota_disable_automatic_update"
        android:title="@string/ota_disable_automatic_update" />

    <PreferenceCategory android:key="debug_debugging_category"
    <PreferenceCategory android:key="debug_debugging_category"
            android:title="@string/debug_debugging_category">
            android:title="@string/debug_debugging_category">


+26 −0
Original line number Original line Diff line number Diff line
@@ -204,6 +204,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
    private static final String KEY_NIGHT_MODE = "night_mode";
    private static final String KEY_NIGHT_MODE = "night_mode";
    private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";
    private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";


    private static final String OTA_DISABLE_AUTOMATIC_UPDATE_KEY = "ota_disable_automatic_update";

    private static final int RESULT_DEBUG_APP = 1000;
    private static final int RESULT_DEBUG_APP = 1000;
    private static final int RESULT_MOCK_LOCATION_APP = 1001;
    private static final int RESULT_MOCK_LOCATION_APP = 1001;


@@ -250,6 +252,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
    private SwitchPreference mWifiAggressiveHandover;
    private SwitchPreference mWifiAggressiveHandover;
    private SwitchPreference mMobileDataAlwaysOn;
    private SwitchPreference mMobileDataAlwaysOn;
    private SwitchPreference mBluetoothDisableAbsVolume;
    private SwitchPreference mBluetoothDisableAbsVolume;
    private SwitchPreference mOtaDisableAutomaticUpdate;


    private SwitchPreference mWifiAllowScansWithTraffic;
    private SwitchPreference mWifiAllowScansWithTraffic;
    private SwitchPreference mStrictMode;
    private SwitchPreference mStrictMode;
@@ -462,6 +465,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
            removePreference(KEY_CONVERT_FBE);
            removePreference(KEY_CONVERT_FBE);
        }
        }


        mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY);

        mNightModePreference = (DropDownPreference) findPreference(KEY_NIGHT_MODE);
        mNightModePreference = (DropDownPreference) findPreference(KEY_NIGHT_MODE);
        final UiModeManager uiManager = (UiModeManager) getSystemService(
        final UiModeManager uiManager = (UiModeManager) getSystemService(
                Context.UI_MODE_SERVICE);
                Context.UI_MODE_SERVICE);
@@ -695,6 +700,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
        updateAppProcessLimitOptions();
        updateAppProcessLimitOptions();
        updateShowAllANRsOptions();
        updateShowAllANRsOptions();
        updateVerifyAppsOverUsbOptions();
        updateVerifyAppsOverUsbOptions();
        updateOtaDisableAutomaticUpdateOptions();
        updateBugreportOptions();
        updateBugreportOptions();
        updateForceRtlOptions();
        updateForceRtlOptions();
        updateLogdSizeValues();
        updateLogdSizeValues();
@@ -945,6 +951,24 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
                mVerifyAppsOverUsb.isChecked() ? 1 : 0);
                mVerifyAppsOverUsb.isChecked() ? 1 : 0);
    }
    }


    private void updateOtaDisableAutomaticUpdateOptions() {
        // We use the "disabled status" in code, but show the opposite text
        // "Automatic system updates" on screen. So a value 0 indicates the
        // automatic update is enabled.
        updateSwitchPreference(mOtaDisableAutomaticUpdate, Settings.Global.getInt(
                getActivity().getContentResolver(),
                Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, 0) != 1);
    }

    private void writeOtaDisableAutomaticUpdateOptions() {
        // We use the "disabled status" in code, but show the opposite text
        // "Automatic system updates" on screen. So a value 0 indicates the
        // automatic update is enabled.
        Settings.Global.putInt(getActivity().getContentResolver(),
                Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
                mOtaDisableAutomaticUpdate.isChecked() ? 0 : 1);
    }

    private boolean enableVerifierSetting() {
    private boolean enableVerifierSetting() {
        final ContentResolver cr = getActivity().getContentResolver();
        final ContentResolver cr = getActivity().getContentResolver();
        if (Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) == 0) {
        if (Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) == 0) {
@@ -1834,6 +1858,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
            writeDebuggerOptions();
            writeDebuggerOptions();
        } else if (preference == mVerifyAppsOverUsb) {
        } else if (preference == mVerifyAppsOverUsb) {
            writeVerifyAppsOverUsbOptions();
            writeVerifyAppsOverUsbOptions();
        } else if (preference == mOtaDisableAutomaticUpdate) {
            writeOtaDisableAutomaticUpdateOptions();
        } else if (preference == mStrictMode) {
        } else if (preference == mStrictMode) {
            writeStrictModeVisualOptions();
            writeStrictModeVisualOptions();
        } else if (preference == mPointerLocation) {
        } else if (preference == mPointerLocation) {