diff options
author | 2024-03-08 16:34:28 -0800 | |
---|---|---|
committer | 2024-03-12 16:36:18 +0000 | |
commit | 68f677f378063974e384c8467051af4b04bd477e (patch) | |
tree | 897209a51225c799746c2f30c0e6ec66a11a66c4 | |
parent | f10bb97b0aaaf36dba417906b488c722ab5e09fa (diff) |
Add test for new RECORD_SENSITIVE_CONTENT permission
This permisison can be granted to on device screen
recorder to get the exemption from blacking out
sensitive content.
Bug: 26420854
Test: atest RecordSensitiveContentPermissionTest
Test: atest PermissionPolicyTest
LOW_COVERAGE_REASON=Only changing tests
Change-Id: I820de4cf9219f8e60f643b74f3c34c06293668dc
-rw-r--r-- | tests/cts/permission/src/android/permission/cts/RecordSensitiveContentPermissionTest.kt | 62 | ||||
-rw-r--r-- | tests/cts/permissionpolicy/res/raw/android_manifest.xml | 6 |
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/cts/permission/src/android/permission/cts/RecordSensitiveContentPermissionTest.kt b/tests/cts/permission/src/android/permission/cts/RecordSensitiveContentPermissionTest.kt new file mode 100644 index 000000000..b80f89938 --- /dev/null +++ b/tests/cts/permission/src/android/permission/cts/RecordSensitiveContentPermissionTest.kt @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 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 android.permission.cts + +import android.os.Build +import android.permission.flags.Flags.FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION +import android.platform.test.annotations.AppModeFull +import android.platform.test.annotations.RequiresFlagsEnabled +import android.platform.test.flag.junit.CheckFlagsRule +import android.platform.test.flag.junit.DeviceFlagsValueProvider +import androidx.test.InstrumentationRegistry +import androidx.test.filters.SdkSuppress +import org.junit.Assert +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(JUnit4::class) +@AppModeFull(reason = "Instant apps cannot install packages") +@SdkSuppress(minSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM, codeName = "VanillaIceCream") +class RecordSensitiveContentPermissionTest { + @Rule + @JvmField + val mCheckFlagsRule: CheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule() + + @Test + @RequiresFlagsEnabled(FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION) + fun testRecordSensitiveContentDuringProjection() { + val packageManager = InstrumentationRegistry.getContext().getPackageManager() + val packagesHoldingPermission = + packageManager + .getPackagesHoldingPermissions( + arrayOf(android.Manifest.permission.RECORD_SENSITIVE_CONTENT), + 0 + ) + .map { it.packageName } + + if (packagesHoldingPermission.size > 1) { + Assert.fail( + "Only one system app on the device is allowed to hold the " + + "RECORD_SENSITIVE_CONTENT_DURING_PROJECTION permission, " + + "packages holding the permissions are: " + + packagesHoldingPermission + ) + } + } +} diff --git a/tests/cts/permissionpolicy/res/raw/android_manifest.xml b/tests/cts/permissionpolicy/res/raw/android_manifest.xml index 1acdc75a6..8ea742d19 100644 --- a/tests/cts/permissionpolicy/res/raw/android_manifest.xml +++ b/tests/cts/permissionpolicy/res/raw/android_manifest.xml @@ -6916,6 +6916,12 @@ <permission android:name="android.permission.MANAGE_MEDIA_PROJECTION" android:protectionLevel="signature" /> + <!-- @hide @TestApi Allows an application to record sensitive content during media + projection. This is intended for on device screen recording system app. + @FlaggedApi("android.permission.flags.sensitive_notification_app_protection") --> + <permission android:name="android.permission.RECORD_SENSITIVE_CONTENT" + android:protectionLevel="signature"/> + <!-- @SystemApi Allows an application to read install sessions @hide This is not a third-party API (intended for system apps). --> <permission android:name="android.permission.READ_INSTALL_SESSIONS" |