Loading res/values/strings.xml +3 −1 Original line number Diff line number Diff line Loading @@ -14525,7 +14525,9 @@ Data usage charges may apply.</string> <!-- Title of toggle to enable or disable device supervision [CHAR LIMIT=60] --> <string name="device_supervision_switch_title">Use device supervision</string> <!-- Description of device supervision toggle when PIN has never been set up [CHAR LIMIT=NONE] --> <string name="device_supervision_switch_no_pin_summary">Set up PIN to get started</string> <string name="device_supervision_switch_no_pin_summary">Set up PIN</string> <!-- Description of device supervision toggle when PIN is set up but supervision is not enabled [CHAR LIMIT=NONE] --> <string name="device_supervision_switch_paused_summary">Paused</string> <!-- Search keywords for supervision settings [CHAR LIMIT=NONE] --> <string name="keywords_supervision_settings">supervision, parental supervision, parental controls</string> <!-- Title for supervision PIN management settings entry [CHAR LIMIT=60] --> src/com/android/settings/supervision/SupervisionMainSwitchPreference.kt +11 −3 Original line number Diff line number Diff line Loading @@ -62,10 +62,14 @@ class SupervisionMainSwitchPreference( override val title get() = R.string.device_supervision_switch_title // TODO(b/383568136): Make presence of summary conditional on whether PIN // has been set up before or not. override fun getSummary(context: Context): CharSequence? = if (!context.isSupervisingCredentialSet) { context.getString(R.string.device_supervision_switch_no_pin_summary) } else if (supervisionMainSwitchStorage.getBoolean(KEY)!!) { context.getString(R.string.switch_on_text) } else { context.getString(R.string.device_supervision_switch_paused_summary) } override fun storage(context: Context): KeyValueStore = supervisionMainSwitchStorage Loading Loading @@ -121,6 +125,9 @@ class SupervisionMainSwitchPreference( } if (resultCode == Activity.RESULT_OK) { val mainSwitchPreference = lifeCycleContext.requirePreference<MainSwitchPreference>(KEY) // Value only needs to be toggled in the non-setup case. The setup flow will // unconditionally enable supervision internally when successful. val newValue = if (requestCode == REQUEST_CODE_SET_UP_SUPERVISION) { true Loading @@ -128,6 +135,7 @@ class SupervisionMainSwitchPreference( !supervisionMainSwitchStorage.getBoolean(KEY)!! } mainSwitchPreference.setChecked(newValue) lifeCycleContext.notifyPreferenceChange(KEY) updateDependentPreferencesEnabledState(mainSwitchPreference, newValue) updateDependentPreferenceSummary(mainSwitchPreference) lifeCycleContext.notifyPreferenceChange(SupervisionPinManagementScreen.KEY) Loading tests/robotests/src/com/android/settings/supervision/SupervisionMainSwitchPreferenceTest.kt +24 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,30 @@ class SupervisionMainSwitchPreferenceTest { preference.onCreate(mockLifeCycleContext) } @Test fun getSummary_noPinSet_returnsNoPinSummary() { setSupervisionEnabled(false) setSupervisingProfileCreated(false) assertThat(preference.getSummary(context)).isEqualTo("Set up PIN") } @Test fun getSummary_disabled_pinSet_returnsPausedSummary() { setSupervisionEnabled(false) setSupervisingProfileCreated(true) assertThat(preference.getSummary(context)).isEqualTo("Paused") } @Test fun getSummary_enabled_pinSet_returnsOnSummary() { setSupervisionEnabled(true) setSupervisingProfileCreated(true) assertThat(preference.getSummary(context)).isEqualTo("On") } @Test fun checked_supervisionEnabled_returnTrue() { setSupervisionEnabled(true) Loading Loading
res/values/strings.xml +3 −1 Original line number Diff line number Diff line Loading @@ -14525,7 +14525,9 @@ Data usage charges may apply.</string> <!-- Title of toggle to enable or disable device supervision [CHAR LIMIT=60] --> <string name="device_supervision_switch_title">Use device supervision</string> <!-- Description of device supervision toggle when PIN has never been set up [CHAR LIMIT=NONE] --> <string name="device_supervision_switch_no_pin_summary">Set up PIN to get started</string> <string name="device_supervision_switch_no_pin_summary">Set up PIN</string> <!-- Description of device supervision toggle when PIN is set up but supervision is not enabled [CHAR LIMIT=NONE] --> <string name="device_supervision_switch_paused_summary">Paused</string> <!-- Search keywords for supervision settings [CHAR LIMIT=NONE] --> <string name="keywords_supervision_settings">supervision, parental supervision, parental controls</string> <!-- Title for supervision PIN management settings entry [CHAR LIMIT=60] -->
src/com/android/settings/supervision/SupervisionMainSwitchPreference.kt +11 −3 Original line number Diff line number Diff line Loading @@ -62,10 +62,14 @@ class SupervisionMainSwitchPreference( override val title get() = R.string.device_supervision_switch_title // TODO(b/383568136): Make presence of summary conditional on whether PIN // has been set up before or not. override fun getSummary(context: Context): CharSequence? = if (!context.isSupervisingCredentialSet) { context.getString(R.string.device_supervision_switch_no_pin_summary) } else if (supervisionMainSwitchStorage.getBoolean(KEY)!!) { context.getString(R.string.switch_on_text) } else { context.getString(R.string.device_supervision_switch_paused_summary) } override fun storage(context: Context): KeyValueStore = supervisionMainSwitchStorage Loading Loading @@ -121,6 +125,9 @@ class SupervisionMainSwitchPreference( } if (resultCode == Activity.RESULT_OK) { val mainSwitchPreference = lifeCycleContext.requirePreference<MainSwitchPreference>(KEY) // Value only needs to be toggled in the non-setup case. The setup flow will // unconditionally enable supervision internally when successful. val newValue = if (requestCode == REQUEST_CODE_SET_UP_SUPERVISION) { true Loading @@ -128,6 +135,7 @@ class SupervisionMainSwitchPreference( !supervisionMainSwitchStorage.getBoolean(KEY)!! } mainSwitchPreference.setChecked(newValue) lifeCycleContext.notifyPreferenceChange(KEY) updateDependentPreferencesEnabledState(mainSwitchPreference, newValue) updateDependentPreferenceSummary(mainSwitchPreference) lifeCycleContext.notifyPreferenceChange(SupervisionPinManagementScreen.KEY) Loading
tests/robotests/src/com/android/settings/supervision/SupervisionMainSwitchPreferenceTest.kt +24 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,30 @@ class SupervisionMainSwitchPreferenceTest { preference.onCreate(mockLifeCycleContext) } @Test fun getSummary_noPinSet_returnsNoPinSummary() { setSupervisionEnabled(false) setSupervisingProfileCreated(false) assertThat(preference.getSummary(context)).isEqualTo("Set up PIN") } @Test fun getSummary_disabled_pinSet_returnsPausedSummary() { setSupervisionEnabled(false) setSupervisingProfileCreated(true) assertThat(preference.getSummary(context)).isEqualTo("Paused") } @Test fun getSummary_enabled_pinSet_returnsOnSummary() { setSupervisionEnabled(true) setSupervisingProfileCreated(true) assertThat(preference.getSummary(context)).isEqualTo("On") } @Test fun checked_supervisionEnabled_returnTrue() { setSupervisionEnabled(true) Loading