Loading services/core/java/com/android/server/pm/ShortcutPackage.java +5 −14 Original line number Original line Diff line number Diff line Loading @@ -708,8 +708,6 @@ class ShortcutPackage extends ShortcutPackageItem { getPackageInfo().updateVersionInfo(pi); getPackageInfo().updateVersionInfo(pi); boolean changed = false; // For existing shortcuts, update timestamps if they have any resources. // For existing shortcuts, update timestamps if they have any resources. // Also check if shortcuts' activities are still main activities. Otherwise, disable them. // Also check if shortcuts' activities are still main activities. Otherwise, disable them. if (!isNewApp) { if (!isNewApp) { Loading @@ -733,7 +731,6 @@ class ShortcutPackage extends ShortcutPackageItem { } } // Still pinned, so fall-through and possibly update the resources. // Still pinned, so fall-through and possibly update the resources. } } changed = true; } } if (si.hasAnyResources()) { if (si.hasAnyResources()) { Loading @@ -750,29 +747,23 @@ class ShortcutPackage extends ShortcutPackageItem { // non-manifest at the moment, but icons can still be resources.) // non-manifest at the moment, but icons can still be resources.) si.lookupAndFillInResourceIds(publisherRes); si.lookupAndFillInResourceIds(publisherRes); } } changed = true; si.setTimestamp(s.injectCurrentTimeMillis()); si.setTimestamp(s.injectCurrentTimeMillis()); } } } } } } // (Re-)publish manifest shortcut. // (Re-)publish manifest shortcut. changed |= publishManifestShortcuts(newManifestShortcutList); publishManifestShortcuts(newManifestShortcutList); if (newManifestShortcutList != null) { if (newManifestShortcutList != null) { changed |= pushOutExcessShortcuts(); pushOutExcessShortcuts(); } } s.verifyStates(); s.verifyStates(); if (changed) { // This will send a notification to the launcher, and also save . // This will send a notification to the launcher, and also save . s.packageShortcutsChanged(getPackageName(), getPackageUserId()); s.packageShortcutsChanged(getPackageName(), getPackageUserId()); } else { return true; // true means changed. // Still save the version code. s.scheduleSaveUser(getPackageUserId()); } return changed; } } private boolean publishManifestShortcuts(List<ShortcutInfo> newManifestShortcutList) { private boolean publishManifestShortcuts(List<ShortcutInfo> newManifestShortcutList) { Loading services/core/java/com/android/server/pm/ShortcutService.java +10 −5 Original line number Original line Diff line number Diff line Loading @@ -1575,15 +1575,15 @@ public class ShortcutService extends IShortcutService.Stub { * - Write to file * - Write to file */ */ void packageShortcutsChanged(@NonNull String packageName, @UserIdInt int userId) { void packageShortcutsChanged(@NonNull String packageName, @UserIdInt int userId) { if (DEBUG) { Slog.d(TAG, String.format( "Shortcut changes: package=%s, user=%d", packageName, userId)); } notifyListeners(packageName, userId); notifyListeners(packageName, userId); scheduleSaveUser(userId); scheduleSaveUser(userId); } } private void notifyListeners(@NonNull String packageName, @UserIdInt int userId) { private void notifyListeners(@NonNull String packageName, @UserIdInt int userId) { if (DEBUG) { Slog.d(TAG, String.format( "Shortcut changes: package=%s, user=%d", packageName, userId)); } injectPostToHandler(() -> { injectPostToHandler(() -> { try { try { final ArrayList<ShortcutChangeListener> copy; final ArrayList<ShortcutChangeListener> copy; Loading Loading @@ -2896,6 +2896,11 @@ public class ShortcutService extends IShortcutService.Stub { } } private void handlePackageChanged(String packageName, int packageUserId) { private void handlePackageChanged(String packageName, int packageUserId) { if (!isPackageInstalled(packageName, packageUserId)) { // Probably disabled, which is the same thing as uninstalled. handlePackageRemoved(packageName, packageUserId); return; } if (DEBUG) { if (DEBUG) { Slog.d(TAG, String.format("handlePackageChanged: %s user=%d", packageName, Slog.d(TAG, String.format("handlePackageChanged: %s user=%d", packageName, packageUserId)); packageUserId)); Loading Loading @@ -3111,7 +3116,7 @@ public class ShortcutService extends IShortcutService.Stub { } } private static boolean isInstalled(@Nullable ApplicationInfo ai) { private static boolean isInstalled(@Nullable ApplicationInfo ai) { return (ai != null) && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0; return (ai != null) && ai.enabled && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0; } } private static boolean isEphemeralApp(@Nullable ApplicationInfo ai) { private static boolean isEphemeralApp(@Nullable ApplicationInfo ai) { Loading services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -569,6 +569,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected Map<String, PackageInfo> mInjectedPackages; protected Map<String, PackageInfo> mInjectedPackages; protected Set<PackageWithUser> mUninstalledPackages; protected Set<PackageWithUser> mUninstalledPackages; protected Set<PackageWithUser> mDisabledPackages; protected Set<PackageWithUser> mEphemeralPackages; protected Set<PackageWithUser> mEphemeralPackages; protected Set<String> mSystemPackages; protected Set<String> mSystemPackages; Loading Loading @@ -740,6 +741,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { pi -> pi.applicationInfo.flags &= ~ApplicationInfo.FLAG_ALLOW_BACKUP); pi -> pi.applicationInfo.flags &= ~ApplicationInfo.FLAG_ALLOW_BACKUP); mUninstalledPackages = new HashSet<>(); mUninstalledPackages = new HashSet<>(); mDisabledPackages = new HashSet<>(); mSystemPackages = new HashSet<>(); mSystemPackages = new HashSet<>(); mEphemeralPackages = new HashSet<>(); mEphemeralPackages = new HashSet<>(); Loading Loading @@ -1026,7 +1028,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected void uninstallPackage(int userId, String packageName) { protected void uninstallPackage(int userId, String packageName) { if (ENABLE_DUMP) { if (ENABLE_DUMP) { Log.v(TAG, "Unnstall package " + packageName + " / " + userId); Log.v(TAG, "Uninstall package " + packageName + " / " + userId); } } mUninstalledPackages.add(PackageWithUser.of(userId, packageName)); mUninstalledPackages.add(PackageWithUser.of(userId, packageName)); } } Loading @@ -1038,6 +1040,20 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { mUninstalledPackages.remove(PackageWithUser.of(userId, packageName)); mUninstalledPackages.remove(PackageWithUser.of(userId, packageName)); } } protected void disablePackage(int userId, String packageName) { if (ENABLE_DUMP) { Log.v(TAG, "Disable package " + packageName + " / " + userId); } mDisabledPackages.add(PackageWithUser.of(userId, packageName)); } protected void enablePackage(int userId, String packageName) { if (ENABLE_DUMP) { Log.v(TAG, "Enable package " + packageName + " / " + userId); } mDisabledPackages.remove(PackageWithUser.of(userId, packageName)); } PackageInfo getInjectedPackageInfo(String packageName, @UserIdInt int userId, PackageInfo getInjectedPackageInfo(String packageName, @UserIdInt int userId, boolean getSignatures) { boolean getSignatures) { final PackageInfo pi = mInjectedPackages.get(packageName); final PackageInfo pi = mInjectedPackages.get(packageName); Loading @@ -1061,6 +1077,8 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { if (mSystemPackages.contains(packageName)) { if (mSystemPackages.contains(packageName)) { ret.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM; ret.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM; } } ret.applicationInfo.enabled = !mDisabledPackages.contains(PackageWithUser.of(userId, packageName)); if (getSignatures) { if (getSignatures) { ret.signatures = pi.signatures; ret.signatures = pi.signatures; Loading services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java +20 −6 Original line number Original line Diff line number Diff line Loading @@ -102,6 +102,8 @@ import java.io.File; import java.io.IOException; import java.io.IOException; import java.util.List; import java.util.List; import java.util.Locale; import java.util.Locale; import java.util.function.BiConsumer; import java.util.function.BiPredicate; /** /** * Tests for ShortcutService and ShortcutManager. * Tests for ShortcutService and ShortcutManager. Loading Loading @@ -3967,6 +3969,22 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { } } public void testHandlePackageDelete() { public void testHandlePackageDelete() { checkHandlePackageDeleteInner((userId, packageName) -> { uninstallPackage(userId, packageName); mService.mPackageMonitor.onReceive(getTestContext(), genPackageDeleteIntent(packageName, userId)); }); } public void testHandlePackageDisable() { checkHandlePackageDeleteInner((userId, packageName) -> { disablePackage(userId, packageName); mService.mPackageMonitor.onReceive(getTestContext(), genPackageChangedIntent(packageName, userId)); }); } private void checkHandlePackageDeleteInner(BiConsumer<Integer, String> remover) { final Icon bmp32x32 = Icon.createWithBitmap(BitmapFactory.decodeResource( final Icon bmp32x32 = Icon.createWithBitmap(BitmapFactory.decodeResource( getTestContext().getResources(), R.drawable.black_32x32)); getTestContext().getResources(), R.drawable.black_32x32)); setCaller(CALLING_PACKAGE_1, USER_0); setCaller(CALLING_PACKAGE_1, USER_0); Loading Loading @@ -4019,9 +4037,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_2, USER_10)); assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_2, USER_10)); assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_3, USER_10)); assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_3, USER_10)); uninstallPackage(USER_0, CALLING_PACKAGE_1); remover.accept(USER_0, CALLING_PACKAGE_1); mService.mPackageMonitor.onReceive(getTestContext(), genPackageDeleteIntent(CALLING_PACKAGE_1, USER_0)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); Loading @@ -4039,9 +4055,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { mRunningUsers.put(USER_10, true); mRunningUsers.put(USER_10, true); uninstallPackage(USER_10, CALLING_PACKAGE_2); remover.accept(USER_10, CALLING_PACKAGE_2); mService.mPackageMonitor.onReceive(getTestContext(), genPackageDeleteIntent(CALLING_PACKAGE_2, USER_10)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); Loading services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyList; import static org.mockito.Matchers.anyList; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.times; Loading Loading @@ -1096,7 +1097,7 @@ public class ShortcutManagerTestUtils { public ShortcutListAsserter assertCallbackCalledForPackageAndUser( public ShortcutListAsserter assertCallbackCalledForPackageAndUser( String publisherPackageName, UserHandle publisherUserHandle) { String publisherPackageName, UserHandle publisherUserHandle) { final ArgumentCaptor<List> shortcuts = ArgumentCaptor.forClass(List.class); final ArgumentCaptor<List> shortcuts = ArgumentCaptor.forClass(List.class); verify(mCallback, times(1)).onShortcutsChanged( verify(mCallback, atLeastOnce()).onShortcutsChanged( eq(publisherPackageName), eq(publisherPackageName), shortcuts.capture(), shortcuts.capture(), eq(publisherUserHandle)); eq(publisherUserHandle)); Loading Loading
services/core/java/com/android/server/pm/ShortcutPackage.java +5 −14 Original line number Original line Diff line number Diff line Loading @@ -708,8 +708,6 @@ class ShortcutPackage extends ShortcutPackageItem { getPackageInfo().updateVersionInfo(pi); getPackageInfo().updateVersionInfo(pi); boolean changed = false; // For existing shortcuts, update timestamps if they have any resources. // For existing shortcuts, update timestamps if they have any resources. // Also check if shortcuts' activities are still main activities. Otherwise, disable them. // Also check if shortcuts' activities are still main activities. Otherwise, disable them. if (!isNewApp) { if (!isNewApp) { Loading @@ -733,7 +731,6 @@ class ShortcutPackage extends ShortcutPackageItem { } } // Still pinned, so fall-through and possibly update the resources. // Still pinned, so fall-through and possibly update the resources. } } changed = true; } } if (si.hasAnyResources()) { if (si.hasAnyResources()) { Loading @@ -750,29 +747,23 @@ class ShortcutPackage extends ShortcutPackageItem { // non-manifest at the moment, but icons can still be resources.) // non-manifest at the moment, but icons can still be resources.) si.lookupAndFillInResourceIds(publisherRes); si.lookupAndFillInResourceIds(publisherRes); } } changed = true; si.setTimestamp(s.injectCurrentTimeMillis()); si.setTimestamp(s.injectCurrentTimeMillis()); } } } } } } // (Re-)publish manifest shortcut. // (Re-)publish manifest shortcut. changed |= publishManifestShortcuts(newManifestShortcutList); publishManifestShortcuts(newManifestShortcutList); if (newManifestShortcutList != null) { if (newManifestShortcutList != null) { changed |= pushOutExcessShortcuts(); pushOutExcessShortcuts(); } } s.verifyStates(); s.verifyStates(); if (changed) { // This will send a notification to the launcher, and also save . // This will send a notification to the launcher, and also save . s.packageShortcutsChanged(getPackageName(), getPackageUserId()); s.packageShortcutsChanged(getPackageName(), getPackageUserId()); } else { return true; // true means changed. // Still save the version code. s.scheduleSaveUser(getPackageUserId()); } return changed; } } private boolean publishManifestShortcuts(List<ShortcutInfo> newManifestShortcutList) { private boolean publishManifestShortcuts(List<ShortcutInfo> newManifestShortcutList) { Loading
services/core/java/com/android/server/pm/ShortcutService.java +10 −5 Original line number Original line Diff line number Diff line Loading @@ -1575,15 +1575,15 @@ public class ShortcutService extends IShortcutService.Stub { * - Write to file * - Write to file */ */ void packageShortcutsChanged(@NonNull String packageName, @UserIdInt int userId) { void packageShortcutsChanged(@NonNull String packageName, @UserIdInt int userId) { if (DEBUG) { Slog.d(TAG, String.format( "Shortcut changes: package=%s, user=%d", packageName, userId)); } notifyListeners(packageName, userId); notifyListeners(packageName, userId); scheduleSaveUser(userId); scheduleSaveUser(userId); } } private void notifyListeners(@NonNull String packageName, @UserIdInt int userId) { private void notifyListeners(@NonNull String packageName, @UserIdInt int userId) { if (DEBUG) { Slog.d(TAG, String.format( "Shortcut changes: package=%s, user=%d", packageName, userId)); } injectPostToHandler(() -> { injectPostToHandler(() -> { try { try { final ArrayList<ShortcutChangeListener> copy; final ArrayList<ShortcutChangeListener> copy; Loading Loading @@ -2896,6 +2896,11 @@ public class ShortcutService extends IShortcutService.Stub { } } private void handlePackageChanged(String packageName, int packageUserId) { private void handlePackageChanged(String packageName, int packageUserId) { if (!isPackageInstalled(packageName, packageUserId)) { // Probably disabled, which is the same thing as uninstalled. handlePackageRemoved(packageName, packageUserId); return; } if (DEBUG) { if (DEBUG) { Slog.d(TAG, String.format("handlePackageChanged: %s user=%d", packageName, Slog.d(TAG, String.format("handlePackageChanged: %s user=%d", packageName, packageUserId)); packageUserId)); Loading Loading @@ -3111,7 +3116,7 @@ public class ShortcutService extends IShortcutService.Stub { } } private static boolean isInstalled(@Nullable ApplicationInfo ai) { private static boolean isInstalled(@Nullable ApplicationInfo ai) { return (ai != null) && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0; return (ai != null) && ai.enabled && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0; } } private static boolean isEphemeralApp(@Nullable ApplicationInfo ai) { private static boolean isEphemeralApp(@Nullable ApplicationInfo ai) { Loading
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -569,6 +569,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected Map<String, PackageInfo> mInjectedPackages; protected Map<String, PackageInfo> mInjectedPackages; protected Set<PackageWithUser> mUninstalledPackages; protected Set<PackageWithUser> mUninstalledPackages; protected Set<PackageWithUser> mDisabledPackages; protected Set<PackageWithUser> mEphemeralPackages; protected Set<PackageWithUser> mEphemeralPackages; protected Set<String> mSystemPackages; protected Set<String> mSystemPackages; Loading Loading @@ -740,6 +741,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { pi -> pi.applicationInfo.flags &= ~ApplicationInfo.FLAG_ALLOW_BACKUP); pi -> pi.applicationInfo.flags &= ~ApplicationInfo.FLAG_ALLOW_BACKUP); mUninstalledPackages = new HashSet<>(); mUninstalledPackages = new HashSet<>(); mDisabledPackages = new HashSet<>(); mSystemPackages = new HashSet<>(); mSystemPackages = new HashSet<>(); mEphemeralPackages = new HashSet<>(); mEphemeralPackages = new HashSet<>(); Loading Loading @@ -1026,7 +1028,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected void uninstallPackage(int userId, String packageName) { protected void uninstallPackage(int userId, String packageName) { if (ENABLE_DUMP) { if (ENABLE_DUMP) { Log.v(TAG, "Unnstall package " + packageName + " / " + userId); Log.v(TAG, "Uninstall package " + packageName + " / " + userId); } } mUninstalledPackages.add(PackageWithUser.of(userId, packageName)); mUninstalledPackages.add(PackageWithUser.of(userId, packageName)); } } Loading @@ -1038,6 +1040,20 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { mUninstalledPackages.remove(PackageWithUser.of(userId, packageName)); mUninstalledPackages.remove(PackageWithUser.of(userId, packageName)); } } protected void disablePackage(int userId, String packageName) { if (ENABLE_DUMP) { Log.v(TAG, "Disable package " + packageName + " / " + userId); } mDisabledPackages.add(PackageWithUser.of(userId, packageName)); } protected void enablePackage(int userId, String packageName) { if (ENABLE_DUMP) { Log.v(TAG, "Enable package " + packageName + " / " + userId); } mDisabledPackages.remove(PackageWithUser.of(userId, packageName)); } PackageInfo getInjectedPackageInfo(String packageName, @UserIdInt int userId, PackageInfo getInjectedPackageInfo(String packageName, @UserIdInt int userId, boolean getSignatures) { boolean getSignatures) { final PackageInfo pi = mInjectedPackages.get(packageName); final PackageInfo pi = mInjectedPackages.get(packageName); Loading @@ -1061,6 +1077,8 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { if (mSystemPackages.contains(packageName)) { if (mSystemPackages.contains(packageName)) { ret.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM; ret.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM; } } ret.applicationInfo.enabled = !mDisabledPackages.contains(PackageWithUser.of(userId, packageName)); if (getSignatures) { if (getSignatures) { ret.signatures = pi.signatures; ret.signatures = pi.signatures; Loading
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java +20 −6 Original line number Original line Diff line number Diff line Loading @@ -102,6 +102,8 @@ import java.io.File; import java.io.IOException; import java.io.IOException; import java.util.List; import java.util.List; import java.util.Locale; import java.util.Locale; import java.util.function.BiConsumer; import java.util.function.BiPredicate; /** /** * Tests for ShortcutService and ShortcutManager. * Tests for ShortcutService and ShortcutManager. Loading Loading @@ -3967,6 +3969,22 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { } } public void testHandlePackageDelete() { public void testHandlePackageDelete() { checkHandlePackageDeleteInner((userId, packageName) -> { uninstallPackage(userId, packageName); mService.mPackageMonitor.onReceive(getTestContext(), genPackageDeleteIntent(packageName, userId)); }); } public void testHandlePackageDisable() { checkHandlePackageDeleteInner((userId, packageName) -> { disablePackage(userId, packageName); mService.mPackageMonitor.onReceive(getTestContext(), genPackageChangedIntent(packageName, userId)); }); } private void checkHandlePackageDeleteInner(BiConsumer<Integer, String> remover) { final Icon bmp32x32 = Icon.createWithBitmap(BitmapFactory.decodeResource( final Icon bmp32x32 = Icon.createWithBitmap(BitmapFactory.decodeResource( getTestContext().getResources(), R.drawable.black_32x32)); getTestContext().getResources(), R.drawable.black_32x32)); setCaller(CALLING_PACKAGE_1, USER_0); setCaller(CALLING_PACKAGE_1, USER_0); Loading Loading @@ -4019,9 +4037,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_2, USER_10)); assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_2, USER_10)); assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_3, USER_10)); assertTrue(bitmapDirectoryExists(CALLING_PACKAGE_3, USER_10)); uninstallPackage(USER_0, CALLING_PACKAGE_1); remover.accept(USER_0, CALLING_PACKAGE_1); mService.mPackageMonitor.onReceive(getTestContext(), genPackageDeleteIntent(CALLING_PACKAGE_1, USER_0)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); Loading @@ -4039,9 +4055,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { mRunningUsers.put(USER_10, true); mRunningUsers.put(USER_10, true); uninstallPackage(USER_10, CALLING_PACKAGE_2); remover.accept(USER_10, CALLING_PACKAGE_2); mService.mPackageMonitor.onReceive(getTestContext(), genPackageDeleteIntent(CALLING_PACKAGE_2, USER_10)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); assertNotNull(mService.getPackageShortcutForTest(CALLING_PACKAGE_2, "s1", USER_0)); Loading
services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyList; import static org.mockito.Matchers.anyList; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.times; Loading Loading @@ -1096,7 +1097,7 @@ public class ShortcutManagerTestUtils { public ShortcutListAsserter assertCallbackCalledForPackageAndUser( public ShortcutListAsserter assertCallbackCalledForPackageAndUser( String publisherPackageName, UserHandle publisherUserHandle) { String publisherPackageName, UserHandle publisherUserHandle) { final ArgumentCaptor<List> shortcuts = ArgumentCaptor.forClass(List.class); final ArgumentCaptor<List> shortcuts = ArgumentCaptor.forClass(List.class); verify(mCallback, times(1)).onShortcutsChanged( verify(mCallback, atLeastOnce()).onShortcutsChanged( eq(publisherPackageName), eq(publisherPackageName), shortcuts.capture(), shortcuts.capture(), eq(publisherUserHandle)); eq(publisherUserHandle)); Loading