Merge "ITS: cleanup print statement in tools/run_parallel_tests.py" into pie-cts-dev
diff --git a/apps/CameraITS/tests/scene0/test_burst_capture.py b/apps/CameraITS/tests/scene0/test_burst_capture.py
index e6ee100..f915a6a 100644
--- a/apps/CameraITS/tests/scene0/test_burst_capture.py
+++ b/apps/CameraITS/tests/scene0/test_burst_capture.py
@@ -23,7 +23,7 @@
of fullsize capture + CPU read for at least some time.
"""
NAME = os.path.basename(__file__).split(".")[0]
- NUM_TEST_FRAMES = 20
+ NUM_TEST_FRAMES = 15
with its.device.ItsSession() as cam:
props = cam.get_camera_properties()
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java
index 6e03cdf..1af0650 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java
@@ -64,7 +64,8 @@
public void runDeviceTests(String packageName, String testClassName, String testMethodName)
throws DeviceNotAvailableException {
- Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
+ Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName,
+ getDevice().getCurrentUser());
}
protected void reinstallClientPackage() throws Exception {
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java
index 3227770..0280bdf 100755
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java
@@ -411,8 +411,13 @@
LocalBroadcastReceiver broadcastReceiver = new LocalBroadcastReceiver();
localBroadcastManager.registerReceiver(broadcastReceiver,
- new IntentFilter(BasicAdminReceiver.ACTION_USER_REMOVED));
+ new IntentFilter(BasicAdminReceiver.ACTION_USER_STARTED));
+ broadcastReceiver.waitForBroadcastReceived();
+ localBroadcastManager.unregisterReceiver(broadcastReceiver);
+ // Register broadcast receiver for the remove action.
+ localBroadcastManager.registerReceiver(broadcastReceiver,
+ new IntentFilter(BasicAdminReceiver.ACTION_USER_REMOVED));
try {
assertEquals(UserManager.USER_OPERATION_SUCCESS,
mDevicePolicyManager.stopUser(getWho(), userHandle));
diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java
index 3885f0a..d391b64 100644
--- a/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java
+++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java
@@ -122,10 +122,29 @@
}
if (parts[0].equals(DEVICE_SIDE_TEST_PACKAGE)) {
- if (Integer.parseInt(parts[6]) >= 8192 && Integer.parseInt(parts[8]) == 0) {
+ /*
+ * order of parts in StoragedService::dumpUidRecords
+ * [0] DEVICE_SIDE_TEST_PACKAGE
+ * [1] read foreground charger_off
+ * [2] write foreground charger_off
+ * [3] read background charger_off
+ * [4] write background charger_off
+ * [5] read foreground charger_on
+ * [6] write foreground charger_on
+ * [7] read background charger_on
+ * [8] write background charger_on
+ */
+ if ((Integer.parseInt(parts[6]) >= 8192 && Integer.parseInt(parts[8]) == 0) ||
+ (Integer.parseInt(parts[2]) >= 8192 && Integer.parseInt(parts[4]) == 0)) {
System.out.print("WARNING: Background I/O was attributed to the "
+ "foreground. This could indicate a broken or malfunctioning "
+ "ActivityManager or UsageStatsService.\n");
+ } else if ((Integer.parseInt(parts[2]) >= 4096 && Integer.parseInt(parts[4]) >= 4096) ||
+ Integer.parseInt(parts[4]) >= 8192) {
+ System.out.print("WARNING: charger on I/O was attributed to "
+ + "charger off. This could indicate a broken or malfunctioning "
+ + "ADB USB connection, or device that refuses to charge at the "
+ + "typical 500mA because it is less than 0.05C.\n");
} else {
assertTrue((Integer.parseInt(parts[6]) >= 4096 && Integer.parseInt(parts[8]) >= 4096) ||
Integer.parseInt(parts[8]) >= 8192);
diff --git a/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java b/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java
index 3efe3bb..59d7e95 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java
@@ -43,7 +43,7 @@
// Use ratios to flexibly accomodate circular or not quite rectangular displays
// Note: Color.BLACK is the pixel color outside of the display region
assertColors(image, mAmWmState.getWmState().getStableBounds(),
- Color.RED, 0.50f, Color.BLACK, 0.01f);
+ Color.RED, 0.50f, Color.BLACK, 0.02f);
}
private void assertColors(Bitmap img, Rect bounds, int primaryColor,
diff --git a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
old mode 100644
new mode 100755
index 7988ef3..63cda8b
--- a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
@@ -22,7 +22,9 @@
import android.hardware.Sensor;
import android.hardware.SensorDirectChannel;
import android.hardware.SensorManager;
+import android.os.Build;
+import com.android.compatibility.common.util.PropertyUtil;
import com.android.compatibility.common.util.CddTest;
/**
@@ -64,8 +66,10 @@
}
@CddTest(requirement="7.9.2/C-1-19,C-1-20")
- public void testSupportsAccelerometerUncalibrated() {
- checkSupportsSensor(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED);
+ public void testSupportsAccelerometerUncalibrated() {
+ if (PropertyUtil.getFirstApiLevel() >= Build.VERSION_CODES.O) {
+ checkSupportsSensor(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED);
+ }
}
@CddTest(requirement="7.9.2/C-1-19,C-1-20")
diff --git a/tests/signature/src/android/signature/cts/AbstractApiChecker.java b/tests/signature/src/android/signature/cts/AbstractApiChecker.java
index 3ea16e1..546b921 100644
--- a/tests/signature/src/android/signature/cts/AbstractApiChecker.java
+++ b/tests/signature/src/android/signature/cts/AbstractApiChecker.java
@@ -62,12 +62,14 @@
.findRequiredClass(classDescription, classProvider);
if (runtimeClass == null) {
- // No class found, notify the observer according to the class type
- resultObserver.notifyFailure(FailureType.missing(classDescription),
- classDescription.getAbsoluteClassName(),
- "Classloader is unable to find " + classDescription
- .getAbsoluteClassName());
-
+ // No class found, notify the observer according to the class type,
+ // if missing a class isn't acceptable.
+ if (!allowMissingClass(classDescription)) {
+ resultObserver.notifyFailure(FailureType.missing(classDescription),
+ classDescription.getAbsoluteClassName(),
+ "Classloader is unable to find " + classDescription
+ .getAbsoluteClassName());
+ }
return null;
}
@@ -106,6 +108,17 @@
/**
+ * Checks that a class that exists in the API xml file but that does not exist
+ * in the runtime is allowed or not.
+ *
+ * @param classDescription the class description that is missing.
+ * @return true if missing the class is acceptable.
+ */
+ protected boolean allowMissingClass(JDiffClassDescription classDescription) {
+ return false;
+ }
+
+ /**
* Checks all fields in test class for compliance with the API xml.
*
* @param classDescription a description of a class in an API.
diff --git a/tests/signature/src/android/signature/cts/AnnotationChecker.java b/tests/signature/src/android/signature/cts/AnnotationChecker.java
index 9419df1..ab111a4 100644
--- a/tests/signature/src/android/signature/cts/AnnotationChecker.java
+++ b/tests/signature/src/android/signature/cts/AnnotationChecker.java
@@ -95,6 +95,17 @@
}
@Override
+ protected boolean allowMissingClass(JDiffClassDescription classDescription) {
+ // A class that exist in the API document is not found in the runtime.
+ // This can happen for classes that are optional (e.g. classes for
+ // Android Auto). This, however, should not be considered as a test
+ // failure, because the purpose of this test is to ensure that every
+ // runtime classes found in the device have more annotations than
+ // the documented.
+ return true;
+ }
+
+ @Override
protected boolean checkClass(JDiffClassDescription classDescription, Class<?> runtimeClass) {
// remove the class from the set if found
annotatedClassesMap.remove(runtimeClass.getName());
diff --git a/tests/tests/media/src/android/media/cts/RoutingTest.java b/tests/tests/media/src/android/media/cts/RoutingTest.java
index 69e3f5c..28d9564 100644
--- a/tests/tests/media/src/android/media/cts/RoutingTest.java
+++ b/tests/tests/media/src/android/media/cts/RoutingTest.java
@@ -668,8 +668,15 @@
// The available output device is less than 2, we can't switch output device.
return;
}
- for (int index = 0; index < deviceList.length; index++) {
- assertTrue(mediaPlayer.setPreferredDevice(deviceList[index]));
+ Set<Integer> testedDeviceTypes = new HashSet<>();
+ for (AudioDeviceInfo device : deviceList) {
+ final int deviceType = device.getType();
+ if (testedDeviceTypes.contains(deviceType)) {
+ // b/122478352 setPreferredDevice can not differentiate devices with same type.
+ continue;
+ }
+ testedDeviceTypes.add(deviceType);
+ assertTrue(mediaPlayer.setPreferredDevice(device));
boolean routingChanged = false;
for (int i = 0; i < MAX_WAITING_ROUTING_CHANGED_COUNT; i++) {
// Create a new CountDownLatch in case it is triggered by previous routing change.
@@ -682,12 +689,12 @@
if (routedDevice == null) {
continue;
}
- if (routedDevice.getId() == deviceList[index].getId()) {
+ if (routedDevice.getId() == device.getId()) {
routingChanged = true;
break;
}
}
- assertTrue("Switching to device" + deviceList[index].getType() + " failed",
+ assertTrue("Switching to device " + device.getType() + " failed",
routingChanged);
}
diff --git a/tests/tests/security/src/android/security/cts/MotionEventTest.java b/tests/tests/security/src/android/security/cts/MotionEventTest.java
index 4a8cc780..d36e420 100644
--- a/tests/tests/security/src/android/security/cts/MotionEventTest.java
+++ b/tests/tests/security/src/android/security/cts/MotionEventTest.java
@@ -39,6 +39,7 @@
import android.view.WindowManager;
import com.android.compatibility.common.util.PollingCheck;
+import com.android.compatibility.common.util.WidgetTestUtils;
import org.junit.Before;
import org.junit.Rule;
@@ -80,13 +81,12 @@
* screen to determine approximate locations of touch events without the user knowing.
*/
@Test
- public void testActionOutsideDoesNotContainedObscuredInformation() throws Exception {
+ public void testActionOutsideDoesNotContainedObscuredInformation() throws Throwable {
enableAppOps();
final OnTouchListener listener = new OnTouchListener();
- final Point size = new Point();
- final View[] viewHolder = new View[1];
- mActivity.runOnUiThread(() -> {
+ FutureTask<View> addViewTask = new FutureTask<>(() -> {
final WindowManager wm = mActivity.getSystemService(WindowManager.class);
+ final Point size = new Point();
wm.getDefaultDisplay().getSize(size);
WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams(
@@ -115,20 +115,26 @@
v.setBackgroundColor(Color.BLUE);
v.setOnTouchListener(listener);
v.setLayoutParams(vglp);
- viewHolder[0] = v;
wm.addView(v, wmlp);
+ return v;
});
- mInstrumentation.waitForIdleSync();
+ mActivity.runOnUiThread(addViewTask);
+ View view = addViewTask.get(5, TimeUnit.SECONDS);
- FutureTask<Point> task = new FutureTask<>(() -> {
+ // Wait for a layout pass to be certain the view is on the screen
+ // before getting the location and injecting touches.
+ WidgetTestUtils.runOnMainAndLayoutSync(mActivityRule, view, null /*runnable*/,
+ true /*forceLayout*/);
+
+ FutureTask<Point> clickLocationTask = new FutureTask<>(() -> {
final int[] viewLocation = new int[2];
- viewHolder[0].getLocationOnScreen(viewLocation);
+ view.getLocationOnScreen(viewLocation);
// Set y position to the center of the view, to make sure it is away from the status bar
- return new Point(viewLocation[0], viewLocation[1] + viewHolder[0].getHeight() / 2);
+ return new Point(viewLocation[0], viewLocation[1] + view.getHeight() / 2);
});
- mActivity.runOnUiThread(task);
- Point viewLocation = task.get(5, TimeUnit.SECONDS);
+ mActivity.runOnUiThread(clickLocationTask);
+ Point viewLocation = clickLocationTask.get(5, TimeUnit.SECONDS);
injectTap(viewLocation.x, viewLocation.y);
List<MotionEvent> outsideEvents = listener.getOutsideEvents();
diff --git a/tests/tests/telecom/AndroidManifest.xml b/tests/tests/telecom/AndroidManifest.xml
index ae62757..cce9785 100644
--- a/tests/tests/telecom/AndroidManifest.xml
+++ b/tests/tests/telecom/AndroidManifest.xml
@@ -26,6 +26,7 @@
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
<uses-permission android:name="android.permission.ACCEPT_HANDOVER" />
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
index 3e0d210..26a7d6c 100644
--- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
+++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
@@ -28,7 +28,9 @@
import android.os.Looper;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
+import android.os.Process;
import android.os.SystemClock;
+import android.os.UserManager;
import android.support.test.InstrumentationRegistry;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -183,7 +185,6 @@
public static final String MERGE_CALLER_NAME = "calls-merged";
public static final String SWAP_CALLER_NAME = "calls-swapped";
- private static final String PRIMARY_USER_SN = "0";
public static boolean shouldTestTelecom(Context context) {
if (!HAS_TELECOM) {
@@ -210,17 +211,19 @@
public static void enablePhoneAccount(Instrumentation instrumentation,
PhoneAccountHandle handle) throws Exception {
final ComponentName component = handle.getComponentName();
+ final long currentUserSerial = getCurrentUserSerialNumber(instrumentation);
executeShellCommand(instrumentation, COMMAND_ENABLE
+ component.getPackageName() + "/" + component.getClassName() + " "
- + handle.getId() + " " + PRIMARY_USER_SN);
+ + handle.getId() + " " + currentUserSerial);
}
public static void registerSimPhoneAccount(Instrumentation instrumentation,
PhoneAccountHandle handle, String label, String address) throws Exception {
final ComponentName component = handle.getComponentName();
+ final long currentUserSerial = getCurrentUserSerialNumber(instrumentation);
executeShellCommand(instrumentation, COMMAND_REGISTER_SIM
+ component.getPackageName() + "/" + component.getClassName() + " "
- + handle.getId() + " " + PRIMARY_USER_SN + " " + label + " " + address);
+ + handle.getId() + " " + currentUserSerial + " " + label + " " + address);
}
public static void waitOnAllHandlers(Instrumentation instrumentation) throws Exception {
@@ -510,4 +513,10 @@
}
}
}
+
+ private static long getCurrentUserSerialNumber(Instrumentation instrumentation) {
+ UserManager userManager =
+ instrumentation.getContext().getSystemService(UserManager.class);
+ return userManager.getSerialNumberForUser(Process.myUserHandle());
+ }
}
diff --git a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
index 7323f30..f6b30d8 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
@@ -50,8 +50,7 @@
}
private boolean isSimCardPresent() {
- return mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE &&
- mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT;
+ return mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT;
}
private void checkConfig(PersistableBundle config) {