Merge "CTS Coverage Report Support for generic types" into mnc-dev
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
index 484dd6e..07b6953 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/AndroidManifest.xml
@@ -30,6 +30,26 @@
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
+ <activity
+ android:name="com.android.cts.deviceandprofileowner.ApplicationRestrictionsActivity" />
+ <activity
+ android:name="com.android.cts.deviceandprofileowner.ScreenCaptureDisabledActivity" />
+ <activity
+ android:name="com.android.cts.deviceandprofileowner.ExampleIntentReceivingActivity1">
+ <intent-filter>
+ <action android:name="com.android.cts.deviceandprofileowner.EXAMPLE_ACTION" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+ <activity
+ android:name="com.android.cts.deviceandprofileowner.ExampleIntentReceivingActivity2">
+ <intent-filter>
+ <action android:name="com.android.cts.deviceandprofileowner.EXAMPLE_ACTION" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionActivity.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ApplicationRestrictionsActivity.java
similarity index 90%
rename from hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionActivity.java
rename to hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ApplicationRestrictionsActivity.java
index 4d8e4f2..ccf8222 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionActivity.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ApplicationRestrictionsActivity.java
@@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package com.android.cts.deviceowner;
+package com.android.cts.deviceandprofileowner;
import android.app.Activity;
import android.content.BroadcastReceiver;
@@ -31,16 +30,16 @@
* activity is to listen for the ACTION_APPLICATION_RESTRICTIONS_CHANGED broadcast
* and relay the retrieved restriction bundle back to the test for validation.
*/
-public class ApplicationRestrictionActivity extends Activity {
+public class ApplicationRestrictionsActivity extends Activity {
// Incoming intent type
public static final String FINISH = "finishActivity";
// Outgoing broadcast
public static final String REGISTERED_ACTION =
- "com.android.cts.deviceowner.APP_RESTRICTION_REGISTERED";
+ "com.android.cts.deviceandprofileowner.APP_RESTRICTION_REGISTERED";
public static final String RESTRICTION_ACTION =
- "com.android.cts.deviceowner.APP_RESTRICTION_VALUE";
+ "com.android.cts.deviceandprofileowner.APP_RESTRICTION_VALUE";
private UserManager mUserManager;
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionsTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ApplicationRestrictionsTest.java
similarity index 83%
rename from hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionsTest.java
rename to hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ApplicationRestrictionsTest.java
index 13a2a6d..98ae202 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionsTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ApplicationRestrictionsTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.cts.deviceowner;
+package com.android.cts.deviceandprofileowner;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -38,7 +38,7 @@
* which is fired by the system whenever its restriction is modified,
* and relays the value back to this test for verification.
*/
-public class ApplicationRestrictionsTest extends BaseDeviceOwnerTest {
+public class ApplicationRestrictionsTest extends BaseDeviceAdminTest {
private static final String[] testStrings = new String[] {
"<bad/>",
@@ -55,8 +55,8 @@
protected void setUp() throws Exception {
super.setUp();
IntentFilter filter = new IntentFilter();
- filter.addAction(ApplicationRestrictionActivity.REGISTERED_ACTION);
- filter.addAction(ApplicationRestrictionActivity.RESTRICTION_ACTION);
+ filter.addAction(ApplicationRestrictionsActivity.REGISTERED_ACTION);
+ filter.addAction(ApplicationRestrictionsActivity.RESTRICTION_ACTION);
mContext.registerReceiver(mReceiver, filter);
}
@@ -76,30 +76,38 @@
Bundle bundle1 = createBundle1();
// Test setting restrictions
- mDevicePolicyManager.setApplicationRestrictions(getWho(), CTS_PACKAGE, bundle0);
- mDevicePolicyManager.setApplicationRestrictions(getWho(), OTHER_PACKAGE, bundle1);
+ mDevicePolicyManager.setApplicationRestrictions(ADMIN_RECEIVER_COMPONENT, CTS_PACKAGE,
+ bundle0);
+ mDevicePolicyManager.setApplicationRestrictions(ADMIN_RECEIVER_COMPONENT, OTHER_PACKAGE,
+ bundle1);
// Retrieve restrictions locally and make sure they are what we put in.
- assertBundle0(mDevicePolicyManager.getApplicationRestrictions(getWho(), CTS_PACKAGE));
- assertBundle1(mDevicePolicyManager.getApplicationRestrictions(getWho(), OTHER_PACKAGE));
+ assertBundle0(mDevicePolicyManager.getApplicationRestrictions(ADMIN_RECEIVER_COMPONENT,
+ CTS_PACKAGE));
+ assertBundle1(mDevicePolicyManager.getApplicationRestrictions(ADMIN_RECEIVER_COMPONENT,
+ OTHER_PACKAGE));
// The test activity should have received a change_restriction broadcast
// and relay the value back to us.
assertBundle0(waitForChangedRestriction());
// Test overwriting
- mDevicePolicyManager.setApplicationRestrictions(getWho(), CTS_PACKAGE, bundle1);
- assertBundle1(mDevicePolicyManager.getApplicationRestrictions(getWho(), CTS_PACKAGE));
+ mDevicePolicyManager.setApplicationRestrictions(ADMIN_RECEIVER_COMPONENT, CTS_PACKAGE,
+ bundle1);
+ assertBundle1(mDevicePolicyManager.getApplicationRestrictions(ADMIN_RECEIVER_COMPONENT,
+ CTS_PACKAGE));
assertBundle1(waitForChangedRestriction());
// Cleanup
- mDevicePolicyManager.setApplicationRestrictions(getWho(), CTS_PACKAGE, new Bundle());
- assertTrue(
- mDevicePolicyManager.getApplicationRestrictions(getWho(), CTS_PACKAGE).isEmpty());
+ mDevicePolicyManager.setApplicationRestrictions(ADMIN_RECEIVER_COMPONENT, CTS_PACKAGE,
+ new Bundle());
+ assertTrue(mDevicePolicyManager.getApplicationRestrictions(
+ ADMIN_RECEIVER_COMPONENT, CTS_PACKAGE).isEmpty());
assertTrue(waitForChangedRestriction().isEmpty());
- mDevicePolicyManager.setApplicationRestrictions(getWho(), OTHER_PACKAGE, new Bundle());
- assertTrue(
- mDevicePolicyManager.getApplicationRestrictions(getWho(), OTHER_PACKAGE).isEmpty());
+ mDevicePolicyManager.setApplicationRestrictions(ADMIN_RECEIVER_COMPONENT, OTHER_PACKAGE,
+ new Bundle());
+ assertTrue(mDevicePolicyManager.getApplicationRestrictions(
+ ADMIN_RECEIVER_COMPONENT, OTHER_PACKAGE).isEmpty());
finish();
}
@@ -185,9 +193,9 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (ApplicationRestrictionActivity.REGISTERED_ACTION.equals(action)) {
+ if (ApplicationRestrictionsActivity.REGISTERED_ACTION.equals(action)) {
mOnRegisteredSemaphore.release();
- } else if (ApplicationRestrictionActivity.RESTRICTION_ACTION.equals(action)) {
+ } else if (ApplicationRestrictionsActivity.RESTRICTION_ACTION.equals(action)) {
mReceivedRestrictions = intent.getBundleExtra("value");
mOnRestrictionSemaphore.release();
}
@@ -196,7 +204,7 @@
private void startTestActivity(String command) {
Intent intent = new Intent();
- intent.setClassName(PACKAGE_NAME, ApplicationRestrictionActivity.class.getName());
+ intent.setClassName(PACKAGE_NAME, ApplicationRestrictionsActivity.class.getName());
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
if (command != null) {
@@ -227,7 +235,7 @@
}
private void finish() {
- startTestActivity(ApplicationRestrictionActivity.FINISH);
+ startTestActivity(ApplicationRestrictionsActivity.FINISH);
}
}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ExampleIntentReceivingActivity1.java
similarity index 88%
rename from hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java
rename to hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ExampleIntentReceivingActivity1.java
index 03ca9a4..bbcc3b1 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ExampleIntentReceivingActivity1.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package com.android.cts.deviceowner;
+package com.android.cts.deviceandprofileowner;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class ExampleIntentReceivingActivity1 extends Activity {
- public static final String CONFIRM_ACTION = "com.android.cts.deviceowner.CONFIRM_1";
+ static final String CONFIRM_ACTION = "com.android.cts.deviceandprofileowner.CONFIRM_1";
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity2.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ExampleIntentReceivingActivity2.java
similarity index 88%
rename from hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity2.java
rename to hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ExampleIntentReceivingActivity2.java
index 65ccb36..5122b06 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity2.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ExampleIntentReceivingActivity2.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package com.android.cts.deviceowner;
+package com.android.cts.deviceandprofileowner;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class ExampleIntentReceivingActivity2 extends Activity {
- public static final String CONFIRM_ACTION = "com.android.cts.deviceowner.CONFIRM_2";
+ static final String CONFIRM_ACTION = "com.android.cts.deviceandprofileowner.CONFIRM_2";
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PersistentIntentResolvingTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PersistentIntentResolvingTest.java
similarity index 89%
rename from hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PersistentIntentResolvingTest.java
rename to hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PersistentIntentResolvingTest.java
index fcef05f..41526ec 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PersistentIntentResolvingTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PersistentIntentResolvingTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.cts.deviceowner;
+package com.android.cts.deviceandprofileowner;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -22,8 +22,8 @@
import android.content.IntentFilter;
import android.os.SystemClock;
-public class PersistentIntentResolvingTest extends BaseDeviceOwnerTest {
- public static final String EXAMPLE_ACTION = "com.android.cts.deviceowner.EXAMPLE_ACTION";
+public class PersistentIntentResolvingTest extends BaseDeviceAdminTest {
+ static final String EXAMPLE_ACTION = "com.android.cts.deviceandprofileowner.EXAMPLE_ACTION";
private boolean mReceivedConfirmationFrom1;
private boolean mReceivedConfirmationFrom2;
@@ -48,7 +48,8 @@
@Override
protected void tearDown() throws Exception {
- mDevicePolicyManager.clearPackagePersistentPreferredActivities(getWho(), PACKAGE_NAME);
+ mDevicePolicyManager.clearPackagePersistentPreferredActivities(ADMIN_RECEIVER_COMPONENT,
+ PACKAGE_NAME);
mContext.unregisterReceiver(mReceiver);
super.tearDown();
@@ -80,7 +81,8 @@
public void testAddAndClearPersistentPreferredActivitiesYieldsResolverActivity() {
addPersistentPreferredActivity();
- mDevicePolicyManager.clearPackagePersistentPreferredActivities(getWho(), PACKAGE_NAME);
+ mDevicePolicyManager.clearPackagePersistentPreferredActivities(ADMIN_RECEIVER_COMPONENT,
+ PACKAGE_NAME);
sendExampleIntent();
SystemClock.sleep(5000);
@@ -121,6 +123,7 @@
filter.addCategory(Intent.CATEGORY_DEFAULT);
ComponentName targetComponent = new ComponentName(PACKAGE_NAME,
ExampleIntentReceivingActivity2.class.getName());
- mDevicePolicyManager.addPersistentPreferredActivity(getWho(), filter, targetComponent);
+ mDevicePolicyManager.addPersistentPreferredActivity(ADMIN_RECEIVER_COMPONENT, filter,
+ targetComponent);
}
}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ScreenCaptureDisabledActivity.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ScreenCaptureDisabledActivity.java
new file mode 100644
index 0000000..b5b4fdc
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ScreenCaptureDisabledActivity.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2015 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.deviceandprofileowner;
+
+import android.app.Activity;
+import android.content.Intent;
+
+/**
+ * Test activity for setScreenCaptureDisabled().
+ */
+public class ScreenCaptureDisabledActivity extends Activity {
+
+ static final String ACTIVITY_RESUMED =
+ "com.android.cts.deviceandprofileowner.ACTIVITY_RESUMED";
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ sendBroadcast(new Intent(ACTIVITY_RESUMED));
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ScreenCaptureDisabledTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ScreenCaptureDisabledTest.java
new file mode 100644
index 0000000..31423c9
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/ScreenCaptureDisabledTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2014 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.deviceandprofileowner;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.util.Log;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Tests for {@link DevicePolicyManager#setScreenCaptureDisabled} and
+ * {@link DevicePolicyManager#getScreenCaptureDisabled} APIs.
+ */
+public class ScreenCaptureDisabledTest extends BaseDeviceAdminTest {
+
+ private static final String TAG = "ScreenCaptureDisabledTest";
+
+ private ScreenCaptureBroadcastReceiver mReceiver = new ScreenCaptureBroadcastReceiver();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mContext.registerReceiver(mReceiver, new IntentFilter(
+ ScreenCaptureDisabledActivity.ACTIVITY_RESUMED));
+ }
+
+ protected void tearDown() throws Exception {
+ mContext.unregisterReceiver(mReceiver);
+ mDevicePolicyManager.setScreenCaptureDisabled(ADMIN_RECEIVER_COMPONENT, false);
+ super.tearDown();
+ }
+
+ public void testSetScreenCaptureDisabled_false() throws Exception {
+ mDevicePolicyManager.setScreenCaptureDisabled(ADMIN_RECEIVER_COMPONENT, false);
+ assertFalse(mDevicePolicyManager.getScreenCaptureDisabled(ADMIN_RECEIVER_COMPONENT));
+ assertFalse(mDevicePolicyManager.getScreenCaptureDisabled(null /* any admin */));
+ startTestActivity();
+ assertNotNull(getInstrumentation().getUiAutomation().takeScreenshot());
+ }
+
+ public void testSetScreenCaptureDisabled_true() throws Exception {
+ mDevicePolicyManager.setScreenCaptureDisabled(ADMIN_RECEIVER_COMPONENT, true);
+ assertTrue(mDevicePolicyManager.getScreenCaptureDisabled(ADMIN_RECEIVER_COMPONENT));
+ assertTrue(mDevicePolicyManager.getScreenCaptureDisabled(null /* any admin */));
+ startTestActivity();
+ assertNull(getInstrumentation().getUiAutomation().takeScreenshot());
+ }
+
+ private void startTestActivity() throws Exception {
+ Intent launchIntent = new Intent();
+ launchIntent.setComponent(new ComponentName(PACKAGE_NAME,
+ ScreenCaptureDisabledActivity.class.getName()));
+ launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(launchIntent);
+ assertTrue(mReceiver.waitForBroadcast());
+ }
+
+ private class ScreenCaptureBroadcastReceiver extends BroadcastReceiver {
+ private final Semaphore mSemaphore = new Semaphore(0);
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "Broadcast received");
+ mSemaphore.release();
+ }
+
+ public boolean waitForBroadcast() throws Exception {
+ if (mSemaphore.tryAcquire(5, TimeUnit.SECONDS)) {
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
index 64c7262..e424f18 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
@@ -35,19 +35,9 @@
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
- <activity android:name="com.android.cts.deviceowner.ExampleIntentReceivingActivity1">
- <intent-filter>
- <action android:name="com.android.cts.deviceowner.EXAMPLE_ACTION" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
- <activity android:name="com.android.cts.deviceowner.ExampleIntentReceivingActivity2">
- <intent-filter>
- <action android:name="com.android.cts.deviceowner.EXAMPLE_ACTION" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
+ <activity
+ android:name="com.android.cts.deviceowner.KeyManagementActivity" />
<activity
android:name="com.android.cts.deviceowner.LockTaskUtilityActivity" />
@@ -62,8 +52,6 @@
android:name="com.android.cts.deviceowner.LockTaskTest$IntentReceivingActivity"
android:taskAffinity="com.android.cts.deviceowner.LockTaskTest.IntentReceivingActivity"
/>
- <activity
- android:name="com.android.cts.deviceowner.ApplicationRestrictionActivity" />
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementActivity.java
similarity index 73%
copy from hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java
copy to hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementActivity.java
index 03ca9a4..c108d24 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementActivity.java
@@ -20,15 +20,11 @@
import android.content.Intent;
import android.os.Bundle;
-public class ExampleIntentReceivingActivity1 extends Activity {
- public static final String CONFIRM_ACTION = "com.android.cts.deviceowner.CONFIRM_1";
+public class KeyManagementActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- if (getIntent().getAction().equals(PersistentIntentResolvingTest.EXAMPLE_ACTION)) {
- sendBroadcast(new Intent(CONFIRM_ACTION));
- }
finish();
}
}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementTest.java
index a608794..5774b0c 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementTest.java
@@ -45,13 +45,13 @@
import android.content.Context;
public class KeyManagementTest extends
- ActivityInstrumentationTestCase2<ExampleIntentReceivingActivity1> {
+ ActivityInstrumentationTestCase2<KeyManagementActivity> {
private static final int KEYCHAIN_TIMEOUT_MS = 8000;
private DevicePolicyManager mDevicePolicyManager;
public KeyManagementTest() {
- super(ExampleIntentReceivingActivity1.class);
+ super(KeyManagementActivity.class);
}
@Override
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ScreenCaptureDisabledTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ScreenCaptureDisabledTest.java
deleted file mode 100644
index 59b9773..0000000
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ScreenCaptureDisabledTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2014 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.deviceowner;
-
-import android.app.admin.DevicePolicyManager;
-
-/**
- * Tests for {@link DevicePolicyManager#setScreenCaptureDisabled} and
- * {@link DevicePolicyManager#getScreenCaptureDisabled} APIs.
- */
-public class ScreenCaptureDisabledTest extends BaseDeviceOwnerTest {
-
- public void testSetScreenCaptureDisabled_false() throws Exception {
- mDevicePolicyManager.setScreenCaptureDisabled(getWho(), false);
- assertFalse(mDevicePolicyManager.getScreenCaptureDisabled(getWho()));
- }
-
- public void testSetScreenCaptureDisabled_true() throws Exception {
- mDevicePolicyManager.setScreenCaptureDisabled(getWho(), true);
- assertTrue(mDevicePolicyManager.getScreenCaptureDisabled(getWho()));
- }
-
- public void testSetScreenCaptureDisabled_anyAdminTrue() {
- mDevicePolicyManager.setScreenCaptureDisabled(getWho(), true);
- assertTrue(mDevicePolicyManager.getScreenCaptureDisabled(null /* any admin */));
- }
-
- public void testSetScreenCaptureDisabled_anyAdminFalse() {
- mDevicePolicyManager.setScreenCaptureDisabled(getWho(), false);
- assertFalse(mDevicePolicyManager.getScreenCaptureDisabled(null /* any admin */));
- }
-}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index b0918bc..02f42ba 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -52,13 +52,19 @@
super.tearDown();
}
+ public void testApplicationRestrictions() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+ executeDeviceTestClass(".ApplicationRestrictionsTest");
+ }
+
public void testPermissionGrant() throws Exception {
if (!mHasFeature) {
return;
}
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionGrantState", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionGrantState");
}
public void testPermissionPolicy() throws Exception {
@@ -66,8 +72,7 @@
return;
}
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionPolicy", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionPolicy");
}
public void testPermissionMixedPolicies() throws Exception {
@@ -75,24 +80,15 @@
return;
}
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionMixedPolicies", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionMixedPolicies");
}
public void testPermissionPrompts() throws Exception {
if (!mHasFeature) {
return;
}
- try {
- // unlock device and ensure that the screen stays on
- getDevice().executeShellCommand("input keyevent 82");
- getDevice().executeShellCommand("settings put global stay_on_while_plugged_in 2");
- installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionPrompts", mUserId));
- } finally {
- getDevice().executeShellCommand("settings put global stay_on_while_plugged_in 0");
- }
+ installAppAsUser(PERMISSIONS_APP_APK, mUserId);
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionPrompts");
}
public void testPermissionAppUpdate() throws Exception {
@@ -100,43 +96,31 @@
return;
}
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_setDeniedState", mUserId));
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkDenied", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_setDeniedState");
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkDenied");
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkDenied", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkDenied");
assertNull(getDevice().uninstallPackage(PERMISSIONS_APP_PKG));
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_setGrantedState", mUserId));
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkGranted", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_setGrantedState");
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkGranted");
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkGranted", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkGranted");
assertNull(getDevice().uninstallPackage(PERMISSIONS_APP_PKG));
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_setAutoDeniedPolicy", mUserId));
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkDenied", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_setAutoDeniedPolicy");
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkDenied");
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkDenied", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkDenied");
assertNull(getDevice().uninstallPackage(PERMISSIONS_APP_PKG));
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_setAutoGrantedPolicy", mUserId));
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkGranted", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_setAutoGrantedPolicy");
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkGranted");
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionUpdate_checkGranted", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionUpdate_checkGranted");
}
public void testPermissionGrantPreMApp() throws Exception {
@@ -144,7 +128,28 @@
return;
}
installAppAsUser(SIMPLE_PRE_M_APP_APK, mUserId);
- assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PermissionsTest",
- "testPermissionGrantStatePreMApp", mUserId));
+ executeDeviceTestMethod(".PermissionsTest", "testPermissionGrantStatePreMApp");
+ }
+
+ public void testPersistentIntentResolving() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+ executeDeviceTestClass(".PersistentIntentResolvingTest");
+ }
+
+ public void testScreenCaptureDisabled() throws Exception {
+ if (!mHasFeature) {
+ return;
+ }
+ executeDeviceTestClass(".ScreenCaptureDisabledTest");
+ }
+
+ private void executeDeviceTestClass(String className) throws Exception {
+ assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, mUserId));
+ }
+
+ private void executeDeviceTestMethod(String className, String testName) throws Exception {
+ assertTrue(runDeviceTestsAsUser(DEVICE_ADMIN_PKG, className, testName, mUserId));
}
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
index 26d0d233..9eaeb87 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -66,10 +66,6 @@
super.tearDown();
}
- public void testApplicationRestrictions() throws Exception {
- executeDeviceOwnerTest("ApplicationRestrictionsTest");
- }
-
public void testCaCertManagement() throws Exception {
executeDeviceOwnerTest("CaCertManagementTest");
}
@@ -91,14 +87,6 @@
}
}
- public void testPersistentIntentResolving() throws Exception {
- executeDeviceOwnerTest("PersistentIntentResolvingTest");
- }
-
- public void testScreenCaptureDisabled() throws Exception {
- executeDeviceOwnerTest("ScreenCaptureDisabledTest");
- }
-
public void testPackageInstall() throws Exception {
final File apk = mCtsBuild.getTestApp(TEST_APP_APK);
try {