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

Commit 98f83d61 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't show "Wipe eSIMs" checkbox for developers." into oc-dr1-dev

parents 241fecbd 4ba7478f
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -247,9 +247,8 @@ public class MasterClear extends OptionsMenuFragment
    /**
     * Whether to show the checkbox to wipe the eUICC.
     *
     * <p>We show the checkbox on any device which supports eUICC as long as either the eUICC was
     * ever provisioned (that is, at least one profile was ever downloaded onto it), or if the user
     * has enabled development mode.
     * <p>We show the checkbox on any device which supports eUICC as long as the eUICC was ever
     * provisioned (that is, at least one profile was ever downloaded onto it).
     */
    @VisibleForTesting
    boolean showWipeEuicc() {
@@ -258,8 +257,7 @@ public class MasterClear extends OptionsMenuFragment
            return false;
        }
        ContentResolver cr = context.getContentResolver();
        return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0
                || Settings.Global.getInt(cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
        return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0;
    }

    @VisibleForTesting
+4 −27
Original line number Diff line number Diff line
@@ -92,55 +92,32 @@ public class MasterClearTest {
    @Test
    public void testShowWipeEuicc_euiccDisabled() {
        prepareEuiccState(
                false /* isEuiccEnabled */, true /* isEuiccProvisioned */,
                true /* isDevelopmentSettingsEnabled */);
                false /* isEuiccEnabled */, true /* isEuiccProvisioned */);
        assertThat(mMasterClear.showWipeEuicc()).isFalse();
    }

    @Test
    public void testShowWipeEuicc_euiccEnabled_unprovisioned() {
        prepareEuiccState(
                true /* isEuiccEnabled */, false /* isEuiccProvisioned */,
                false /* isDevelopmentSettingsEnabled */);
                true /* isEuiccEnabled */, false /* isEuiccProvisioned */);
        assertThat(mMasterClear.showWipeEuicc()).isFalse();
    }

    @Test
    public void testShowWipeEuicc_euiccEnabled_provisioned() {
        prepareEuiccState(
                true /* isEuiccEnabled */, true /* isEuiccProvisioned */,
                false /* isDevelopmentSettingsEnabled */);
        assertThat(mMasterClear.showWipeEuicc()).isTrue();
    }

    @Test
    public void testShowWipeEuicc_euiccEnabled_developmentSettingsEnabled() {
        prepareEuiccState(
                true /* isEuiccEnabled */, false /* isEuiccProvisioned */,
                true /* isDevelopmentSettingsEnabled */);
        assertThat(mMasterClear.showWipeEuicc()).isTrue();
    }

    @Test
    public void testShowWipeEuicc_euiccEnabled_provisioned_developmentSettingsEnabled() {
        prepareEuiccState(
                true /* isEuiccEnabled */, true /* isEuiccProvisioned */,
                true /* isDevelopmentSettingsEnabled */);
                true /* isEuiccEnabled */, true /* isEuiccProvisioned */);
        assertThat(mMasterClear.showWipeEuicc()).isTrue();
    }

    private void prepareEuiccState(
            boolean isEuiccEnabled,
            boolean isEuiccProvisioned,
            boolean isDevelopmentSettingsEnabled) {
            boolean isEuiccProvisioned) {
        doReturn(mActivity).when(mMasterClear).getContext();
        doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
        ContentResolver cr = mActivity.getContentResolver();
        Settings.Global.putInt(
                cr, android.provider.Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
        Settings.Global.putInt(
                cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
                isDevelopmentSettingsEnabled ? 1 : 0);
    }

    @Test