Revert "CTS for LauncherApps lock-down"

This reverts commit d61f52ec3dc8955173c897aebde485e26ba490f4.

Change-Id: Ib963676c7919c751c36a858109969c35f35bde17
(cherry picked from commit 639ea8ac68c171f3edc1fdd5938bf122da89cf5a)
diff --git a/hostsidetests/devicepolicy/app/LauncherTests/src/com/android/cts/launchertests/LauncherAppsTests.java b/hostsidetests/devicepolicy/app/LauncherTests/src/com/android/cts/launchertests/LauncherAppsTests.java
index d39f96b..e4af64c 100644
--- a/hostsidetests/devicepolicy/app/LauncherTests/src/com/android/cts/launchertests/LauncherAppsTests.java
+++ b/hostsidetests/devicepolicy/app/LauncherTests/src/com/android/cts/launchertests/LauncherAppsTests.java
@@ -129,36 +129,6 @@
         assertEquals(mUser, UserHandle.getUserHandleForUid(ai.uid));
     }
 
-    public void testAccessPrimaryProfileFromManagedProfile() throws Exception {
-        // Try to access main profile from managed profile, which is not allowed.
-        try {
-            mLauncherApps.getActivityList(null, mUser);
-            fail("Didn't throw SecurityException");
-        } catch (SecurityException e) {
-            assertTrue(e.getMessage().contains("another profile"));
-        }
-        try {
-            mLauncherApps.getApplicationInfo(SIMPLE_APP_PACKAGE, /* flags= */ 0, mUser);
-            fail("Didn't throw SecurityException");
-        } catch (SecurityException e) {
-            assertTrue(e.getMessage().contains("another profile"));
-        }
-    }
-
-    public void testGetProfiles_fromMainProfile() {
-        final List<UserHandle> profiles = mLauncherApps.getProfiles();
-        assertEquals(2, profiles.size());
-        assertTrue(profiles.contains(android.os.Process.myUserHandle()));
-        assertEquals(getContext().getSystemService(UserManager.class).getUserProfiles(),
-                profiles);
-    }
-
-    public void testGetProfiles_fromManagedProfile() {
-        final List<UserHandle> profiles = mLauncherApps.getProfiles();
-        assertEquals(1, profiles.size());
-        assertEquals(android.os.Process.myUserHandle(), profiles.get(0));
-    }
-
     public void testPackageAddedCallbackForUser() throws Throwable {
         int result = sendMessageToCallbacksService(MSG_CHECK_PACKAGE_ADDED,
                 mUser, SIMPLE_APP_PACKAGE);
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java
index ed885c5..51b9d30 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java
@@ -30,10 +30,10 @@
     protected static final String LAUNCHER_TESTS_CLASS = LAUNCHER_TESTS_PKG + ".LauncherAppsTests";
     protected static final String PARAM_TEST_USER = "testUser";
 
-    protected static final String LAUNCHER_TESTS_APK = "CtsLauncherAppsTests.apk";
-    protected static final String LAUNCHER_TESTS_SUPPORT_PKG =
+    private static final String LAUNCHER_TESTS_APK = "CtsLauncherAppsTests.apk";
+    private static final String LAUNCHER_TESTS_SUPPORT_PKG =
             "com.android.cts.launchertests.support";
-    protected static final String LAUNCHER_TESTS_SUPPORT_APK = "CtsLauncherAppsTestsSupport.apk";
+    private static final String LAUNCHER_TESTS_SUPPORT_APK = "CtsLauncherAppsTestsSupport.apk";
 
     protected void installTestApps() throws Exception {
         uninstallTestApps();
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java
index a978ccf..6521ed8 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java
@@ -43,6 +43,7 @@
         mHasFeature = mHasFeature && hasDeviceFeature("android.software.managed_users");
         if (mHasFeature) {
             removeTestUsers();
+            installTestApps();
             // Create a managed profile
             mParentUserId = mPrimaryUserId;
             mProfileUserId = createManagedProfile(mParentUserId);
@@ -52,13 +53,6 @@
             mProfileSerialNumber = Integer.toString(getUserSerialNumber(mProfileUserId));
             mMainUserSerialNumber = Integer.toString(getUserSerialNumber(mParentUserId));
             startUser(mProfileUserId);
-
-            // Install test APK.
-            installTestApps();
-
-            // Also install on the managed profile too.
-            installAppAsUser(LAUNCHER_TESTS_APK, mProfileUserId);
-            installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, mProfileUserId);
         }
     }
 
