Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54b6d1a3 authored by Pinyao Ting's avatar Pinyao Ting Committed by Android (Google) Code Review
Browse files

Merge "Fix shortcut's unit test in comply with HSUM" into main

parents 031edc48 fee7ad09
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
{
 "shortcut": [
  {
   "userId": 0,
   "userId": 10,
   "launchers": [
    {
     "name": "com.android.launcher.1"
@@ -55,7 +55,7 @@
   ]
  },
  {
   "userId": 10,
   "userId": 11,
   "launchers": [
    {
     "name": "com.android.launcher.1"
+68 −66
Original line number Diff line number Diff line
@@ -721,54 +721,56 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
    protected static final String SYSTEM_PACKAGE_NAME = "android";

    protected static final String CALLING_PACKAGE_1 = "com.android.test.1";
    protected static final int CALLING_UID_1 = 10001;
    protected static final int CALLING_UID_1 = 1000001;

    protected static final String CALLING_PACKAGE_2 = "com.android.test.2";
    protected static final int CALLING_UID_2 = 10002;
    protected static final int CALLING_UID_2 = 1000002;

    protected static final String CALLING_PACKAGE_3 = "com.android.test.3";
    protected static final int CALLING_UID_3 = 10003;
    protected static final int CALLING_UID_3 = 1000003;

    protected static final String CALLING_PACKAGE_4 = "com.android.test.4";
    protected static final int CALLING_UID_4 = 10004;
    protected static final int CALLING_UID_4 = 1000004;

    protected static final String LAUNCHER_1 = "com.android.launcher.1";
    protected static final int LAUNCHER_UID_1 = 10011;
    protected static final int LAUNCHER_UID_1 = 1000011;

    protected static final String LAUNCHER_2 = "com.android.launcher.2";
    protected static final int LAUNCHER_UID_2 = 10012;
    protected static final int LAUNCHER_UID_2 = 1000012;

    protected static final String LAUNCHER_3 = "com.android.launcher.3";
    protected static final int LAUNCHER_UID_3 = 10013;
    protected static final int LAUNCHER_UID_3 = 1000013;

    protected static final String LAUNCHER_4 = "com.android.launcher.4";
    protected static final int LAUNCHER_UID_4 = 10014;
    protected static final int LAUNCHER_UID_4 = 1000014;

    protected static final String CHOOSER_ACTIVITY_PACKAGE = "com.android.intentresolver";
    protected static final int CHOOSER_ACTIVITY_UID = 10015;
    protected static final int CHOOSER_ACTIVITY_UID = 1000015;

    protected static final int USER_0 = UserHandle.USER_SYSTEM;
    // Shifting primary user to 10 to support HSUM
    protected static final int USER_10 = 10;
    protected static final int USER_11 = 11;
    protected static final int USER_12 = 12;
    protected static final int USER_P0 = 20; // profile of user 0 (MANAGED_PROFILE *not* set)
    protected static final int USER_P1 = 21; // another profile of user 0 (MANAGED_PROFILE set)

    protected static final UserHandle HANDLE_USER_0 = UserHandle.of(USER_0);
    protected static final UserHandle HANDLE_USER_10 = UserHandle.of(USER_10);
    protected static final UserHandle HANDLE_USER_11 = UserHandle.of(USER_11);
    protected static final UserHandle HANDLE_USER_12 = UserHandle.of(USER_12);
    protected static final UserHandle HANDLE_USER_P0 = UserHandle.of(USER_P0);
    protected static final UserHandle HANDLE_USER_P1 = UserHandle.of(USER_P1);

    protected static final UserInfo USER_INFO_0 = withProfileGroupId(
            new UserInfo(USER_0, "user0",
                    UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY | UserInfo.FLAG_INITIALIZED), 0);

    protected static final UserInfo USER_INFO_10 =
            new UserInfo(USER_10, "user10", UserInfo.FLAG_INITIALIZED);
    protected static final UserInfo USER_INFO_10 = withProfileGroupId(
            new UserInfo(USER_10, "user10",
                    UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY | UserInfo.FLAG_INITIALIZED),
            USER_10);

    protected static final UserInfo USER_INFO_11 =
            new UserInfo(USER_11, "user11", UserInfo.FLAG_INITIALIZED);

    protected static final UserInfo USER_INFO_12 =
            new UserInfo(USER_12, "user12", UserInfo.FLAG_INITIALIZED);

    /*
     * Cheat: USER_P0 is a sub profile of USER_0, but it doesn't have the MANAGED_PROFILE flag set.
     * Due to a change made to LauncherApps (b/34340531), work profile apps a no longer able
@@ -778,11 +780,11 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
     * can't access main profile's shortcuts.)
     */
    protected static final UserInfo USER_INFO_P0 = withProfileGroupId(
            new UserInfo(USER_P0, "userP0", UserInfo.FLAG_INITIALIZED), 0);
            new UserInfo(USER_P0, "userP0", UserInfo.FLAG_INITIALIZED), USER_10);

    protected static final UserInfo USER_INFO_P1 = withProfileGroupId(
            new UserInfo(USER_P1, "userP1",
                    UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_MANAGED_PROFILE), 0);
                    UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_MANAGED_PROFILE), USER_10);

    protected static final UserProperties USER_PROPERTIES_0 =
            new UserProperties.Builder().setItemsRestrictedOnHomeScreen(false).build();
@@ -925,14 +927,14 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
        deleteAllSavedFiles();

        // Set up users.
        mUserInfos.put(USER_0, USER_INFO_0);
        mUserInfos.put(USER_10, USER_INFO_10);
        mUserInfos.put(USER_11, USER_INFO_11);
        mUserInfos.put(USER_12, USER_INFO_12);
        mUserInfos.put(USER_P0, USER_INFO_P0);
        mUserInfos.put(USER_P1, USER_INFO_P1);
        mUserProperties.put(USER_0, USER_PROPERTIES_0);
        mUserProperties.put(USER_10, USER_PROPERTIES_10);
        mUserProperties.put(USER_11, USER_PROPERTIES_11);
        mUserProperties.put(USER_10, USER_PROPERTIES_0);
        mUserProperties.put(USER_11, USER_PROPERTIES_10);
        mUserProperties.put(USER_12, USER_PROPERTIES_11);

        when(mMockUserManagerInternal.isUserUnlockingOrUnlocked(anyInt()))
                .thenAnswer(inv -> {
@@ -994,16 +996,16 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
                mUserInfos.values().toArray(new UserInfo[0]));

        // User 0 and P0 are always running
        mRunningUsers.put(USER_0, true);
        mRunningUsers.put(USER_10, false);
        mRunningUsers.put(USER_10, true);
        mRunningUsers.put(USER_11, false);
        mRunningUsers.put(USER_12, false);
        mRunningUsers.put(USER_P0, true);
        mRunningUsers.put(USER_P1, true);

        // Unlock all users by default.
        mUnlockedUsers.put(USER_0, true);
        mUnlockedUsers.put(USER_10, true);
        mUnlockedUsers.put(USER_11, true);
        mUnlockedUsers.put(USER_12, true);
        mUnlockedUsers.put(USER_P0, true);
        mUnlockedUsers.put(USER_P1, true);

@@ -1391,7 +1393,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
    }

    protected void setCaller(String packageName) {
        setCaller(packageName, UserHandle.USER_SYSTEM);
        setCaller(packageName, USER_10);
    }

    protected String getCallingPackage() {
@@ -2223,7 +2225,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {

        dumpsysOnLogcat("Before backup");

        final byte[] payload =  mService.getBackupPayload(USER_0);
        final byte[] payload =  mService.getBackupPayload(USER_10);
        if (ENABLE_DUMP) {
            final String xml = new String(payload);
            Log.v(TAG, "Backup payload:");
@@ -2233,7 +2235,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
        }

        // Before doing anything else, uninstall all packages.
        for (int userId : list(USER_0, USER_P0)) {
        for (int userId : list(USER_10, USER_P0)) {
            for (String pkg : list(CALLING_PACKAGE_1, CALLING_PACKAGE_2, CALLING_PACKAGE_3,
                    LAUNCHER_1, LAUNCHER_2, LAUNCHER_3)) {
                uninstallPackage(userId, pkg);
@@ -2245,11 +2247,11 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
        deleteAllSavedFiles();

        initService();
        mService.applyRestore(payload, USER_0);
        mService.applyRestore(payload, USER_10);

        // handleUnlockUser will perform the gone package check, but it shouldn't remove
        // shadow information.
        mService.handleUnlockUser(USER_0);
        mService.handleUnlockUser(USER_10);

        dumpsysOnLogcat("After restore");

@@ -2257,24 +2259,24 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
    }

    protected void prepareCrossProfileDataSet() {
        mRunningUsers.put(USER_10, true); // this test needs user 10.
        mRunningUsers.put(USER_11, true); // this test needs user 10.

        runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_1, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"),
                    makeShortcut("s4"), makeShortcut("s5"), makeShortcut("s6"))));
        });
        runWithCaller(CALLING_PACKAGE_2, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_2, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"),
                    makeShortcut("s4"), makeShortcut("s5"), makeShortcut("s6"))));
        });
        runWithCaller(CALLING_PACKAGE_3, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_3, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"),
                    makeShortcut("s4"), makeShortcut("s5"), makeShortcut("s6"))));
        });
        runWithCaller(CALLING_PACKAGE_4, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_4, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list()));
        });
        runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
