Suppress all new Enterprise CTS tests.

As requested by Unsuk, new test cases should be added to knownfailures.txt,
so that the test team can help running them as part of the CTS-staging plan.
The stable tests will then be moved out of CTS-staging by the test team.

Also, suppressed LockTaskTest separately until we stop it being flaky.

Bug: 17890673
Change-Id: Ia3c0516d5aec436e9c7944d418acb3683b9ada0c
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskTest.java
index c0ca8e2..42aa847 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskTest.java
@@ -30,6 +30,9 @@
 
     private static final String TEST_PACKAGE = "com.google.android.example.somepackage";
 
+    private static final int ACTIVITY_RESUMED_TIMEOUT_MILLIS = 60000;  // 60 seconds
+    private static final int ACTIVITY_RUNNING_TIMEOUT_MILLIS = 20000;  // 20 seconds
+
     /**
      * The tests below need to keep detailed track of the state of the activity
      * that is started and stopped frequently.  To do this it sends a number of
@@ -139,52 +142,49 @@
     // This test has the UtilityActivity trigger starting another activity (settings)
     // this should be permitted as a part of lock task (since it isn't a new task).
     // As a result onPause should be called as it goes to a new activity.
-// TODO: Reinstate once we make this test not flaky (if fails on Nexus 7 v2 most of the time,
-//       especially if testCannotStartActivityOutsideTask() is commented out.
-//    public void testStartActivityWithinTask() {
-//        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
-//        startLockTask();
-//        waitForResume();
-//
-//        Intent launchIntent = new Intent(Settings.ACTION_SETTINGS);
-//        Intent lockTaskUtility = getLockTaskUtility();
-//        lockTaskUtility.putExtra(LockTaskUtilityActivity.START_ACTIVITY, launchIntent);
-//        mContext.startActivity(lockTaskUtility);
-//
-//        synchronized (mActivityResumedLock) {
-//            if (mIsActivityResumed) {
-//                try {
-//                    mActivityResumedLock.wait(60000);
-//                } catch (InterruptedException e) {
-//                }
-//                assertFalse(mIsActivityResumed);
-//            }
-//        }
-//        stopAndFinish(null);
-//    }
+    public void testStartActivityWithinTask() {
+        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
+        startLockTask();
+        waitForResume();
+
+        Intent launchIntent = new Intent(Settings.ACTION_SETTINGS);
+        Intent lockTaskUtility = getLockTaskUtility();
+        lockTaskUtility.putExtra(LockTaskUtilityActivity.START_ACTIVITY, launchIntent);
+        mContext.startActivity(lockTaskUtility);
+
+        synchronized (mActivityResumedLock) {
+            if (mIsActivityResumed) {
+                try {
+                    mActivityResumedLock.wait(ACTIVITY_RESUMED_TIMEOUT_MILLIS);
+                } catch (InterruptedException e) {
+                }
+                assertFalse(mIsActivityResumed);
+            }
+        }
+        stopAndFinish(null);
+    }
 
     // This launches an activity that is not part of the current task and therefore
     // should be blocked.  This is verified by making sure that the activity does
     // not get a call to onPause.
-// TODO: Reinstate once we make this test not flaky (if fails on Nexus 7 v2 most of the time) 
-//    public void testCannotStartActivityOutsideTask() {
-//        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
-//        startLockTask();
-//        waitForResume();
-//
-//        Intent launchIntent = new Intent(Settings.ACTION_SETTINGS);
-//        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-//        mContext.startActivity(launchIntent);
-//
-//        synchronized (mActivityResumedLock) {
-//            try {
-//                mActivityResumedLock.wait(90000);
-//            } catch (InterruptedException e) {
-//            }
-//            assertTrue(mIsActivityResumed);
-//        }
-//        stopAndFinish(null);
-//    }
+    public void testCannotStartActivityOutsideTask() {
+        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
+        startLockTask();
+        waitForResume();
+
+        Intent launchIntent = new Intent(Settings.ACTION_SETTINGS);
+        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(launchIntent);
+
+        synchronized (mActivityResumedLock) {
+            try {
+                mActivityResumedLock.wait(ACTIVITY_RESUMED_TIMEOUT_MILLIS);
+            } catch (InterruptedException e) {
+            }
+            assertTrue(mIsActivityResumed);
+        }
+        stopAndFinish(null);
+    }
 
     /**
      * Call stopLockTask and finish on the LockTaskUtilityActivity.
@@ -212,7 +212,7 @@
             finish();
             if (mIsActivityRunning) {
                 try {
-                    mActivityRunningLock.wait(20000);
+                    mActivityRunningLock.wait(ACTIVITY_RUNNING_TIMEOUT_MILLIS);
                 } catch (InterruptedException e) {
                 }
             }
@@ -227,7 +227,7 @@
         synchronized (mActivityResumedLock) {
             if (!mIsActivityResumed) {
                 try {
-                    mActivityResumedLock.wait(20000);
+                    mActivityResumedLock.wait(ACTIVITY_RESUMED_TIMEOUT_MILLIS);
                 } catch (InterruptedException e) {
                 }
             }
@@ -272,7 +272,7 @@
             mContext.startActivity(intent);
             // Give 20 secs to finish.
             try {
-                wait(20000);
+                wait(ACTIVITY_RUNNING_TIMEOUT_MILLIS);
             } catch (InterruptedException e) {
             }
             assertTrue(mIntentHandled);
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 5ce84f7..2f436ee 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -85,6 +85,28 @@
   bug: 17508787
 },
 {
+  description: "New tests recently added for Android Enterprise. To be moved out of CTS-staging as soon as they show that they are stable",
+  names: [
+    "com.android.cts.devicepolicy.DeviceOwnerTest#testApplicationRestrictions",
+    "com.android.cts.devicepolicy.DeviceOwnerTest#testCaCertManagement",
+    "com.android.cts.devicepolicy.DeviceOwnerTest#testDeviceOwnerSetup",
+    "com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement",
+    "com.android.cts.devicepolicy.DeviceOwnerTest#testPersistentIntentResolving",
+    "com.android.cts.devicepolicy.DeviceOwnerTest#testScreenCaptureDisabled",
+    "com.android.cts.devicepolicy.ManagedProfileTest#testManagedProfileSetup",
+    "com.android.cts.devicepolicy.ManagedProfileTest#testWipeData",
+    "com.android.cts.devicepolicy.ManagedProfileTest#testCrossProfileIntentFilters",
+    "com.android.cts.devicepolicy.ManagedProfileTest#testCrossProfileContent"
+  ]
+},
+{
+  description: "Flaky test which ocassionally fails",
+  names: [
+    "com.android.cts.devicepolicy.DeviceOwnerTest#testLockTask"
+  ],
+  bug: 17890673
+},
+{
 
   description: "These tests fail on some devices.",
   names: [