@@ -81,29 +75,12 @@
 
         // Run tests to check SimpleApp exists in both profile and main user.
         runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
-                LAUNCHER_TESTS_CLASS, "testSimpleAppInstalledForUser",
+                LAUNCHER_TESTS_CLASS,
+                "testSimpleAppInstalledForUser",
                 mParentUserId, Collections.singletonMap(PARAM_TEST_USER, mProfileSerialNumber));
         runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
-                LAUNCHER_TESTS_CLASS, "testSimpleAppInstalledForUser",
+                LAUNCHER_TESTS_PKG + ".LauncherAppsTests", "testSimpleAppInstalledForUser",
                 mParentUserId, Collections.singletonMap(PARAM_TEST_USER, mMainUserSerialNumber));
-
-        // Run the same test on the managed profile.  This still works.
-        runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
-                LAUNCHER_TESTS_CLASS, "testSimpleAppInstalledForUser",
-                mProfileUserId, Collections.singletonMap(PARAM_TEST_USER, mProfileSerialNumber));
-
-        // This tries to access main prorfile from work profiel, which is not allowed.
-        runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
-                LAUNCHER_TESTS_CLASS, "testAccessPrimaryProfileFromManagedProfile",
-                mProfileUserId, Collections.singletonMap(PARAM_TEST_USER, mMainUserSerialNumber));
-
-        // Test for getProfiles.
-        runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
-                LAUNCHER_TESTS_CLASS, "testGetProfiles_fromMainProfile",
-                mParentUserId);
-        runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
-                LAUNCHER_TESTS_CLASS, "testGetProfiles_fromManagedProfile",
-                mProfileUserId);
     }
 
     public void testLauncherCallbackPackageAddedProfile() throws Exception {
diff --git a/hostsidetests/shortcuts/deviceside/multiuser/src/android/content/pm/cts/shortcut/multiuser/ShortcutManagerManagedUserTest.java b/hostsidetests/shortcuts/deviceside/multiuser/src/android/content/pm/cts/shortcut/multiuser/ShortcutManagerManagedUserTest.java
index 4de7848..0c5e662 100644
--- a/hostsidetests/shortcuts/deviceside/multiuser/src/android/content/pm/cts/shortcut/multiuser/ShortcutManagerManagedUserTest.java
+++ b/hostsidetests/shortcuts/deviceside/multiuser/src/android/content/pm/cts/shortcut/multiuser/ShortcutManagerManagedUserTest.java
@@ -59,75 +59,38 @@
                                 new ComponentName(getContext(), MainActivity.class))).build())));
     }
 