@@ -2282,79 +2284,79 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"),
                    makeShortcut("s4"), makeShortcut("s5"), makeShortcut("s6"))));
        });
        runWithCaller(CALLING_PACKAGE_1, USER_10, () -> {
        runWithCaller(CALLING_PACKAGE_1, USER_11, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("x1"), makeShortcut("x2"), makeShortcut("x3"),
                    makeShortcut("x4"), makeShortcut("x5"), makeShortcut("x6"))));
        });

        runWithCaller(LAUNCHER_1, USER_0, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s1", "s2"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("s1", "s2", "s3"), HANDLE_USER_0);
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s1", "s2"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("s1", "s2", "s3"), HANDLE_USER_10);

            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1", "s4"), HANDLE_USER_P0);
        });
        runWithCaller(LAUNCHER_2, USER_0, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s2"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s2", "s3"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("s2", "s3", "s4"), HANDLE_USER_0);
        runWithCaller(LAUNCHER_2, USER_10, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s2"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s2", "s3"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("s2", "s3", "s4"), HANDLE_USER_10);

            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s2", "s5"), HANDLE_USER_P0);
        });

        // Note LAUNCHER_3 has allowBackup=false.
        runWithCaller(LAUNCHER_3, USER_0, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s3"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s3", "s4"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("s3", "s4", "s5"), HANDLE_USER_0);
        runWithCaller(LAUNCHER_3, USER_10, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s3"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s3", "s4"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("s3", "s4", "s5"), HANDLE_USER_10);

            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s3", "s6"), HANDLE_USER_P0);
        });
        runWithCaller(LAUNCHER_4, USER_0, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list(), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list(), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list(), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_4, list(), HANDLE_USER_0);
        runWithCaller(LAUNCHER_4, USER_10, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list(), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list(), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list(), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_4, list(), HANDLE_USER_10);
        });

        // Launcher on a managed profile is referring ot user 0!
        runWithCaller(LAUNCHER_1, USER_P0, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s3", "s4"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s3", "s4", "s5"), HANDLE_USER_0);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s3", "s4"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("s3", "s4", "s5"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("s3", "s4", "s5", "s6"),
                    HANDLE_USER_0);
                    HANDLE_USER_10);

            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s4", "s1"), HANDLE_USER_P0);
        });
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("x4", "x5"), HANDLE_USER_10);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("x4", "x5", "x6"), HANDLE_USER_10);
        runWithCaller(LAUNCHER_1, USER_11, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("x4", "x5"), HANDLE_USER_11);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_2, list("x4", "x5", "x6"), HANDLE_USER_11);
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_3, list("x4", "x5", "x6", "x1"),
                    HANDLE_USER_10);
                    HANDLE_USER_11);
        });

        // Then remove some dynamic shortcuts.
        runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_1, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"))));
        });
        runWithCaller(CALLING_PACKAGE_2, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_2, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"))));
        });
        runWithCaller(CALLING_PACKAGE_3, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_3, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"))));
        });
        runWithCaller(CALLING_PACKAGE_4, USER_0, () -> {
        runWithCaller(CALLING_PACKAGE_4, USER_10, () -> {
            assertTrue(mManager.setDynamicShortcuts(list()));
        });
        runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("s1"), makeShortcut("s2"), makeShortcut("s3"))));
        });
        runWithCaller(CALLING_PACKAGE_1, USER_10, () -> {
        runWithCaller(CALLING_PACKAGE_1, USER_11, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(
                    makeShortcut("x1"), makeShortcut("x2"), makeShortcut("x3"))));
        });
