Merge "Switch to final value of EGL extension value in protected texture test." into nyc-dev
diff --git a/OldCtsTestCaseList.mk b/OldCtsTestCaseList.mk
index 2e7de5e..e3ff634 100644
--- a/OldCtsTestCaseList.mk
+++ b/OldCtsTestCaseList.mk
@@ -162,7 +162,6 @@
CtsCarTestCases \
CtsContentTestCases \
CtsDatabaseTestCases \
- CtsDeviceAdminUninstallerTestCases \
CtsDisplayTestCases \
CtsDpiTestCases \
CtsDpiTestCases2 \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 646d1f8..bd77bda 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1662,7 +1662,8 @@
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_INSTALL_APK" />
<action android:name="com.android.cts.verifier.managedprovisioning.action.CHECK_INTENT_FILTERS" />
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_IMAGE" />
- <action android:name="com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_VIDEO" />
+ <action android:name="com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT" />
+ <action android:name="com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT" />
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_AUDIO" />
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_KEYGUARD_DISABLED_FEATURES" />
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_LOCKNOW" />
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index b921e1c..94e7bd4 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1363,7 +1363,7 @@
2. Verify that the captured picture is shown.\n
3. Click on the close button.
</string>
- <string name="provisioning_byod_capture_video_support">Camera support cross profile video capture</string>
+ <string name="provisioning_byod_capture_video_support_with_extra_output">Camera support cross profile video capture (with extra output path)</string>
<string name="provisioning_byod_capture_video_support_info">
This test verifies that videos can be captured from the managed profile using the primary profile camera.\n
1. Capture a video using the camera.\n
@@ -1371,6 +1371,7 @@
3. Verify that the captured video is played.\n
4. Click on the close button.
</string>
+ <string name="provisioning_byod_capture_video_support_without_extra_output">Camera support cross profile video capture (without extra output path)</string>
<string name="provisioning_byod_capture_audio_support">Sound recorder support cross profile audio capture</string>
<string name="provisioning_byod_capture_audio_support_info">
This test verifies that audio can be captured from the managed profile using the primary profile sound recorder.\n
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
index 9b5df85..8cbbb1b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
@@ -81,7 +81,8 @@
private DialogTestListItem mTurnOffWorkLauncher;
private DialogTestListItem mTurnOffWorkNotifications;
private DialogTestListItem mCrossProfileImageCaptureSupportTest;
- private DialogTestListItem mCrossProfileVideoCaptureSupportTest;
+ private DialogTestListItem mCrossProfileVideoCaptureWithExtraOutputSupportTest;
+ private DialogTestListItem mCrossProfileVideoCaptureWithoutExtraOutputSupportTest;
private DialogTestListItem mCrossProfileAudioCaptureSupportTest;
private TestListItem mKeyguardDisabledFeaturesTest;
private DialogTestListItem mDisableNfcBeamTest;
@@ -455,12 +456,18 @@
*/
if (canResolveIntent(ByodHelperActivity.getCaptureVideoIntent())) {
// Capture video intent can be resolved in primary profile, so test.
- mCrossProfileVideoCaptureSupportTest = new DialogTestListItem(this,
- R.string.provisioning_byod_capture_video_support,
- "BYOD_CrossProfileVideoCaptureSupportTest",
+ mCrossProfileVideoCaptureWithExtraOutputSupportTest = new DialogTestListItem(this,
+ R.string.provisioning_byod_capture_video_support_with_extra_output,
+ "BYOD_CrossProfileVideoCaptureWithExtraOutputSupportTest",
R.string.provisioning_byod_capture_video_support_info,
- new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO));
- adapter.add(mCrossProfileVideoCaptureSupportTest);
+ new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT));
+ adapter.add(mCrossProfileVideoCaptureWithExtraOutputSupportTest);
+ mCrossProfileVideoCaptureWithoutExtraOutputSupportTest = new DialogTestListItem(this,
+ R.string.provisioning_byod_capture_video_support_without_extra_output,
+ "BYOD_CrossProfileVideoCaptureWithoutExtraOutputSupportTest",
+ R.string.provisioning_byod_capture_video_support_info,
+ new Intent(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT));
+ adapter.add(mCrossProfileVideoCaptureWithoutExtraOutputSupportTest);
} else {
// Capture video intent cannot be resolved in primary profile, so skip test.
Toast.makeText(ByodFlowTestActivity.this,
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
index b9e6541..e9a2728 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
@@ -74,11 +74,13 @@
public static final String ACTION_REMOVE_MANAGED_PROFILE = "com.android.cts.verifier.managedprovisioning.BYOD_REMOVE";
// Managed -> managed intent: provisioning completed successfully
public static final String ACTION_PROFILE_PROVISIONED = "com.android.cts.verifier.managedprovisioning.BYOD_PROVISIONED";
- // Primage -> managed intent: request to capture and check an image
+ // Primary -> managed intent: request to capture and check an image
public static final String ACTION_CAPTURE_AND_CHECK_IMAGE = "com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_IMAGE";
- // Primage -> managed intent: request to capture and check a video
- public static final String ACTION_CAPTURE_AND_CHECK_VIDEO = "com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_VIDEO";
- // Primage -> managed intent: request to capture and check an audio recording
+ // Primary -> managed intent: request to capture and check a video with custom output path
+ public static final String ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT = "com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT";
+ // Primary -> managed intent: request to capture and check a video without custom output path
+ public static final String ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT = "com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT";
+ // Primary -> managed intent: request to capture and check an audio recording
public static final String ACTION_CAPTURE_AND_CHECK_AUDIO = "com.android.cts.verifier.managedprovisioning.BYOD_CAPTURE_AND_CHECK_AUDIO";
public static final String ACTION_KEYGUARD_DISABLED_FEATURES =
"com.android.cts.verifier.managedprovisioning.BYOD_KEYGUARD_DISABLED_FEATURES";
@@ -142,8 +144,10 @@
private static final int REQUEST_INSTALL_PACKAGE = 2;
private static final int REQUEST_IMAGE_CAPTURE = 3;
- private static final int REQUEST_VIDEO_CAPTURE = 4;
- private static final int REQUEST_AUDIO_CAPTURE = 5;
+ private static final int REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT = 4;
+ private static final int REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT = 5;
+ private static final int REQUEST_AUDIO_CAPTURE = 6;
+ private static final int REQUEST_LOCATION_UPDATE = 7;
private static final String ORIGINAL_SETTINGS_NAME = "original settings";
@@ -248,14 +252,21 @@
finish();
}
return;
- } else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO)) {
+ } else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT) ||
+ action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT)) {
// We need the camera permission to send the video capture intent.
grantCameraPermissionToSelf();
Intent captureVideoIntent = getCaptureVideoIntent();
- mVideoUri = getTempUri("video.mp4").second;
- captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri);
+ int videoCaptureRequestId;
+ if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)) {
+ mVideoUri = getTempUri("video.mp4").second;
+ captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri);
+ videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT;
+ } else {
+ videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT;
+ }
if (captureVideoIntent.resolveActivity(getPackageManager()) != null) {
- startActivityForResult(captureVideoIntent, REQUEST_VIDEO_CAPTURE);
+ startActivityForResult(captureVideoIntent, videoCaptureRequestId);
} else {
Log.e(TAG, "Capture video intent could not be resolved in managed profile.");
showToast(R.string.provisioning_byod_capture_media_error);
@@ -372,7 +383,7 @@
}
break;
}
- case REQUEST_VIDEO_CAPTURE: {
+ case REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT: {
if (resultCode == RESULT_OK) {
ByodPresentMediaDialog.newVideoInstance(mVideoUri)
.show(getFragmentManager(), "PlayVideoDialogFragment");
@@ -382,6 +393,16 @@
}
break;
}
+ case REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT: {
+ if (resultCode == RESULT_OK) {
+ ByodPresentMediaDialog.newVideoInstance(data.getData())
+ .show(getFragmentManager(), "PlayVideoDialogFragment");
+ } else {
+ // Failed capturing video.
+ finish();
+ }
+ break;
+ }
case REQUEST_AUDIO_CAPTURE: {
if (resultCode == RESULT_OK) {
ByodPresentMediaDialog.newAudioInstance(data.getData())
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
index e4250f0..3c3720f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
@@ -80,7 +80,8 @@
filter.addAction(ByodHelperActivity.ACTION_INSTALL_APK);
filter.addAction(ByodHelperActivity.ACTION_CHECK_INTENT_FILTERS);
filter.addAction(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_IMAGE);
- filter.addAction(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO);
+ filter.addAction(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT);
+ filter.addAction(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT);
filter.addAction(ByodHelperActivity.ACTION_CAPTURE_AND_CHECK_AUDIO);
filter.addAction(ByodHelperActivity.ACTION_KEYGUARD_DISABLED_FEATURES);
filter.addAction(ByodHelperActivity.ACTION_LOCKNOW);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
index 50d1de1..dfc7d02 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -271,7 +271,7 @@
long expected = module.getRuntimeHint();
long delta = Math.abs(duration - expected);
// Show warning if delta is more than 10% of expected
- if ((delta / expected) > 0.1f) {
+ if (expected > 0 && ((float)delta / (float)expected) > 0.1f) {
CLog.logAndDisplay(LogLevel.WARN,
"Inaccurate runtime hint for %s, expected %s was %s",
module.getId(),
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SupportMessageTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SupportMessageTest.java
index 4cd3537..03ca1a3 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SupportMessageTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SupportMessageTest.java
@@ -33,22 +33,22 @@
// Declare a different string of the same type for both long and short messages, so we can be
// sure they aren't mixed up by any API calls.
private static class ShortMessage {
- static final String EMPTY = "";
- static final String SIMPLE = "short-message-short";
- static final String MAX_LENGTH =
+ static final CharSequence EMPTY = "";
+ static final CharSequence SIMPLE = "short-message-short";
+ static final CharSequence MAX_LENGTH =
new String(new char[MAX_SHORT_MSG_LENGTH]).replace('\0', 'X');
- static final String TOO_LONG =
+ static final CharSequence TOO_LONG =
new String(new char[MAX_SHORT_MSG_LENGTH + 10]).replace('\0', 'A');
- static final String UNICODE = new String(Character.toChars(0x1F634)) + " zzz";
- static final String CONTAINS_NULL = "short\0null";
+ static final CharSequence UNICODE = new String(Character.toChars(0x1F634)) + " zzz";
+ static final CharSequence CONTAINS_NULL = "short\0null";
}
private static class LongMessage {
- static final String EMPTY = "";
- static final String SIMPLE = "long-message-long";
- static final String LONG =
+ static final CharSequence EMPTY = "";
+ static final CharSequence SIMPLE = "long-message-long";
+ static final CharSequence LONG =
new String(new char[REASONABLE_LONG_MSG_LENGTH]).replace('\0', 'B');
- static final String UNICODE = new String(Character.toChars(0x1F609)) + " ;)";
- static final String CONTAINS_NULL = "long\0null";
+ static final CharSequence UNICODE = new String(Character.toChars(0x1F609)) + " ;)";
+ static final CharSequence CONTAINS_NULL = "long\0null";
}
@Override
@@ -86,7 +86,7 @@
*/
mDevicePolicyManager.setShortSupportMessage(ADMIN_RECEIVER_COMPONENT,
ShortMessage.TOO_LONG);
- assertStartsWith(ShortMessage.TOO_LONG.substring(0, MAX_SHORT_MSG_LENGTH),
+ assertStartsWith(ShortMessage.TOO_LONG.subSequence(0, MAX_SHORT_MSG_LENGTH),
getShortMessage());
// Long support messages should not be affected; verify that.
@@ -117,7 +117,7 @@
} catch (NullPointerException expected) {
}
try {
- String message = mDevicePolicyManager.getShortSupportMessage(null);
+ CharSequence message = mDevicePolicyManager.getShortSupportMessage(null);
fail("Exception should have been thrown for null admin ComponentName");
} catch (NullPointerException expected) {
}
@@ -130,7 +130,7 @@
}
try {
- String message = mDevicePolicyManager.getLongSupportMessage(null);
+ CharSequence message = mDevicePolicyManager.getLongSupportMessage(null);
fail("Exception should have been thrown for null admin ComponentName");
} catch (NullPointerException expected) {
}
@@ -149,7 +149,7 @@
*
* @throws AssertionError in the case that the message could not be set.
*/
- private void setShortMessage(String message) {
+ private void setShortMessage(CharSequence message) {
mDevicePolicyManager.setShortSupportMessage(ADMIN_RECEIVER_COMPONENT, message);
assertEquals(message, getShortMessage());
}
@@ -159,23 +159,23 @@
*
* @throws AssertionError in the case that the message could not be set.
*/
- private void setLongMessage(String message) {
+ private void setLongMessage(CharSequence message) {
mDevicePolicyManager.setLongSupportMessage(ADMIN_RECEIVER_COMPONENT, message);
assertEquals(message, getLongMessage());
}
- private String getShortMessage() {
+ private CharSequence getShortMessage() {
return mDevicePolicyManager.getShortSupportMessage(ADMIN_RECEIVER_COMPONENT);
}
- private String getLongMessage() {
+ private CharSequence getLongMessage() {
return mDevicePolicyManager.getLongSupportMessage(ADMIN_RECEIVER_COMPONENT);
}
- private static void assertStartsWith(String expectPrefix, String actual) {
+ private static void assertStartsWith(CharSequence expectPrefix, CharSequence actual) {
assertNotNull(expectPrefix);
assertNotNull(actual);
- if (!actual.startsWith(expectPrefix)) {
+ if (!actual.toString().startsWith(expectPrefix.toString())) {
fail("Expected prefix: '" + expectPrefix + "'\n" +
" got: '" + actual + "'");
}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/device_admin.xml b/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/device_admin.xml
index 0398509..36c767b 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/device_admin.xml
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/device_admin.xml
@@ -17,5 +17,6 @@
<wipe-data />
<disable-camera />
<limit-password />
+ <disable-keyguard-features/>
</uses-policies>
</device-admin>
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BaseManagedProfileTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BaseManagedProfileTest.java
index 49754d0..45d540e 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BaseManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BaseManagedProfileTest.java
@@ -37,6 +37,7 @@
BasicAdminReceiver.class.getPackage().getName(), BasicAdminReceiver.class.getName());
protected DevicePolicyManager mDevicePolicyManager;
+ protected DevicePolicyManager mParentDevicePolicyManager;
protected Context mContext;
@Override
@@ -46,6 +47,8 @@
mDevicePolicyManager = (DevicePolicyManager)
mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ mParentDevicePolicyManager =
+ mDevicePolicyManager.getParentProfileInstance(ADMIN_RECEIVER_COMPONENT);
assertNotNull(mDevicePolicyManager);
// TODO: Only check the below if we are running as the profile user. If running under the
@@ -56,4 +59,8 @@
assertTrue(mDevicePolicyManager.isProfileOwnerApp(
ADMIN_RECEIVER_COMPONENT.getPackageName()));
}
+
+ protected DevicePolicyManager getDevicePolicyManager(boolean isParent) {
+ return isParent ? mParentDevicePolicyManager : mDevicePolicyManager;
+ }
}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/OrganizationInfoTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/OrganizationInfoTest.java
index aa319e3..ec5ea0f 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/OrganizationInfoTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/OrganizationInfoTest.java
@@ -64,19 +64,24 @@
}
public void testDefaultOrganizationNameIsNull() {
- final String name = mDevicePolicyManager.getOrganizationName(ADMIN_RECEIVER_COMPONENT);
- assertNull(name);
+ CharSequence organizationName = mDevicePolicyManager.getOrganizationName(
+ ADMIN_RECEIVER_COMPONENT);
+ assertNull(organizationName);
}
public void testSetOrganizationName() {
- String previousName = mDevicePolicyManager.getOrganizationName(ADMIN_RECEIVER_COMPONENT);
+ CharSequence previousOrganizationName = mDevicePolicyManager.getOrganizationName(
+ ADMIN_RECEIVER_COMPONENT);
try {
- final String name = "test-set-name";
+ final CharSequence name = "test-set-name";
mDevicePolicyManager.setOrganizationName(ADMIN_RECEIVER_COMPONENT, name);
- assertEquals(name, mDevicePolicyManager.getOrganizationName(ADMIN_RECEIVER_COMPONENT));
+ CharSequence organizationName = mDevicePolicyManager.getOrganizationName(
+ ADMIN_RECEIVER_COMPONENT);
+ assertEquals(name, organizationName);
} finally {
- mDevicePolicyManager.setOrganizationName(ADMIN_RECEIVER_COMPONENT, previousName);
+ mDevicePolicyManager.setOrganizationName(ADMIN_RECEIVER_COMPONENT,
+ previousOrganizationName);
}
}
@@ -88,7 +93,7 @@
}
try {
- String name = mDevicePolicyManager.getOrganizationName(null);
+ mDevicePolicyManager.getOrganizationName(null);
fail("Exception should have been thrown for null admin ComponentName");
} catch (Exception expected) {
}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/TrustAgentInfoTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/TrustAgentInfoTest.java
new file mode 100644
index 0000000..2e2a334
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/TrustAgentInfoTest.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2016 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.cts.managedprofile;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.os.PersistableBundle;
+import android.test.MoreAsserts;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static com.android.cts.managedprofile.TrustAgentInfoTest.AssertConfigMode.*;
+
+public class TrustAgentInfoTest extends BaseManagedProfileTest {
+ private static final String BUNDLE_KEY = "testing";
+ private static final String BUNDLE_PARENT_VALUE = "parent";
+ private static final String BUNDLE_CHILD_VALUE = "child";
+ private static final PersistableBundle CHILD_CONFIG = new PersistableBundle();
+ private static final PersistableBundle PARENT_CONFIG = new PersistableBundle();
+ private static final ComponentName TRUST_AGENT_COMPONENT =
+ new ComponentName("com.trustagent", "com.trustagent.xxx");
+
+ static {
+ CHILD_CONFIG.putString(BUNDLE_KEY, BUNDLE_CHILD_VALUE);
+ PARENT_CONFIG.putString(BUNDLE_KEY, BUNDLE_PARENT_VALUE);
+ }
+
+ enum AssertConfigMode {
+ ASSERT_PARENT_CONFIG, ASSERT_CHILD_CONFIG, ASSERT_BOTH
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ clearTrustAgentConfiguration(true /* isParent */);
+ clearTrustAgentConfiguration(false /* isParent */);
+ enableTrustAgents(true /* isParent */);
+ enableTrustAgents(false /* isParent */);
+ super.tearDown();
+ }
+
+ public void testSetAndGetTrustAgentConfiguration_child() {
+ setAndGetTrustAgentConfigurationInternal(false /* isParent */);
+ }
+
+ public void testSetAndGetTrustAgentConfiguration_parent() {
+ setAndGetTrustAgentConfigurationInternal(true /* isParent */);
+ }
+
+ public void testSetTrustAgentConfiguration_bothHaveTrustAgentConfigAndUnified() {
+ // Set both trust agents.
+ setTrustAgentConfiguration(false /* isParent */);
+ setTrustAgentConfiguration(true /* isParent */);
+
+ // Case when trust agents is not disabled
+ List<PersistableBundle> parentConfig =
+ mParentDevicePolicyManager.getTrustAgentConfiguration(
+ null, TRUST_AGENT_COMPONENT);
+ List<PersistableBundle> childConfig = mDevicePolicyManager.getTrustAgentConfiguration(
+ null, TRUST_AGENT_COMPONENT);
+ assertNull(parentConfig);
+ assertNull(childConfig);
+
+ // Case when trust agents is disabled
+ disableTrustAgents(false /* isParent */);
+ disableTrustAgents(true /* isParent */);
+
+ parentConfig = mParentDevicePolicyManager.getTrustAgentConfiguration(
+ null, TRUST_AGENT_COMPONENT);
+ childConfig = mDevicePolicyManager.getTrustAgentConfiguration(
+ null, TRUST_AGENT_COMPONENT);
+ assertPersistableBundleListEquals(ASSERT_BOTH, parentConfig);
+ assertPersistableBundleListEquals(ASSERT_BOTH, childConfig);
+ }
+
+ public void testSetTrustAgentConfiguration_bothHaveTrustAgentConfigAndNonUnified() {
+ // Enable separate challenge for the managed profile.
+ mDevicePolicyManager.resetPassword("1234", 0);
+ // Set both trust agents.
+ setTrustAgentConfiguration(false /* isParent */);
+ setTrustAgentConfiguration(true /* isParent */);
+ disableTrustAgents(false /* isParent */);
+ disableTrustAgents(true /* isParent */);
+
+ List<PersistableBundle> parentConfig =
+ mParentDevicePolicyManager.getTrustAgentConfiguration(
+ null, TRUST_AGENT_COMPONENT);
+ List<PersistableBundle> childConfig =
+ mDevicePolicyManager.getTrustAgentConfiguration(
+ null, TRUST_AGENT_COMPONENT);
+ // Separate credential in managed profile, should only get its own config.
+ assertPersistableBundleListEquals(ASSERT_PARENT_CONFIG, parentConfig);
+ assertPersistableBundleListEquals(ASSERT_CHILD_CONFIG, childConfig);
+ }
+
+ private void setAndGetTrustAgentConfigurationInternal(boolean isParent) {
+ // Set the config
+ setTrustAgentConfiguration(isParent);
+ // Case when trust agents is not disabled
+ List<PersistableBundle> configs = getDevicePolicyManager(isParent)
+ .getTrustAgentConfiguration(null, TRUST_AGENT_COMPONENT);
+ assertNull(configs);
+ // Case when trust agents is disabled
+ disableTrustAgents(isParent);
+ configs = getDevicePolicyManager(isParent)
+ .getTrustAgentConfiguration(null, TRUST_AGENT_COMPONENT);
+ assertPersistableBundleListEquals(isParent ?
+ ASSERT_PARENT_CONFIG : ASSERT_CHILD_CONFIG, configs);
+ }
+
+ private void disableTrustAgents(boolean isParent) {
+ getDevicePolicyManager(isParent).setKeyguardDisabledFeatures(ADMIN_RECEIVER_COMPONENT,
+ DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS);
+ }
+
+ private void enableTrustAgents(boolean isParent) {
+ getDevicePolicyManager(isParent).setKeyguardDisabledFeatures(ADMIN_RECEIVER_COMPONENT,
+ DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE);
+ }
+
+ private void clearTrustAgentConfiguration(boolean isParent) {
+ getDevicePolicyManager(isParent).setTrustAgentConfiguration(ADMIN_RECEIVER_COMPONENT,
+ TRUST_AGENT_COMPONENT, null);
+ assertNull(getDevicePolicyManager(isParent).getTrustAgentConfiguration(
+ ADMIN_RECEIVER_COMPONENT, TRUST_AGENT_COMPONENT));
+ }
+
+ private PersistableBundle setTrustAgentConfiguration(boolean isParent) {
+ PersistableBundle expected = isParent ? PARENT_CONFIG : CHILD_CONFIG;
+ getDevicePolicyManager(isParent).setTrustAgentConfiguration(ADMIN_RECEIVER_COMPONENT,
+ TRUST_AGENT_COMPONENT, expected);
+ List<PersistableBundle> configs =
+ getDevicePolicyManager(isParent).getTrustAgentConfiguration(
+ ADMIN_RECEIVER_COMPONENT, TRUST_AGENT_COMPONENT);
+ assertPersistableBundleListEquals(isParent ?
+ ASSERT_PARENT_CONFIG :
+ ASSERT_CHILD_CONFIG, configs);
+ return expected;
+ }
+
+ private static void assertPersistableBundleListEquals(
+ AssertConfigMode mode, List<PersistableBundle> actual) {
+ Set<String> expectedValues = new HashSet<>();
+ switch (mode) {
+ case ASSERT_CHILD_CONFIG:
+ expectedValues.add(BUNDLE_CHILD_VALUE);
+ break;
+ case ASSERT_PARENT_CONFIG:
+ expectedValues.add(BUNDLE_PARENT_VALUE);
+ break;
+ case ASSERT_BOTH:
+ expectedValues.add(BUNDLE_PARENT_VALUE);
+ expectedValues.add(BUNDLE_CHILD_VALUE);
+ break;
+ }
+ assertNotNull(actual);
+ Set<String> actualValues = new HashSet<>();
+ for (PersistableBundle bundle : actual) {
+ actualValues.add(bundle.getString(BUNDLE_KEY));
+ }
+ MoreAsserts.assertEquals(expectedValues, actualValues);
+ }
+
+}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
index 3919dc3..b5e7f5d 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
@@ -80,7 +80,8 @@
/** Whether multi-user is supported. */
protected boolean mSupportsMultiUser;
- private ArrayList<Integer> mOriginalUsers;
+ /** Users we shouldn't delete in the tests */
+ private ArrayList<Integer> mFixedUsers;
@Override
public void setBuild(IBuildInfo buildInfo) {
@@ -100,9 +101,14 @@
"settings get global package_verifier_enable");
getDevice().executeShellCommand("settings put global package_verifier_enable 0");
- mOriginalUsers = listUsers();
+ mFixedUsers = new ArrayList();
mPrimaryUserId = getPrimaryUser();
+ mFixedUsers.add(mPrimaryUserId);
+ if (mPrimaryUserId != USER_SYSTEM) {
+ mFixedUsers.add(USER_SYSTEM);
+ }
switchUser(mPrimaryUserId);
+ removeTestUsers();
}
@Override
@@ -110,6 +116,7 @@
// reset the package verifier setting to its original value
getDevice().executeShellCommand("settings put global package_verifier_enable "
+ mPackageVerifier);
+ removeTestUsers();
super.tearDown();
}
@@ -179,14 +186,15 @@
}
protected void removeUser(int userId) throws Exception {
- if (listUsers().contains(userId) && userId != 0) {
+ if (listUsers().contains(userId) && userId != USER_SYSTEM) {
+ stopUser(userId);
assertTrue("Couldn't remove user", getDevice().removeUser(userId));
}
}
protected void removeTestUsers() throws Exception {
for (int userId : listUsers()) {
- if (!mOriginalUsers.contains(userId)) {
+ if (!mFixedUsers.contains(userId)) {
removeUser(userId);
}
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index 975cf4b..e21a07f 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -687,6 +687,29 @@
mParentUserId));
}
+ public void testTrustAgentInfo() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+ // Set and get trust agent config using child dpm instance.
+ assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".TrustAgentInfoTest",
+ "testSetAndGetTrustAgentConfiguration_child",
+ mProfileUserId));
+ // Set and get trust agent config using parent dpm instance.
+ assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".TrustAgentInfoTest",
+ "testSetAndGetTrustAgentConfiguration_parent",
+ mProfileUserId));
+ // Unified case
+ assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".TrustAgentInfoTest",
+ "testSetTrustAgentConfiguration_bothHaveTrustAgentConfigAndUnified",
+ mProfileUserId));
+ // Non-unified case, this test must run last because we have no way to clear work side
+ // password.
+ assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".TrustAgentInfoTest",
+ "testSetTrustAgentConfiguration_bothHaveTrustAgentConfigAndNonUnified",
+ mProfileUserId));
+ }
+
private void disableActivityForUser(String activityName, int userId)
throws DeviceNotAvailableException {
String command = "am start -W --user " + userId
diff --git a/hostsidetests/numberblocking/src/com/android/cts/numberblocking/hostside/NumberBlockingTest.java b/hostsidetests/numberblocking/src/com/android/cts/numberblocking/hostside/NumberBlockingTest.java
index dfd2798..eae6d86 100644
--- a/hostsidetests/numberblocking/src/com/android/cts/numberblocking/hostside/NumberBlockingTest.java
+++ b/hostsidetests/numberblocking/src/com/android/cts/numberblocking/hostside/NumberBlockingTest.java
@@ -49,23 +49,17 @@
private int mSecondaryUserId;
private int mPrimaryUserSerialNumber;
private int mSecondaryUserSerialNumber;
- private String mPackageVerifier;
+
private IBuildInfo mCtsBuild;
@Override
protected void setUp() throws Exception {
super.setUp();
- assertNotNull(mCtsBuild); // ensure build has been set before test is run.
if (!getDevice().isMultiUserSupported()) {
return;
}
- // disable the package verifier to avoid the dialog when installing an app
- mPackageVerifier = getDevice().executeShellCommand(
- "settings get global package_verifier_enable");
- getDevice().executeShellCommand("settings put global package_verifier_enable 0");
-
installTestAppForUser(getDevice().getPrimaryUserId());
createSecondaryUser();
installTestAppForUser(mSecondaryUserId);
@@ -78,9 +72,6 @@
protected void tearDown() throws Exception {
if (getDevice().isMultiUserSupported()) {
getDevice().removeUser(mSecondaryUserId);
- // reset the package verifier setting to its original value
- getDevice().executeShellCommand("settings put global package_verifier_enable "
- + mPackageVerifier);
}
super.tearDown();
@@ -145,15 +136,13 @@
private void createSecondaryUser() throws Exception {
mSecondaryUserId = getDevice().createUser(SECONDARY_USER_NAME);
getDevice().waitForDeviceAvailable();
- LogUtil.CLog.logAndDisplay(
- Log.LogLevel.INFO, "Created secondary user: " + mSecondaryUserId);
}
private void installTestAppForUser(int userId) throws Exception {
LogUtil.CLog.logAndDisplay(Log.LogLevel.INFO, "Installing test app for user: " + userId);
File testAppFile = MigrationHelper.getTestFile(mCtsBuild, TEST_APK);
String installResult = getDevice().installPackageForUser(
- testAppFile, true /*reinstall*/, true /*grantPermissions*/, userId);
+ testAppFile, true /*reinstall*/, userId);
assertNull(String.format(
"failed to install number blocking test app. Reason: %s", installResult),
installResult);
diff --git a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
index b8366d8..6861989 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
@@ -74,6 +74,7 @@
private static final int REPEATING_CAPTURE_EXPECTED_RESULT_COUNT = 5;
private static final int MAX_NUM_IMAGES = 5;
private static final int MIN_FPS_REQUIRED_FOR_STREAMING = 20;
+ private static final int DEFAULT_POST_RAW_SENSITIVITY_BOOST = 100;
private CameraCaptureSession mSession;
@@ -1745,6 +1746,22 @@
}
}
+ int[] outputFormats = mStaticInfo.getAvailableFormats(
+ StaticMetadata.StreamDirection.Output);
+ boolean supportRaw = false;
+ for (int format : outputFormats) {
+ if (format == ImageFormat.RAW_SENSOR || format == ImageFormat.RAW10 ||
+ format == ImageFormat.RAW12 || format == ImageFormat.RAW_PRIVATE) {
+ supportRaw = true;
+ break;
+ }
+ }
+ if (supportRaw) {
+ mCollector.expectKeyValueEquals(request,
+ CONTROL_POST_RAW_SENSITIVITY_BOOST,
+ DEFAULT_POST_RAW_SENSITIVITY_BOOST);
+ }
+
mCollector.expectKeyValueEquals(request, CONTROL_CAPTURE_INTENT, template);
// TODO: use the list of keys from CameraCharacteristics to avoid expecting
diff --git a/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java b/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java
index 89e3891..802c500 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java
@@ -29,6 +29,7 @@
import android.os.SystemClock;
import android.util.Pair;
import android.util.Size;
+import android.hardware.camera2.cts.helpers.StaticMetadata;
import android.hardware.camera2.cts.testcases.Camera2AndroidTestCase;
import static android.hardware.camera2.cts.CameraTestUtils.*;
@@ -463,9 +464,6 @@
waiverKeys.add(CaptureResult.JPEG_QUALITY);
waiverKeys.add(CaptureResult.JPEG_THUMBNAIL_QUALITY);
waiverKeys.add(CaptureResult.JPEG_THUMBNAIL_SIZE);
- // Waived until framework implemented deriving logic for this key
- // b/26625646
- waiverKeys.add(CaptureResult.CONTROL_POST_RAW_SENSITIVITY_BOOST);
// Keys only present when corresponding control is on are being
// verified in its own functional test
@@ -502,6 +500,21 @@
waiverKeys.add(CaptureResult.LENS_RADIAL_DISTORTION);
}
+ // Waived if RAW output is not supported
+ int[] outputFormats = mStaticInfo.getAvailableFormats(
+ StaticMetadata.StreamDirection.Output);
+ boolean supportRaw = false;
+ for (int format : outputFormats) {
+ if (format == ImageFormat.RAW_SENSOR || format == ImageFormat.RAW10 ||
+ format == ImageFormat.RAW12 || format == ImageFormat.RAW_PRIVATE) {
+ supportRaw = true;
+ break;
+ }
+ }
+ if (!supportRaw) {
+ waiverKeys.add(CaptureResult.CONTROL_POST_RAW_SENSITIVITY_BOOST);
+ }
+
if (mStaticInfo.getAeMaxRegionsChecked() == 0) {
waiverKeys.add(CaptureResult.CONTROL_AE_REGIONS);
}
diff --git a/tests/deviceadmin/deviceadminapp/Android.mk b/tests/deviceadmin/deviceadminapp/Android.mk
index 6ee3943..29c7cb3 100644
--- a/tests/deviceadmin/deviceadminapp/Android.mk
+++ b/tests/deviceadmin/deviceadminapp/Android.mk
@@ -31,4 +31,4 @@
# tag this module as a cts test artifact
LOCAL_COMPATIBILITY_SUITE := cts
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_PACKAGE)
diff --git a/tests/deviceadmin/uninstalltest/Android.mk b/tests/deviceadmin/uninstalltest/Android.mk
index ceee809..03831e2 100644
--- a/tests/deviceadmin/uninstalltest/Android.mk
+++ b/tests/deviceadmin/uninstalltest/Android.mk
@@ -31,4 +31,4 @@
# tag this module as a cts test artifact
LOCAL_COMPATIBILITY_SUITE := cts
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java b/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
index 9ad8de9..7d5742e 100644
--- a/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
+++ b/tests/tests/media/src/android/media/cts/ClearKeySystemTest.java
@@ -68,7 +68,7 @@
private static final int VIDEO_HEIGHT_CENC = 720;
private static final int VIDEO_WIDTH_WEBM = 320;
private static final int VIDEO_HEIGHT_WEBM = 180;
- private static final long PLAY_TIME_MS = TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
+ private static final long PLAY_TIME_MS = TimeUnit.MILLISECONDS.convert(25, TimeUnit.SECONDS);
private static final String MIME_VIDEO_AVC = MediaFormat.MIMETYPE_VIDEO_AVC;
private static final String MIME_VIDEO_VP8 = MediaFormat.MIMETYPE_VIDEO_VP8;
@@ -379,7 +379,7 @@
// starts video playback
mMediaCodecPlayer.startThread();
- long timeOut = System.currentTimeMillis() + PLAY_TIME_MS * 4;
+ long timeOut = System.currentTimeMillis() + PLAY_TIME_MS;
while (timeOut > System.currentTimeMillis() && !mMediaCodecPlayer.isEnded()) {
Thread.sleep(SLEEP_TIME_MS);
if (mMediaCodecPlayer.getCurrentPosition() >= mMediaCodecPlayer.getDuration() ) {
diff --git a/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java b/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java
index 355ef65..54480949 100644
--- a/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java
+++ b/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java
@@ -22,9 +22,11 @@
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.os.Environment;
+import android.os.Parcel;
import android.cts.util.FileUtils;
import android.os.storage.OnObbStateChangeListener;
import android.os.storage.StorageManager;
+import android.os.storage.StorageVolume;
import android.test.AndroidTestCase;
import android.test.ComparisonFailure;
import android.util.Log;
@@ -35,6 +37,8 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -158,6 +162,81 @@
}
}
+ public void testGetPrimaryVolume() throws Exception {
+ final StorageVolume volume = mStorageManager.getPrimaryStorageVolume();
+ assertNotNull("Did not get primary storage", volume);
+
+ // Tests some basic Scoped Directory Access requests.
+ assertNull("Should not grant access for root directory", volume.createAccessIntent(null));
+ assertNull("Should not grant access for invalid directory",
+ volume.createAccessIntent("/system"));
+ assertNotNull("Should grant access for valid directory " + Environment.DIRECTORY_DOCUMENTS,
+ volume.createAccessIntent(Environment.DIRECTORY_DOCUMENTS));
+
+ // Tests basic properties.
+ assertNotNull("Should have description", volume.getDescription(mContext));
+ assertTrue("Should be primary", volume.isPrimary());
+ assertEquals("Wrong state", Environment.MEDIA_MOUNTED, volume.getState());
+
+ // Tests properties that depend on storage type (emulated or physical)
+ final String uuid = volume.getUuid();
+ final boolean removable = volume.isRemovable();
+ final boolean emulated = volume.isEmulated();
+ if (emulated) {
+ assertFalse("Should not be removable", removable);
+ assertNull("Should not have uuid", uuid);
+ } else {
+ assertTrue("Should be removable", removable);
+ assertNotNull("Should have uuid", uuid);
+ }
+
+ // Tests path - although it's not a public API, sm.getPrimaryStorageVolume()
+ // explicitly states it should match Environment#getExternalStorageDirectory
+ final String path = volume.getPath();
+ assertEquals("Path does not match Environment's",
+ Environment.getExternalStorageDirectory().getAbsolutePath(), path);
+
+ // Tests Parcelable contract.
+ assertEquals("Wrong describeContents", 0, volume.describeContents());
+ final Parcel parcel = Parcel.obtain();
+ try {
+ volume.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ final StorageVolume clone = StorageVolume.CREATOR.createFromParcel(parcel);
+ assertStorageVolumesEquals(volume, clone);
+ } finally {
+ parcel.recycle();
+ }
+ }
+
+ public void testGetStorageVolumes() throws Exception {
+ final List<StorageVolume> volumes = mStorageManager.getStorageVolumes();
+ assertFalse("No volume return", volumes.isEmpty());
+ StorageVolume primary = null;
+ for (StorageVolume volume : volumes) {
+ if (volume.isPrimary()) {
+ assertNull("There can be only one primary volume: " + volumes, primary);
+ primary = volume;
+ }
+ }
+ assertNotNull("No primary volume on " + volumes, primary);
+ assertStorageVolumesEquals(primary, mStorageManager.getPrimaryVolume());
+ }
+
+ private void assertStorageVolumesEquals(StorageVolume volume, StorageVolume clone)
+ throws Exception {
+ // Asserts equals() method.
+ assertEquals("StorageVolume.equals() mismatch", volume, clone);
+ // Make sure all fields match.
+ for (Field field : StorageVolume.class.getDeclaredFields()) {
+ if (Modifier.isStatic(field.getModifiers())) continue;
+ field.setAccessible(true);
+ final Object originalValue = field.get(volume);
+ final Object clonedValue = field.get(clone);
+ assertEquals("Mismatch for field " + field.getName(), originalValue, clonedValue);
+ }
+ }
+
private static void assertStartsWith(String message, String prefix, String actual) {
if (!actual.startsWith(prefix)) {
throw new ComparisonFailure(message, prefix, actual);
diff --git a/tests/tests/print/src/android/print/cts/BasePrintTest.java b/tests/tests/print/src/android/print/cts/BasePrintTest.java
index 3f27330..f0d81d7 100644
--- a/tests/tests/print/src/android/print/cts/BasePrintTest.java
+++ b/tests/tests/print/src/android/print/cts/BasePrintTest.java
@@ -48,6 +48,7 @@
import android.printservice.CustomPrinterIconCallback;
import android.printservice.PrintJob;
import android.printservice.PrintService;
+import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
@@ -316,11 +317,42 @@
protected void selectPrinter(String printerName) throws UiObjectNotFoundException, IOException {
try {
+ long delay = 100;
UiObject destinationSpinner = mUiDevice.findObject(new UiSelector().resourceId(
"com.android.printspooler:id/destination_spinner"));
- destinationSpinner.click();
- UiObject printerOption = mUiDevice.findObject(new UiSelector().text(printerName));
- printerOption.click();
+ while (true) {
+ destinationSpinner.click();
+
+ // Give spinner some time to expand
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
+ // try to select printer
+ try {
+ UiObject printerOption = mUiDevice
+ .findObject(new UiSelector().text(printerName));
+ printerOption.click();
+ } catch (UiObjectNotFoundException e) {
+ Log.w(LOG_TAG, "Could not select printer " + printerName);
+ }
+
+ // Make sure printer is selected
+ if (getUiDevice().hasObject(By.text(printerName))) {
+ break;
+ } else {
+ if (delay <= OPERATION_TIMEOUT_MILLIS) {
+ Log.w(LOG_TAG, "Cannot find printer " + printerName + ", retrying.");
+ delay *= 2;
+ continue;
+ } else {
+ throw new UiObjectNotFoundException("Could find printer " + printerName +
+ " even though we retried");
+ }
+ }
+ }
} catch (UiObjectNotFoundException e) {
dumpWindowHierarchy();
throw new UiObjectNotFoundException(e);
diff --git a/tests/tests/print/src/android/print/cts/PrinterCapabilitiesTest.java b/tests/tests/print/src/android/print/cts/PrinterCapabilitiesTest.java
index 1df068d..9e5e751 100644
--- a/tests/tests/print/src/android/print/cts/PrinterCapabilitiesTest.java
+++ b/tests/tests/print/src/android/print/cts/PrinterCapabilitiesTest.java
@@ -320,17 +320,9 @@
testCase(session, printerId, false, MediaSize.ISO_A0, true, null);
testCase(session, printerId, false, MediaSize.ISO_A0, true, MediaSize.ISO_A0);
testCase(session, printerId, false, MediaSize.ISO_A0, true, MediaSize.ISO_B0);
- testCase(session, printerId, false, MediaSize.ISO_B0, false, null);
- testCase(session, printerId, false, MediaSize.ISO_B0, false, MediaSize.ISO_A0);
- testCase(session, printerId, false, MediaSize.ISO_B0, false, MediaSize.ISO_B0);
- testCase(session, printerId, false, MediaSize.ISO_B0, true, null);
- testCase(session, printerId, false, MediaSize.ISO_B0, true, MediaSize.ISO_A0);
- testCase(session, printerId, false, MediaSize.ISO_B0, true, MediaSize.ISO_B0);
testCase(session, printerId, true, null, false, null);
- testCase(session, printerId, true, null, false, MediaSize.ISO_A0);
testCase(session, printerId, true, null, false, MediaSize.ISO_B0);
testCase(session, printerId, true, null, true, null);
- testCase(session, printerId, true, null, true, MediaSize.ISO_A0);
testCase(session, printerId, true, null, true, MediaSize.ISO_B0);
testCase(session, printerId, true, MediaSize.ISO_A0, false, null);
testCase(session, printerId, true, MediaSize.ISO_A0, false, MediaSize.ISO_A0);
@@ -338,12 +330,6 @@
testCase(session, printerId, true, MediaSize.ISO_A0, true, null);
testCase(session, printerId, true, MediaSize.ISO_A0, true, MediaSize.ISO_A0);
testCase(session, printerId, true, MediaSize.ISO_A0, true, MediaSize.ISO_B0);
- testCase(session, printerId, true, MediaSize.ISO_B0, false, null);
- testCase(session, printerId, true, MediaSize.ISO_B0, false, MediaSize.ISO_A0);
- testCase(session, printerId, true, MediaSize.ISO_B0, false, MediaSize.ISO_B0);
- testCase(session, printerId, true, MediaSize.ISO_B0, true, null);
- testCase(session, printerId, true, MediaSize.ISO_B0, true, MediaSize.ISO_A0);
- testCase(session, printerId, true, MediaSize.ISO_B0, true, MediaSize.ISO_B0);
waitForPrinterDiscoverySessionDestroyCallbackCalled();
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java
index 6a1ed16..11ecec8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java
@@ -37,23 +37,23 @@
String imageName,
Context mContext) {
File picDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
-
- if (!picDir.exists()) {
+ if (!picDir.exists() && picDir.mkdirs()) {
// The Pictures directory does not exist on an x86 emulator
picDir = mContext.getFilesDir();
}
File dir = new File(picDir, folderName);
- dir.mkdirs();
+ if (!dir.exists() && !dir.mkdirs()) {
+ return "";
+ }
try {
File file = File.createTempFile(imageName, ".png", dir);
FileOutputStream fOut = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut);
- System.out.println("saved image: " + file.getAbsolutePath());
+ android.util.Log.v("RefocusTest", "saved image: " + file.getAbsolutePath());
fOut.flush();
fOut.close();
- MediaStorageScan(mContext, file);
return file.getAbsolutePath();
} catch (FileNotFoundException e) {
e.printStackTrace();
@@ -63,22 +63,4 @@
return "";
}
-
- /*
- * Refresh image files to view them on computer
- */
- private static void MediaStorageScan(Context context, final File file) {
- final Uri fileUri = Uri.fromFile(file);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- context.sendBroadcast(new Intent("android.hardware.action.NEW_PICTURE", fileUri));
- }
-
- context.sendBroadcast(new Intent("com.android.camera.NEW_PICTURE", fileUri));
-
- final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
- intent.setData(fileUri);
- context.sendBroadcast(intent);
- }
-
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
index 018e4a1..042e2cc 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
@@ -35,26 +35,26 @@
*/
public class RefocusTest extends RSBaseCompute {
/**
- * Test the orignal and current refocus code
+ * Test the orignal refocus code
*/
public void testOriginalRefocus() {
refocus(RenderScriptTask.script.f32, Double.POSITIVE_INFINITY);
}
/**
- * Test the orignal and current refocus code
+ * Test the new refocus code
*/
public void testNewRefocus() {
// The new implementation may run on a GPU using relaxed floating point
// mathematics. Hence more relaxed precision requirement.
- refocus(RenderScriptTask.script.d1new, 50);
+ refocus(RenderScriptTask.script.d1new, 45);
}
/**
* Test a refocus operator against the refocus_reference image
- * @param d1new which version of refocus to run
+ * @param impl version of refocus to run
*/
- private void refocus(RenderScriptTask.script d1new, double minimumPSNR) {
+ private void refocus(RenderScriptTask.script impl, double minimumPSNR) {
Context ctx = getContext();
RenderScript rs = RenderScript.create(ctx);
@@ -70,7 +70,7 @@
DepthOfFieldOptions current_depth_options = new DepthOfFieldOptions(current_rgbz);
RsTaskParams rsTaskParam = new RsTaskParams(rs, current_depth_options);
- RenderScriptTask renderScriptTask = new RenderScriptTask(rs, d1new);
+ RenderScriptTask renderScriptTask = new RenderScriptTask(rs, impl);
Bitmap outputImage = renderScriptTask.applyRefocusFilter(rsTaskParam.mOptions);
Bitmap expectedImage = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.expected_output);
diff --git a/tests/tests/tv/src/android/media/tv/cts/TvInputInfoTest.java b/tests/tests/tv/src/android/media/tv/cts/TvInputInfoTest.java
index 84372e3..76cd550 100644
--- a/tests/tests/tv/src/android/media/tv/cts/TvInputInfoTest.java
+++ b/tests/tests/tv/src/android/media/tv/cts/TvInputInfoTest.java
@@ -23,6 +23,7 @@
import android.media.tv.TvContract;
import android.media.tv.TvInputInfo;
import android.media.tv.TvInputManager;
+import android.os.Bundle;
import android.os.Parcel;
import android.test.AndroidTestCase;
import android.text.TextUtils;
@@ -202,11 +203,16 @@
assertEquals(mStubInfo.getTunerCount(), defaultInfo.getTunerCount());
assertEquals(mStubInfo.canRecord(), defaultInfo.canRecord());
+ Bundle extras = new Bundle();
+ final String TEST_KEY = "android.media.tv.cts.TEST_KEY";
+ final String TEST_VALUE = "android.media.tv.cts.TEST_VALUE";
+ extras.putString(TEST_KEY, TEST_VALUE);
TvInputInfo updatedInfo = new TvInputInfo.Builder(getContext(),
new ComponentName(getContext(), StubTunerTvInputService.class)).setTunerCount(10)
- .setCanRecord(true).build();
+ .setCanRecord(true).setExtras(extras).build();
assertEquals(mStubInfo.getId(), updatedInfo.getId());
assertEquals(10, updatedInfo.getTunerCount());
assertTrue(updatedInfo.canRecord());
+ assertEquals(TEST_VALUE, updatedInfo.getExtras().getString(TEST_KEY));
}
}
diff --git a/tools/cts-tradefed/res/config/collect-tests-only.xml b/tools/cts-tradefed/res/config/collect-tests-only.xml
index 9fd7757..5c9efce 100644
--- a/tools/cts-tradefed/res/config/collect-tests-only.xml
+++ b/tools/cts-tradefed/res/config/collect-tests-only.xml
@@ -36,4 +36,7 @@
<!-- Tell all deqp tests to only list the tests -->
<option name="compatibility:test-arg" value="com.drawelements.deqp.runner.DeqpTestRunner:collect-tests-only:true" />
+ <!-- Tell all JarHostTests to only list the tests -->
+ <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:collect-tests-only:true" />
+
</configuration>