From a6eb7b35252774c930c029f88915c7d9050b348b Mon Sep 17 00:00:00 2001 From: Varun Praveen Goyal Date: Fri, 27 Jan 2023 09:13:46 +0000 Subject: CTS test for Android Security b/258653813 Bug: 258653813 Bug: 264917439 Test: Ran the new testcase on android-11.0.0_r2 with/without patch Change-Id: I3beebc3a8abb471fcbf130f50fb225d52f567d6a --- .../src/android/security/cts/CVE_2023_20955.java | 81 +++++++++++++ .../test-apps/CVE-2023-20955/Android.bp | 54 +++++++++ .../CVE-2023-20955/test-app/AndroidManifest.xml | 33 ++++++ .../CVE-2023-20955/test-app/res/values/strings.xml | 29 +++++ .../test-app/res/xml/device_policies.xml | 20 ++++ .../cts/CVE_2023_20955_test/DeviceTest.java | 131 +++++++++++++++++++++ .../PocDeviceAdminReceiver.java | 22 ++++ .../test-helper-app/AndroidManifest.xml | 20 ++++ 8 files changed, 390 insertions(+) create mode 100644 hostsidetests/securitybulletin/src/android/security/cts/CVE_2023_20955.java create mode 100644 hostsidetests/securitybulletin/test-apps/CVE-2023-20955/Android.bp create mode 100644 hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/AndroidManifest.xml create mode 100644 hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/values/strings.xml create mode 100644 hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/xml/device_policies.xml create mode 100644 hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/DeviceTest.java create mode 100644 hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/PocDeviceAdminReceiver.java create mode 100644 hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-helper-app/AndroidManifest.xml diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2023_20955.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2023_20955.java new file mode 100644 index 00000000000..96f2257ed15 --- /dev/null +++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2023_20955.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2023 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.security.cts; + +import static org.junit.Assume.assumeNoException; +import static org.junit.Assume.assumeTrue; + +import android.platform.test.annotations.AsbSecurityTest; + +import com.android.sts.common.tradefed.testtype.NonRootSecurityTestCase; +import com.android.tradefed.device.ITestDevice; +import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(DeviceJUnit4ClassRunner.class) +public class CVE_2023_20955 extends NonRootSecurityTestCase { + + // b/258653813 + // Vulnerable app : Settings.apk + // Vulnerable package : com.android.settings + // Is Play Managed : No + @AsbSecurityTest(cveBugId = 240663194) + @Test + public void testPocCVE_2023_20955() { + int userId = -1; + ITestDevice device = null; + final String testPkg = "android.security.cts.CVE_2023_20955_test"; + final String componentName = testPkg + "/.PocDeviceAdminReceiver"; + try { + device = getDevice(); + + // Install the test app + installPackage("CVE-2023-20955-test.apk", "-t"); + + // Set test app as device owner + assumeTrue("Failed to set test app as device owner", + device.setDeviceOwner(componentName, 0)); + + // Create a new user + userId = device.createUser("CTSUser"); + assumeTrue("Failed to create a user. ITestDevice.createUser() returned -1", + userId != -1); + + // Install test helper app for all users + installPackage("CVE-2023-20955-test-helper.apk", "--user all"); + + // Run device test to check if App Info window allows uninstall for all users if + // DevicePolicyManager has restricted it. + runDeviceTests(testPkg, testPkg + ".DeviceTest", + "testAppInfoUninstallForAllUsersDisabled"); + } catch (Exception e) { + assumeNoException(e); + } finally { + try { + // Remove user + device.removeUser(userId); + + // Remove test app as device owner + device.removeAdmin(componentName, 0); + } catch (Exception e) { + // ignore + } + } + } +} diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/Android.bp b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/Android.bp new file mode 100644 index 00000000000..e856574ef9c --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/Android.bp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2023 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +android_test_helper_app { + name: "CVE-2023-20955-test", + defaults: [ + "cts_support_defaults", + ], + srcs: [ + "test-app/src/**/*.java", + ], + test_suites: [ + "sts", + ], + static_libs: [ + "androidx.test.core", + "androidx.test.rules", + "androidx.test.uiautomator_uiautomator", + ], + resource_dirs: [ + "test-app/res", + ], + manifest: "test-app/AndroidManifest.xml", + sdk_version: "current", +} + +android_test_helper_app { + name: "CVE-2023-20955-test-helper", + defaults: [ + "cts_support_defaults", + ], + test_suites: [ + "sts", + ], + manifest: "test-helper-app/AndroidManifest.xml", + sdk_version: "current", +} diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/AndroidManifest.xml b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/AndroidManifest.xml new file mode 100644 index 00000000000..2d74f5492fc --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/values/strings.xml b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/values/strings.xml new file mode 100644 index 00000000000..194436bd2b9 --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/values/strings.xml @@ -0,0 +1,29 @@ + + + + + Vulnerable to b/258653813 !! + Did not find an object with selector %1$s on the screen + Failed to set user restriction DISALLOW_APPS_CONTROL + + .*more options.* + .*uninstall.* + .*uninstall for all users.* + android.security.cts.CVE_2023_20955_test_helper + com.android.packageinstaller + package + diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/xml/device_policies.xml b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/xml/device_policies.xml new file mode 100644 index 00000000000..ed5352d7c0f --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/res/xml/device_policies.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/DeviceTest.java b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/DeviceTest.java new file mode 100644 index 00000000000..8b769040010 --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/DeviceTest.java @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2023 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.security.cts.CVE_2023_20955_test; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assume.assumeNoException; +import static org.junit.Assume.assumeTrue; + +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.UserManager; +import android.provider.Settings; +import android.widget.ImageButton; + +import androidx.test.runner.AndroidJUnit4; +import androidx.test.uiautomator.By; +import androidx.test.uiautomator.BySelector; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.Until; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.regex.Pattern; + +@RunWith(AndroidJUnit4.class) +public class DeviceTest { + private static final int TIMEOUT_MS = 5000; + private Context mContext; + private UiDevice mDevice; + + private void waitAndClick(BySelector selector) { + assumeTrue(mContext.getString(R.string.msgNotFoundTxt, selector.toString()), + mDevice.wait(Until.hasObject(selector), TIMEOUT_MS)); + mDevice.findObject(selector).click(); + } + + @Test + public void testAppInfoUninstallForAllUsersDisabled() { + try { + mContext = getInstrumentation().getTargetContext(); + mDevice = UiDevice.getInstance(getInstrumentation()); + + // Restrict current user to disallow controlling apps + ComponentName deviceAdminComponent = + new ComponentName(mContext, PocDeviceAdminReceiver.class); + DevicePolicyManager policyManager = null; + policyManager = mContext.getSystemService(DevicePolicyManager.class); + policyManager.addUserRestriction(deviceAdminComponent, + UserManager.DISALLOW_APPS_CONTROL); + + // Waiting for user restriction to be added + boolean disallowAppsControlVal = + (boolean) policyManager.getUserRestrictions(deviceAdminComponent) + .getBoolean(UserManager.DISALLOW_APPS_CONTROL); + while (!disallowAppsControlVal && System.currentTimeMillis() < TIMEOUT_MS) { + disallowAppsControlVal = policyManager.getUserRestrictions(deviceAdminComponent) + .getBoolean(UserManager.DISALLOW_APPS_CONTROL); + Thread.sleep(100); + } + assumeTrue(mContext.getString(R.string.msgSetUserRestrictionFailed), + disallowAppsControlVal); + + // Launching "application info" window for test helper app + Uri pkgUri = Uri.fromParts(mContext.getString(R.string.uriScheme), + mContext.getString(R.string.pkgNameHelper), null); + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, pkgUri); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + mContext.startActivity(intent); + + // Wait for the application info window and click on 3 dots with: + // content description = "More options" + Pattern descPattern = Pattern.compile(mContext.getString(R.string.patternMoreOptions), + Pattern.CASE_INSENSITIVE); + waitAndClick(By.clazz(ImageButton.class).desc(descPattern)); + + // Wait for a menu to appear. When it appears, click on the text "Uninstall for all + // users". + Pattern textPattern = + Pattern.compile(mContext.getString(R.string.patternUninstallAllUsers), + Pattern.CASE_INSENSITIVE); + waitAndClick(By.text(textPattern)); + + // Retrieve the package name of installer app + Intent packageInstallerIntent = new Intent(Intent.ACTION_DELETE, pkgUri); + ComponentName componentName = + packageInstallerIntent.resolveActivity(mContext.getPackageManager()); + String pkgNameInstaller = mContext.getString(R.string.pkgNameInstaller); + if (componentName != null && componentName.getPackageName() != null) { + pkgNameInstaller = componentName.getPackageName(); + } + + // Wait for UI with package = "com.android.packageinstaller" (AOSP), text containing + // "uninstall". If found, it indicates vulnerable behaviour and anyone can uninstall + // app for all users despite the user restrictions. + textPattern = Pattern.compile(mContext.getString(R.string.patternUninstall), + Pattern.CASE_INSENSITIVE); + assertFalse(mContext.getString(R.string.failMsg), mDevice + .wait(Until.hasObject(By.pkg(pkgNameInstaller).text(textPattern)), TIMEOUT_MS)); + } catch (Exception e) { + assumeNoException(e); + } finally { + try { + // Go to the home screen + mDevice.pressHome(); + } catch (Exception e) { + // ignore + } + } + } +} diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/PocDeviceAdminReceiver.java b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/PocDeviceAdminReceiver.java new file mode 100644 index 00000000000..7141a402e65 --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-app/src/android/security/cts/CVE_2023_20955_test/PocDeviceAdminReceiver.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2023 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.security.cts.CVE_2023_20955_test; + +import android.app.admin.DeviceAdminReceiver; + +public class PocDeviceAdminReceiver extends DeviceAdminReceiver { +} diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-helper-app/AndroidManifest.xml b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-helper-app/AndroidManifest.xml new file mode 100644 index 00000000000..73420e4b366 --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20955/test-helper-app/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + -- cgit v1.2.3 From 5b8dcc85065a9ced33335012f2d129307c52c9b8 Mon Sep 17 00:00:00 2001 From: Dushant Meshram Date: Tue, 7 Feb 2023 09:09:20 +0000 Subject: CTS test for Android Security b/249057848 Bug: 249057848 Bug: 267332077 Test: Ran the new testcase on android-13.0.0_r7 with/without patch Change-Id: I2986a7169c0c14db3817489c6a8fddcac3a731b0 --- .../src/android/security/cts/CVE_2023_20959.java | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/tests/security/src/android/security/cts/CVE_2023_20959.java diff --git a/tests/tests/security/src/android/security/cts/CVE_2023_20959.java b/tests/tests/security/src/android/security/cts/CVE_2023_20959.java new file mode 100644 index 00000000000..00c0e6dabd1 --- /dev/null +++ b/tests/tests/security/src/android/security/cts/CVE_2023_20959.java @@ -0,0 +1,73 @@ +/** + * Copyright (C) 2023 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.security.cts; + +import static org.junit.Assert.assertNull; +import static org.junit.Assume.assumeNoException; + +import android.app.Instrumentation; +import android.app.UiAutomation; +import android.content.ComponentName; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.os.UserHandle; +import android.platform.test.annotations.AsbSecurityTest; +import android.provider.Settings; + +import androidx.test.runner.AndroidJUnit4; + +import com.android.sts.common.util.StsExtraBusinessLogicTestCase; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class CVE_2023_20959 extends StsExtraBusinessLogicTestCase { + + @AsbSecurityTest(cveBugId = 249057848) + @Test + public void testPocCVE_2023_20959() { + UiAutomation uiAutomation = null; + try { + String settingsPackageName = "com.android.settings"; + Instrumentation instrumentation = getInstrumentation(); + PackageManager packageManager = instrumentation.getTargetContext().getPackageManager(); + uiAutomation = instrumentation.getUiAutomation(); + uiAutomation.adoptShellPermissionIdentity( + android.Manifest.permission.INTERACT_ACROSS_USERS); + ResolveInfo info = + packageManager.resolveActivityAsUser(new Intent(Settings.ACTION_SETTINGS), + PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); + if (info != null && info.activityInfo != null) { + settingsPackageName = info.activityInfo.packageName; + } + assertNull(new Intent() + .setComponent(new ComponentName(settingsPackageName, + settingsPackageName + ".users.AddSupervisedUserActivity")) + .resolveActivityInfo(packageManager, PackageManager.MATCH_SYSTEM_ONLY)); + } catch (Exception e) { + assumeNoException(e); + } finally { + try { + uiAutomation.dropShellPermissionIdentity(); + } catch (Exception e) { + // Ignore exceptions as the test has finished + } + } + } +} -- cgit v1.2.3 From 571076e4b48cfe61dab2f35f388b12b13d371a0c Mon Sep 17 00:00:00 2001 From: Varun Praveen Goyal Date: Tue, 7 Feb 2023 09:22:19 +0000 Subject: CTS test for Android Security b/251778420 Bug: 251778420 Bug: 267331730 Test: Ran the new testcase on android-13.0.0_r1 with/without patch Change-Id: Ib64516c2d477c516a659faf709d8ef1fe19bcb6e --- tests/tests/security/AndroidManifest.xml | 3 + .../cts/CVE_2023_20953/CVE_2023_20953.java | 108 +++++++++++++++++++++ .../security/cts/CVE_2023_20953/PocActivity.java | 36 +++++++ 3 files changed, 147 insertions(+) create mode 100644 tests/tests/security/src/android/security/cts/CVE_2023_20953/CVE_2023_20953.java create mode 100644 tests/tests/security/src/android/security/cts/CVE_2023_20953/PocActivity.java diff --git a/tests/tests/security/AndroidManifest.xml b/tests/tests/security/AndroidManifest.xml index 7627600c97c..01fb9b3cfac 100644 --- a/tests/tests/security/AndroidManifest.xml +++ b/tests/tests/security/AndroidManifest.xml @@ -232,6 +232,9 @@ android:resource="@xml/syncadapter" /> + + diff --git a/tests/tests/security/src/android/security/cts/CVE_2023_20953/CVE_2023_20953.java b/tests/tests/security/src/android/security/cts/CVE_2023_20953/CVE_2023_20953.java new file mode 100644 index 00000000000..8c1863cffd7 --- /dev/null +++ b/tests/tests/security/src/android/security/cts/CVE_2023_20953/CVE_2023_20953.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2023 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.security.cts.CVE_2023_20953; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assume.assumeNoException; +import static org.junit.Assume.assumeTrue; + +import android.app.Instrumentation; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.platform.test.annotations.AsbSecurityTest; +import android.support.test.uiautomator.By; +import android.support.test.uiautomator.BySelector; +import android.support.test.uiautomator.UiDevice; +import android.support.test.uiautomator.UiObject2; +import android.support.test.uiautomator.Until; + +import androidx.test.runner.AndroidJUnit4; + +import com.android.sts.common.SystemUtil; +import com.android.sts.common.util.StsExtraBusinessLogicTestCase; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.regex.Pattern; + +@RunWith(AndroidJUnit4.class) +public class CVE_2023_20953 extends StsExtraBusinessLogicTestCase { + + @AsbSecurityTest(cveBugId = 251778420) + @Test + public void testCliboardIfUserSetupNotComplete() { + try { + Instrumentation instrumentation = getInstrumentation(); + Context context = instrumentation.getContext(); + UiDevice device = UiDevice.getInstance(instrumentation); + + // Change the setting 'user_setup_complete' to 0. + try (AutoCloseable withSettingCloseable = + SystemUtil.withSetting(instrumentation, "secure", "user_setup_complete", "0")) { + // Launch the PocActivity which shows a basic view to edit some text. + final String pkgName = context.getPackageName(); + Intent intent = new Intent(); + intent.setClassName(pkgName, pkgName + ".CVE_2023_20953.PocActivity"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + + // Look for UI with text "CVE-2023-20955" and select it. Doing so will show some + // clipboard options such as 'copy', 'select all', 'cut'. + final String uiNotFoundMsg = "UI not found with selector %s"; + BySelector selector = By.text("CVE-2023-20955"); + final long timeoutMs = 5000; + boolean uiFound = device.wait(Until.findObject(selector), timeoutMs) != null; + assumeTrue(String.format(uiNotFoundMsg, selector), uiFound); + UiObject2 object = device.findObject(selector); + device.drag(object.getVisibleBounds().left, object.getVisibleCenter().y, + object.getVisibleBounds().right, object.getVisibleCenter().y, 1); + + // Click on 'Copy' option. + selector = By.desc(Pattern.compile(".*copy.*", Pattern.CASE_INSENSITIVE)); + uiFound = device.wait(Until.findObject(selector), timeoutMs) != null; + assumeTrue(String.format(uiNotFoundMsg, selector), uiFound); + device.findObject(selector).click(); + + // Retrieve System UI package name dynamically. + String systemUiPkgName = "com.android.systemui"; + intent = new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG); + PackageManager pm = context.getPackageManager(); + ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_SYSTEM_ONLY); + if (info != null && info.activityInfo != null + && info.activityInfo.packageName != null) { + systemUiPkgName = info.activityInfo.packageName; + } + + // On vulnerable device, user whose setup is not yet complete will be able to share + // the copied text, in which case test fails, else it passes. + // Look for UI with resource = com.android.systemui:id/share_chip, if found test + // will fail. + final String shareBtnResName = "%s:id/share_chip"; + selector = By.res(String.format(shareBtnResName, systemUiPkgName)); + assertFalse("Vulnerable to b/251778420 !!", + device.wait(Until.hasObject(selector), timeoutMs)); + } + } catch (Exception e) { + assumeNoException(e); + } + } +} diff --git a/tests/tests/security/src/android/security/cts/CVE_2023_20953/PocActivity.java b/tests/tests/security/src/android/security/cts/CVE_2023_20953/PocActivity.java new file mode 100644 index 00000000000..5ef6ceba4f2 --- /dev/null +++ b/tests/tests/security/src/android/security/cts/CVE_2023_20953/PocActivity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 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.security.cts.CVE_2023_20953; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.EditText; + +public class PocActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + try { + super.onCreate(savedInstanceState); + EditText editText = new EditText(this); + editText.setText("CVE-2023-20955"); + setContentView(editText); + } catch (Exception e) { + // ignore + } + } +} -- cgit v1.2.3 From 730cac35aac1e3fec59a37a529f79235ca07e199 Mon Sep 17 00:00:00 2001 From: Daichi Hirono Date: Mon, 21 Nov 2022 14:22:48 +0900 Subject: Merge duplicated DisableFixedToUserRotationRule util class Merge resolution I3e138cbeeacae79fd3949f47179264bf26a881a9 brought back DisableFixToUserRotationRule class which was renamed to DisableFixedToUserRotationRule. This CL - Applys I153c0f7e38b3ef719f2b469d1d8abac91ca3c949 to new DisableFixedToUserRotationRule. The change has been applied only to the old DisableFixToUserRotationRule. - Removes old DisableFixToUserRotationRule Bug: 259875732 Test: m CtsViewTestCases Change-Id: Iff378d064d5a4ce841bf8ac6b825e9827123a906 (cherry picked from commit 75c11d15d95203f420f40ec045317b262499ca4d) --- .../cts/util/DisableFixToUserRotationRule.java | 87 ---------------------- .../cts/util/DisableFixedToUserRotationRule.java | 18 ++++- 2 files changed, 15 insertions(+), 90 deletions(-) delete mode 100644 tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java diff --git a/tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java b/tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java deleted file mode 100644 index 36b63145964..00000000000 --- a/tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2020 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.view.cts.util; - -import android.app.UiAutomation; -import android.content.pm.PackageManager; -import android.os.ParcelFileDescriptor; -import android.util.Log; - -import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; - -public class DisableFixToUserRotationRule implements TestRule { - private static final String TAG = "DisableFixToUserRotationRule"; - private static final String COMMAND = "cmd window set-fix-to-user-rotation "; - - private final UiAutomation mUiAutomation; - private final boolean mSupportsRotation; - - public DisableFixToUserRotationRule() { - mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation(); - PackageManager pm = InstrumentationRegistry - .getInstrumentation() - .getContext() - .getPackageManager(); - mSupportsRotation = pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE) - && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT); - } - - @Override - public Statement apply(Statement base, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - if (mSupportsRotation) { - executeShellCommandAndPrint(COMMAND + "disabled"); - } - try { - base.evaluate(); - } finally { - if (mSupportsRotation) { - executeShellCommandAndPrint(COMMAND + "default"); - } - } - } - }; - } - - private void executeShellCommandAndPrint(String cmd) { - ParcelFileDescriptor pfd = mUiAutomation.executeShellCommand(cmd); - StringBuilder builder = new StringBuilder(); - char[] buffer = new char[256]; - int charRead; - try (Reader reader = - new InputStreamReader(new ParcelFileDescriptor.AutoCloseInputStream(pfd))) { - while ((charRead = reader.read(buffer)) > 0) { - builder.append(buffer, 0, charRead); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - - Log.i(TAG, "Command: " + cmd + " Output: " + builder); - } - -} diff --git a/tests/tests/view/src/android/view/cts/util/DisableFixedToUserRotationRule.java b/tests/tests/view/src/android/view/cts/util/DisableFixedToUserRotationRule.java index 17a50ff4be4..711923e8454 100644 --- a/tests/tests/view/src/android/view/cts/util/DisableFixedToUserRotationRule.java +++ b/tests/tests/view/src/android/view/cts/util/DisableFixedToUserRotationRule.java @@ -17,6 +17,7 @@ package android.view.cts.util; import android.app.UiAutomation; +import android.content.pm.PackageManager; import android.os.ParcelFileDescriptor; import android.util.Log; @@ -35,11 +36,18 @@ public class DisableFixedToUserRotationRule implements TestRule { private static final String COMMAND = "cmd window fixed-to-user-rotation "; private final UiAutomation mUiAutomation; + private final boolean mSupportsRotation; private String mOriginalValue; public DisableFixedToUserRotationRule() { mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation(); + PackageManager pm = InstrumentationRegistry + .getInstrumentation() + .getContext() + .getPackageManager(); + mSupportsRotation = pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE) + && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT); } @Override @@ -47,12 +55,16 @@ public class DisableFixedToUserRotationRule implements TestRule { return new Statement() { @Override public void evaluate() throws Throwable { - mOriginalValue = executeShellCommand(COMMAND); - executeShellCommandAndPrint(COMMAND + "disabled"); + if (mSupportsRotation) { + mOriginalValue = executeShellCommand(COMMAND); + executeShellCommandAndPrint(COMMAND + "disabled"); + } try { base.evaluate(); } finally { - executeShellCommandAndPrint(COMMAND + mOriginalValue); + if (mSupportsRotation) { + executeShellCommandAndPrint(COMMAND + mOriginalValue); + } } } }; -- cgit v1.2.3 From b43f387ebca50993957a3a7860112794887247cb Mon Sep 17 00:00:00 2001 From: Christopher Dombroski Date: Thu, 2 Mar 2023 13:13:28 -0800 Subject: Remove unnecessary resources from helper apps Bug: 271454297 Test: inspect size of artifacts in out/host/linux-x86/sts/android-sts/ Change-Id: I1e41f65af766f7f130209d77298db65710390569 Merged-In: I1e41f65af766f7f130209d77298db65710390569 --- tests/tests/security/Android.bp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/tests/security/Android.bp b/tests/tests/security/Android.bp index 56d02d21ee3..989edcac454 100644 --- a/tests/tests/security/Android.bp +++ b/tests/tests/security/Android.bp @@ -104,6 +104,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert1", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-1", manifest: "testdata/permissionbackuptestapp/AndroidManifest.xml", } @@ -111,6 +113,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert1Dup", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-1", manifest: "testdata/permissionbackuptestapp/AndroidManifest.xml", } @@ -118,6 +122,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert2", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-2", manifest: "testdata/permissionbackuptestapp/AndroidManifest.xml", } @@ -125,6 +131,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert3", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-3", manifest: "testdata/permissionbackuptestapp/AndroidManifest.xml", } @@ -132,6 +140,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert4", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-4", manifest: "testdata/permissionbackuptestapp/AndroidManifest.xml", } @@ -139,6 +149,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert12", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-1", additional_certificates: [ ":permission-test-cert-2", @@ -149,6 +161,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert12Dup", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-1", additional_certificates: [ ":permission-test-cert-2", @@ -159,6 +173,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert34", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-3", additional_certificates: [ ":permission-test-cert-4", @@ -169,6 +185,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert123", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-1", additional_certificates: [ ":permission-test-cert-2", @@ -180,6 +198,8 @@ android_test_helper_app { android_test_helper_app { name: "CtsPermissionBackupAppCert4History124", min_sdk_version: "30", + resource_dirs: [], + asset_dirs: [], certificate: ":permission-test-cert-4", additional_certificates: [ ":permission-test-cert-1", @@ -197,6 +217,8 @@ android_app_certificate { android_test_helper_app { name: "RolePermissionOverrideTestApp", + resource_dirs: [], + asset_dirs: [], manifest: "testdata/rolepermissionoverridetestapp.xml", } -- cgit v1.2.3 From b24f6b1e80551c3001b20533e66a1fa82e15c264 Mon Sep 17 00:00:00 2001 From: Ross Yeh Date: Wed, 15 Mar 2023 19:41:36 +0000 Subject: Revert "Adding tests to list aliases of large number of Keystore entries with" This reverts commit d4c9e15dd674f081a6aa13e0e59136c509ca750f. Reason for revert: new tests should be scoped in the next major release. Bug: 222287335 Change-Id: I2289793b79240cdbd5d96f91f1b10e743eac6d62 --- .../android/keystore/cts/AndroidKeyStoreTest.java | 206 +++------------------ 1 file changed, 30 insertions(+), 176 deletions(-) diff --git a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java index bf2e941bfa5..56dd1b0f561 100644 --- a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java +++ b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java @@ -16,13 +16,11 @@ package android.keystore.cts; -import static com.google.common.truth.Truth.assertThat; - import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -39,13 +37,6 @@ import android.util.Log; import androidx.test.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; -import com.android.bedstead.nene.annotations.Nullable; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.OutputStream; @@ -72,7 +63,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Collection; -import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashSet; @@ -88,6 +78,11 @@ import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.security.auth.x500.X500Principal; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + @RunWith(AndroidJUnit4.class) public class AndroidKeyStoreTest { private static final String TAG = AndroidKeyStoreTest.class.getSimpleName(); @@ -828,12 +823,6 @@ public class AndroidKeyStoreTest { expectedAliases.length, count); } - private void deleteEntryIfNotNull(@Nullable String alias) throws Exception { - if (alias != null) { - mKeyStore.deleteEntry(alias); - } - } - @Test public void testKeyStore_Aliases_Unencrypted_Success() throws Exception { mKeyStore.load(null, null); @@ -2172,9 +2161,8 @@ public class AndroidKeyStoreTest { PrivateKey privateKey3 = generatePrivateKey("RSA", FAKE_RSA_KEY_1); final int MAX_NUMBER_OF_KEYS = 2500; - final StringBuilder aliasPrefix = new StringBuilder("test_large_number_of_rsa_keys_"); + final String ALIAS_PREFIX = "test_large_number_of_rsa_keys_"; int keyCount = 0; - String entryName2 = null; mKeyStore.load(null); try { @@ -2187,12 +2175,11 @@ public class AndroidKeyStoreTest { new KeyStore.PrivateKeyEntry(privateKey1, new Certificate[] {cert1}), protectionParams); - keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, aliasPrefix, - new PrivateKeyEntry(privateKey3, new Certificate[] {cert3}), - protectionParams); + keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, ALIAS_PREFIX, + new PrivateKeyEntry(privateKey3, new Certificate[] {cert3}), protectionParams); keyCount++; - entryName2 = "test" + keyCount; + String entryName2 = "test" + keyCount; mKeyStore.setEntry(entryName2, new KeyStore.PrivateKeyEntry(privateKey2, new Certificate[] {cert2}), protectionParams); @@ -2219,9 +2206,7 @@ public class AndroidKeyStoreTest { sig.update(message); assertTrue(sig.verify(signature)); } finally { - mKeyStore.deleteEntry(entryName1); - deleteEntryIfNotNull(entryName2); - deleteManyTestKeys(keyCount, aliasPrefix); + deleteManyTestKeys(keyCount, ALIAS_PREFIX); } } @@ -2250,9 +2235,8 @@ public class AndroidKeyStoreTest { PrivateKey privateKey3 = generatePrivateKey("EC", FAKE_EC_KEY_1); final int MAX_NUMBER_OF_KEYS = 2500; - final StringBuilder aliasPrefix = new StringBuilder("test_large_number_of_ec_keys_"); + final String ALIAS_PREFIX = "test_large_number_of_ec_keys_"; int keyCount = 0; - String entryName2 = null; mKeyStore.load(null); try { @@ -2264,12 +2248,12 @@ public class AndroidKeyStoreTest { new KeyStore.PrivateKeyEntry(privateKey1, new Certificate[] {cert1}), protectionParams); - keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, aliasPrefix, + keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, ALIAS_PREFIX, new KeyStore.PrivateKeyEntry(privateKey3, new Certificate[] {cert3}), protectionParams); keyCount++; - entryName2 = "test" + keyCount; + String entryName2 = "test" + keyCount; mKeyStore.setEntry(entryName2, new KeyStore.PrivateKeyEntry(privateKey2, new Certificate[] {cert2}), protectionParams); @@ -2296,9 +2280,7 @@ public class AndroidKeyStoreTest { sig.update(message); assertTrue(sig.verify(signature)); } finally { - mKeyStore.deleteEntry(entryName1); - deleteEntryIfNotNull(entryName2); - deleteManyTestKeys(keyCount, aliasPrefix); + deleteManyTestKeys(keyCount, ALIAS_PREFIX); } } @@ -2325,9 +2307,8 @@ public class AndroidKeyStoreTest { HexEncoding.decode("33333333333333333333777777777777"), "AES"); final int MAX_NUMBER_OF_KEYS = 10000; - final StringBuilder aliasPrefix = new StringBuilder("test_large_number_of_aes_keys_"); + final String ALIAS_PREFIX = "test_large_number_of_aes_keys_"; int keyCount = 0; - String entryName2 = null; mKeyStore.load(null); try { @@ -2338,11 +2319,11 @@ public class AndroidKeyStoreTest { .build(); mKeyStore.setEntry(entryName1, new KeyStore.SecretKeyEntry(key1), protectionParams); - keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, aliasPrefix, + keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, ALIAS_PREFIX, new KeyStore.SecretKeyEntry(key3), protectionParams); ++keyCount; - entryName2 = "test" + keyCount; + String entryName2 = "test" + keyCount; mKeyStore.setEntry(entryName2, new KeyStore.SecretKeyEntry(key2), protectionParams); SecretKey keystoreKey2 = (SecretKey) mKeyStore.getKey(entryName2, null); SecretKey keystoreKey1 = (SecretKey) mKeyStore.getKey(entryName1, null); @@ -2364,9 +2345,7 @@ public class AndroidKeyStoreTest { cipher.init(Cipher.DECRYPT_MODE, key2, cipherParams); assertArrayEquals(plaintext, cipher.doFinal(ciphertext)); } finally { - mKeyStore.deleteEntry(entryName1); - deleteEntryIfNotNull(entryName2); - deleteManyTestKeys(keyCount, aliasPrefix); + deleteManyTestKeys(keyCount, ALIAS_PREFIX); } } @@ -2395,9 +2374,8 @@ public class AndroidKeyStoreTest { HexEncoding.decode("33333333333333333333777777777777"), "HmacSHA256"); final int MAX_NUMBER_OF_KEYS = 10000; - final StringBuilder aliasPrefix = new StringBuilder("test_large_number_of_hmac_keys_"); + final String ALIAS_PREFIX = "test_large_number_of_hmac_keys_"; int keyCount = 0; - String entryName2 = null; mKeyStore.load(null); try { @@ -2406,11 +2384,11 @@ public class AndroidKeyStoreTest { .build(); mKeyStore.setEntry(entryName1, new KeyStore.SecretKeyEntry(key1), protectionParams); - keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, aliasPrefix, + keyCount = importKeyManyTimes(MAX_NUMBER_OF_KEYS, ALIAS_PREFIX, new KeyStore.SecretKeyEntry(key3), protectionParams); keyCount++; - entryName2 = "test" + keyCount; + String entryName2 = "test" + keyCount; mKeyStore.setEntry(entryName2, new KeyStore.SecretKeyEntry(key2), protectionParams); SecretKey keystoreKey2 = (SecretKey) mKeyStore.getKey(entryName2, null); SecretKey keystoreKey1 = (SecretKey) mKeyStore.getKey(entryName1, null); @@ -2430,9 +2408,7 @@ public class AndroidKeyStoreTest { "59b57e77e4e2cb36b5c7b84af198ac004327bc549de6931a1b5505372dd8c957"), mac.doFinal(message)); } finally { - mKeyStore.deleteEntry(entryName1); - deleteEntryIfNotNull(entryName2); - deleteManyTestKeys(keyCount, aliasPrefix); + deleteManyTestKeys(keyCount, ALIAS_PREFIX); } } @@ -2630,8 +2606,8 @@ public class AndroidKeyStoreTest { * * This method is time-bounded */ - private int importKeyManyTimes(int numberOfKeys, StringBuilder aliasPrefix, Entry keyEntry, - KeyProtection protectionParams, boolean isTimeBound) + private int importKeyManyTimes(int numberOfKeys, String aliasPrefix, Entry keyEntry, + KeyProtection protectionParams) throws InterruptedException { TimeBox timeBox = new TimeBox(mMaxImportDuration); AtomicInteger keyCounter = new AtomicInteger(0); @@ -2640,7 +2616,7 @@ public class AndroidKeyStoreTest { threads.add(new Thread(() -> { // Import key lots of times, under different aliases. Do this until we either run // out of time or we import the key numberOfKeys times. - while (!isTimeBound || !timeBox.isOutOfTime()) { + while (!timeBox.isOutOfTime()) { int count = keyCounter.incrementAndGet(); if (count > numberOfKeys) { // The loop is inherently racy, as multiple threads are simultaneously @@ -2653,7 +2629,7 @@ public class AndroidKeyStoreTest { if ((count % 1000) == 0) { Log.i(TAG, "Imported " + count + " keys"); } - String entryAlias = aliasPrefix.toString() + count; + String entryAlias = aliasPrefix + count; try { mKeyStore.setEntry(entryAlias, keyEntry, protectionParams); } catch (Throwable e) { @@ -2670,7 +2646,7 @@ public class AndroidKeyStoreTest { threads.get(i).join(); } Log.i(TAG, "Imported " + keyCounter.get() + " keys in " + timeBox.elapsed()); - if (keyCounter.get() != numberOfKeys && keyCounter.get() < MIN_SUPPORTED_KEY_COUNT) { + if (keyCounter.get() < MIN_SUPPORTED_KEY_COUNT) { fail("Failed to import " + MIN_SUPPORTED_KEY_COUNT + " keys in " + timeBox.elapsed() + ". Imported: " + keyCounter.get() + " keys"); } @@ -2678,22 +2654,11 @@ public class AndroidKeyStoreTest { return keyCounter.get(); } - private int importKeyManyTimes(int numberOfKeys, StringBuilder aliasPrefix, Entry keyEntry, - KeyProtection protectionParams) throws InterruptedException { - return importKeyManyTimes(numberOfKeys, aliasPrefix, keyEntry, protectionParams, true); - } - - private int importKeyManyTimesWithoutTimeLimit(int numberOfKeys, StringBuilder aliasPrefix, - Entry keyEntry, - KeyProtection protectionParams) throws InterruptedException { - return importKeyManyTimes(numberOfKeys, aliasPrefix, keyEntry, protectionParams, false); - } - /** * Delete numberOfKeys keys that follow the pattern "[aliasPrefix][keyCounter]". * This is done across multiple threads to both increase throughput as well as stress keystore. */ - private void deleteManyTestKeys(int numberOfKeys, StringBuilder aliasPrefix) + private void deleteManyTestKeys(int numberOfKeys, String aliasPrefix) throws InterruptedException { // Clean up Keystore without using KeyStore.aliases() which can't handle this many // entries. @@ -2708,9 +2673,8 @@ public class AndroidKeyStoreTest { if ((key > 0) && ((key % 1000) == 0)) { Log.i(TAG, "Deleted " + key + " keys"); } - String entryAlias = aliasPrefix.toString() + key; try { - mKeyStore.deleteEntry(entryAlias); + mKeyStore.deleteEntry("test" + key); } catch (Exception e) { fail("Unexpected exception in key cleanup: " + e); } @@ -2726,114 +2690,4 @@ public class AndroidKeyStoreTest { } Log.i(TAG, "Deleted " + numberOfKeys + " keys"); } - - private Set createLargeNumberOfKeyStoreEntryAliases(int numberOfKeys, - StringBuilder aliasPrefix) - throws Exception { - Certificate cert = generateCertificate(FAKE_RSA_USER_1); - PrivateKey privateKey = generatePrivateKey("RSA", FAKE_RSA_KEY_1); - - mKeyStore.load(null); - KeyProtection protectionParams = new KeyProtection.Builder( - KeyProperties.PURPOSE_SIGN) - .setDigests(KeyProperties.DIGEST_SHA256) - .setSignaturePaddings(KeyProperties.SIGNATURE_PADDING_RSA_PKCS1) - .build(); - - int keyCount = importKeyManyTimesWithoutTimeLimit(numberOfKeys, aliasPrefix, - new PrivateKeyEntry(privateKey, new Certificate[]{cert}), protectionParams); - - // Construct expected aliases list. - final Set expectedAliases = new HashSet<>(keyCount); - for (int count = 1; count <= keyCount; count++) { - String entryAlias = aliasPrefix.toString() + count; - expectedAliases.add(entryAlias); - } - - return expectedAliases; - } - - private void importLargeNumberOfKeysValidateAliases(int numberOfKeys, StringBuilder aliasPrefix) - throws Exception { - Set importedKeyAliases = createLargeNumberOfKeyStoreEntryAliases(numberOfKeys, - aliasPrefix); - assertThat(importedKeyAliases.size()).isEqualTo(numberOfKeys); - - try { - // b/222287335 Currently, limiting Keystore `listEntries` API to return subset of the - // Keystore entries to avoid running out of binder buffer space. - // To verify that all the imported key aliases are present in Keystore, get the list of - // aliases from Keystore, delete the matched aliases from Keystore and imported list of - // key aliases, continue this till all the imported key aliases are matched. - while (!importedKeyAliases.isEmpty()) { - // List the keystore entries aliases until all the imported key aliases are matched. - Set aliases = new HashSet(Collections.list(mKeyStore.aliases())); - - // Try to match the aliases with imported key aliases. - // Cleanup matching aliases from Keystore and imported key aliases list. - for (String alias: aliases) { - if (importedKeyAliases.contains(alias)) { - mKeyStore.deleteEntry(alias); - importedKeyAliases.remove(alias); - } - } - } - assertTrue("Failed to match imported keystore entries.", - importedKeyAliases.isEmpty()); - } finally { - if (!importedKeyAliases.isEmpty()) { - Log.i(TAG, "Final cleanup of imported keys"); - for (String alias: importedKeyAliases) { - mKeyStore.deleteEntry(alias); - } - } - } - assertTrue(importedKeyAliases.isEmpty()); - } - - /** - * Create long alias prefix of length 6000 characters. - */ - private StringBuilder createLongAliasPrefix() { - char[] prefixChar = new char[6000]; - Arrays.fill(prefixChar, 'T'); - StringBuilder prefixAlias = new StringBuilder(); - prefixAlias.append(prefixChar); - - return prefixAlias; - } - - /** - * Create large number of Keystore entries with long aliases and try to list aliases of all the - * entries in the keystore. - */ - @Test - public void testKeyStore_LargeNumberOfLongAliases() throws Exception { - final int maxNumberOfKeys = 100; - - importLargeNumberOfKeysValidateAliases(maxNumberOfKeys, createLongAliasPrefix()); - } - - /** - * Create limited number of Keystore entries with long aliases and try to list aliases of all - * the entries in the keystore. Test should successfully list all the Keystore entries aliases. - */ - @Test - public void testKeyStore_LimitedNumberOfLongAliasesSuccess() throws Exception { - final int maxNumberOfKeys = 10; - importLargeNumberOfKeysValidateAliases(maxNumberOfKeys, createLongAliasPrefix()); - } - - /** - * Create large number of Keystore entries with short length aliases and try to list aliases of - * all the entries in the keystore. Test should successfully list all the Keystore entries - * aliases. - */ - @Test - public void testKeyStore_LargeNumberShortAliasesSuccess() throws Exception { - final int maxNumberOfKeys = 2500; - final StringBuilder aliasPrefix = new StringBuilder("test_short_key_alias_"); - - importLargeNumberOfKeysValidateAliases(maxNumberOfKeys, aliasPrefix); - } } -- cgit v1.2.3 From efcb6b3af14f3afb61dc881546697c0a799c0851 Mon Sep 17 00:00:00 2001 From: Emil Bengtsson Date: Tue, 14 Mar 2023 14:51:51 +0100 Subject: Skip SensorBlockedBannerTest for wear Wear does not currently support the blocked sensor banner Bug: 271487483 Test: atest SensorBlockedBannerTest#testLocationCardDisplayed Change-Id: Ie4dacbfc6300bef339669c82a7fc192a44358b23 --- .../permission3/src/android/permission3/cts/SensorBlockedBannerTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/tests/permission3/src/android/permission3/cts/SensorBlockedBannerTest.kt b/tests/tests/permission3/src/android/permission3/cts/SensorBlockedBannerTest.kt index 0b88e01f772..7499e0f2c04 100644 --- a/tests/tests/permission3/src/android/permission3/cts/SensorBlockedBannerTest.kt +++ b/tests/tests/permission3/src/android/permission3/cts/SensorBlockedBannerTest.kt @@ -65,6 +65,7 @@ class SensorBlockedBannerTest : BaseUsePermissionTest() { @Before fun setup() { Assume.assumeFalse(isTv) + Assume.assumeFalse(isWatch) // TODO(b/203784852) Auto will eventually support the blocked sensor banner, but there won't // be support in T or below Assume.assumeFalse(isAutomotive) -- cgit v1.2.3 From 83ae50736741923c1a46068c1b5d989cb51a7db4 Mon Sep 17 00:00:00 2001 From: Shivam Garg Date: Fri, 17 Mar 2023 06:42:49 +0000 Subject: In CTS test use Intent.EXTRA_MIME_TYPES instead of CloudMediaProviderContract.EXTRA_MIME_TYPE In order to reuse existing keys rather than creating our own, Use Intent.EXTRA_MIME_TYPE instead of CloudMediaProviderContract.EXTRA_MIME_TYPE. Also replace CloudMediaProviderContract.EXTRA_MIME_TYPE with Intent.EXTRA_MIME_TYPES in cts test as well since it is not used anywhere. Bug: b/270958022 Test: - Change-Id: I203d0ca80849e4bcd0be6d1ebde05cf3f9674fa6 --- .../src/android/photopicker/cts/PickerProviderMediaGenerator.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java b/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java index 5110781914f..216b5de1d1f 100644 --- a/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java +++ b/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java @@ -432,8 +432,7 @@ public class PickerProviderMediaGenerator { } albumId = bundle.getString(CloudMediaProviderContract.EXTRA_ALBUM_ID, null); - mimeType = bundle.getString(CloudMediaProviderContract.EXTRA_MIME_TYPE, - null); + mimeType = bundle.getString(Intent.EXTRA_MIME_TYPES, null); sizeBytes = bundle.getLong(CloudMediaProviderContract.EXTRA_SIZE_LIMIT_BYTES, 0); generation = bundle.getLong(CloudMediaProviderContract.EXTRA_SYNC_GENERATION, 0); } -- cgit v1.2.3 From 5b5c3c81968830e2d025b4f9a9b592a1d5cab72f Mon Sep 17 00:00:00 2001 From: Shrisha Udupa S Date: Wed, 22 Mar 2023 15:54:16 +0100 Subject: CTS-V: Skip Audio Descriptor Test if HDMI feature is not supported This change skips listing the Audio Descriptor test in CTSVerifier on devices that do not support the HDMI feature. Bug: 273946244 Test: Tested on a wearable device that the Audio Descriptor test no longer shows up in CTSVerifier Change-Id: I1092474b7076b00b3efe91d3c2d56b7913857660 --- apps/CtsVerifier/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml index 9c6d4b8f17d..80b4d1355ff 100644 --- a/apps/CtsVerifier/AndroidManifest.xml +++ b/apps/CtsVerifier/AndroidManifest.xml @@ -5375,6 +5375,7 @@ + { - extra.putParcelableArrayList(EXTRA_KEEP_CLEAR_RECTS, - new ArrayList(TEST_KEEP_CLEAR_RECTS)); - }) - .setTargetActivity(KEEP_CLEAR_RECTS_ACTIVITY); + startKeepClearActivitiesInSplitscreen(KEEP_CLEAR_RECTS_ACTIVITY, + KEEP_CLEAR_RECTS_ACTIVITY2, Collections.emptyList(), Collections.emptyList()); + final List prevKeepClearRectsOnDisplay = getKeepClearRectsOnDefaultDisplay(); - final LaunchActivityBuilder activityBuilder2 = getLaunchActivityBuilder() - .setUseInstrumentation() - .setIntentExtra(extra -> { - extra.putParcelableArrayList(EXTRA_KEEP_CLEAR_RECTS, - new ArrayList(TEST_KEEP_CLEAR_RECTS_2)); - }) - .setTargetActivity(KEEP_CLEAR_RECTS_ACTIVITY2); + removeRootTask(mWmState.getTaskByActivity(KEEP_CLEAR_RECTS_ACTIVITY).mTaskId); + removeRootTask(mWmState.getTaskByActivity(KEEP_CLEAR_RECTS_ACTIVITY2).mTaskId); - launchActivitiesInSplitScreen(activityBuilder1, activityBuilder2); - - waitAndAssertResumedActivity(KEEP_CLEAR_RECTS_ACTIVITY, KEEP_CLEAR_RECTS_ACTIVITY - + " must be resumed"); - waitAndAssertResumedActivity(KEEP_CLEAR_RECTS_ACTIVITY2, KEEP_CLEAR_RECTS_ACTIVITY2 - + " must be resumed"); - mWmState.assertVisibility(KEEP_CLEAR_RECTS_ACTIVITY, true); - mWmState.assertVisibility(KEEP_CLEAR_RECTS_ACTIVITY2, true); + startKeepClearActivitiesInSplitscreen(KEEP_CLEAR_RECTS_ACTIVITY, + KEEP_CLEAR_RECTS_ACTIVITY2, TEST_KEEP_CLEAR_RECTS, TEST_KEEP_CLEAR_RECTS_2); assertSameElementsEventually(TEST_KEEP_CLEAR_RECTS, () -> getKeepClearRectsForActivity(KEEP_CLEAR_RECTS_ACTIVITY)); @@ -506,11 +512,38 @@ public class KeepClearRectsTests extends WindowManagerTestBase { () -> getKeepClearRectsForActivity(KEEP_CLEAR_RECTS_ACTIVITY2)); final List expected = new ArrayList(); + expected.addAll(prevKeepClearRectsOnDisplay); expected.addAll(getRectsInScreenSpace(TEST_KEEP_CLEAR_RECTS, KEEP_CLEAR_RECTS_ACTIVITY)); expected.addAll(getRectsInScreenSpace(TEST_KEEP_CLEAR_RECTS_2, KEEP_CLEAR_RECTS_ACTIVITY2)); assertSameElementsEventually(expected, () -> getKeepClearRectsOnDefaultDisplay()); } + private void startKeepClearActivitiesInSplitscreen(ComponentName activity1, + ComponentName activity2, List keepClearRects1, List keepClearRects2) { + final LaunchActivityBuilder activityBuilder1 = getLaunchActivityBuilder() + .setUseInstrumentation() + .setTargetActivity(activity1) + .setIntentExtra(extra -> { + extra.putParcelableArrayList(EXTRA_KEEP_CLEAR_RECTS, + new ArrayList(keepClearRects1)); + }); + + final LaunchActivityBuilder activityBuilder2 = getLaunchActivityBuilder() + .setUseInstrumentation() + .setTargetActivity(activity2) + .setIntentExtra(extra -> { + extra.putParcelableArrayList(EXTRA_KEEP_CLEAR_RECTS, + new ArrayList(keepClearRects2)); + }); + + launchActivitiesInSplitScreen(activityBuilder1, activityBuilder2); + + waitAndAssertResumedActivity(activity1, activity1 + " must be resumed"); + waitAndAssertResumedActivity(activity2, activity2 + " must be resumed"); + mWmState.assertVisibility(activity1, true); + mWmState.assertVisibility(activity2, true); + } + @Test public void testUnrestrictedKeepClearRects() throws Exception { mTestSession.launchTestActivityOnDisplaySync(TestActivity.class, DEFAULT_DISPLAY); @@ -547,6 +580,7 @@ public class KeepClearRectsTests extends WindowManagerTestBase { mTestSession.runOnMainSyncAndWait(() -> { activity.addView(newView, params); }); + waitForIdle(); return newView; } @@ -607,7 +641,8 @@ public class KeepClearRectsTests extends WindowManagerTestBase { private static void assertSameElementsEventually(List expected, Callable> actual) throws Exception { - PollingCheck.check("Lists do not have the same elements.", + PollingCheck.check("Lists do not have the same elements." + + "Expected=" + expected + ", actual=" + actual.call(), SAME_ELEMENT_ASSERTION_TIMEOUT, () -> hasSameElements(expected, actual.call())); } -- cgit v1.2.3 From c52c938da721cab683b0757da75a98ba3190e2a6 Mon Sep 17 00:00:00 2001 From: Pranav Madapurmath Date: Fri, 24 Mar 2023 13:16:31 +0000 Subject: Call Redirection: unbind service when onBind returns null The call redirection service does not handle the corner case of onNullBinding (occurs when onBind returns null). This vulnerability would give the app that has the call redirection role unintentional access to launch background activities outside the scope of a call lifecycle. Fixes: 273260090 Test: Unit test to ensure we unbind the service on null onBind Test: CTS for similar assertion Change-Id: I65a504775fd4dbcd3f063a9db62cd61da224086b Merged-In: I65a504775fd4dbcd3f063a9db62cd61da224086b --- tests/tests/telecom/AndroidManifest.xml | 7 +++ .../telecom/cts/CallRedirectionServiceTest.java | 51 +++++++++++++--- ...ullBindingCallRedirectionServiceController.java | 70 ++++++++++++++++++++++ 3 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 tests/tests/telecom/src/android/telecom/cts/NullBindingCallRedirectionServiceController.java diff --git a/tests/tests/telecom/AndroidManifest.xml b/tests/tests/telecom/AndroidManifest.xml index 6718ecf1006..689189b5639 100644 --- a/tests/tests/telecom/AndroidManifest.xml +++ b/tests/tests/telecom/AndroidManifest.xml @@ -78,6 +78,13 @@ + + + + + + diff --git a/tests/tests/telecom/src/android/telecom/cts/CallRedirectionServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/CallRedirectionServiceTest.java index 5e8f3f53358..5758894f695 100644 --- a/tests/tests/telecom/src/android/telecom/cts/CallRedirectionServiceTest.java +++ b/tests/tests/telecom/src/android/telecom/cts/CallRedirectionServiceTest.java @@ -25,7 +25,6 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; - import android.net.Uri; import android.os.Bundle; import android.os.Handler; @@ -33,13 +32,14 @@ import android.os.IBinder; import android.os.Looper; import android.os.Process; import android.os.UserHandle; - import android.telecom.Call; import android.telecom.PhoneAccount; +import android.telecom.TelecomManager; import android.telecom.cts.redirectiontestapp.CtsCallRedirectionService; import android.telecom.cts.redirectiontestapp.CtsCallRedirectionServiceController; import android.telecom.cts.redirectiontestapp.ICtsCallRedirectionServiceController; import android.text.TextUtils; +import android.util.Log; import com.android.compatibility.common.util.CddTest; @@ -89,7 +89,7 @@ public class CallRedirectionServiceTest extends BaseTelecomTestWithMockServices NewOutgoingCallBroadcastReceiver.reset(); mHandler = new Handler(Looper.getMainLooper()); mRoleManager = (RoleManager) mContext.getSystemService(Context.ROLE_SERVICE); - setupControlBinder(); + setupControlBinder(null, null); setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE); rememberPreviousCallRedirectionApp(); // Ensure CTS app holds the call redirection role. @@ -202,16 +202,44 @@ public class CallRedirectionServiceTest extends BaseTelecomTestWithMockServices assertTrue(Call.STATE_DISCONNECTED != mCall.getState()); } + public void testServiceUnbindOnNullBinding() + throws Exception { + if (!shouldTestTelecom(mContext)) { + return; + } + // Set up control binder using NullBindingCallRedirectionServiceController. + // This will invoke onNullBinding. + setupControlBinder(NullBindingCallRedirectionServiceController.CONTROL_INTERFACE_ACTION, + NullBindingCallRedirectionServiceController.CONTROL_INTERFACE_COMPONENT); + Bundle extras = new Bundle(); + extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, + TestUtils.TEST_PHONE_ACCOUNT_HANDLE); + mTelecomManager.placeCall(createTestNumber(), extras); + // Assert bind and unbind latch countdown + assertTrue(TestUtils.waitForLatchCountDown( + NullBindingCallRedirectionServiceController.sBindLatch)); + assertTrue(TestUtils.waitForLatchCountDown( + NullBindingCallRedirectionServiceController.sUnbindLatch)); + } + /** * Sets up a binder used to control the CallRedirectionServiceCtsTestApp. * This app is a standalone APK so that it can reside in a package name outside of the one the * CTS test itself runs in. * @throws InterruptedException */ - private void setupControlBinder() throws InterruptedException { - Intent bindIntent = new Intent( - CtsCallRedirectionServiceController.CONTROL_INTERFACE_ACTION); - bindIntent.setComponent(CtsCallRedirectionServiceController.CONTROL_INTERFACE_COMPONENT); + private void setupControlBinder(String interfaceAction, + ComponentName interfaceComponentName) throws InterruptedException { + if (interfaceAction == null) { + interfaceAction = CtsCallRedirectionServiceController.CONTROL_INTERFACE_ACTION; + } + if (interfaceComponentName == null) { + interfaceComponentName = + CtsCallRedirectionServiceController.CONTROL_INTERFACE_COMPONENT; + } + + Intent bindIntent = new Intent(interfaceAction); + bindIntent.setComponent(interfaceComponentName); final CountDownLatch bindLatch = new CountDownLatch(1); boolean success = mContext.bindService(bindIntent, new ServiceConnection() { @@ -225,6 +253,15 @@ public class CallRedirectionServiceTest extends BaseTelecomTestWithMockServices public void onServiceDisconnected(ComponentName name) { mCallRedirectionServiceController = null; } + + @Override + public void onNullBinding(ComponentName name) { + // This path will only be hit if NullBindingCallRedirectionServiceController is set + // as the controller. + Log.i(TAG, "onNullBinding: null binding received from onBind"); + bindLatch.countDown(); + mContext.unbindService(this); + } }, Context.BIND_AUTO_CREATE); if (!success) { fail("Failed to get control interface -- bind error"); diff --git a/tests/tests/telecom/src/android/telecom/cts/NullBindingCallRedirectionServiceController.java b/tests/tests/telecom/src/android/telecom/cts/NullBindingCallRedirectionServiceController.java new file mode 100644 index 00000000000..2ffc6d65ee9 --- /dev/null +++ b/tests/tests/telecom/src/android/telecom/cts/NullBindingCallRedirectionServiceController.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2019 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.telecom.cts; + +import android.app.Service; +import android.content.ComponentName; +import android.content.Intent; +import android.os.IBinder; +import android.util.Log; + +import java.util.concurrent.CountDownLatch; + +public class NullBindingCallRedirectionServiceController extends Service { + private static final String TAG = NullBindingCallRedirectionServiceController.class + .getSimpleName(); + public static final String CONTROL_INTERFACE_ACTION = + "android.telecom.cts.ACTION_CONTROL_CALL_REDIRECTION_SERVICE"; + public static final ComponentName CONTROL_INTERFACE_COMPONENT = + ComponentName.unflattenFromString( + "android.telecom.cts/.NullBindingCallRedirectionServiceController"); + + public static CountDownLatch sBindLatch = new CountDownLatch(1); + public static CountDownLatch sUnbindLatch = new CountDownLatch(1); + + private static NullBindingCallRedirectionServiceController + sCallRedirectionServiceController = null; + + + public static NullBindingCallRedirectionServiceController getInstance() { + return sCallRedirectionServiceController; + } + + public static void resetBindLatches() { + sBindLatch = new CountDownLatch(1); + sUnbindLatch = new CountDownLatch(1); + } + + @Override + public IBinder onBind(Intent intent) { + Log.i(TAG, "onBind: returning null binding"); + sCallRedirectionServiceController = this; + // Treat case as null binding from onBind. This should hit onNullBinding. + sUnbindLatch = new CountDownLatch(1); + sBindLatch.countDown(); + return null; + } + + @Override + public boolean onUnbind(Intent intent) { + Log.i(TAG, "onUnbind: unbinding service"); + sCallRedirectionServiceController = null; + sUnbindLatch.countDown(); + return false; + } +} + -- cgit v1.2.3 From 9fcb07f8380b96e6b948e531f6d138845a1c0e04 Mon Sep 17 00:00:00 2001 From: Sainath Varanasi Date: Wed, 15 Feb 2023 05:19:07 +0000 Subject: Use setDecorFitsSystemWindows and setting this to false The framework will not fit the content view to the insets and will just pass through the WindowInsets to the content view. Bug: 268428735 Change-Id: Iedc607c46cbe9b558f11971cc408f47f53512ee9 --- .../android/view/cts/surfacevalidator/ASurfaceControlTestActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/ASurfaceControlTestActivity.java b/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/ASurfaceControlTestActivity.java index ccecf850d49..850f970db64 100644 --- a/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/ASurfaceControlTestActivity.java +++ b/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/ASurfaceControlTestActivity.java @@ -89,6 +89,7 @@ public class ASurfaceControlTestActivity extends Activity { getWindow().getDecorView().setPointerIcon( PointerIcon.getSystemIcon(this, PointerIcon.TYPE_NULL)); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + getWindow().setDecorFitsSystemWindows(false); mLayoutParams = new FrameLayout.LayoutParams(DEFAULT_LAYOUT_WIDTH, DEFAULT_LAYOUT_HEIGHT, Gravity.LEFT | Gravity.TOP); -- cgit v1.2.3 From 820f89b19761e0db6ca1aff192761cc294a3e955 Mon Sep 17 00:00:00 2001 From: Mitali Kulkarni Date: Wed, 8 Mar 2023 17:50:15 -0500 Subject: Fix PixelCopyTest CTS issue The test case didn't handle cutout properly while windowLayoutInDisplayCutoutMode is always, set it to default could fix the issue Test:run cts -m CtsViewTestCases -t android.view.cts.PixelCopyTest#testDialogProducerScaling --abi arm64-v8a Bug: 271314822 Change-Id: Ic889f6bdc7932a081da3d7e7d1d546326c4e0b5c --- tests/tests/view/AndroidManifest.xml | 2 +- tests/tests/view/res/values/styles.xml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/tests/view/AndroidManifest.xml b/tests/tests/view/AndroidManifest.xml index a892da1d6cc..6de3aac86d3 100644 --- a/tests/tests/view/AndroidManifest.xml +++ b/tests/tests/view/AndroidManifest.xml @@ -203,7 +203,7 @@ android:label="PixelCopyViewProducerDialogActivity" android:screenOrientation="portrait" android:rotationAnimation="jumpcut" - android:theme="@android:style/Theme.Material.Dialog.NoActionBar" + android:theme="@style/PixelCopyViewProducerDialogActivityTheme" android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize"/> @null + +