+1373 −1369

File changed.

Preview size limit exceeded, changes collapsed.

+18 −19
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps.PinItemRequest;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.os.Process;
import android.platform.test.annotations.Presubmit;

import androidx.test.filters.SmallTest;
@@ -56,7 +55,7 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
    }

    public void testCreateShortcutResult_validResult() {
        setDefaultLauncher(USER_0, LAUNCHER_1);
        setDefaultLauncher(USER_10, LAUNCHER_1);

        runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
            ShortcutInfo s1 = makeShortcut("s1");
@@ -64,20 +63,20 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
            mRequest = verifyAndGetCreateShortcutResult(intent);
        });

        runWithCaller(LAUNCHER_1, USER_0, () -> {
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            assertTrue(mRequest.isValid());
            assertTrue(mRequest.accept());
        });
    }

    public void testCreateShortcutResult_alreadyPinned() {
        setDefaultLauncher(USER_0, LAUNCHER_1);
        setDefaultLauncher(USER_10, LAUNCHER_1);

        runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
            assertTrue(mManager.setDynamicShortcuts(list(makeShortcut("s1"))));
        });

        runWithCaller(LAUNCHER_1, USER_0, () -> {
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1"), HANDLE_USER_P0);
        });

@@ -87,7 +86,7 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
            mRequest = verifyAndGetCreateShortcutResult(intent);
        });

        runWithCaller(LAUNCHER_1, USER_0, () -> {
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            assertTrue(mRequest.isValid());
            assertTrue(mRequest.getShortcutInfo().isPinned());
            assertTrue(mRequest.accept());
@@ -100,18 +99,18 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
        });

        // Initially all launchers have the shortcut permission, until we call setDefaultLauncher().
        runWithCaller(LAUNCHER_2, USER_0, () -> {
        runWithCaller(LAUNCHER_2, USER_10, () -> {
            mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1"), HANDLE_USER_P0);
        });

        setDefaultLauncher(USER_0, LAUNCHER_1);
        setDefaultLauncher(USER_10, LAUNCHER_1);
        runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
            ShortcutInfo s1 = makeShortcut("s1");
            Intent intent = mManager.createShortcutResultIntent(s1);
            mRequest = verifyAndGetCreateShortcutResult(intent);
        });

        runWithCaller(LAUNCHER_1, USER_0, () -> {
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            assertTrue(mRequest.isValid());
            assertFalse(mRequest.getShortcutInfo().isPinned());
            assertTrue(mRequest.accept());
@@ -119,7 +118,7 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
    }

    public void testCreateShortcutResult_defaultLauncherChanges() {
        setDefaultLauncher(USER_0, LAUNCHER_1);
        setDefaultLauncher(USER_10, LAUNCHER_1);

        runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
            ShortcutInfo s1 = makeShortcut("s1");
@@ -127,15 +126,15 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
            mRequest = verifyAndGetCreateShortcutResult(intent);
        });

        setDefaultLauncher(USER_0, LAUNCHER_2);
        setDefaultLauncher(USER_10, LAUNCHER_2);
        // Verify that other launcher can't use this request
        runWithCaller(LAUNCHER_2, USER_0, () -> {
        runWithCaller(LAUNCHER_2, USER_10, () -> {
            assertFalse(mRequest.isValid());
            assertExpectException(SecurityException.class, "Calling uid mismatch",
                    mRequest::accept);
        });

        runWithCaller(LAUNCHER_1, USER_0, () -> {
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            // Set some random caller UID.
            mInjectedCallingUid = 12345;

@@ -144,7 +143,7 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
                    mRequest::accept);
        });

        runWithCaller(LAUNCHER_1, USER_0, () -> {
        runWithCaller(LAUNCHER_1, USER_10, () -> {
            assertTrue(mRequest.isValid());
            assertTrue(mRequest.accept());
        });
@@ -157,23 +156,23 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest {
        LauncherActivityInfo info = mock(LauncherActivityInfo.class);
        when(info.getComponentName()).thenReturn(
                new ComponentName(getTestContext(), "a.ShortcutConfigActivity"));
        when(info.getUser()).thenReturn(Process.myUserHandle());
        when(info.getUser()).thenReturn(HANDLE_USER_10);
        return info;
    }

    public void testStartConfigActivity_defaultLauncher() {
        LauncherActivityInfo info = setupMockActivityInfo();
        prepareIntentActivities(info.getComponentName());
        setDefaultLauncher(USER_0, LAUNCHER_1);
        runWithCaller(LAUNCHER_1, USER_0, () ->
        setDefaultLauncher(USER_10, LAUNCHER_1);
        runWithCaller(LAUNCHER_1, USER_10, () ->
            assertNotNull(mLauncherApps.getShortcutConfigActivityIntent(info))
        );
    }

    public void testStartConfigActivity_nonDefaultLauncher() {
        LauncherActivityInfo info = setupMockActivityInfo();
        setDefaultLauncher(USER_0, LAUNCHER_1);
        runWithCaller(LAUNCHER_2, USER_0, () ->
        setDefaultLauncher(USER_10, LAUNCHER_1);
        runWithCaller(LAUNCHER_2, USER_10, () ->
            assertExpectException(SecurityException.class, null, () ->
                    mLauncherApps.getShortcutConfigActivityIntent(info))
        );
+131 −131

File changed.

Preview size limit exceeded, changes collapsed.

Loading