Set setModeByUid to align with current behavior
For the following App Lists, - All Files Access - Media Management Apps Default false, if true, use AppOpsManager#setUidMode instead of #setMode This follows Change: I261953ff88bc049cf0a2f04f8caac00b8cc6f704 Reason: Security related app-ops should be set with AppOpsManager#setUidMode instead of AppOpsManager#setMode. Bug: 235727273 Test: Unit test Change-Id: I953b63c2bf6f3bd94aacc935c8c3579bc8aed199
This commit is contained in:
@@ -34,4 +34,5 @@ class AllFilesAccessListModel(context: Context) : AppOpPermissionListModel(conte
|
|||||||
override val footerResId = R.string.allow_manage_external_storage_description
|
override val footerResId = R.string.allow_manage_external_storage_description
|
||||||
override val appOp = AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE
|
override val appOp = AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE
|
||||||
override val permission = Manifest.permission.MANAGE_EXTERNAL_STORAGE
|
override val permission = Manifest.permission.MANAGE_EXTERNAL_STORAGE
|
||||||
|
override val setModeByUid = true
|
||||||
}
|
}
|
||||||
|
@@ -34,4 +34,5 @@ class MediaManagementAppsListModel(context: Context) : AppOpPermissionListModel(
|
|||||||
override val footerResId = R.string.media_management_apps_description
|
override val footerResId = R.string.media_management_apps_description
|
||||||
override val appOp = AppOpsManager.OP_MANAGE_MEDIA
|
override val appOp = AppOpsManager.OP_MANAGE_MEDIA
|
||||||
override val permission = Manifest.permission.MANAGE_MEDIA
|
override val permission = Manifest.permission.MANAGE_MEDIA
|
||||||
|
override val setModeByUid = true
|
||||||
}
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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 androidx.test.core.app.ApplicationProvider
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import com.android.settings.R
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class AllFilesAccessTest {
|
||||||
|
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||||
|
|
||||||
|
private val listModel = AllFilesAccessListModel(context)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun pageTitleResId() {
|
||||||
|
assertThat(listModel.pageTitleResId).isEqualTo(R.string.manage_external_storage_title)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun switchTitleResId() {
|
||||||
|
assertThat(listModel.switchTitleResId).isEqualTo(R.string.permit_manage_external_storage)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun footerResId() {
|
||||||
|
assertThat(listModel.footerResId)
|
||||||
|
.isEqualTo(R.string.allow_manage_external_storage_description)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun appOp() {
|
||||||
|
assertThat(listModel.appOp).isEqualTo(AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun permission() {
|
||||||
|
assertThat(listModel.permission).isEqualTo(Manifest.permission.MANAGE_EXTERNAL_STORAGE)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun setModeByUid() {
|
||||||
|
assertThat(listModel.setModeByUid).isTrue()
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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 androidx.test.core.app.ApplicationProvider
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import com.android.settings.R
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class MediaManagementAppsTest {
|
||||||
|
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||||
|
|
||||||
|
private val listModel = MediaManagementAppsListModel(context)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun pageTitleResId() {
|
||||||
|
assertThat(listModel.pageTitleResId).isEqualTo(R.string.media_management_apps_title)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun switchTitleResId() {
|
||||||
|
assertThat(listModel.switchTitleResId)
|
||||||
|
.isEqualTo(R.string.media_management_apps_toggle_label)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun footerResId() {
|
||||||
|
assertThat(listModel.footerResId).isEqualTo(R.string.media_management_apps_description)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun appOp() {
|
||||||
|
assertThat(listModel.appOp).isEqualTo(AppOpsManager.OP_MANAGE_MEDIA)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun permission() {
|
||||||
|
assertThat(listModel.permission).isEqualTo(Manifest.permission.MANAGE_MEDIA)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun setModeByUid() {
|
||||||
|
assertThat(listModel.setModeByUid).isTrue()
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user