1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.spa.app.specialaccess 18 19 import android.Manifest 20 import android.app.AppOpsManager 21 import android.app.AppOpsManager.MODE_IGNORED 22 import android.content.Context 23 import com.android.settings.R 24 import com.android.settingslib.spaprivileged.model.app.AppOps 25 import com.android.settingslib.spaprivileged.model.app.IPackageManagers 26 import com.android.settingslib.spaprivileged.model.app.PackageManagers 27 import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel 28 import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider 29 30 object WifiControlAppListProvider : TogglePermissionAppListProvider { 31 override val permissionType = "WifiControl" createModelnull32 override fun createModel(context: Context) = WifiControlAppListModel(context) 33 } 34 35 class WifiControlAppListModel( 36 context: Context, 37 packageManagers: IPackageManagers = PackageManagers 38 ) : AppOpPermissionListModel(context, packageManagers) { 39 override val pageTitleResId = R.string.change_wifi_state_title 40 override val switchTitleResId = R.string.change_wifi_state_app_detail_switch 41 override val footerResId = R.string.change_wifi_state_app_detail_summary 42 43 override val appOps = AppOps( 44 op = AppOpsManager.OP_CHANGE_WIFI_STATE, 45 modeForNotAllowed = MODE_IGNORED, 46 ) 47 override val permission = Manifest.permission.CHANGE_WIFI_STATE 48 49 /** NETWORK_SETTINGS permission trumps CHANGE_WIFI_CONFIG. */ 50 override val broaderPermission = Manifest.permission.NETWORK_SETTINGS 51 override val permissionHasAppOpFlag = false 52 } 53