Add 4 app op permission App List
- All files access - Display over other apps - Media management apps - Modify system settings Bug: 235727273 Test: Manual with Settings App Change-Id: I60abb44558f535d5e26d498164d5429ede4033f8
This commit is contained in:
@@ -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,
|
||||
),
|
||||
|
@@ -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
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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
|
||||
}
|
@@ -51,6 +51,12 @@ object SpecialAppAccessPageProvider : SettingsPageProvider {
|
||||
override fun buildEntry(arguments: Bundle?): List<SettingsEntry> {
|
||||
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()
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user