Loading services/core/java/com/android/server/pm/ShortcutService.java +2 −2 Original line number Diff line number Diff line Loading @@ -169,7 +169,7 @@ public class ShortcutService extends IShortcutService.Stub { static final int DEFAULT_MAX_UPDATES_PER_INTERVAL = 10; @VisibleForTesting static final int DEFAULT_MAX_SHORTCUTS_PER_APP = 10; static final int DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY = 15; @VisibleForTesting static final int DEFAULT_MAX_ICON_DIMENSION_DP = 96; Loading Loading @@ -730,7 +730,7 @@ public class ShortcutService extends IShortcutService.Stub { ConfigConstants.KEY_MAX_UPDATES_PER_INTERVAL, DEFAULT_MAX_UPDATES_PER_INTERVAL)); mMaxShortcuts = Math.max(0, (int) parser.getLong( ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP)); ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY)); final int iconDimensionDp = Math.max(1, injectIsLowRamDevice() ? (int) parser.getLong( Loading services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -720,6 +720,8 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected static final long INTERVAL = 10000; // This doesn't need to match the max shortcuts limit in the framework, and tests should either // use this or set their own limit for testing, without assuming any particular max value. protected static final int MAX_SHORTCUTS = 10; protected static final int MAX_UPDATES_PER_INTERVAL = 3; Loading services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java +37 −38 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { assertEquals(ShortcutService.DEFAULT_RESET_INTERVAL_SEC * 1000, mService.getResetIntervalForTest()); assertEquals(ShortcutService.DEFAULT_MAX_SHORTCUTS_PER_APP, assertEquals(ShortcutService.DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY, mService.getMaxShortcutsForTest()); assertEquals(ShortcutService.DEFAULT_MAX_UPDATES_PER_INTERVAL, Loading Loading @@ -393,6 +393,8 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { } public void testPushDynamicShortcut() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=5"); setCaller(CALLING_PACKAGE_1, USER_0); Loading @@ -400,12 +402,11 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { final ShortcutInfo s2 = makeShortcut("s2"); final ShortcutInfo s3 = makeShortcut("s3"); final ShortcutInfo s4 = makeShortcut("s4"); final ShortcutInfo s10 = makeShortcut("s10"); final ShortcutInfo s11 = makeShortcut("s11"); final ShortcutInfo s12 = makeShortcut("s12"); final ShortcutInfo s13 = makeShortcut("s13"); final ShortcutInfo s14 = makeShortcut("s14"); final ShortcutInfo s5 = makeShortcut("s5"); final ShortcutInfo s6 = makeShortcut("s6"); final ShortcutInfo s7 = makeShortcut("s7"); final ShortcutInfo s8 = makeShortcut("s8"); final ShortcutInfo s9 = makeShortcut("s9"); // Test push as first shortcut mManager.pushDynamicShortcut(s1); Loading Loading @@ -440,63 +441,61 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { mInjectedCurrentTimeMillis += INTERVAL; // reset // Test push as last assertTrue(mManager.addDynamicShortcuts(makeShortcuts("s5", "s6", "s7", "s8", "s9"))); mManager.pushDynamicShortcut(s10); mManager.pushDynamicShortcut(s5); assertShortcutIds(assertAllNotKeyFieldsOnly(mManager.getDynamicShortcuts()), "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10"); assertEquals(0, getCallerShortcut("s10").getRank()); assertEquals(1, getCallerShortcut("s5").getRank()); assertEquals(6, getCallerShortcut("s3").getRank()); assertEquals(7, getCallerShortcut("s1").getRank()); assertEquals(8, getCallerShortcut("s2").getRank()); assertEquals(9, getCallerShortcut("s4").getRank()); "s1", "s2", "s3", "s4", "s5"); assertEquals(0, getCallerShortcut("s5").getRank()); assertEquals(1, getCallerShortcut("s3").getRank()); assertEquals(2, getCallerShortcut("s1").getRank()); assertEquals(3, getCallerShortcut("s2").getRank()); assertEquals(4, getCallerShortcut("s4").getRank()); // Push when max has already reached mManager.pushDynamicShortcut(s11); mManager.pushDynamicShortcut(s6); assertShortcutIds(assertAllNotKeyFieldsOnly(mManager.getDynamicShortcuts()), "s1", "s2", "s3", "s5", "s6", "s7", "s8", "s9", "s10", "s11"); assertEquals(0, getCallerShortcut("s11").getRank()); assertEquals(1, getCallerShortcut("s10").getRank()); assertEquals(9, getCallerShortcut("s2").getRank()); "s1", "s2", "s3", "s5", "s6"); assertEquals(0, getCallerShortcut("s6").getRank()); assertEquals(1, getCallerShortcut("s5").getRank()); assertEquals(4, getCallerShortcut("s2").getRank()); mInjectedCurrentTimeMillis += INTERVAL; // reset // Push with different activity s12.setActivity(makeComponent(ShortcutActivity2.class)); mManager.pushDynamicShortcut(s12); s7.setActivity(makeComponent(ShortcutActivity2.class)); mManager.pushDynamicShortcut(s7); assertEquals(makeComponent(ShortcutActivity2.class), getCallerShortcut("s12").getActivity()); assertEquals(0, getCallerShortcut("s12").getRank()); getCallerShortcut("s7").getActivity()); assertEquals(0, getCallerShortcut("s7").getRank()); // Push to update shortcut with different activity final ShortcutInfo s1_2 = makeShortcut("s1"); s1_2.setActivity(makeComponent(ShortcutActivity2.class)); s1_2.setRank(1); mManager.pushDynamicShortcut(s1_2); assertEquals(0, getCallerShortcut("s12").getRank()); assertEquals(0, getCallerShortcut("s7").getRank()); assertEquals(1, getCallerShortcut("s1").getRank()); assertEquals(0, getCallerShortcut("s11").getRank()); assertEquals(1, getCallerShortcut("s10").getRank()); assertEquals(7, getCallerShortcut("s3").getRank()); assertEquals(8, getCallerShortcut("s2").getRank()); assertEquals(0, getCallerShortcut("s6").getRank()); assertEquals(1, getCallerShortcut("s5").getRank()); assertEquals(2, getCallerShortcut("s3").getRank()); assertEquals(3, getCallerShortcut("s2").getRank()); mInjectedCurrentTimeMillis += INTERVAL; // reset // Test push when dropped shortcut is cached s13.setLongLived(); s13.setRank(100); mManager.pushDynamicShortcut(s13); assertEquals(9, getCallerShortcut("s13").getRank()); s8.setLongLived(); s8.setRank(100); mManager.pushDynamicShortcut(s8); assertEquals(4, getCallerShortcut("s8").getRank()); runWithCaller(LAUNCHER_1, USER_0, () -> { mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s13"), HANDLE_USER_0); mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s8"), HANDLE_USER_0); }); mManager.pushDynamicShortcut(s14); mManager.pushDynamicShortcut(s9); assertShortcutIds(assertAllNotKeyFieldsOnly(mManager.getDynamicShortcuts()), "s1", "s2", "s3", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s14"); "s1", "s2", "s3", "s5", "s6", "s7", "s9"); // Verify s13 stayed as cached assertShortcutIds(mManager.getShortcuts(ShortcutManager.FLAG_MATCH_CACHED), "s13"); "s8"); } public void testUnlimitedCalls() { Loading services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest11.java +25 −17 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.content.pm.LauncherApps.ShortcutQuery; import android.content.pm.ShortcutInfo; import android.os.test.TestLooper; import com.android.server.pm.ShortcutService.ConfigConstants; import org.mockito.ArgumentCaptor; import java.util.List; Loading Loading @@ -372,9 +374,11 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { } public void testShortcutChangeCallback_pushDynamicShortcut_existingId() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=3"); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10")))); assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3")))); }); ShortcutChangeCallback callback = mock(ShortcutChangeCallback.class); Loading @@ -384,7 +388,7 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { }); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { mManager.pushDynamicShortcut(makeShortcut("s5")); mManager.pushDynamicShortcut(makeShortcut("s2")); }); mTestLooper.dispatchAll(); Loading @@ -396,13 +400,15 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { assertWith(shortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s5"); .haveIds("s2"); } public void testShortcutChangeCallback_pushDynamicShortcut_causeDeletion() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=3"); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10")))); assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3")))); }); ShortcutChangeCallback callback = mock(ShortcutChangeCallback.class); Loading @@ -412,7 +418,7 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { }); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { mManager.pushDynamicShortcut(makeShortcut("s11")); mManager.pushDynamicShortcut(makeShortcut("s4")); }); mTestLooper.dispatchAll(); Loading @@ -427,31 +433,33 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { assertWith(changedShortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s11"); .haveIds("s4"); assertWith(removedShortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s10"); .haveIds("s3"); } public void testShortcutChangeCallback_pushDynamicShortcut_causeDeletionButCached() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=3"); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9")))); ShortcutInfo s10 = makeLongLivedShortcut("s10"); s10.setRank(10); mManager.pushDynamicShortcut(s10); // Add a long lived shortcut to the end of the list. assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2")))); ShortcutInfo s3 = makeLongLivedShortcut("s3"); s3.setRank(3); mManager.pushDynamicShortcut(s3); // Add a long lived shortcut to the end of the list. }); ShortcutChangeCallback callback = mock(ShortcutChangeCallback.class); runWithCaller(LAUNCHER_1, USER_0, () -> { mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s10"), HANDLE_USER_0); mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s3"), HANDLE_USER_0); mLauncherApps.registerShortcutChangeCallback(callback, QUERY_MATCH_ALL, mTestLooper.getNewExecutor()); }); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { mManager.pushDynamicShortcut(makeShortcut("s11")); mManager.pushDynamicShortcut(makeShortcut("s4")); }); mTestLooper.dispatchAll(); Loading @@ -463,7 +471,7 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { assertWith(shortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s10", "s11"); .haveIds("s3", "s4"); } public void testShortcutChangeCallback_disableShortcuts() { Loading Loading
services/core/java/com/android/server/pm/ShortcutService.java +2 −2 Original line number Diff line number Diff line Loading @@ -169,7 +169,7 @@ public class ShortcutService extends IShortcutService.Stub { static final int DEFAULT_MAX_UPDATES_PER_INTERVAL = 10; @VisibleForTesting static final int DEFAULT_MAX_SHORTCUTS_PER_APP = 10; static final int DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY = 15; @VisibleForTesting static final int DEFAULT_MAX_ICON_DIMENSION_DP = 96; Loading Loading @@ -730,7 +730,7 @@ public class ShortcutService extends IShortcutService.Stub { ConfigConstants.KEY_MAX_UPDATES_PER_INTERVAL, DEFAULT_MAX_UPDATES_PER_INTERVAL)); mMaxShortcuts = Math.max(0, (int) parser.getLong( ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP)); ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY)); final int iconDimensionDp = Math.max(1, injectIsLowRamDevice() ? (int) parser.getLong( Loading
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -720,6 +720,8 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected static final long INTERVAL = 10000; // This doesn't need to match the max shortcuts limit in the framework, and tests should either // use this or set their own limit for testing, without assuming any particular max value. protected static final int MAX_SHORTCUTS = 10; protected static final int MAX_UPDATES_PER_INTERVAL = 3; Loading
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java +37 −38 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { assertEquals(ShortcutService.DEFAULT_RESET_INTERVAL_SEC * 1000, mService.getResetIntervalForTest()); assertEquals(ShortcutService.DEFAULT_MAX_SHORTCUTS_PER_APP, assertEquals(ShortcutService.DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY, mService.getMaxShortcutsForTest()); assertEquals(ShortcutService.DEFAULT_MAX_UPDATES_PER_INTERVAL, Loading Loading @@ -393,6 +393,8 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { } public void testPushDynamicShortcut() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=5"); setCaller(CALLING_PACKAGE_1, USER_0); Loading @@ -400,12 +402,11 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { final ShortcutInfo s2 = makeShortcut("s2"); final ShortcutInfo s3 = makeShortcut("s3"); final ShortcutInfo s4 = makeShortcut("s4"); final ShortcutInfo s10 = makeShortcut("s10"); final ShortcutInfo s11 = makeShortcut("s11"); final ShortcutInfo s12 = makeShortcut("s12"); final ShortcutInfo s13 = makeShortcut("s13"); final ShortcutInfo s14 = makeShortcut("s14"); final ShortcutInfo s5 = makeShortcut("s5"); final ShortcutInfo s6 = makeShortcut("s6"); final ShortcutInfo s7 = makeShortcut("s7"); final ShortcutInfo s8 = makeShortcut("s8"); final ShortcutInfo s9 = makeShortcut("s9"); // Test push as first shortcut mManager.pushDynamicShortcut(s1); Loading Loading @@ -440,63 +441,61 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { mInjectedCurrentTimeMillis += INTERVAL; // reset // Test push as last assertTrue(mManager.addDynamicShortcuts(makeShortcuts("s5", "s6", "s7", "s8", "s9"))); mManager.pushDynamicShortcut(s10); mManager.pushDynamicShortcut(s5); assertShortcutIds(assertAllNotKeyFieldsOnly(mManager.getDynamicShortcuts()), "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10"); assertEquals(0, getCallerShortcut("s10").getRank()); assertEquals(1, getCallerShortcut("s5").getRank()); assertEquals(6, getCallerShortcut("s3").getRank()); assertEquals(7, getCallerShortcut("s1").getRank()); assertEquals(8, getCallerShortcut("s2").getRank()); assertEquals(9, getCallerShortcut("s4").getRank()); "s1", "s2", "s3", "s4", "s5"); assertEquals(0, getCallerShortcut("s5").getRank()); assertEquals(1, getCallerShortcut("s3").getRank()); assertEquals(2, getCallerShortcut("s1").getRank()); assertEquals(3, getCallerShortcut("s2").getRank()); assertEquals(4, getCallerShortcut("s4").getRank()); // Push when max has already reached mManager.pushDynamicShortcut(s11); mManager.pushDynamicShortcut(s6); assertShortcutIds(assertAllNotKeyFieldsOnly(mManager.getDynamicShortcuts()), "s1", "s2", "s3", "s5", "s6", "s7", "s8", "s9", "s10", "s11"); assertEquals(0, getCallerShortcut("s11").getRank()); assertEquals(1, getCallerShortcut("s10").getRank()); assertEquals(9, getCallerShortcut("s2").getRank()); "s1", "s2", "s3", "s5", "s6"); assertEquals(0, getCallerShortcut("s6").getRank()); assertEquals(1, getCallerShortcut("s5").getRank()); assertEquals(4, getCallerShortcut("s2").getRank()); mInjectedCurrentTimeMillis += INTERVAL; // reset // Push with different activity s12.setActivity(makeComponent(ShortcutActivity2.class)); mManager.pushDynamicShortcut(s12); s7.setActivity(makeComponent(ShortcutActivity2.class)); mManager.pushDynamicShortcut(s7); assertEquals(makeComponent(ShortcutActivity2.class), getCallerShortcut("s12").getActivity()); assertEquals(0, getCallerShortcut("s12").getRank()); getCallerShortcut("s7").getActivity()); assertEquals(0, getCallerShortcut("s7").getRank()); // Push to update shortcut with different activity final ShortcutInfo s1_2 = makeShortcut("s1"); s1_2.setActivity(makeComponent(ShortcutActivity2.class)); s1_2.setRank(1); mManager.pushDynamicShortcut(s1_2); assertEquals(0, getCallerShortcut("s12").getRank()); assertEquals(0, getCallerShortcut("s7").getRank()); assertEquals(1, getCallerShortcut("s1").getRank()); assertEquals(0, getCallerShortcut("s11").getRank()); assertEquals(1, getCallerShortcut("s10").getRank()); assertEquals(7, getCallerShortcut("s3").getRank()); assertEquals(8, getCallerShortcut("s2").getRank()); assertEquals(0, getCallerShortcut("s6").getRank()); assertEquals(1, getCallerShortcut("s5").getRank()); assertEquals(2, getCallerShortcut("s3").getRank()); assertEquals(3, getCallerShortcut("s2").getRank()); mInjectedCurrentTimeMillis += INTERVAL; // reset // Test push when dropped shortcut is cached s13.setLongLived(); s13.setRank(100); mManager.pushDynamicShortcut(s13); assertEquals(9, getCallerShortcut("s13").getRank()); s8.setLongLived(); s8.setRank(100); mManager.pushDynamicShortcut(s8); assertEquals(4, getCallerShortcut("s8").getRank()); runWithCaller(LAUNCHER_1, USER_0, () -> { mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s13"), HANDLE_USER_0); mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s8"), HANDLE_USER_0); }); mManager.pushDynamicShortcut(s14); mManager.pushDynamicShortcut(s9); assertShortcutIds(assertAllNotKeyFieldsOnly(mManager.getDynamicShortcuts()), "s1", "s2", "s3", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s14"); "s1", "s2", "s3", "s5", "s6", "s7", "s9"); // Verify s13 stayed as cached assertShortcutIds(mManager.getShortcuts(ShortcutManager.FLAG_MATCH_CACHED), "s13"); "s8"); } public void testUnlimitedCalls() { Loading
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest11.java +25 −17 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.content.pm.LauncherApps.ShortcutQuery; import android.content.pm.ShortcutInfo; import android.os.test.TestLooper; import com.android.server.pm.ShortcutService.ConfigConstants; import org.mockito.ArgumentCaptor; import java.util.List; Loading Loading @@ -372,9 +374,11 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { } public void testShortcutChangeCallback_pushDynamicShortcut_existingId() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=3"); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10")))); assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3")))); }); ShortcutChangeCallback callback = mock(ShortcutChangeCallback.class); Loading @@ -384,7 +388,7 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { }); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { mManager.pushDynamicShortcut(makeShortcut("s5")); mManager.pushDynamicShortcut(makeShortcut("s2")); }); mTestLooper.dispatchAll(); Loading @@ -396,13 +400,15 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { assertWith(shortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s5"); .haveIds("s2"); } public void testShortcutChangeCallback_pushDynamicShortcut_causeDeletion() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=3"); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10")))); assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3")))); }); ShortcutChangeCallback callback = mock(ShortcutChangeCallback.class); Loading @@ -412,7 +418,7 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { }); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { mManager.pushDynamicShortcut(makeShortcut("s11")); mManager.pushDynamicShortcut(makeShortcut("s4")); }); mTestLooper.dispatchAll(); Loading @@ -427,31 +433,33 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { assertWith(changedShortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s11"); .haveIds("s4"); assertWith(removedShortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s10"); .haveIds("s3"); } public void testShortcutChangeCallback_pushDynamicShortcut_causeDeletionButCached() { // Change the max number of shortcuts. mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=3"); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9")))); ShortcutInfo s10 = makeLongLivedShortcut("s10"); s10.setRank(10); mManager.pushDynamicShortcut(s10); // Add a long lived shortcut to the end of the list. assertTrue(mManager.setDynamicShortcuts((makeShortcuts("s1", "s2")))); ShortcutInfo s3 = makeLongLivedShortcut("s3"); s3.setRank(3); mManager.pushDynamicShortcut(s3); // Add a long lived shortcut to the end of the list. }); ShortcutChangeCallback callback = mock(ShortcutChangeCallback.class); runWithCaller(LAUNCHER_1, USER_0, () -> { mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s10"), HANDLE_USER_0); mLauncherApps.cacheShortcuts(CALLING_PACKAGE_1, list("s3"), HANDLE_USER_0); mLauncherApps.registerShortcutChangeCallback(callback, QUERY_MATCH_ALL, mTestLooper.getNewExecutor()); }); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { mManager.pushDynamicShortcut(makeShortcut("s11")); mManager.pushDynamicShortcut(makeShortcut("s4")); }); mTestLooper.dispatchAll(); Loading @@ -463,7 +471,7 @@ public class ShortcutManagerTest11 extends BaseShortcutManagerTest { assertWith(shortcuts.getValue()) .areAllWithKeyFieldsOnly() .haveIds("s10", "s11"); .haveIds("s3", "s4"); } public void testShortcutChangeCallback_disableShortcuts() { Loading