Loading src/com/android/settings/applications/manageapplications/ManageApplicationsUtil.kt +2 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider import com.android.settings.spa.app.specialaccess.MediaManagementAppsAppListProvider import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider import com.android.settings.spa.app.storage.StorageAppListPageProvider import com.android.settings.spa.notification.AppListNotificationsPageProvider Loading Loading @@ -120,6 +121,7 @@ object ManageApplicationsUtil { LIST_TYPE_MAIN -> AllAppListPageProvider.name LIST_TYPE_NFC_TAG_APPS -> NfcTagAppsSettingsProvider.getAppListRoute() LIST_TYPE_USER_ASPECT_RATIO_APPS -> UserAspectRatioAppsPageProvider.name LIST_TYPE_TURN_SCREEN_ON -> TurnScreenOnAppsAppListProvider.getAppListRoute() // TODO(b/292165031) enable once sorting is supported //LIST_TYPE_STORAGE -> StorageAppListPageProvider.Apps.name //LIST_TYPE_GAMES -> StorageAppListPageProvider.Games.name Loading src/com/android/settings/spa/SettingsSpaEnvironment.kt +2 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListPro import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider import com.android.settings.spa.app.specialaccess.SpecialAppAccessPageProvider import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider import com.android.settings.spa.app.specialaccess.UseFullScreenIntentAppListProvider import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider import com.android.settings.spa.app.storage.StorageAppListPageProvider Loading Loading @@ -68,6 +69,7 @@ open class SettingsSpaEnvironment(context: Context) : SpaEnvironment(context) { AlarmsAndRemindersAppListProvider, WifiControlAppListProvider, NfcTagAppsSettingsProvider, TurnScreenOnAppsAppListProvider, ) } Loading src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt +1 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ object SpecialAppAccessPageProvider : SettingsPageProvider { InstallUnknownAppsListProvider, AlarmsAndRemindersAppListProvider, WifiControlAppListProvider, TurnScreenOnAppsAppListProvider, ) .map { it.buildAppListInjectEntry().setLink(fromPage = owner).build() } } Loading src/com/android/settings/spa/app/specialaccess/TurnScreenOnApps.kt 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.spa.app.specialaccess import android.Manifest import android.app.AppOpsManager import android.app.settings.SettingsEnums import android.content.Context import com.android.settings.R import com.android.settings.overlay.FeatureFactory.Companion.featureFactory import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel import com.android.settingslib.spaprivileged.template.app.AppOpPermissionRecord import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider object TurnScreenOnAppsAppListProvider : TogglePermissionAppListProvider { override val permissionType = "TurnScreenOnApps" override fun createModel(context: Context) = TurnScreenOnAppsListModel(context) } class TurnScreenOnAppsListModel(context: Context) : AppOpPermissionListModel(context) { override val pageTitleResId = com.android.settingslib.R.string.turn_screen_on_title override val switchTitleResId = com.android.settingslib.R.string.allow_turn_screen_on override val footerResId = com.android.settingslib.R.string.allow_turn_screen_on_description override val appOp = AppOpsManager.OP_TURN_SCREEN_ON override val permission = Manifest.permission.TURN_SCREEN_ON override val setModeByUid = true override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) { super.setAllowed(record, newAllowed) logPermissionChange(newAllowed) } private fun logPermissionChange(newAllowed: Boolean) { featureFactory.metricsFeatureProvider.action( context, SettingsEnums.SETTINGS_MANAGE_TURN_SCREEN_ON, if (newAllowed) 1 else 0 ) } } No newline at end of file tests/spa_unit/src/com/android/settings/spa/app/specialaccess/TurnScreenOnAppsTest.kt 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.spa.app.specialaccess import android.Manifest import android.app.AppOpsManager import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class TurnScreenOnAppsTest { private val context: Context = ApplicationProvider.getApplicationContext() private val listModel = TurnScreenOnAppsListModel(context) @Test fun pageTitleResId() { assertThat(listModel.pageTitleResId).isEqualTo(com.android.settingslib.R.string.turn_screen_on_title) } @Test fun switchTitleResId() { assertThat(listModel.switchTitleResId).isEqualTo(com.android.settingslib.R.string.allow_turn_screen_on) } @Test fun footerResId() { assertThat(listModel.footerResId).isEqualTo(com.android.settingslib.R.string.allow_turn_screen_on_description) } @Test fun appOp() { assertThat(listModel.appOp).isEqualTo(AppOpsManager.OP_TURN_SCREEN_ON) } @Test fun permission() { assertThat(listModel.permission).isEqualTo(Manifest.permission.TURN_SCREEN_ON) } @Test fun setModeByUid() { assertThat(listModel.setModeByUid).isTrue() } } No newline at end of file Loading
src/com/android/settings/applications/manageapplications/ManageApplicationsUtil.kt +2 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider import com.android.settings.spa.app.specialaccess.MediaManagementAppsAppListProvider import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider import com.android.settings.spa.app.storage.StorageAppListPageProvider import com.android.settings.spa.notification.AppListNotificationsPageProvider Loading Loading @@ -120,6 +121,7 @@ object ManageApplicationsUtil { LIST_TYPE_MAIN -> AllAppListPageProvider.name LIST_TYPE_NFC_TAG_APPS -> NfcTagAppsSettingsProvider.getAppListRoute() LIST_TYPE_USER_ASPECT_RATIO_APPS -> UserAspectRatioAppsPageProvider.name LIST_TYPE_TURN_SCREEN_ON -> TurnScreenOnAppsAppListProvider.getAppListRoute() // TODO(b/292165031) enable once sorting is supported //LIST_TYPE_STORAGE -> StorageAppListPageProvider.Apps.name //LIST_TYPE_GAMES -> StorageAppListPageProvider.Games.name Loading
src/com/android/settings/spa/SettingsSpaEnvironment.kt +2 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListPro import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider import com.android.settings.spa.app.specialaccess.SpecialAppAccessPageProvider import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider import com.android.settings.spa.app.specialaccess.UseFullScreenIntentAppListProvider import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider import com.android.settings.spa.app.storage.StorageAppListPageProvider Loading Loading @@ -68,6 +69,7 @@ open class SettingsSpaEnvironment(context: Context) : SpaEnvironment(context) { AlarmsAndRemindersAppListProvider, WifiControlAppListProvider, NfcTagAppsSettingsProvider, TurnScreenOnAppsAppListProvider, ) } Loading
src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt +1 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ object SpecialAppAccessPageProvider : SettingsPageProvider { InstallUnknownAppsListProvider, AlarmsAndRemindersAppListProvider, WifiControlAppListProvider, TurnScreenOnAppsAppListProvider, ) .map { it.buildAppListInjectEntry().setLink(fromPage = owner).build() } } Loading
src/com/android/settings/spa/app/specialaccess/TurnScreenOnApps.kt 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.spa.app.specialaccess import android.Manifest import android.app.AppOpsManager import android.app.settings.SettingsEnums import android.content.Context import com.android.settings.R import com.android.settings.overlay.FeatureFactory.Companion.featureFactory import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel import com.android.settingslib.spaprivileged.template.app.AppOpPermissionRecord import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider object TurnScreenOnAppsAppListProvider : TogglePermissionAppListProvider { override val permissionType = "TurnScreenOnApps" override fun createModel(context: Context) = TurnScreenOnAppsListModel(context) } class TurnScreenOnAppsListModel(context: Context) : AppOpPermissionListModel(context) { override val pageTitleResId = com.android.settingslib.R.string.turn_screen_on_title override val switchTitleResId = com.android.settingslib.R.string.allow_turn_screen_on override val footerResId = com.android.settingslib.R.string.allow_turn_screen_on_description override val appOp = AppOpsManager.OP_TURN_SCREEN_ON override val permission = Manifest.permission.TURN_SCREEN_ON override val setModeByUid = true override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) { super.setAllowed(record, newAllowed) logPermissionChange(newAllowed) } private fun logPermissionChange(newAllowed: Boolean) { featureFactory.metricsFeatureProvider.action( context, SettingsEnums.SETTINGS_MANAGE_TURN_SCREEN_ON, if (newAllowed) 1 else 0 ) } } No newline at end of file
tests/spa_unit/src/com/android/settings/spa/app/specialaccess/TurnScreenOnAppsTest.kt 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.spa.app.specialaccess import android.Manifest import android.app.AppOpsManager import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class TurnScreenOnAppsTest { private val context: Context = ApplicationProvider.getApplicationContext() private val listModel = TurnScreenOnAppsListModel(context) @Test fun pageTitleResId() { assertThat(listModel.pageTitleResId).isEqualTo(com.android.settingslib.R.string.turn_screen_on_title) } @Test fun switchTitleResId() { assertThat(listModel.switchTitleResId).isEqualTo(com.android.settingslib.R.string.allow_turn_screen_on) } @Test fun footerResId() { assertThat(listModel.footerResId).isEqualTo(com.android.settingslib.R.string.allow_turn_screen_on_description) } @Test fun appOp() { assertThat(listModel.appOp).isEqualTo(AppOpsManager.OP_TURN_SCREEN_ON) } @Test fun permission() { assertThat(listModel.permission).isEqualTo(Manifest.permission.TURN_SCREEN_ON) } @Test fun setModeByUid() { assertThat(listModel.setModeByUid).isTrue() } } No newline at end of file