-    public void test04_getAndLaunch_primary() {
-        Launcher.setAsDefaultLauncher(getInstrumentation(), getContext());
-
-        final UserHandle userCurrent = android.os.Process.myUserHandle();
-        final UserHandle userOther = getManagedUser();
-
-        final ShortcutQuery q = new ShortcutQuery()
-                .setQueryFlags(ShortcutQuery.FLAG_MATCH_DYNAMIC)
-                .setPackage(getContext().getPackageName())
-                .setShortcutIds(list("s1"));
-        assertWith(getLauncherApps().getShortcuts(q, userCurrent))
-                .haveIds("s1")
-                .areAllDynamic()
-                .forShortcutWithId("s1", si -> {
-                    assertEquals("label1", si.getShortLabel());
-                    assertEquals(userCurrent, si.getUserHandle());
-                });
-        assertWith(getLauncherApps().getShortcuts(q, userOther))
-                .haveIds("s1")
-                .areAllDynamic()
-                .forShortcutWithId("s1", si -> {
-                    assertEquals("label2", si.getShortLabel());
-                    assertEquals(userOther, si.getUserHandle());
-                });
-
-        // Just call start and make sure they don't throw.
-        getLauncherApps().startShortcut(getContext().getPackageName(), "s1", null, null,
-                userCurrent);
-
-        // TODO Make sure the activity actually starts.
-        getLauncherApps().startShortcut(getContext().getPackageName(), "s1", null, null,
-                userOther);
-    }
-
-    public void test04_getAndLaunch_managed() {
+    public void test04_getAndLaunch() {
         Launcher.setAsDefaultLauncher(getInstrumentation(), getContext());
 
         final UserHandle userMain = android.os.Process.myUserHandle();
-        final UserHandle userOther = getManagedUser();
+        final UserHandle userManaged = getManagedUser();
 
         final ShortcutQuery q = new ShortcutQuery()
                 .setQueryFlags(ShortcutQuery.FLAG_MATCH_DYNAMIC)
                 .setPackage(getContext().getPackageName())
                 .setShortcutIds(list("s1"));
-        try {
-            getLauncherApps().getShortcuts(q, userOther);
-            fail("Didn't throw SecurityException");
-        } catch (SecurityException e) {
-            assertTrue(e.getMessage().contains("another profile"));
-        }
         assertWith(getLauncherApps().getShortcuts(q, userMain))
                 .haveIds("s1")
                 .areAllDynamic()
                 .forShortcutWithId("s1", si -> {
-                    assertEquals("label2", si.getShortLabel());
+                    assertEquals("label1", si.getShortLabel());
                     assertEquals(userMain, si.getUserHandle());
                 });
+        assertWith(getLauncherApps().getShortcuts(q, userManaged))
+                .haveIds("s1")
+                .areAllDynamic()
+                .forShortcutWithId("s1", si -> {
+                    assertEquals("label2", si.getShortLabel());
+                    assertEquals(userManaged, si.getUserHandle());
+                });
 
-        try {
-            getLauncherApps().startShortcut(getContext().getPackageName(), "s1", null, null,
-                    userOther);
-            fail("Didn't throw SecurityException");
-        } catch (SecurityException e) {
-            assertTrue(e.getMessage().contains("another profile"));
-        }
+        // Just call start and make sure they don't throw.
+        getLauncherApps().startShortcut(getContext().getPackageName(), "s1", null, null,
+                userMain);
 
         // TODO Make sure the activity actually starts.
         getLauncherApps().startShortcut(getContext().getPackageName(), "s1", null, null,
-                userMain);
+                userManaged);
     }
 
     private UserHandle getManagedUser() {
diff --git a/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerMultiuserTest.java b/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerMultiuserTest.java
index c5a97e7..a74ab45 100644
--- a/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerMultiuserTest.java
+++ b/hostsidetests/shortcuts/hostside/src/android/content/pm/cts/shortcuthost/ShortcutManagerMultiuserTest.java
@@ -51,11 +51,8 @@
                 "test02_createShortuctsOnPrimaryUser", getPrimaryUserId());
         runDeviceTestsAsUser(TARGET_PKG, ".ShortcutManagerManagedUserTest",
                 "test03_createShortuctsOnManagedProfile", profileId);
-
         runDeviceTestsAsUser(TARGET_PKG, ".ShortcutManagerManagedUserTest",
-                "test04_getAndLaunch_primary", getPrimaryUserId());
-        runDeviceTestsAsUser(TARGET_PKG, ".ShortcutManagerManagedUserTest",
-                "test04_getAndLaunch_managed", profileId);
+                "test04_getAndLaunch", getPrimaryUserId());
     }
 
     public void testSecondaryUser() throws Exception {