Loading services/core/java/com/android/server/pm/ShortcutPackage.java +15 −10 Original line number Diff line number Diff line Loading @@ -663,12 +663,14 @@ class ShortcutPackage extends ShortcutPackageItem { }); // Then, update the pinned state if necessary. final List<ShortcutInfo> pinned = getShortcutById(pinnedShortcuts); if (pinned != null) { pinned.forEach(si -> { if (!si.isPinned()) { si.addFlags(ShortcutInfo.FLAG_PINNED); } }); saveShortcut(pinned); } forEachShortcutMutateIf(AppSearchShortcutInfo.QUERY_IS_PINNED, si -> { if (!pinnedShortcuts.contains(si.getId()) && si.isPinned()) { si.clearFlags(ShortcutInfo.FLAG_PINNED); Loading Loading @@ -826,11 +828,13 @@ class ShortcutPackage extends ShortcutPackageItem { : s.getLauncherShortcutsLocked(callingLauncher, getPackageUserId(), launcherUserId) .getPinnedShortcutIds(getPackageName(), getPackageUserId()); final List<ShortcutInfo> shortcuts = getShortcutById(ids); if (shortcuts != null) { for (ShortcutInfo si : shortcuts) { filter(result, query, cloneFlag, callingLauncher, pinnedByCallerSet, getPinnedByAnyLauncher, si); } } } /** * Find all pinned shortcuts that match {@code query}. Loading Loading @@ -1903,7 +1907,8 @@ class ShortcutPackage extends ShortcutPackageItem { final ShortcutPackage ret = new ShortcutPackage(shortcutUser, shortcutUser.getUserId(), packageName); ret.mIsInitilized = ShortcutService.parseIntAttribute(parser, ATTR_SCHEMA_VERSON, 0) > 0; ret.mIsInitilized = ShortcutService.parseIntAttribute(parser, ATTR_SCHEMA_VERSON, 0) == AppSearchShortcutInfo.SCHEMA_VERSION; ret.mApiCallCount = ShortcutService.parseIntAttribute(parser, ATTR_CALL_COUNT); ret.mLastResetTime = Loading services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; Loading Loading @@ -2598,6 +2599,13 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { }).when(mMockPackageManagerInternal).getHomeActivitiesAsUser(any(List.class), eq(userId)); } protected void prepareIntentActivities(ComponentName cn) { when(mMockPackageManagerInternal.queryIntentActivities( anyOrNull(Intent.class), anyStringOrNull(), anyInt(), anyInt(), anyInt())) .thenReturn(Collections.singletonList( ri(cn.getPackageName(), cn.getClassName(), false, 0))); } protected static ComponentName cn(String packageName, String name) { return new ComponentName(packageName, name); } Loading services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest10.java +1 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,7 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest { public void testStartConfigActivity_defaultLauncher() { LauncherActivityInfo info = setupMockActivityInfo(); prepareIntentActivities(info.getComponentName()); setDefaultLauncher(USER_0, LAUNCHER_1); runWithCaller(LAUNCHER_1, USER_0, () -> assertNotNull(mLauncherApps.getShortcutConfigActivityIntent(info)) Loading Loading
services/core/java/com/android/server/pm/ShortcutPackage.java +15 −10 Original line number Diff line number Diff line Loading @@ -663,12 +663,14 @@ class ShortcutPackage extends ShortcutPackageItem { }); // Then, update the pinned state if necessary. final List<ShortcutInfo> pinned = getShortcutById(pinnedShortcuts); if (pinned != null) { pinned.forEach(si -> { if (!si.isPinned()) { si.addFlags(ShortcutInfo.FLAG_PINNED); } }); saveShortcut(pinned); } forEachShortcutMutateIf(AppSearchShortcutInfo.QUERY_IS_PINNED, si -> { if (!pinnedShortcuts.contains(si.getId()) && si.isPinned()) { si.clearFlags(ShortcutInfo.FLAG_PINNED); Loading Loading @@ -826,11 +828,13 @@ class ShortcutPackage extends ShortcutPackageItem { : s.getLauncherShortcutsLocked(callingLauncher, getPackageUserId(), launcherUserId) .getPinnedShortcutIds(getPackageName(), getPackageUserId()); final List<ShortcutInfo> shortcuts = getShortcutById(ids); if (shortcuts != null) { for (ShortcutInfo si : shortcuts) { filter(result, query, cloneFlag, callingLauncher, pinnedByCallerSet, getPinnedByAnyLauncher, si); } } } /** * Find all pinned shortcuts that match {@code query}. Loading Loading @@ -1903,7 +1907,8 @@ class ShortcutPackage extends ShortcutPackageItem { final ShortcutPackage ret = new ShortcutPackage(shortcutUser, shortcutUser.getUserId(), packageName); ret.mIsInitilized = ShortcutService.parseIntAttribute(parser, ATTR_SCHEMA_VERSON, 0) > 0; ret.mIsInitilized = ShortcutService.parseIntAttribute(parser, ATTR_SCHEMA_VERSON, 0) == AppSearchShortcutInfo.SCHEMA_VERSION; ret.mApiCallCount = ShortcutService.parseIntAttribute(parser, ATTR_CALL_COUNT); ret.mLastResetTime = Loading
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; Loading Loading @@ -2598,6 +2599,13 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { }).when(mMockPackageManagerInternal).getHomeActivitiesAsUser(any(List.class), eq(userId)); } protected void prepareIntentActivities(ComponentName cn) { when(mMockPackageManagerInternal.queryIntentActivities( anyOrNull(Intent.class), anyStringOrNull(), anyInt(), anyInt(), anyInt())) .thenReturn(Collections.singletonList( ri(cn.getPackageName(), cn.getClassName(), false, 0))); } protected static ComponentName cn(String packageName, String name) { return new ComponentName(packageName, name); } Loading
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest10.java +1 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,7 @@ public class ShortcutManagerTest10 extends BaseShortcutManagerTest { public void testStartConfigActivity_defaultLauncher() { LauncherActivityInfo info = setupMockActivityInfo(); prepareIntentActivities(info.getComponentName()); setDefaultLauncher(USER_0, LAUNCHER_1); runWithCaller(LAUNCHER_1, USER_0, () -> assertNotNull(mLauncherApps.getShortcutConfigActivityIntent(info)) Loading