summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Manjeet Rulhania <mrulhania@google.com> 2024-03-12 16:37:54 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-03-12 16:37:54 +0000
commita93b49a1439bec48f258b8460586206d5ee817cc (patch)
treefd27008c76d693cf57a6a4655d8a75b63b500c65
parentacfaad4082b9236a48e90fb720d6e0cea432b7ba (diff)
parent68f677f378063974e384c8467051af4b04bd477e (diff)
Merge "Add test for new RECORD_SENSITIVE_CONTENT permission" into main
-rw-r--r--tests/cts/permission/src/android/permission/cts/RecordSensitiveContentPermissionTest.kt62
-rw-r--r--tests/cts/permissionpolicy/res/raw/android_manifest.xml6
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"