diff options
44 files changed, 415 insertions, 88 deletions
diff --git a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py index 657f20c206d..107877d10bd 100644 --- a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py +++ b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py @@ -216,7 +216,12 @@ def _find_raw_fov_reference(cam, req, props, log_path): fd = float(cap_raw['metadata']['android.lens.focalLength']) k = camera_properties_utils.get_intrinsic_calibration(props, True, fd) opencv_dist = camera_properties_utils.get_distortion_matrix(props) - img_raw = cv2.undistort(img_raw, k, opencv_dist) + k_new = cv2.getOptimalNewCameraMatrix( + k, opencv_dist, (img_raw.shape[1], img_raw.shape[0]), 0)[0] + scale = max(k_new[0][0] / k[0][0], k_new[1][1] / k[1][1]) + k_new[0][0] = k[0][0] * scale + k_new[1][1] = k[1][1] * scale + img_raw = cv2.undistort(img_raw, k, opencv_dist, None, k_new) # Get image size. size_raw = img_raw.shape diff --git a/apps/CameraITS/utils/opencv_processing_utils.py b/apps/CameraITS/utils/opencv_processing_utils.py index 69bad61e991..6cc692b4258 100644 --- a/apps/CameraITS/utils/opencv_processing_utils.py +++ b/apps/CameraITS/utils/opencv_processing_utils.py @@ -557,29 +557,17 @@ def get_angle(input_img): class Cv2ImageProcessingUtilsTests(unittest.TestCase): """Unit tests for this module.""" - def test_get_angle_identify_unrotated_chessboard_angle(self): - normal_img_path = os.path.join( - TEST_IMG_DIR, 'rotated_chessboards/normal.jpg') - wide_img_path = os.path.join( - TEST_IMG_DIR, 'rotated_chessboards/wide.jpg') - normal_img = cv2.cvtColor(cv2.imread(normal_img_path), cv2.COLOR_BGR2GRAY) - wide_img = cv2.cvtColor(cv2.imread(wide_img_path), cv2.COLOR_BGR2GRAY) - normal_angle = get_angle(normal_img) - wide_angle = get_angle(wide_img) - e_msg = f'Angle: 0, Regular: {normal_angle}, Wide: {wide_angle}' - self.assertEqual(get_angle(normal_img), 0, e_msg) - self.assertEqual(get_angle(wide_img), 0, e_msg) - def test_get_angle_identify_rotated_chessboard_angle(self): # Array of the image files and angles containing rotated chessboards. test_cases = [ - ('_15_ccw', 15), - ('_30_ccw', 30), - ('_45_ccw', 45), - ('_60_ccw', 60), - ('_75_ccw', 75), - ('_90_ccw', 90) + ('', 0), + ('_15_ccw', -15), + ('_30_ccw', -30), + ('_45_ccw', -45), + ('_60_ccw', -60), + ('_75_ccw', -75), ] + test_fails = '' # For each rotated image pair (normal, wide), check angle against expected. for suffix, angle in test_cases: @@ -594,13 +582,21 @@ class Cv2ImageProcessingUtilsTests(unittest.TestCase): wide_img = cv2.cvtColor(cv2.imread(wide_img_path), cv2.COLOR_BGR2GRAY) # Assert angle as expected. - normal_angle = get_angle(normal_img) - wide_angle = get_angle(wide_img) - e_msg = f'Angle: {angle}, Regular: {normal_angle}, Wide: {wide_angle}' - self.assertTrue( - numpy.isclose(abs(normal_angle), angle, ANGLE_CHECK_TOL), e_msg) - self.assertTrue( - numpy.isclose(abs(wide_angle), angle, ANGLE_CHECK_TOL), e_msg) + normal = get_angle(normal_img) + wide = get_angle(wide_img) + valid_angles = (angle, angle+90) # try both angle & +90 due to squares + e_msg = (f'\n Rotation angle test failed: {angle}, extracted normal: ' + f'{normal:.2f}, wide: {wide:.2f}, valid_angles: {valid_angles}') + matched_angles = False + for a in valid_angles: + if (math.isclose(normal, a, abs_tol=ANGLE_CHECK_TOL) and + math.isclose(wide, a, abs_tol=ANGLE_CHECK_TOL)): + matched_angles = True + + if not matched_angles: + test_fails += e_msg + + self.assertEqual(len(test_fails), 0, test_fails) if __name__ == '__main__': diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml index 9855e6d3c3c..ba399637335 100644 --- a/apps/CtsVerifier/AndroidManifest.xml +++ b/apps/CtsVerifier/AndroidManifest.xml @@ -5474,6 +5474,15 @@ <action android:name="android.intent.action.MAIN" /> <category android:name="android.cts.intent.category.MANUAL_TEST" /> </intent-filter> + <meta-data + android:name="test_category" + android:value="@string/test_category_telecom"/> + <meta-data + android:name="test_required_features" + android:value="android.hardware.telephony"/> + <meta-data + android:name="test_required_configs" + android:value="config_voice_capable"/> <meta-data android:name="display_mode" android:value="multi_display_mode" /> </activity> diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInColdStartLatencyActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInColdStartLatencyActivity.java index 9af7e14c0ac..c5308065ac3 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInColdStartLatencyActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInColdStartLatencyActivity.java @@ -150,6 +150,7 @@ public class AudioInColdStartLatencyActivity } mRecorder.stopStream(); + mRecorder.teardownStream(); mIsTestRunning = false; diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutColdStartLatencyActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutColdStartLatencyActivity.java index 8f6c7f945f6..1d782806f0b 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutColdStartLatencyActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutColdStartLatencyActivity.java @@ -112,10 +112,6 @@ public class AudioOutColdStartLatencyActivity return mColdStartlatencyMS; } - protected void stopAudio() { - stopAudioTest(); - } - void startOutTimer() { TimerTask task = new TimerTask() { public void run() { @@ -198,6 +194,8 @@ public class AudioOutColdStartLatencyActivity } mPlayer.stopStream(); + mPlayer.teardownStream(); + mIsTestRunning = false; stopOutTimer(); diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientTestListActivity.java index 54f8ad1d304..90848a9e07f 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientTestListActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientTestListActivity.java @@ -17,7 +17,9 @@ package com.android.cts.verifier.bluetooth;
import android.bluetooth.BluetoothAdapter;
+import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.os.SystemProperties;
import com.android.cts.verifier.ManifestTestListAdapter;
import com.android.cts.verifier.PassFailButtons;
@@ -42,6 +44,16 @@ public class BleSecureClientTestListActivity extends PassFailButtons.TestListAct "com.android.cts.verifier.bluetooth.BleAdvertiserHardwareScanFilterActivity.");
}
+ // RPA is optional on TVs already released before Android 11
+ boolean isTv = getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);
+ int firstSdk = SystemProperties.getInt("ro.product.first_api_level", 0);
+ if (isTv && (firstSdk <= 29)) {
+ disabledTest.add(
+ "com.android.cts.verifier.bluetooth.BleSecureConnectionPriorityClientTestActivity");
+ disabledTest.add(
+ "com.android.cts.verifier.bluetooth.BleSecureEncryptedClientTestActivity");
+ }
+
setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),
disabledTest.toArray(new String[disabledTest.size()])));
}
diff --git a/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/DeviceState.java b/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/DeviceState.java index cf92bf70899..ab66ee5d23d 100644 --- a/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/DeviceState.java +++ b/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/DeviceState.java @@ -990,7 +990,6 @@ public final class DeviceState implements TestRule { UserType forUser, boolean hasProfileOwner, boolean profileOwnerIsPrimary) { - requireFeature("android.software.managed_users", FailureMode.SKIP); com.android.bedstead.nene.users.UserType resolvedUserType = requireUserSupported(profileType, FailureMode.SKIP); @@ -1023,8 +1022,6 @@ public final class DeviceState implements TestRule { } private void ensureHasNoProfile(String profileType, UserType forUser) { - requireFeature("android.software.managed_users", FailureMode.SKIP); - UserReference forUserReference = resolveUserTypeToUser(forUser); com.android.bedstead.nene.users.UserType resolvedProfileType = sTestApis.users().supportedType(profileType); diff --git a/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/annotations/EnsureHasNoWorkProfile.java b/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/annotations/EnsureHasNoWorkProfile.java index 63736259a21..6cc76a2bf78 100644 --- a/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/annotations/EnsureHasNoWorkProfile.java +++ b/common/device-side/bedstead/harrier/src/main/java/com/android/bedstead/harrier/annotations/EnsureHasNoWorkProfile.java @@ -36,6 +36,7 @@ import java.lang.annotation.Target; @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @EnsureHasNoProfileAnnotation("android.os.usertype.profile.MANAGED") +@RequireFeature("android.software.managed_users") public @interface EnsureHasNoWorkProfile { /** Which user type the work profile should not be attached to. */ DeviceState.UserType forUser() default CURRENT_USER; diff --git a/hostsidetests/accounts/AndroidTest.xml b/hostsidetests/accounts/AndroidTest.xml index d2676309b28..8603a71ef61 100644 --- a/hostsidetests/accounts/AndroidTest.xml +++ b/hostsidetests/accounts/AndroidTest.xml @@ -16,7 +16,7 @@ <configuration description="Config for the CTS accounts host tests"> <option name="test-suite-tag" value="cts" /> <option name="config-descriptor:metadata" key="component" value="framework" /> - <option name="config-descriptor:metadata" key="parameter" value="instant_app" /> + <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" /> <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" /> <option name="config-descriptor:metadata" key="parameter" value="secondary_user" /> <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" > diff --git a/hostsidetests/blobstore/src/com/android/cts/host/blob/BaseBlobStoreHostTest.java b/hostsidetests/blobstore/src/com/android/cts/host/blob/BaseBlobStoreHostTest.java index fc355afc020..69287180e53 100644 --- a/hostsidetests/blobstore/src/com/android/cts/host/blob/BaseBlobStoreHostTest.java +++ b/hostsidetests/blobstore/src/com/android/cts/host/blob/BaseBlobStoreHostTest.java @@ -98,6 +98,10 @@ abstract class BaseBlobStoreHostTest extends BaseHostJUnit4Test { return device.isMultiUserSupported(); } + protected boolean isMultiUserSupported() throws Exception { + return isMultiUserSupported(getDevice()); + } + protected Map<String, String> createArgsFromLastTestRun() { final Map<String, String> args = new HashMap<>(); for (String key : new String[] { diff --git a/hostsidetests/blobstore/src/com/android/cts/host/blob/BlobStoreMultiUserTest.java b/hostsidetests/blobstore/src/com/android/cts/host/blob/BlobStoreMultiUserTest.java index ec13654ffb5..9a78386495d 100644 --- a/hostsidetests/blobstore/src/com/android/cts/host/blob/BlobStoreMultiUserTest.java +++ b/hostsidetests/blobstore/src/com/android/cts/host/blob/BlobStoreMultiUserTest.java @@ -40,9 +40,9 @@ public class BlobStoreMultiUserTest extends BaseBlobStoreHostTest { @BeforeClassWithInfo public static void setUpClass(TestInformation testInfo) throws Exception { - assumeTrue("Multi-user is not supported on this device", - isMultiUserSupported(testInfo.getDevice())); - + if(!isMultiUserSupported(testInfo.getDevice())) { + return; + } mPrimaryUserId = testInfo.getDevice().getPrimaryUserId(); mSecondaryUserId = testInfo.getDevice().createUser("Test_User"); assertThat(testInfo.getDevice().startUser(mSecondaryUserId)).isTrue(); @@ -50,6 +50,8 @@ public class BlobStoreMultiUserTest extends BaseBlobStoreHostTest { @Before public void setUp() throws Exception { + assumeTrue("Multi-user is not supported on this device", isMultiUserSupported()); + for (String apk : new String[] {TARGET_APK, TARGET_APK_DEV}) { installPackageAsUser(apk, true /* grantPermissions */, mPrimaryUserId, "-t"); installPackageAsUser(apk, true /* grantPermissions */, mSecondaryUserId, "-t"); diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DevicePolicySafetyCheckerIntegrationTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DevicePolicySafetyCheckerIntegrationTest.java index 922745df545..a6dcb8d5b50 100644 --- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DevicePolicySafetyCheckerIntegrationTest.java +++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DevicePolicySafetyCheckerIntegrationTest.java @@ -99,7 +99,6 @@ public final class DevicePolicySafetyCheckerIntegrationTest extends BaseDeviceOw OPERATION_SET_APPLICATION_HIDDEN, OPERATION_SET_APPLICATION_RESTRICTIONS, OPERATION_SET_CAMERA_DISABLED, - OPERATION_SET_FACTORY_RESET_PROTECTION_POLICY, OPERATION_SET_GLOBAL_PRIVATE_DNS, OPERATION_SET_KEEP_UNINSTALLED_PACKAGES, OPERATION_SET_KEYGUARD_DISABLED, @@ -125,6 +124,10 @@ public final class DevicePolicySafetyCheckerIntegrationTest extends BaseDeviceOw operations = ArrayUtils.appendInt(operations, OPERATION_SET_TRUST_AGENT_CONFIGURATION); } + if (mDevicePolicyManager.isFactoryResetProtectionPolicySupported()) { + operations = ArrayUtils.appendInt(operations, + OPERATION_SET_FACTORY_RESET_PROTECTION_POLICY); + } return operations; } diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java index 27897398a2a..d157fc0bed6 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java @@ -167,6 +167,7 @@ public class QuietModeHostsideTest extends BaseDevicePolicyTest { private void clearLogcat() throws DeviceNotAvailableException { getDevice().executeAdbCommand("logcat", "-c"); + getDevice().executeAdbCommand("logcat", "-G", "16M"); } private void verifyBroadcastSent(String actionName, boolean needPermissions) diff --git a/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecDeviceOsdNameTest.java b/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecDeviceOsdNameTest.java index c5f5b36e077..561b57578c0 100644 --- a/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecDeviceOsdNameTest.java +++ b/hostsidetests/hdmicec/src/android/hdmicec/cts/playback/HdmiCecDeviceOsdNameTest.java @@ -99,9 +99,6 @@ public final class HdmiCecDeviceOsdNameTest extends BaseHdmiCecCtsTest { */ @Test public void cect_11_2_11_2_UnregisteredDeviceGiveOsdNameTest() throws Exception { - hdmiCecClient.sendCecMessage(LogicalAddress.PLAYBACK_1, CecOperand.GIVE_OSD_NAME); - hdmiCecClient.checkOutputDoesNotContainMessage(LogicalAddress.PLAYBACK_1, - CecOperand.SET_OSD_NAME); hdmiCecClient.sendCecMessage(LogicalAddress.BROADCAST, CecOperand.GIVE_OSD_NAME); hdmiCecClient.checkOutputDoesNotContainMessage(LogicalAddress.BROADCAST, CecOperand.SET_OSD_NAME); diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0481.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0481.java index 81e559ae1f0..e5e6810c8fb 100644 --- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0481.java +++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0481.java @@ -72,9 +72,18 @@ public class CVE_2021_0481 extends BaseHostJUnit4Test { installPackage(); //ensure the screen is woken up. - //(we need to do this twice. once wakes up the screen, and another unlocks the lock screen) - getDevice().executeShellCommand("input keyevent KEYCODE_WAKEUP"); + //KEYCODE_WAKEUP wakes up the screen + //KEYCODE_MENU called twice unlocks the screen (if locked) + //Note: (applies to Android 12 only): + // KEYCODE_MENU called less than twice doesnot unlock the screen + // no matter how many times KEYCODE_HOME is called. + // This is likely a timing issue which has to be investigated further getDevice().executeShellCommand("input keyevent KEYCODE_WAKEUP"); + getDevice().executeShellCommand("input keyevent KEYCODE_MENU"); + getDevice().executeShellCommand("input keyevent KEYCODE_HOME"); + getDevice().executeShellCommand("input keyevent KEYCODE_MENU"); + + //run the test Assert.assertTrue(runDeviceTests(TEST_PKG, TEST_CLASS, "testUserPhotoSetUp")); //Check if TEST_FILE_NAME has been copied by "Evil activity" diff --git a/tests/libcore/jsr166/AndroidTest.xml b/tests/libcore/jsr166/AndroidTest.xml index 93a2b76e479..3dc2bdb503c 100644 --- a/tests/libcore/jsr166/AndroidTest.xml +++ b/tests/libcore/jsr166/AndroidTest.xml @@ -54,4 +54,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/libcore/luni/AndroidTest.xml b/tests/libcore/luni/AndroidTest.xml index 2173c92b487..8fcaaab19c3 100644 --- a/tests/libcore/luni/AndroidTest.xml +++ b/tests/libcore/luni/AndroidTest.xml @@ -80,4 +80,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/libcore/ojluni/AndroidTest.xml b/tests/libcore/ojluni/AndroidTest.xml index 86e04f6192e..f929c4bd4b4 100644 --- a/tests/libcore/ojluni/AndroidTest.xml +++ b/tests/libcore/ojluni/AndroidTest.xml @@ -58,4 +58,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/libcore/okhttp/MtsLibcoreOkHttpTestCases.xml b/tests/libcore/okhttp/MtsLibcoreOkHttpTestCases.xml index 8219e38ce64..c3e97a4b258 100644 --- a/tests/libcore/okhttp/MtsLibcoreOkHttpTestCases.xml +++ b/tests/libcore/okhttp/MtsLibcoreOkHttpTestCases.xml @@ -56,4 +56,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/libcore/wycheproof-bc/AndroidTest.xml b/tests/libcore/wycheproof-bc/AndroidTest.xml index b0471d01f3c..dce14b56515 100644 --- a/tests/libcore/wycheproof-bc/AndroidTest.xml +++ b/tests/libcore/wycheproof-bc/AndroidTest.xml @@ -52,4 +52,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/location/location_fine/src/android/location/cts/fine/GeofencingTest.java b/tests/location/location_fine/src/android/location/cts/fine/GeofencingTest.java index 59c91c91341..b4b62cce647 100644 --- a/tests/location/location_fine/src/android/location/cts/fine/GeofencingTest.java +++ b/tests/location/location_fine/src/android/location/cts/fine/GeofencingTest.java @@ -30,6 +30,7 @@ import android.content.Intent; import android.location.Criteria; import android.location.LocationManager; import android.location.cts.common.ProximityPendingIntentCapture; +import android.os.UserManager; import android.util.Log; import androidx.test.core.app.ApplicationProvider; @@ -100,6 +101,10 @@ public class GeofencingTest { @Test public void testAddProximityAlert() throws Exception { + if (isNotSystemUser()) { + Log.i(TAG, "Skipping test on secondary user"); + return; + } mManager.addTestProvider(FUSED_PROVIDER, true, false, @@ -173,6 +178,11 @@ public class GeofencingTest { @Test public void testRemoveProximityAlert() throws Exception { + if (isNotSystemUser()) { + Log.i(TAG, "Skipping test on secondary user"); + return; + } + mManager.addTestProvider(FUSED_PROVIDER, true, false, @@ -206,6 +216,11 @@ public class GeofencingTest { @Test public void testAddProximityAlert_StartProximate() throws Exception { + if (isNotSystemUser()) { + Log.i(TAG, "Skipping test on secondary user"); + return; + } + mManager.addTestProvider(FUSED_PROVIDER, true, false, @@ -227,6 +242,11 @@ public class GeofencingTest { @Test public void testAddProximityAlert_Multiple() throws Exception { + if (isNotSystemUser()) { + Log.i(TAG, "Skipping test on secondary user"); + return; + } + mManager.addTestProvider(FUSED_PROVIDER, true, false, @@ -266,6 +286,11 @@ public class GeofencingTest { @Test public void testAddProximityAlert_Expires() throws Exception { + if (isNotSystemUser()) { + Log.i(TAG, "Skipping test on secondary user"); + return; + } + mManager.addTestProvider(FUSED_PROVIDER, true, false, @@ -288,4 +313,8 @@ public class GeofencingTest { assertThat(capture.getNextProximityChange(FAILURE_TIMEOUT_MS)).isNull(); } } + + private boolean isNotSystemUser() { + return !mContext.getSystemService(UserManager.class).isSystemUser(); + } } diff --git a/tests/tests/accounts/OWNERS b/tests/tests/accounts/OWNERS index d486f4c3d90..695530b86e8 100644 --- a/tests/tests/accounts/OWNERS +++ b/tests/tests/accounts/OWNERS @@ -2,3 +2,4 @@ carlosvaldivia@google.com dementyev@google.com sandrakwan@google.com +aseemk@google.com diff --git a/tests/tests/app.usage/TestApp1/AndroidManifest.xml b/tests/tests/app.usage/TestApp1/AndroidManifest.xml index 1cb7e1fe944..06ddfad4e5b 100644 --- a/tests/tests/app.usage/TestApp1/AndroidManifest.xml +++ b/tests/tests/app.usage/TestApp1/AndroidManifest.xml @@ -28,5 +28,12 @@ <service android:name=".TestService" android:exported="true" /> + <receiver android:name=".TestBroadcastReceiver" + android:exported="true" + /> + <provider android:name=".TestContentProvider" + android:authorities="android.app.usage.cts.test1.provider" + android:exported="true" + /> </application> </manifest> diff --git a/tests/tests/app.usage/TestApp1/src/android/app/usage/cts/test1/TestBroadcastReceiver.java b/tests/tests/app.usage/TestApp1/src/android/app/usage/cts/test1/TestBroadcastReceiver.java new file mode 100644 index 00000000000..cfa7e2fad7f --- /dev/null +++ b/tests/tests/app.usage/TestApp1/src/android/app/usage/cts/test1/TestBroadcastReceiver.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2021 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.app.usage.cts.test1; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public final class TestBroadcastReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) {} +} diff --git a/tests/tests/app.usage/TestApp1/src/android/app/usage/cts/test1/TestContentProvider.java b/tests/tests/app.usage/TestApp1/src/android/app/usage/cts/test1/TestContentProvider.java new file mode 100644 index 00000000000..8852e9bcd9a --- /dev/null +++ b/tests/tests/app.usage/TestApp1/src/android/app/usage/cts/test1/TestContentProvider.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 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.app.usage.cts.test1; + +import android.content.ContentProvider; +import android.content.ContentValues; +import android.database.Cursor; +import android.database.MatrixCursor; +import android.net.Uri; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public final class TestContentProvider extends ContentProvider { + + @Override + public boolean onCreate() { + return true; + } + + @Nullable + @Override + public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, + @Nullable String[] selectionArgs, @Nullable String sortOrder) { + MatrixCursor cursor = new MatrixCursor(new String[]{"Test"}, 0); + return cursor; + } + + @Nullable + @Override + public String getType(@NonNull Uri uri) { + return null; + } + + @Nullable + @Override + public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) { + return null; + } + + @Override + public int delete(@NonNull Uri uri, @Nullable String selection, + @Nullable String[] selectionArgs) { + return 0; + } + + @Override + public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, + @Nullable String[] selectionArgs) { + return 0; + } +} diff --git a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java index 1aa05ef3a4a..a20a8f9ee00 100644 --- a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java +++ b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java @@ -38,11 +38,15 @@ import android.app.usage.UsageEvents; import android.app.usage.UsageEvents.Event; import android.app.usage.UsageStats; import android.app.usage.UsageStatsManager; +import android.content.BroadcastReceiver; import android.content.ComponentName; +import android.content.ContentProviderClient; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; +import android.database.Cursor; +import android.net.Uri; import android.os.IBinder; import android.os.Parcel; import android.os.SystemClock; @@ -83,6 +87,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.function.BooleanSupplier; @@ -123,6 +128,10 @@ public class UsageStatsTest { = "android.app.usage.cts.test1.SomeActivityWithLocus"; private static final String TEST_APP_CLASS_SERVICE = "android.app.usage.cts.test1.TestService"; + private static final String TEST_APP_CLASS_BROADCAST_RECEIVER + = "android.app.usage.cts.test1.TestBroadcastReceiver"; + private static final String TEST_AUTHORITY = "android.app.usage.cts.test1.provider"; + private static final String TEST_APP_CONTENT_URI_STRING = "content://" + TEST_AUTHORITY; private static final String TEST_APP2_PKG = "android.app.usage.cts.test2"; private static final String TEST_APP2_CLASS_FINISHING_TASK_ROOT = "android.app.usage.cts.test2.FinishingTaskRootActivity"; @@ -274,6 +283,34 @@ public class UsageStatsTest { verifyLastTimeAnyComponentUsedWithinRange(startTime, endTime, TEST_APP_PKG); } + @AppModeFull(reason = "No usage events access in instant apps") + @Test + public void testLastTimeAnyComponentUsed_bindExplicitBroadcastReceiverShouldBeDetected() + throws Exception { + mUiDevice.wakeUp(); + dismissKeyguard(); // also want to start out with the keyguard dismissed. + + final long startTime = System.currentTimeMillis(); + bindToTestBroadcastReceiver(); + final long endTime = System.currentTimeMillis(); + + verifyLastTimeAnyComponentUsedWithinRange(startTime, endTime, TEST_APP_PKG); + } + + @AppModeFull(reason = "No usage events access in instant apps") + @Test + public void testLastTimeAnyComponentUsed_bindContentProviderShouldBeDetected() + throws Exception { + mUiDevice.wakeUp(); + dismissKeyguard(); // also want to start out with the keyguard dismissed. + + final long startTime = System.currentTimeMillis(); + bindToTestContentProvider(); + final long endTime = System.currentTimeMillis(); + + verifyLastTimeAnyComponentUsedWithinRange(startTime, endTime, TEST_APP_PKG); + } + private void verifyLastTimeAnyComponentUsedWithinRange( long startTime, long endTime, String targetPackage) { final Map<String, UsageStats> map = mUsageStatsManager.queryAndAggregateUsageStats( @@ -281,8 +318,8 @@ public class UsageStatsTest { final UsageStats stats = map.get(targetPackage); assertNotNull(stats); final long lastTimeAnyComponentUsed = stats.getLastTimeAnyComponentUsed(); - assertLessThan(startTime, lastTimeAnyComponentUsed); - assertLessThan(lastTimeAnyComponentUsed, endTime); + assertLessThanOrEqual(startTime, lastTimeAnyComponentUsed); + assertLessThanOrEqual(lastTimeAnyComponentUsed, endTime); SystemUtil.runWithShellPermissionIdentity(()-> { final long lastDayAnyComponentUsedGlobal = @@ -1802,6 +1839,52 @@ public class UsageStatsTest { return ITestReceiver.Stub.asInterface(connection.getService()); } + /** + * Send broadcast to test app's receiver and wait for it to be received. + */ + private void bindToTestBroadcastReceiver() { + final Intent intent = new Intent().setComponent( + new ComponentName(TEST_APP_PKG, TEST_APP_CLASS_BROADCAST_RECEIVER)); + CountDownLatch latch = new CountDownLatch(1); + mContext.sendOrderedBroadcast( + intent, + null /* receiverPermission */, + new BroadcastReceiver() { + @Override public void onReceive(Context context, Intent intent) { + latch.countDown(); + } + }, + null /* scheduler */, + Activity.RESULT_OK, + null /* initialData */, + null /* initialExtras */); + try { + assertTrue("Timed out waiting for test broadcast to be received", + latch.await(TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException e) { + throw new IllegalStateException("Interrupted", e); + } + } + + /** + * Bind to the test app's content provider. + */ + private void bindToTestContentProvider() throws Exception { + // Acquire unstable content provider so that test process isn't killed when content + // provider app is killed. + final Uri testUri = Uri.parse(TEST_APP_CONTENT_URI_STRING); + ContentProviderClient client = + mContext.getContentResolver().acquireUnstableContentProviderClient(testUri); + try (Cursor cursor = client.query( + testUri, + null /* projection */, + null /* selection */, + null /* selectionArgs */, + null /* sortOrder */)) { + assertNotNull(cursor); + } + } + private class TestServiceConnection implements ServiceConnection { private BlockingQueue<IBinder> mBlockingQueue = new LinkedBlockingQueue<>(); diff --git a/tests/tests/graphics/src/android/graphics/fonts/FontManagerTest.java b/tests/tests/graphics/src/android/graphics/fonts/FontManagerTest.java index dd9576f1ad3..0e2711dbd7c 100644 --- a/tests/tests/graphics/src/android/graphics/fonts/FontManagerTest.java +++ b/tests/tests/graphics/src/android/graphics/fonts/FontManagerTest.java @@ -34,6 +34,7 @@ import androidx.test.filters.SmallTest; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -117,6 +118,7 @@ public class FontManagerTest { } } + @Ignore("TODO(b/199671094)") @Test public void fontManager_getFontConfig_checkAlias() { FontConfig config = getFontConfig(); diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java index 51ae06565f3..5a3b712c12e 100644 --- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java +++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java @@ -220,7 +220,10 @@ public class KeyAttestationTest extends AndroidTestCase { fail("Attestation challenges larger than 128 bytes should be rejected"); } catch (ProviderException e) { KeyStoreException cause = (KeyStoreException) e.getCause(); - assertEquals(KM_ERROR_INVALID_INPUT_LENGTH, cause.getErrorCode()); + assertTrue(KM_ERROR_INVALID_INPUT_LENGTH == cause.getErrorCode() || + (devicePropertiesAttestation + && KM_ERROR_CANNOT_ATTEST_IDS == cause.getErrorCode()) + ); } } } @@ -495,7 +498,10 @@ public class KeyAttestationTest extends AndroidTestCase { fail("Attestation challenges larger than 128 bytes should be rejected"); } catch(ProviderException e){ KeyStoreException cause = (KeyStoreException) e.getCause(); - assertEquals(KM_ERROR_INVALID_INPUT_LENGTH, cause.getErrorCode()); + assertTrue(KM_ERROR_INVALID_INPUT_LENGTH == cause.getErrorCode() || + (devicePropertiesAttestation + && KM_ERROR_CANNOT_ATTEST_IDS == cause.getErrorCode()) + ); } } } diff --git a/tests/tests/libcoreapievolution/AndroidTest.xml b/tests/tests/libcoreapievolution/AndroidTest.xml index 08f47fdd769..79aa4b2940a 100644 --- a/tests/tests/libcoreapievolution/AndroidTest.xml +++ b/tests/tests/libcoreapievolution/AndroidTest.xml @@ -42,4 +42,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/tests/libcorefileio/AndroidTest.xml b/tests/tests/libcorefileio/AndroidTest.xml index c90b7027970..22209734c65 100644 --- a/tests/tests/libcorefileio/AndroidTest.xml +++ b/tests/tests/libcorefileio/AndroidTest.xml @@ -40,4 +40,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/tests/libcorelegacy22/AndroidTest.xml b/tests/tests/libcorelegacy22/AndroidTest.xml index 94c1134d536..670a3af8d87 100644 --- a/tests/tests/libcorelegacy22/AndroidTest.xml +++ b/tests/tests/libcorelegacy22/AndroidTest.xml @@ -42,4 +42,7 @@ <!-- ART Mainline Module (external (AOSP) version). --> <option name="mainline-module-package-name" value="com.android.art" /> </object> + + <!--- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> + <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> </configuration> diff --git a/tests/tests/media/src/android/media/cts/AudioTrackTest.java b/tests/tests/media/src/android/media/cts/AudioTrackTest.java index 248ba82893d..c745207b167 100755 --- a/tests/tests/media/src/android/media/cts/AudioTrackTest.java +++ b/tests/tests/media/src/android/media/cts/AudioTrackTest.java @@ -3244,9 +3244,9 @@ public class AudioTrackTest { }; final int MAX_CHANNEL_BIT = 1 << (AudioSystem.FCC_24 - 1); // highest allowed channel. final int TEST_CONF_ARRAY[] = { - (1 << AudioSystem.OUT_CHANNEL_COUNT_MAX) - 1, MAX_CHANNEL_BIT, // likely silent - no physical device on top channel. MAX_CHANNEL_BIT | 1, // first channel will likely have physical device. + (1 << AudioSystem.OUT_CHANNEL_COUNT_MAX) - 1, }; final int TEST_WRITE_MODE_ARRAY[] = { AudioTrack.WRITE_BLOCKING, @@ -3258,10 +3258,12 @@ public class AudioTrackTest { double frequency = 200; // frequency changes for each test for (int TEST_FORMAT : TEST_FORMAT_ARRAY) { - for (int TEST_CONF : TEST_CONF_ARRAY) { - for (int TEST_SR : TEST_SR_ARRAY) { - for (int TEST_WRITE_MODE : TEST_WRITE_MODE_ARRAY) { - for (int useDirect = 0; useDirect < 2; ++useDirect) { + for (int TEST_SR : TEST_SR_ARRAY) { + for (int TEST_WRITE_MODE : TEST_WRITE_MODE_ARRAY) { + for (int useDirect = 0; useDirect < 2; ++useDirect) { + for (int TEST_CONF : TEST_CONF_ARRAY) { + // put TEST_CONF in the inner loop to avoid + // back-to-back creation of large tracks. playOnceStreamByteBuffer( TEST_NAME, frequency, TEST_SWEEP, TEST_STREAM_TYPE, TEST_SR, TEST_CONF, TEST_FORMAT, diff --git a/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java b/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java index 4b5608a4592..be2b0665202 100644 --- a/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java +++ b/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java @@ -15,8 +15,6 @@ */ package android.media.cts; -import static android.Manifest.permission.MEDIA_CONTENT_CONTROL; - import android.media.AudioManager; import android.platform.test.annotations.AppModeFull; import com.android.compatibility.common.util.ApiLevelUtil; @@ -107,8 +105,9 @@ public class MediaSessionManagerTest extends InstrumentationTestCase { // The permission can be held only on S+ if (!MediaUtils.check(sIsAtLeastS, "test invalid before Android 12")) return; - getInstrumentation().getUiAutomation() - .adoptShellPermissionIdentity(Manifest.permission.MEDIA_CONTENT_CONTROL); + getInstrumentation().getUiAutomation().adoptShellPermissionIdentity( + Manifest.permission.MEDIA_CONTENT_CONTROL, + Manifest.permission.MANAGE_EXTERNAL_STORAGE); MediaKeyEventSessionListener keyEventSessionListener = new MediaKeyEventSessionListener(); mSessionManager.addOnMediaKeyEventSessionChangedListener( @@ -141,8 +140,9 @@ public class MediaSessionManagerTest extends InstrumentationTestCase { // The permission can be held only on S+ if (!MediaUtils.check(sIsAtLeastS, "test invalid before Android 12")) return; - getInstrumentation().getUiAutomation() - .adoptShellPermissionIdentity(Manifest.permission.MEDIA_CONTENT_CONTROL); + getInstrumentation().getUiAutomation().adoptShellPermissionIdentity( + Manifest.permission.MEDIA_CONTENT_CONTROL, + Manifest.permission.MANAGE_EXTERNAL_STORAGE); MediaKeyEventDispatchedListener keyEventDispatchedListener = new MediaKeyEventDispatchedListener(); diff --git a/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt b/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt index 5e932c30bdc..cfd62fb01fd 100644 --- a/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt +++ b/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt @@ -49,6 +49,7 @@ import org.junit.After import org.junit.Assert.assertFalse import org.junit.Assert.assertThat import org.junit.Assert.assertTrue +import org.junit.Assume.assumeFalse import org.junit.Before import org.junit.Rule import org.junit.Test @@ -119,8 +120,12 @@ class AppHibernationIntegrationTest { packageManager.getApplicationInfo(APK_PACKAGE_NAME_S_APP, 0 /* flags */) val stopped = ((ai.flags and ApplicationInfo.FLAG_STOPPED) != 0) assertTrue(stopped) - openUnusedAppsNotification() + if (hasFeatureTV()) { + // Skip checking unused apps screen because it may be unavailable on TV + return + } + openUnusedAppsNotification() waitFindObject(By.text(APK_PACKAGE_NAME_S_APP)) } } @@ -129,6 +134,9 @@ class AppHibernationIntegrationTest { @Test fun testPreSVersionUnusedApp_doesntGetForceStopped() { + assumeFalse( + "TV may have different behaviour for Pre-S version apps", + hasFeatureTV()) withUnusedThresholdMs(TEST_UNUSED_THRESHOLD) { withApp(APK_PATH_R_APP, APK_PACKAGE_NAME_R_APP) { // Use app @@ -154,6 +162,9 @@ class AppHibernationIntegrationTest { @AppModeFull(reason = "Uses application details settings") @Test fun testAppInfo_RemovePermissionsAndFreeUpSpaceToggleExists() { + assumeFalse( + "Remove permissions and free up space toggle may be unavailable on TV", + hasFeatureTV()) withDeviceConfig(NAMESPACE_APP_HIBERNATION, "app_hibernation_enabled", "true") { withApp(APK_PATH_S_APP, APK_PACKAGE_NAME_S_APP) { // Open app info diff --git a/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt b/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt index da554097481..b1688d24dcc 100644 --- a/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt +++ b/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt @@ -190,6 +190,13 @@ fun hasFeatureWatch(): Boolean { PackageManager.FEATURE_WATCH) } +fun hasFeatureTV(): Boolean { + return InstrumentationRegistry.getTargetContext().packageManager.hasSystemFeature( + PackageManager.FEATURE_LEANBACK) || + InstrumentationRegistry.getTargetContext().packageManager.hasSystemFeature( + PackageManager.FEATURE_TELEVISION) +} + private fun expandNotificationsWatch(uiDevice: UiDevice) { with(uiDevice) { wakeUp() diff --git a/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt b/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt index 2d3610b8e6e..a9535622a85 100644 --- a/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt +++ b/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt @@ -149,6 +149,11 @@ class AutoRevokeTest { // Verify assertPermission(PERMISSION_DENIED) + + if (hasFeatureTV()) { + // Skip checking unused apps screen because it may be unavailable on TV + return + } openUnusedAppsNotification() waitFindObject(By.text(supportedAppPackageName)) @@ -161,6 +166,9 @@ class AutoRevokeTest { @AppModeFull(reason = "Uses separate apps for testing") @Test fun testUnusedApp_uninstallApp() { + assumeFalse( + "Unused apps screen may be unavailable on TV", + hasFeatureTV()) withUnusedThresholdMs(3L) { withDummyAppNoUninstallAssertion { // Setup diff --git a/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt b/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt index 6869889e68b..ee2ab83cb4d 100644 --- a/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt +++ b/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt @@ -19,6 +19,7 @@ package android.os.cts import android.companion.CompanionDeviceManager import android.content.pm.PackageManager import android.content.pm.PackageManager.FEATURE_AUTOMOTIVE +import android.content.pm.PackageManager.FEATURE_LEANBACK import android.content.pm.PackageManager.FEATURE_COMPANION_DEVICE_SETUP import android.content.pm.PackageManager.PERMISSION_GRANTED import android.net.MacAddress @@ -87,6 +88,7 @@ class CompanionDeviceManagerTest : InstrumentationTestCase() { pm.hasSystemFeature(FEATURE_COMPANION_DEVICE_SETUP) } private val isAuto: Boolean by lazy { pm.hasSystemFeature(FEATURE_AUTOMOTIVE) } + private val isTV: Boolean by lazy { pm.hasSystemFeature(FEATURE_LEANBACK) } private fun isShellAssociated(macAddress: String, packageName: String): Boolean { val userId = context.userId @@ -218,6 +220,10 @@ class CompanionDeviceManagerTest : InstrumentationTestCase() { @AppModeFull(reason = "Companion API for non-instant apps only") @Test fun testRequestNotifications() { + // Skip this test for Android TV due to NotificationAccessConfirmationActivity only exists + // in Settings but not in TvSettings for Android TV devices (b/199224565). + assumeFalse(isTV) + installApk("--user ${UserHandle.myUserId()} $TEST_APP_APK_LOCATION") startApp(TEST_APP_PACKAGE_NAME) diff --git a/tests/tests/os/src/android/os/cts/StrictModeTest.java b/tests/tests/os/src/android/os/cts/StrictModeTest.java index 3fa3dac2b27..0b5ed0d56f0 100644 --- a/tests/tests/os/src/android/os/cts/StrictModeTest.java +++ b/tests/tests/os/src/android/os/cts/StrictModeTest.java @@ -874,6 +874,9 @@ public class StrictModeTest { assertViolation("Tried to access visual service " + WM_CLASS_NAME, () -> configContext.getSystemService(WindowManager.class)); + // Make the ViewConfiguration to be cached so that we won't call WindowManager + ViewConfiguration.get(configContext); + assertNoViolation(() -> ViewConfiguration.get(configContext)); mInstrumentation.runOnMainSync(() -> { diff --git a/tests/tests/provider/src/android/provider/cts/SettingsPanelTest.java b/tests/tests/provider/src/android/provider/cts/SettingsPanelTest.java index 6db2d4c59c3..8122b4dfb26 100644 --- a/tests/tests/provider/src/android/provider/cts/SettingsPanelTest.java +++ b/tests/tests/provider/src/android/provider/cts/SettingsPanelTest.java @@ -37,6 +37,7 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -99,6 +100,7 @@ public class SettingsPanelTest { // Check correct package is opened + @Ignore @Test public void internetPanel_correctPackage() { launchInternetPanel(); @@ -136,6 +138,7 @@ public class SettingsPanelTest { assertThat(currentPackage).isEqualTo(mSettingsPackage); } + @Ignore @Test public void internetPanel_doneClosesPanel() { // Launch panel diff --git a/tests/tests/systemui/src/android/systemui/cts/tv/BasicPipTests.kt b/tests/tests/systemui/src/android/systemui/cts/tv/BasicPipTests.kt index 82be3e2f6df..7e0bdcce540 100644 --- a/tests/tests/systemui/src/android/systemui/cts/tv/BasicPipTests.kt +++ b/tests/tests/systemui/src/android/systemui/cts/tv/BasicPipTests.kt @@ -36,6 +36,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.compatibility.common.util.SystemUtil import com.android.compatibility.common.util.ThrowingSupplier import org.junit.Assume +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import kotlin.test.assertTrue @@ -73,6 +74,7 @@ class BasicPipTests : TvTestBase() { /** Ensure an app can be launched into pip mode from the screensaver state. */ @Test + @Ignore("b/163116693") fun openPip_afterScreenSaver() { runWithDreamManager { dreamManager -> dreamManager.dream() diff --git a/tests/tests/view/src/android/view/cts/PixelCopyTest.java b/tests/tests/view/src/android/view/cts/PixelCopyTest.java index 502170d621f..8a1f853980d 100644 --- a/tests/tests/view/src/android/view/cts/PixelCopyTest.java +++ b/tests/tests/view/src/android/view/cts/PixelCopyTest.java @@ -73,6 +73,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.function.Function; @MediumTest @RunWith(AndroidJUnit4.class) @@ -894,31 +895,29 @@ public class PixelCopyTest { private void assertBitmapQuadColor(Bitmap bitmap, int topLeft, int topRight, int bottomLeft, int bottomRight, int threshold) { - try { - // Just quickly sample 4 pixels in the various regions. - assertTrue("Top left", pixelsAreSame(topLeft, - getPixelFloatPos(bitmap, .25f, .25f), threshold)); - assertTrue("Top right", pixelsAreSame(topRight, - getPixelFloatPos(bitmap, .75f, .25f), threshold)); - assertTrue("Bottom left", pixelsAreSame(bottomLeft, - getPixelFloatPos(bitmap, .25f, .75f), threshold)); - assertTrue("Bottom right", pixelsAreSame(bottomRight, - getPixelFloatPos(bitmap, .75f, .75f), threshold)); - - float below = .45f; - float above = .55f; - assertTrue("Top left II", pixelsAreSame(topLeft, - getPixelFloatPos(bitmap, below, below), threshold)); - assertTrue("Top right II", pixelsAreSame(topRight, - getPixelFloatPos(bitmap, above, below), threshold)); - assertTrue("Bottom left II", pixelsAreSame(bottomLeft, - getPixelFloatPos(bitmap, below, above), threshold)); - assertTrue("Bottom right II", pixelsAreSame(bottomRight, - getPixelFloatPos(bitmap, above, above), threshold)); - } catch (AssertionError err) { - BitmapDumper.dumpBitmap(bitmap, mTestName.getMethodName(), "PixelCopyTest"); - throw err; - } + Function<Float, Integer> getX = (Float x) -> (int) (bitmap.getWidth() * x); + Function<Float, Integer> getY = (Float y) -> (int) (bitmap.getHeight() * y); + + // Just quickly sample 4 pixels in the various regions. + assertBitmapColor("Top left", bitmap, topLeft, + getX.apply(.25f), getY.apply(.25f), threshold); + assertBitmapColor("Top right", bitmap, topRight, + getX.apply(.75f), getY.apply(.25f), threshold); + assertBitmapColor("Bottom left", bitmap, bottomLeft, + getX.apply(.25f), getY.apply(.75f), threshold); + assertBitmapColor("Bottom right", bitmap, bottomRight, + getX.apply(.75f), getY.apply(.75f), threshold); + + float below = .4f; + float above = .6f; + assertBitmapColor("Top left II", bitmap, topLeft, + getX.apply(below), getY.apply(below), threshold); + assertBitmapColor("Top right II", bitmap, topRight, + getX.apply(above), getY.apply(below), threshold); + assertBitmapColor("Bottom left II", bitmap, bottomLeft, + getX.apply(below), getY.apply(above), threshold); + assertBitmapColor("Bottom right II", bitmap, bottomRight, + getX.apply(above), getY.apply(above), threshold); } private void assertBitmapEdgeColor(Bitmap bitmap, int edgeColor) { @@ -941,7 +940,7 @@ public class PixelCopyTest { bitmap.getWidth() - 3, bitmap.getHeight() / 2); } - private boolean pixelsAreSame(int ideal, int given, int threshold) { + private static boolean pixelsAreSame(int ideal, int given, int threshold) { int error = Math.abs(Color.red(ideal) - Color.red(given)); error += Math.abs(Color.green(ideal) - Color.green(given)); error += Math.abs(Color.blue(ideal) - Color.blue(given)); @@ -954,8 +953,13 @@ public class PixelCopyTest { } private void assertBitmapColor(String debug, Bitmap bitmap, int color, int x, int y) { + assertBitmapColor(debug, bitmap, color, x, y, 10); + } + + private void assertBitmapColor(String debug, Bitmap bitmap, int color, int x, int y, + int threshold) { int pixel = bitmap.getPixel(x, y); - if (!pixelsAreSame(color, pixel, 10)) { + if (!pixelsAreSame(color, pixel, threshold)) { fail(bitmap, debug + "; expected=" + Integer.toHexString(color) + ", actual=" + Integer.toHexString(pixel)); } diff --git a/tests/tests/wifi/AndroidTest.xml b/tests/tests/wifi/AndroidTest.xml index 421a9f7528f..5da40eafc64 100644 --- a/tests/tests/wifi/AndroidTest.xml +++ b/tests/tests/wifi/AndroidTest.xml @@ -43,6 +43,5 @@ <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController"> <option name="mainline-module-package-name" value="com.google.android.wifi" /> - <option name="mainline-module-package-name" value="com.google.android.tethering" /> </object> </configuration> diff --git a/cts-camera-hal.xml b/tools/cts-tradefed/res/config/cts-camera-hal.xml index ec049c067d7..ec049c067d7 100644 --- a/cts-camera-hal.xml +++ b/tools/cts-tradefed/res/config/cts-camera-hal.xml diff --git a/tools/cts-tradefed/res/config/cts-foldable.xml b/tools/cts-tradefed/res/config/cts-foldable.xml index 1b6b9bbc9a5..250fba80eb8 100644 --- a/tools/cts-tradefed/res/config/cts-foldable.xml +++ b/tools/cts-tradefed/res/config/cts-foldable.xml @@ -26,5 +26,8 @@ <!-- b/178344549: CtsCameraTestCases failures due to covered lenses in folded mode--> <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.camera2.cts.BurstCaptureTest#testJpegBurst" /> <option name="compatibility:exclude-filter" value="CtsCameraTestCases[instant] android.hardware.camera2.cts.BurstCaptureTest#testJpegBurst" /> + <!-- b/193752359: OrgOwnedProfileOwnerTest#testScreenCaptureDisabled failures due to personal + launcher always visible on one of the screens. --> + <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testScreenCaptureDisabled" /> </configuration> |