diff --git a/src/com/android/settings/spa/SpaEnvironment.kt b/src/com/android/settings/spa/SpaEnvironment.kt index febb2fd7b7e..8c88a03cd7e 100644 --- a/src/com/android/settings/spa/SpaEnvironment.kt +++ b/src/com/android/settings/spa/SpaEnvironment.kt @@ -17,7 +17,11 @@ package com.android.settings.spa import com.android.settings.spa.app.AppsMainPageProvider +import com.android.settings.spa.app.specialaccess.AllFilesAccessAppListProvider +import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider 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.PictureInPictureListProvider import com.android.settings.spa.app.specialaccess.SpecialAppAccessPageProvider import com.android.settings.spa.home.HomePageProvider @@ -33,6 +37,10 @@ object SpaEnvironment { lazy(LazyThreadSafetyMode.SYNCHRONIZED) { val togglePermissionAppListTemplate = TogglePermissionAppListTemplate( allProviders = listOf( + AllFilesAccessAppListProvider, + DisplayOverOtherAppsAppListProvider, + MediaManagementAppsAppListProvider, + ModifySystemSettingsAppListProvider, InstallUnknownAppsListProvider, PictureInPictureListProvider, ), diff --git a/src/com/android/settings/spa/app/specialaccess/AllFilesAccess.kt b/src/com/android/settings/spa/app/specialaccess/AllFilesAccess.kt new file mode 100644 index 00000000000..5efe3227191 --- /dev/null +++ b/src/com/android/settings/spa/app/specialaccess/AllFilesAccess.kt @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022 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 com.android.settings.R +import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel +import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider + +object AllFilesAccessAppListProvider : TogglePermissionAppListProvider { + override val permissionType = "AllFilesAccess" + override fun createModel(context: Context) = AllFilesAccessListModel(context) +} + +class AllFilesAccessListModel(context: Context) : AppOpPermissionListModel(context) { + override val pageTitleResId = R.string.manage_external_storage_title + override val switchTitleResId = R.string.permit_manage_external_storage + override val footerResId = R.string.allow_manage_external_storage_description + override val appOp = AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE + override val permission = Manifest.permission.MANAGE_EXTERNAL_STORAGE +} diff --git a/src/com/android/settings/spa/app/specialaccess/DisplayOverOtherApps.kt b/src/com/android/settings/spa/app/specialaccess/DisplayOverOtherApps.kt new file mode 100644 index 00000000000..d3cd2b506e9 --- /dev/null +++ b/src/com/android/settings/spa/app/specialaccess/DisplayOverOtherApps.kt @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022 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 com.android.settings.R +import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel +import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider + +object DisplayOverOtherAppsAppListProvider : TogglePermissionAppListProvider { + override val permissionType = "DisplayOverOtherApps" + override fun createModel(context: Context) = DisplayOverOtherAppsListModel(context) +} + +class DisplayOverOtherAppsListModel(context: Context) : AppOpPermissionListModel(context) { + override val pageTitleResId = R.string.system_alert_window_settings + override val switchTitleResId = R.string.permit_draw_overlay + override val footerResId = R.string.allow_overlay_description + override val appOp = AppOpsManager.OP_SYSTEM_ALERT_WINDOW + override val permission = Manifest.permission.SYSTEM_ALERT_WINDOW +} diff --git a/src/com/android/settings/spa/app/specialaccess/MediaManagementApps.kt b/src/com/android/settings/spa/app/specialaccess/MediaManagementApps.kt new file mode 100644 index 00000000000..92e369dd065 --- /dev/null +++ b/src/com/android/settings/spa/app/specialaccess/MediaManagementApps.kt @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022 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 com.android.settings.R +import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel +import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider + +object MediaManagementAppsAppListProvider : TogglePermissionAppListProvider { + override val permissionType = "MediaManagementApps" + override fun createModel(context: Context) = MediaManagementAppsListModel(context) +} + +class MediaManagementAppsListModel(context: Context) : AppOpPermissionListModel(context) { + override val pageTitleResId = R.string.media_management_apps_title + override val switchTitleResId = R.string.media_management_apps_toggle_label + override val footerResId = R.string.media_management_apps_description + override val appOp = AppOpsManager.OP_MANAGE_MEDIA + override val permission = Manifest.permission.MANAGE_MEDIA +} \ No newline at end of file diff --git a/src/com/android/settings/spa/app/specialaccess/ModifySystemSettings.kt b/src/com/android/settings/spa/app/specialaccess/ModifySystemSettings.kt new file mode 100644 index 00000000000..9a70871b1e2 --- /dev/null +++ b/src/com/android/settings/spa/app/specialaccess/ModifySystemSettings.kt @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022 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 com.android.settings.R +import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel +import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider + +object ModifySystemSettingsAppListProvider : TogglePermissionAppListProvider { + override val permissionType = "ModifySystemSettings" + override fun createModel(context: Context) = ModifySystemSettingsListModel(context) +} + +class ModifySystemSettingsListModel(context: Context) : AppOpPermissionListModel(context) { + override val pageTitleResId = R.string.write_system_settings + override val switchTitleResId = R.string.permit_write_settings + override val footerResId = R.string.write_settings_description + override val appOp = AppOpsManager.OP_WRITE_SETTINGS + override val permission = Manifest.permission.WRITE_SETTINGS +} \ No newline at end of file diff --git a/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt b/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt index 34575cbb3a9..7ab1db77750 100644 --- a/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt +++ b/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt @@ -51,6 +51,12 @@ object SpecialAppAccessPageProvider : SettingsPageProvider { override fun buildEntry(arguments: Bundle?): List { val owner = SettingsPage.create(name, parameter, arguments) return listOf( + AllFilesAccessAppListProvider.buildInjectEntry().setLink(fromPage = owner).build(), + DisplayOverOtherAppsAppListProvider.buildInjectEntry() + .setLink(fromPage = owner).build(), + MediaManagementAppsAppListProvider.buildInjectEntry().setLink(fromPage = owner).build(), + ModifySystemSettingsAppListProvider.buildInjectEntry() + .setLink(fromPage = owner).build(), PictureInPictureListProvider.buildInjectEntry().setLink(fromPage = owner).build(), InstallUnknownAppsListProvider.buildInjectEntry().setLink(fromPage = owner).build(), ) @@ -60,6 +66,10 @@ object SpecialAppAccessPageProvider : SettingsPageProvider { @Composable private fun SpecialAppAccessPage() { RegularScaffold(title = stringResource(R.string.special_access)) { + AllFilesAccessAppListProvider.EntryItem() + DisplayOverOtherAppsAppListProvider.EntryItem() + MediaManagementAppsAppListProvider.EntryItem() + ModifySystemSettingsAppListProvider.EntryItem() PictureInPictureListProvider.EntryItem() InstallUnknownAppsListProvider.EntryItem() } diff --git a/src/com/android/settings/spa/notification/AppNotificationRepository.kt b/src/com/android/settings/spa/notification/AppNotificationRepository.kt index c73aa0047ba..0f88ac93a91 100644 --- a/src/com/android/settings/spa/notification/AppNotificationRepository.kt +++ b/src/com/android/settings/spa/notification/AppNotificationRepository.kt @@ -90,7 +90,7 @@ class AppNotificationRepository(private val context: Context) { // If the app targets T but has not requested the permission, we cannot change the // permission state. return app.targetSdkVersion < Build.VERSION_CODES.TIRAMISU || - hasRequestPermission(app, Manifest.permission.POST_NOTIFICATIONS) + app.hasRequestPermission(Manifest.permission.POST_NOTIFICATIONS) } fun setEnabled(app: ApplicationInfo, enabled: Boolean): Boolean {