Add handling for main Supervision settings toggle.

This change introduces the basic behavior for the main toggle switch to
enable supervision. There is currently no PIN setup dialog when the
toggle is clicked. That will be added as a follow-up.

Intake bug: b/379312924

Change-Id: I75d6b2de1a7234c6da26fcdcf1d933eed3106a8c
Test: atest SupervisionMainSwitchPreferenceTest
Bug: 392694561
Flag: android.app.supervision.flags.enable_supervision_settings_screen
This commit is contained in:
Yvonne Jiang
2025-01-28 02:32:44 -08:00
parent 96d615ad18
commit 4f74b50b3a
2 changed files with 32 additions and 2 deletions

View File

@@ -49,7 +49,6 @@ class SupervisionMainSwitchPreference :
override val sensitivityLevel: Int
get() = SensitivityLevel.HIGH_SENSITIVITY
// TODO(b/390505725): Listen for changes in supervision state.
@Suppress("UNCHECKED_CAST")
private class SupervisionMainSwitchStorage(private val context: Context) :
NoOpKeyedObservable<String>(), KeyValueStore {
@@ -61,7 +60,11 @@ class SupervisionMainSwitchPreference :
as T
override fun <T : Any> setValue(key: String, valueType: Class<T>, value: T?) {
// TODO(b/383402852): implement handling of main toggle.
// TODO(b/392694561): add PIN protection to main toggle.
if (key == KEY && value is Boolean) {
val supervisionManager = context.getSystemService(SupervisionManager::class.java)
supervisionManager.setSupervisionEnabled(value)
}
}
}