diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-11 21:09:38 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-11-11 21:09:38 +0000 |
commit | 73568f63bc998af84146a9202b13b57eb8e3e11d (patch) | |
tree | a0558b75b67e15f3642a7bf4d4f6b95ba4d97966 | |
parent | 6d7e0077a1ed24585de03a33b6db21ed80c89057 (diff) | |
parent | d3663fdfce848c079fdfef245f5f885d540fabf0 (diff) | |
download | cts-sparse-7907387-L65300000952126381.tar.gz |
Merge "Snap for 7906468 from 578d21a83a80da8c78a1a7b20b3903efa9dff182 to android12-tests-release" into android12-tests-releasesparse-7907387-L65300000952126381
26 files changed, 336 insertions, 247 deletions
diff --git a/apps/CameraITS/tests/its_base_test.py b/apps/CameraITS/tests/its_base_test.py index 1c105627837..afa0128785e 100644 --- a/apps/CameraITS/tests/its_base_test.py +++ b/apps/CameraITS/tests/its_base_test.py @@ -160,6 +160,7 @@ class ItsBaseTest(base_test.BaseTestClass): self.tablet.adb.shell('am force-stop com.google.android.apps.docs') self.tablet.adb.shell('am force-stop com.google.android.apps.photos') self.tablet.adb.shell('am force-stop com.android.gallery3d') + self.tablet.adb.shell('am force-stop com.sec.android.gallery3d') def set_tablet_landscape_orientation(self): """Sets the screen orientation to landscape. 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/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java new file mode 100644 index 00000000000..27d86b51a28 --- /dev/null +++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/ExtraBusinessLogicTestCase.java @@ -0,0 +1,73 @@ +/* + * 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 com.android.compatibility.common.util; + +import static org.junit.Assert.assertTrue; + +import android.util.Log; + +import org.junit.Before; + +import java.util.List; + +/** + * Device-side base class for tests to run extra Business Logics in addition to the test-specific + * Business Logics. + * + * Used when running a common set of business logics against several tests. + * + * Usage: + * 1. Implement the common logic in an interface with default methods. + * 2. Extend this class and implement the interface. + * + * Now Business Logics rules and actions can be called from the GCL by using the interface fully + * qualified name. + */ +public abstract class ExtraBusinessLogicTestCase extends BusinessLogicTestCase { + + private static final String LOG_TAG = BusinessLogicTestCase.class.getSimpleName(); + + protected boolean mDependentOnBusinessLogic = true; + + public abstract List<String> getExtraBusinessLogics(); + + @Before + @Override + public void handleBusinessLogic() { + loadBusinessLogic(); + if (mDependentOnBusinessLogic) { + assertTrue(String.format( + "Test \"%s\" is unable to execute as it depends on the missing remote " + + "configuration.", mTestCase.getMethodName()), mCanReadBusinessLogic); + } else if (!mCanReadBusinessLogic) { + Log.i(LOG_TAG, String.format( + "Skipping Business Logic for %s", mTestCase.getMethodName())); + return; + } + + BusinessLogicExecutor executor = new BusinessLogicDeviceExecutor( + getContext(), this, mBusinessLogic.getRedactionRegexes()); + for (String extraBusinessLogic : getExtraBusinessLogics()) { + if (!mBusinessLogic.hasLogicFor(extraBusinessLogic)) { + throw new RuntimeException(String.format( + "can't find extra business logic for %s.", extraBusinessLogic)); + } + mBusinessLogic.applyLogicFor(extraBusinessLogic, executor); + } + executeBusinessLogic(); + } +} diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java index d157fc0bed6..e1f3901ddb5 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/QuietModeHostsideTest.java @@ -143,9 +143,13 @@ public class QuietModeHostsideTest extends BaseDevicePolicyTest { "testTryEnableQuietMode", mPrimaryUserId, createParams(mProfileId)); + // In case of a necessary log is not captured + // cause of too many logs while waiting idle broadcast, capture log previously. + // This log will be concatenated. + String log = getDevice().executeAdbCommand("logcat", "-d"); waitForBroadcastIdle(); verifyBroadcastSent("android.intent.action.MANAGED_PROFILE_UNAVAILABLE", - /* needPermissions= */ !withCrossProfileAppOps); + /* needPermissions= */ !withCrossProfileAppOps, log); clearLogcat(); runDeviceTestsAsUser( @@ -154,15 +158,17 @@ public class QuietModeHostsideTest extends BaseDevicePolicyTest { "testTryDisableQuietMode", mPrimaryUserId, createParams(mProfileId)); + log = getDevice().executeAdbCommand("logcat", "-d"); waitForBroadcastIdle(); verifyBroadcastSent("android.intent.action.MANAGED_PROFILE_AVAILABLE", - /* needPermissions= */ !withCrossProfileAppOps); + /* needPermissions= */ !withCrossProfileAppOps, log); clearLogcat(); removeUser(mProfileId); + log = getDevice().executeAdbCommand("logcat", "-d"); waitForBroadcastIdle(); verifyBroadcastSent("android.intent.action.MANAGED_PROFILE_REMOVED", - /* needPermissions= */ false); + /* needPermissions= */ false, log); } private void clearLogcat() throws DeviceNotAvailableException { @@ -170,9 +176,10 @@ public class QuietModeHostsideTest extends BaseDevicePolicyTest { getDevice().executeAdbCommand("logcat", "-G", "16M"); } - private void verifyBroadcastSent(String actionName, boolean needPermissions) + private void verifyBroadcastSent(String actionName, boolean needPermissions, String prevLog) throws DeviceNotAvailableException { - final String result = getDevice().executeAdbCommand("logcat", "-d"); + String result = getDevice().executeAdbCommand("logcat", "-d"); + result = prevLog + result; assertThat(result).contains( buildReceivedBroadcastRegex(actionName, "CrossProfileEnabledAppReceiver")); assertThat(result).contains( diff --git a/hostsidetests/theme/app/src/android/theme/app/AssetBucketVerifier.java b/hostsidetests/theme/app/src/android/theme/app/AssetBucketVerifier.java deleted file mode 100644 index 09875b141b3..00000000000 --- a/hostsidetests/theme/app/src/android/theme/app/AssetBucketVerifier.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.theme.app; - -import android.content.Context; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -class AssetBucketVerifier { - /** Asset file to verify. */ - private static final String ASSET_NAME = "ic_star_black_16dp.png"; - - /** Densities at which {@link #ASSET_NAME} may be defined. */ - private static final int[] DENSITIES_DPI = new int[] { - 160, // mdpi - 240, // hdpi - 320, // xhdpi - 480, // xxhdpi - 640, // xxxhdpi - }; - - /** Bucket names corresponding to {@link #DENSITIES_DPI} entries. */ - private static final String[] DENSITIES_NAME = new String[] { - "mdpi", - "hdpi", - "xhdpi", - "xxhdpi", - "xxxhdpi" - }; - - static class Result { - String expectedAtDensity; - List<String> foundAtDensity; - } - - static Result verifyAssetBucket(Context context) { - List<String> foundAtDensity = new ArrayList<>(); - String expectedAtDensity = null; - - int deviceDensityDpi = context.getResources().getConfiguration().densityDpi; - for (int i = 0; i < DENSITIES_DPI.length; i++) { - // Find the matching or next-highest density bucket. - if (expectedAtDensity == null && DENSITIES_DPI[i] >= deviceDensityDpi) { - expectedAtDensity = DENSITIES_NAME[i]; - } - - // Try to load and close the asset from the current density. - try { - context.getAssets().openNonAssetFd(1, - "res/drawable-" + DENSITIES_NAME[i] + "-v4/" + ASSET_NAME).close(); - foundAtDensity.add(DENSITIES_NAME[i]); - } catch (IOException e) { - e.printStackTrace(); - } - } - - if (expectedAtDensity == null) { - expectedAtDensity = DENSITIES_NAME[DENSITIES_NAME.length - 1]; - } - - Result result = new Result(); - result.expectedAtDensity = expectedAtDensity; - result.foundAtDensity = foundAtDensity; - return result; - } -} diff --git a/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java b/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java index 6be679b43f5..b7647524f8b 100644 --- a/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java +++ b/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java @@ -65,41 +65,14 @@ public class GenerateImagesActivity extends Activity { // Useful for local testing. Not required for CTS harness. getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); - // Make sure the device has reasonable assets. - String assetDensityFailureMsg = checkAssetDensity(); - if (assetDensityFailureMsg != null) { - finish("Failed to verify device assets: "+ assetDensityFailureMsg, false); + mOutputDir = setupOutputDirectory(); + if (mOutputDir == null) { + finish("Failed to create output directory " + mOutputDir.getAbsolutePath(), false); } else { - mOutputDir = setupOutputDirectory(); - if (mOutputDir == null) { - finish("Failed to create output directory: " + OUT_DIR, false); - } else { - generateNextImage(); - } + generateNextImage(); } } - private String checkAssetDensity() { - AssetBucketVerifier.Result result = AssetBucketVerifier.verifyAssetBucket(this); - - String message; - if (result.foundAtDensity.contains(result.expectedAtDensity)) { - message = null; - } else if (result.foundAtDensity.isEmpty()) { - message = "Failed to find expected device assets at any density"; - } else { - StringBuilder foundAtDensityStr = new StringBuilder(result.foundAtDensity.get(0)); - for (int i = 1; i < result.foundAtDensity.size(); i++) { - foundAtDensityStr.append(", "); - foundAtDensityStr.append(result.foundAtDensity.get(i)); - } - message = "Failed to find device assets at expected density (" - + result.expectedAtDensity + "), but found at " + foundAtDensityStr; - } - - return message; - } - private File setupOutputDirectory() { mOutputDir = new File(Environment.getExternalStorageDirectory(), OUT_DIR); ThemeTestUtils.deleteDirectory(mOutputDir); @@ -132,9 +105,8 @@ public class GenerateImagesActivity extends Activity { private void generateNextImage() { // Keep trying themes until one works. boolean success = false; - while (mCurrentTheme < THEMES.length && !success) { + while (++mCurrentTheme < THEMES.length && !success) { success = launchThemeDeviceActivity(); - mCurrentTheme++; } // If we ran out of themes, we're done. diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java index c47a21635dd..f0e3b6704cf 100644 --- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java +++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java @@ -88,6 +88,8 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import android.graphics.Rect; + /** * Verify that gestures dispatched from an accessibility service show up in the current UI */ @@ -346,7 +348,7 @@ public class AccessibilityGestureDispatchTest { } } - // This test assumes device's screen contains its center (W/2, H/2) with some surroundings + // This test assumes the test activity contains its center (W/2, H/2) with some surroundings // and should work for rectangular, round and round with chin screens. @Test public void testClickWhenMagnified_matchesActualTouch() throws InterruptedException { @@ -354,6 +356,8 @@ public class AccessibilityGestureDispatchTest { final float CLICK_OFFSET_X = 10; final float CLICK_OFFSET_Y = 20; final float MAGNIFICATION_FACTOR = 2; + final int MAGNIFICATION_SPEC_WAIT_MILLIS = 200; + if (!mHasTouchScreen) { return; } @@ -364,36 +368,54 @@ public class AccessibilityGestureDispatchTest { return; } - final WindowManager wm = (WindowManager) getInstrumentation().getContext().getSystemService( - Context.WINDOW_SERVICE); final StubMagnificationAccessibilityService magnificationService = enableService(StubMagnificationAccessibilityService.class); final AccessibilityService.MagnificationController magnificationController = magnificationService.getMagnificationController(); - final PointF magRegionCenterPoint = new PointF(); + final PointF magRegionCenterClickPoint = new PointF(); + // Determine the center of the test activity to center the magnification viewport. + final Rect activityBounds = mActivity.getWindowManager() + .getCurrentWindowMetrics().getBounds(); + final PointF activityCenterPoint = new PointF(activityBounds.centerX(), + activityBounds.centerY()); + // Target points where the clicks are expected to land after magnification. + final PointF viewPortCenter = new PointF(); + final PointF viewPortCenterWithOffset = new PointF(); + magnificationService.runOnServiceSync(() -> { magnificationController.reset(false); - magRegionCenterPoint.set(magnificationController.getCenterX(), + magRegionCenterClickPoint.set(magnificationController.getCenterX(), magnificationController.getCenterY()); }); - final PointF magRegionOffsetPoint - = add(magRegionCenterPoint, CLICK_OFFSET_X, CLICK_OFFSET_Y); - final PointF magRegionOffsetClickPoint = add(magRegionCenterPoint, - CLICK_OFFSET_X * MAGNIFICATION_FACTOR, CLICK_OFFSET_Y * MAGNIFICATION_FACTOR); + final PointF magRegionOffsetClickPoint = + add(magRegionCenterClickPoint, CLICK_OFFSET_X * MAGNIFICATION_FACTOR, + CLICK_OFFSET_Y * MAGNIFICATION_FACTOR); try { // Zoom in final AtomicBoolean setScale = new AtomicBoolean(); magnificationService.runOnServiceSync(() -> { setScale.set(magnificationController.setScale(MAGNIFICATION_FACTOR, false)); + magnificationController.setCenter(activityCenterPoint.x, + activityCenterPoint.y, false); + // The magnification's viewport center can be different than the activity's center + // (e.g. on foldable devices when the activity is on half of the screen). + viewPortCenter.set(magnificationController.getCenterX(), + magnificationController.getCenterY()); + viewPortCenterWithOffset.set(viewPortCenter.x + CLICK_OFFSET_X, + viewPortCenter.y + CLICK_OFFSET_Y); }); assertTrue("Failed to set scale", setScale.get()); + // DisplayContent#applyMagnificationSpec uses the pending transaction and there's no + // signal to know when it gets executed. Wait for UI to get updated. + Thread.sleep(MAGNIFICATION_SPEC_WAIT_MILLIS); + // Click in the center of the magnification region dispatch(new GestureDescription.Builder() - .addStroke(click(magRegionCenterPoint)) + .addStroke(click(magRegionCenterClickPoint)) .build(), GESTURE_COMPLETION_TIMEOUT); @@ -415,21 +437,21 @@ public class AccessibilityGestureDispatchTest { assertEquals(4, mMotionEvents.size()); // Because the MotionEvents have been captures by the view, the coordinates will // be in the View's coordinate system. - magRegionCenterPoint.offset(-mViewLocation[0], -mViewLocation[1]); - magRegionOffsetPoint.offset(-mViewLocation[0], -mViewLocation[1]); + viewPortCenter.offset(-mViewLocation[0], -mViewLocation[1]); + viewPortCenterWithOffset.offset(-mViewLocation[0], -mViewLocation[1]); // The first click should be at the magnification center, as that point is invariant // for zoom only assertThat(mMotionEvents.get(0), - both(IS_ACTION_DOWN).and(isAtPoint(magRegionCenterPoint, POINT_TOL))); + both(IS_ACTION_DOWN).and(isAtPoint(viewPortCenter, POINT_TOL))); assertThat(mMotionEvents.get(1), - both(IS_ACTION_UP).and(isAtPoint(magRegionCenterPoint, POINT_TOL))); + both(IS_ACTION_UP).and(isAtPoint(viewPortCenter, POINT_TOL))); // The second point should be at the offset point assertThat(mMotionEvents.get(2), - both(IS_ACTION_DOWN).and(isAtPoint(magRegionOffsetPoint, POINT_TOL))); + both(IS_ACTION_DOWN).and(isAtPoint(viewPortCenterWithOffset, POINT_TOL))); assertThat(mMotionEvents.get(3), - both(IS_ACTION_UP).and(isAtPoint(magRegionOffsetPoint, POINT_TOL))); + both(IS_ACTION_UP).and(isAtPoint(viewPortCenterWithOffset, POINT_TOL))); } @Test diff --git a/tests/camera/src/android/hardware/cts/CameraGLTest.java b/tests/camera/src/android/hardware/cts/CameraGLTest.java index 7478e795484..73eaa34eb29 100644 --- a/tests/camera/src/android/hardware/cts/CameraGLTest.java +++ b/tests/camera/src/android/hardware/cts/CameraGLTest.java @@ -67,7 +67,7 @@ public class CameraGLTest { private boolean mSurfaceTextureCallbackResult = false; - private static final int WAIT_FOR_COMMAND_TO_COMPLETE = 5000; // Milliseconds. + private static final int WAIT_FOR_COMMAND_TO_COMPLETE = 7000; // Milliseconds. private static final int WAIT_FOR_FOCUS_TO_COMPLETE = 5000; private static final int WAIT_FOR_SNAPSHOT_TO_COMPLETE = 5000; diff --git a/tests/camera/src/android/hardware/cts/CameraTest.java b/tests/camera/src/android/hardware/cts/CameraTest.java index 3ccf8c1ecf5..bfe70f018be 100644 --- a/tests/camera/src/android/hardware/cts/CameraTest.java +++ b/tests/camera/src/android/hardware/cts/CameraTest.java @@ -94,7 +94,7 @@ public class CameraTest extends Assert { private int mCameraErrorCode = NO_ERROR; private boolean mAutoFocusSucceeded = false; - private static final int WAIT_FOR_COMMAND_TO_COMPLETE = 5000; // Milliseconds. + private static final int WAIT_FOR_COMMAND_TO_COMPLETE = 7000; // Milliseconds. private static final int WAIT_FOR_FOCUS_TO_COMPLETE = 5000; private static final int WAIT_FOR_SNAPSHOT_TO_COMPLETE = 5000; diff --git a/tests/framework/base/windowmanager/AndroidManifest.xml b/tests/framework/base/windowmanager/AndroidManifest.xml index 9df83c834fe..48272466321 100644 --- a/tests/framework/base/windowmanager/AndroidManifest.xml +++ b/tests/framework/base/windowmanager/AndroidManifest.xml @@ -384,7 +384,8 @@ <activity android:name="android.server.wm.WindowInsetsLayoutTests$TestActivity"/> <activity android:name="android.server.wm.WindowInsetsControllerTests$TestActivity" android:theme="@style/no_starting_window"/> - <activity android:name="android.server.wm.WindowInsetsControllerTests$TestHideOnCreateActivity"/> + <activity android:name="android.server.wm.WindowInsetsControllerTests$TestHideOnCreateActivity" + android:windowSoftInputMode="adjustPan|stateUnchanged"/> <activity android:name="android.server.wm.WindowInsetsControllerTests$TestShowOnCreateActivity"/> <activity android:name="android.server.wm.DragDropTest$DragDropActivity" diff --git a/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java b/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java index ec4903bcd84..aaeedc29721 100644 --- a/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java +++ b/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java @@ -205,18 +205,14 @@ public class ActivityVisibilityTests extends ActivityManagerTestBase { } final ActivitySessionClient activityClient = createManagedActivityClientSession(); testTurnScreenOnActivity(lockScreenSession, activityClient, - true /* useWindowFlags */, true /* showWhenLocked */); + true /* useWindowFlags */); testTurnScreenOnActivity(lockScreenSession, activityClient, - false /* useWindowFlags */, true /* showWhenLocked */); + false /* useWindowFlags */); if (notSupportsInsecureLock) { // In the platform without InsecureLock, we just test if the display is on with // TurnScreenOnActivity. mObjectTracker.close(lockScreenSession); } - testTurnScreenOnActivity(lockScreenSession, activityClient, - true /* useWindowFlags */, false /* showWhenLocked */); - testTurnScreenOnActivity(lockScreenSession, activityClient, - false /* useWindowFlags */, false /* showWhenLocked */); } @Test @@ -230,21 +226,20 @@ public class ActivityVisibilityTests extends ActivityManagerTestBase { // timeout should still notify the client activity to be visible. Then the relayout can // send the visible request to apply the flags and turn on screen. testTurnScreenOnActivity(lockScreenSession, activityClient, true /* useWindowFlags */, - true /* showWhenLocked */, 1000 /* sleepMsInOnCreate */); + 1000 /* sleepMsInOnCreate */); } private void testTurnScreenOnActivity(LockScreenSession lockScreenSession, - ActivitySessionClient activitySessionClient, boolean useWindowFlags, - boolean showWhenLocked) { + ActivitySessionClient activitySessionClient, boolean useWindowFlags) { testTurnScreenOnActivity(lockScreenSession, activitySessionClient, useWindowFlags, - showWhenLocked, 0 /* sleepMsInOnCreate */); + 0 /* sleepMsInOnCreate */); } private void testTurnScreenOnActivity(LockScreenSession lockScreenSession, ActivitySessionClient activitySessionClient, boolean useWindowFlags, - boolean showWhenLocked, int sleepMsInOnCreate) { + int sleepMsInOnCreate) { ActivitySession activity = sleepDeviceAndLaunchTurnScreenOnActivity(lockScreenSession, - activitySessionClient, useWindowFlags, showWhenLocked, sleepMsInOnCreate, + activitySessionClient, useWindowFlags, sleepMsInOnCreate, WINDOWING_MODE_FULLSCREEN); mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, true); @@ -263,21 +258,16 @@ public class ActivityVisibilityTests extends ActivityManagerTestBase { final ActivitySessionClient activityClient = createManagedActivityClientSession(); testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient, - true/* useWindowFlags */, true/* showWhenLocked */); - testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient, - true/* useWindowFlags */, false/* showWhenLocked */); - testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient, - false/* useWindowFlags */, true/* showWhenLocked */); + true/* useWindowFlags */); testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient, - false/* useWindowFlags */, false/* showWhenLocked */); + false/* useWindowFlags */); } private void testFreeformWindowTurnScreenOnActivity(LockScreenSession lockScreenSession, - ActivitySessionClient activityClient, boolean useWindowFlags, - boolean showWhenLocked) { + ActivitySessionClient activityClient, boolean useWindowFlags) { ActivitySession activity = sleepDeviceAndLaunchTurnScreenOnActivity(lockScreenSession, - activityClient, useWindowFlags, showWhenLocked, - 0 /* sleepMsInOnCreate */, WINDOWING_MODE_FREEFORM); + activityClient, useWindowFlags, 0 /* sleepMsInOnCreate */, + WINDOWING_MODE_FREEFORM); mWmState.waitForValidState( new WaitForValidActivityState.Builder(TURN_SCREEN_ON_ACTIVITY) .setWindowingMode(WINDOWING_MODE_FULLSCREEN) @@ -291,16 +281,13 @@ public class ActivityVisibilityTests extends ActivityManagerTestBase { private ActivitySession sleepDeviceAndLaunchTurnScreenOnActivity( LockScreenSession lockScreenSession, ActivitySessionClient activitySessionClient, - boolean useWindowFlags, boolean showWhenLocked, int sleepMsInOnCreate, - int windowingMode) { + boolean useWindowFlags, int sleepMsInOnCreate, int windowingMode) { lockScreenSession.sleepDevice(); return activitySessionClient.startActivity( getLaunchActivityBuilder().setUseInstrumentation().setIntentExtra(extra -> { extra.putBoolean(Components.TurnScreenOnActivity.EXTRA_USE_WINDOW_FLAGS, useWindowFlags); - extra.putBoolean(Components.TurnScreenOnActivity.EXTRA_SHOW_WHEN_LOCKED, - showWhenLocked); extra.putLong(Components.TurnScreenOnActivity.EXTRA_SLEEP_MS_IN_ON_CREATE, sleepMsInOnCreate); }).setTargetActivity(TURN_SCREEN_ON_ACTIVITY).setWindowingMode(windowingMode)); diff --git a/tests/framework/base/windowmanager/src/android/server/wm/BlurTests.java b/tests/framework/base/windowmanager/src/android/server/wm/BlurTests.java index 20567c3f11f..bb2fdddfab7 100644 --- a/tests/framework/base/windowmanager/src/android/server/wm/BlurTests.java +++ b/tests/framework/base/windowmanager/src/android/server/wm/BlurTests.java @@ -59,6 +59,7 @@ import java.util.function.Consumer; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.mockito.Mockito; @@ -74,6 +75,9 @@ public class BlurTests extends WindowManagerTestBase { private float mSavedAnimatorDurationScale; private boolean mSavedWindowBlurDisabledSetting; + @Rule + public final DumpOnFailure dumpOnFailure = new DumpOnFailure(); + @Before public void setUp() { assumeTrue(supportsBlur()); @@ -353,16 +357,16 @@ public class BlurTests extends WindowManagerTestBase { } } - private static void assertBlurBehind(Bitmap screenshot, Rect windowFrame) { + private void assertBlurBehind(Bitmap screenshot, Rect windowFrame) { assertBlur(screenshot, BLUR_BEHIND_PX, 0, windowFrame.top); assertBlur(screenshot, BLUR_BEHIND_PX, windowFrame.bottom, screenshot.getHeight()); } - private static void assertBackgroundBlur(Bitmap screenshot, Rect windowFrame) { + private void assertBackgroundBlur(Bitmap screenshot, Rect windowFrame) { assertBlur(screenshot, BACKGROUND_BLUR_PX, windowFrame.top, windowFrame.bottom); } - private static void assertBackgroundBlurOverBlurBehind(Bitmap screenshot, Rect windowFrame) { + private void assertBackgroundBlurOverBlurBehind(Bitmap screenshot, Rect windowFrame) { assertBlur( screenshot, (int) Math.sqrt(Math.pow(BACKGROUND_BLUR_PX, 2.f) + Math.pow(BLUR_BEHIND_PX, 2.f)), @@ -370,7 +374,7 @@ public class BlurTests extends WindowManagerTestBase { windowFrame.bottom); } - private static void assertNoBlurBehind(Bitmap screenshot, Rect windowFrame) { + private void assertNoBlurBehind(Bitmap screenshot, Rect windowFrame) { for (int x = 0; x < screenshot.getWidth(); x++) { for (int y = 0; y < screenshot.getHeight(); y++) { if (x < windowFrame.left) { @@ -404,8 +408,9 @@ public class BlurTests extends WindowManagerTestBase { } } - private static void assertBlur(Bitmap screenshot, int blurRadius, int startHeight, + private void assertBlur(Bitmap screenshot, int blurRadius, int startHeight, int endHeight) { + dumpOnFailure.dumpOnFailure("assert-blur", screenshot); final int width = screenshot.getWidth(); // Adjust the test to check a smaller part of the blurred area in order to accept various @@ -414,17 +419,15 @@ public class BlurTests extends WindowManagerTestBase { final int blurAreaStartX = width / 2 - blurRadius + stepSize; final int blurAreaEndX = width / 2 + blurRadius; - Color previousColor; - Color currentColor; - final int unaffectedBluePixelX = width / 2 - blurRadius - 1; - final int unaffectedRedPixelX = width / 2 + blurRadius + 1; + // At 2 * radius there should be no visible blur effects. + final int unaffectedBluePixelX = width / 2 - blurRadius * 2 - 1; + final int unaffectedRedPixelX = width / 2 + blurRadius * 2 + 1; + for (int y = startHeight; y < endHeight; y++) { - ColorUtils.verifyColor( - "failed for pixel (x, y) = (" + unaffectedBluePixelX + ", " + y + ")", - Color.BLUE, screenshot.getPixel(unaffectedBluePixelX, y), 1); - previousColor = Color.valueOf(Color.BLUE); - for (int x = blurAreaStartX; x <= blurAreaEndX; x += stepSize) { - currentColor = screenshot.getColor(x, y); + Color previousColor = Color.valueOf(Color.BLUE); + for (int x = blurAreaStartX; x < blurAreaEndX; x += stepSize) { + Color currentColor = screenshot.getColor(x, y); + assertTrue("assertBlur failed for blue for pixel (x, y) = (" + x + ", " + y + ");" + " previousColor blue: " + previousColor.blue() + ", currentColor blue: " + currentColor.blue() @@ -436,6 +439,12 @@ public class BlurTests extends WindowManagerTestBase { previousColor = currentColor; } + } + + for (int y = startHeight; y < endHeight; y++) { + ColorUtils.verifyColor( + "failed for pixel (x, y) = (" + unaffectedBluePixelX + ", " + y + ")", + Color.BLUE, screenshot.getPixel(unaffectedBluePixelX, y), 1); ColorUtils.verifyColor( "failed for pixel (x, y) = (" + unaffectedRedPixelX + ", " + y + ")", Color.RED, screenshot.getPixel(unaffectedRedPixelX, y), 1); diff --git a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java index 8bbbddc0765..79328909505 100644 --- a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java +++ b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java @@ -217,40 +217,6 @@ public class KeyguardLockedTests extends KeyguardTestBase { } @Test - public void testTurnScreenOnActivity_withSecureKeyguardAndAod() { - final AodSession aodSession = createManagedAodSession(); - final LockScreenSession lockScreenSession = createManagedLockScreenSession(); - lockScreenSession.setLockCredential(); - testTurnScreenOnActivity_withSecureKeyguard(aodSession, lockScreenSession, - false /* enableAod */); - testTurnScreenOnActivity_withSecureKeyguard(aodSession, lockScreenSession, - true /* enableAod */); - } - - private void testTurnScreenOnActivity_withSecureKeyguard(AodSession aodSession, - LockScreenSession lockScreenSession, boolean enableAod) { - if (enableAod) { - assumeTrue(aodSession.isAodAvailable()); - } - aodSession.setAodEnabled(enableAod); - lockScreenSession.sleepDevice(); - mWmState.computeState(); - assertTrue(mWmState.getKeyguardControllerState().keyguardShowing); - - final CommandSession.ActivitySessionClient activityClient = - createManagedActivityClientSession(); - final CommandSession.ActivitySession activity = activityClient.startActivity( - getLaunchActivityBuilder().setUseInstrumentation().setIntentExtra(extra -> { - extra.putBoolean(Components.TurnScreenOnActivity.EXTRA_SHOW_WHEN_LOCKED, false); - }).setTargetActivity(TURN_SCREEN_ON_ACTIVITY)); - mWmState.waitForKeyguardShowingAndNotOccluded(); - mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, false); - assertTrue(mWmState.getKeyguardControllerState().keyguardShowing); - assertFalse(isDisplayOn(DEFAULT_DISPLAY)); - activity.finish(); - } - - @Test public void testDismissKeyguardAttrActivity_method_turnScreenOn_withSecureKeyguard() { final LockScreenSession lockScreenSession = createManagedLockScreenSession(); lockScreenSession.setLockCredential().sleepDevice(); diff --git a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java index 42139843c7e..dc7c30870c2 100755 --- a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java +++ b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java @@ -443,7 +443,7 @@ public class KeyguardTests extends KeyguardTestBase { } @Test - public void testTurnScreenOnOnActivityOnAod() { + public void testTurnScreenOnActivityOnAod() { final AodSession aodSession = createManagedAodSession(); assumeTrue(aodSession.isAodAvailable()); aodSession.setAodEnabled(true); @@ -460,10 +460,13 @@ public class KeyguardTests extends KeyguardTestBase { false); }).setTargetActivity(TURN_SCREEN_ON_ACTIVITY)); - mWmState.computeState(TURN_SCREEN_ON_ACTIVITY); - mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, true); - assertFalse(mWmState.getKeyguardControllerState().keyguardShowing); - assertTrue(isDisplayOn(DEFAULT_DISPLAY)); + mWmState.waitForAllStoppedActivities(); + // An activity without set showWhenLocked or dismissKeyguard cannot wakeup device and/or + // unlock insecure keyguard even if it has setTurnScreenOn, so the device should stay + // invisible and the display stay in dozing. + mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, false); + assertTrue(mWmState.getKeyguardControllerState().keyguardShowing); + assertFalse(isDisplayOn(DEFAULT_DISPLAY)); } /** * Tests whether a FLAG_DISMISS_KEYGUARD activity occludes Keyguard. diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerStateHelper.java b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerStateHelper.java index 458d7857461..66f24ec9ea1 100644 --- a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerStateHelper.java +++ b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerStateHelper.java @@ -160,6 +160,7 @@ public class WindowManagerStateHelper extends WindowManagerState { public static boolean isKeyguardShowingAndNotOccluded(WindowManagerState state) { return state.getKeyguardControllerState().keyguardShowing + && !state.getKeyguardControllerState().aodShowing && !state.getKeyguardControllerState().isKeyguardOccluded(DEFAULT_DISPLAY); } diff --git a/tests/signature/api-check/src/java/android/signature/cts/api/BootClassPathClassesProvider.java b/tests/signature/api-check/src/java/android/signature/cts/api/BootClassPathClassesProvider.java index d1f019b5078..e0f22e24a57 100644 --- a/tests/signature/api-check/src/java/android/signature/cts/api/BootClassPathClassesProvider.java +++ b/tests/signature/api-check/src/java/android/signature/cts/api/BootClassPathClassesProvider.java @@ -29,6 +29,7 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; +import java.util.Objects; import java.util.stream.Stream; @SuppressWarnings("deprecation") @@ -38,7 +39,8 @@ public class BootClassPathClassesProvider extends ClassProvider { @Override public Stream<Class<?>> getAllClasses() { maybeAttachJvmtiAgent(); - return Arrays.stream(getClassloaderDescriptors(Object.class.getClassLoader())) + return (Stream<Class<?>>) + Arrays.stream(getClassloaderDescriptors(Object.class.getClassLoader())) .map(descriptor -> { String classname = descriptor.replace('/', '.'); // omit L and ; at the front and at the end @@ -48,9 +50,12 @@ public class BootClassPathClassesProvider extends ClassProvider { try { return getClass(classname); } catch (ClassNotFoundException e) { - throw new RuntimeException("Cannot load " + classname, e); + // It could be that a class failed to verify. + // No process will be able to load it, so it's ok to silently ignore. + return null; } - }); + }) + .filter(Objects::nonNull); } @Override diff --git a/tests/signature/lib/android/src/android/signature/cts/DexMemberChecker.java b/tests/signature/lib/android/src/android/signature/cts/DexMemberChecker.java index 181f9d4d259..a64a483fc07 100644 --- a/tests/signature/lib/android/src/android/signature/cts/DexMemberChecker.java +++ b/tests/signature/lib/android/src/android/signature/cts/DexMemberChecker.java @@ -112,8 +112,12 @@ public class DexMemberChecker { } else if (dexMember instanceof DexMethod) { DexMethod method = (DexMethod) dexMember; if (reflection) { - observer.methodAccessibleViaReflection(hasMatchingMethod_Reflection(klass, method), - method); + try { + observer.methodAccessibleViaReflection( + hasMatchingMethod_Reflection(klass, method), method); + } catch (ClassNotFoundException e) { + Log.w(TAG, "Failed resolution of " + dexMember.toString(), e); + } } if (jni) { try { @@ -164,11 +168,22 @@ public class DexMemberChecker { return true; } catch (NoSuchFieldException ex) { return false; + } catch (NoClassDefFoundError ex) { + // The field has a type that cannot be loaded. + return true; } } private static boolean hasMatchingField_JNI(Class<?> klass, DexField dexField) { try { + DexMember.typeToClass(dexField.getDexType()); + } catch (ClassNotFoundException e) { + Log.w(TAG, "Type of field not found: " + dexField.toString(), e); + // Skip this field, no process is able to load it. + return true; + } + + try { Field ifield = getField_JNI(klass, dexField.getName(), dexField.getDexType()); if (ifield.getDeclaringClass() == klass) { return true; @@ -189,22 +204,57 @@ public class DexMemberChecker { return false; } - private static boolean hasMatchingMethod_Reflection(Class<?> klass, DexMethod dexMethod) { - List<String> methodParams = dexMethod.getJavaParameterTypes(); + private static boolean hasMatchingMethod_Reflection(Class<?> klass, DexMethod dexMethod) + throws ClassNotFoundException { + // If we fail to resolve all parameters or return type, we will throw + // ClassNotFoundException. + Class<?>[] parameterClasses = dexMethod.getJavaParameterClasses(); + Class<?> returnClass = DexMember.typeToClass(dexMethod.getDexType()); if (dexMethod.isConstructor()) { - for (Constructor<?> constructor : klass.getDeclaredConstructors()) { - if (typesMatch(constructor.getParameterTypes(), methodParams)) { + try { + if (klass.getDeclaredConstructor(parameterClasses) != null) { return true; } + } catch (NoSuchMethodException e) { + return false; } - } else { + } else if (!dexMethod.isStaticConstructor()) { + List<String> methodParams = dexMethod.getJavaParameterTypes(); String methodReturnType = dexMethod.getJavaType(); - for (Method method : klass.getDeclaredMethods()) { - if (method.getName().equals(dexMethod.getName()) - && method.getReturnType().getTypeName().equals(methodReturnType) - && typesMatch(method.getParameterTypes(), methodParams)) { - return true; + try { + // First try with getDeclaredMethods, hoping all parameter and return types can be + // resolved. + for (Method method : klass.getDeclaredMethods()) { + if (method.getName().equals(dexMethod.getName()) + && method.getReturnType().getTypeName().equals(methodReturnType) + && typesMatch(method.getParameterTypes(), methodParams)) { + return true; + } + } + } catch (NoClassDefFoundError ncdfe) { + // Try with getMethods, which does not check parameter and return types are + // resolved, but only returns public methods. + for (Method method : klass.getMethods()) { + if (method.getName().equals(dexMethod.getName()) + && method.getClass() == klass + && method.getReturnType().getTypeName().equals(methodReturnType) + && typesMatch(method.getParameterTypes(), methodParams)) { + return true; + } + } + // Last chance, try with getDeclaredMethod. + try { + Method m = klass.getDeclaredMethod(dexMethod.getName(), parameterClasses); + if (m.getReturnType().getTypeName().equals(dexMethod.getJavaType())) { + return true; + } + // This means we found a method with a different return type. We cannot make + // any conclusion here: the method may exisit or not. However, given we have + // not found the method through getMethods and getDeclaredMethods, we know + // this method won't be accessible through reflection. + } catch (NoSuchMethodException nsme) { + return false; } } } diff --git a/tests/signature/lib/common/src/android/signature/cts/DexMember.java b/tests/signature/lib/common/src/android/signature/cts/DexMember.java index c8470b92bcf..165341a2f8f 100644 --- a/tests/signature/lib/common/src/android/signature/cts/DexMember.java +++ b/tests/signature/lib/common/src/android/signature/cts/DexMember.java @@ -97,4 +97,35 @@ public abstract class DexMember { return javaType + javaDimension; } + + public static Class<?> typeToClass(String type) throws ClassNotFoundException { + if ("V".equals(type)) { + return void.class; + } else if ("Z".equals(type)) { + return boolean.class; + } else if ("B".equals(type)) { + return byte.class; + } else if ("C".equals(type)) { + return char.class; + } else if ("S".equals(type)) { + return short.class; + } else if ("I".equals(type)) { + return int.class; + } else if ("J".equals(type)) { + return long.class; + } else if ("F".equals(type)) { + return float.class; + } else if ("D".equals(type)) { + return double.class; + } else { + // Class names expected for Class.forName are: + // * for reference types: Ljava/lang/String; -> java.lang.String + // * for array types: [Ljava/lang/String; -> [Ljava.lang.String; + type = type.startsWith("L") + ? type.substring(1, type.length() - 1).replace('/', '.') + : type.replace('/', '.'); + } + + return Class.forName(type, /* initialize */ false, DexMember.class.getClassLoader()); + } } diff --git a/tests/signature/lib/common/src/android/signature/cts/DexMethod.java b/tests/signature/lib/common/src/android/signature/cts/DexMethod.java index 967a5a84a62..972f69c067c 100644 --- a/tests/signature/lib/common/src/android/signature/cts/DexMethod.java +++ b/tests/signature/lib/common/src/android/signature/cts/DexMethod.java @@ -42,6 +42,17 @@ public class DexMethod extends DexMember { return mParamTypeList.stream().map(DexMember::dexToJavaType).collect(Collectors.toList()); } + public Class<?>[] getJavaParameterClasses() throws ClassNotFoundException { + // Ideally we'd use streams, but DexMember.typeToClass throws a checked exception, and that's + // tricky to handle. + Class<?>[] classes = new Class<?>[mParamTypeList.size()]; + int i = 0; + for (String param : mParamTypeList) { + classes[i++] = DexMember.typeToClass(param); + } + return classes; + } + public boolean isConstructor() { return "<init>".equals(getName()) && "V".equals(getDexType()); } diff --git a/tests/tests/os/src/android/os/cts/FileObserverTest.java b/tests/tests/os/src/android/os/cts/FileObserverTest.java index e2e9c9d6709..1ae870622a1 100644 --- a/tests/tests/os/src/android/os/cts/FileObserverTest.java +++ b/tests/tests/os/src/android/os/cts/FileObserverTest.java @@ -345,11 +345,8 @@ public class FileObserverTest extends AndroidTestCase { + "] expected: " + expectedEvents + " Actual: " + actualEvents; int j = 0; for (int i = 0; i < expected.length; i++) { - while (expected[i] != moveEvents[j].event) { - j++; - if (j >= moveEvents.length) - fail(message); - } + while (j < moveEvents.length && expected[i] != moveEvents[j].event) j++; + if (j >= moveEvents.length) fail(message); j++; } } diff --git a/tests/tests/permission/src/android/permission/cts/OneTimePermissionTest.java b/tests/tests/permission/src/android/permission/cts/OneTimePermissionTest.java index 70147e2cd96..f243b3b5095 100644 --- a/tests/tests/permission/src/android/permission/cts/OneTimePermissionTest.java +++ b/tests/tests/permission/src/android/permission/cts/OneTimePermissionTest.java @@ -34,6 +34,7 @@ import android.content.pm.PackageManager; import android.provider.DeviceConfig; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; +import android.support.test.uiautomator.UiObject2; import androidx.test.platform.app.InstrumentationRegistry; @@ -256,9 +257,10 @@ public class OneTimePermissionTest { } private void clickOneTimeButton() throws Throwable { - UiAutomatorUtils.waitFindObject(By.res( - "com.android.permissioncontroller:id/permission_allow_one_time_button"), 10000) - .click(); + final UiObject2 uiObject = UiAutomatorUtils.waitFindObject(By.res( + "com.android.permissioncontroller:id/permission_allow_one_time_button"), 10000); + Thread.sleep(500); + uiObject.click(); } /** diff --git a/tests/tests/security/src/android/security/cts/EncryptionTest.java b/tests/tests/security/src/android/security/cts/EncryptionTest.java index 875f9c7c2a7..1f071ca818f 100644 --- a/tests/tests/security/src/android/security/cts/EncryptionTest.java +++ b/tests/tests/security/src/android/security/cts/EncryptionTest.java @@ -86,7 +86,8 @@ public class EncryptionTest { } private void handleEncryptedDevice() { - if ("file".equals(PropertyUtil.getProperty("ro.crypto.type"))) { + final String cryptoType = PropertyUtil.getProperty("ro.crypto.type"); + if ("file".equals(cryptoType)) { Log.d(TAG, "Device is encrypted with file-based encryption."); // Note: this test doesn't check whether the requirements for // encryption algorithms are met, since apps don't have a way to @@ -94,6 +95,14 @@ public class EncryptionTest { // CtsNativeEncryptionTestCases. return; } + if ("managed".equals(cryptoType)) { + // Android is running in a virtualized environment and the file + // system is encrypted by the host system. + Log.d(TAG, "Device encryption is managed by the host system."); + // Note: All encryption-related CDD requirements still must be met, + // but they can't be tested directly in this case. + return; + } // Prior to Android Q, file-based encryption wasn't required // (full-disk encryption was also allowed). if (PropertyUtil.getFirstApiLevel() < Build.VERSION_CODES.Q) { diff --git a/tests/tests/voiceinteraction/common/Android.bp b/tests/tests/voiceinteraction/common/Android.bp index e9052de8d8b..d667329344f 100644 --- a/tests/tests/voiceinteraction/common/Android.bp +++ b/tests/tests/voiceinteraction/common/Android.bp @@ -19,5 +19,6 @@ package { java_library { name: "CtsVoiceInteractionCommon", srcs: ["src/**/*.java"], - sdk_version: "current", + static_libs: ["compatibility-device-util-axt"], + sdk_version: "test_current", } diff --git a/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java b/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java index 4a34e2a617a..29a8bb5fe38 100644 --- a/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java +++ b/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java @@ -22,7 +22,10 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.Log; +import com.android.compatibility.common.util.PropertyUtil; + import java.util.ArrayList; +import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; @@ -267,4 +270,10 @@ public class Utils { } return bits; } + + public static boolean isVirtualDevice() { + final String property = PropertyUtil.getProperty("ro.hardware.virtual_device"); + Log.v(TAG, "virtual device property=" + property); + return Objects.equals(property, "1"); + } } diff --git a/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainHotwordDetectionService.java b/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainHotwordDetectionService.java index 759876cd409..4fb3f8e8697 100644 --- a/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainHotwordDetectionService.java +++ b/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainHotwordDetectionService.java @@ -324,6 +324,11 @@ public class MainHotwordDetectionService extends HotwordDetectionService { } numBytes += bytesRead; } + // The audio data will be zero on virtual device, so it would be better to skip to + // check the audio data. + if (Utils.isVirtualDevice()) { + return true; + } for (byte b : buffer) { // TODO: Maybe check that some portion of the bytes are non-zero. if (b != 0) { diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java index 47153afeaaf..0161540fa1f 100644 --- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java +++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java @@ -38,8 +38,6 @@ import android.webkit.WebViewClient; import android.webkit.cts.WebViewSyncLoader.WaitForLoadedClient; import android.util.Pair; -import androidx.test.filters.FlakyTest; - import com.android.compatibility.common.util.NullWebViewUtils; import com.android.compatibility.common.util.PollingCheck; import com.google.common.util.concurrent.SettableFuture; @@ -144,7 +142,6 @@ public class WebViewClientTest extends ActivityInstrumentationTestCase2<WebViewC // Verify shouldoverrideurlloading called on webview called via onCreateWindow // TODO(sgurun) upstream this test to Aw. - @FlakyTest(bugId = 172331117) public void testShouldOverrideUrlLoadingOnCreateWindow() throws Exception { if (!NullWebViewUtils.isWebViewAvailable()) { return; |