Loading core/java/android/content/pm/ShortcutInfo.java +1 −6 Original line number Diff line number Diff line Loading @@ -1061,11 +1061,6 @@ public final class ShortcutInfo implements Parcelable { * Launcher apps should show the launcher icon for the returned activity alongside * this shortcut. * * <p>When a shortcut is dynamic or manifest * (i.e. either {@link #isDynamic()} or {@link #isDeclaredInManifest()} returns {@code TRUE}), * then it should always have a non-null target activity. * Otherwise it will return null. * * @see Builder#setActivity */ @Nullable Loading Loading @@ -1372,7 +1367,7 @@ public final class ShortcutInfo implements Parcelable { } /** * Return {@code TRUE} if a shortcut is pinned but neither manifest nor dynamic. * @return true if pinned but neither static nor dynamic. * @hide */ public boolean isFloating() { Loading services/core/java/com/android/server/pm/ShortcutPackage.java +5 −24 Original line number Diff line number Diff line Loading @@ -259,11 +259,6 @@ class ShortcutPackage extends ShortcutPackageItem { for (int i = mShortcuts.size() - 1; i >= 0; i--) { final ShortcutInfo si = mShortcuts.valueAt(i); if (si.isFloating()) { si.setRank(0); si.setActivity(null); } if (si.isAlive()) continue; if (removeList == null) { Loading Loading @@ -293,7 +288,6 @@ class ShortcutPackage extends ShortcutPackageItem { si.setTimestamp(now); si.clearFlags(ShortcutInfo.FLAG_DYNAMIC); si.setRank(0); // It may still be pinned, so clear the rank. si.setActivity(null); } } if (changed) { Loading Loading @@ -361,7 +355,6 @@ class ShortcutPackage extends ShortcutPackageItem { if (oldShortcut.isPinned()) { oldShortcut.setRank(0); oldShortcut.setActivity(null); oldShortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC | ShortcutInfo.FLAG_MANIFEST); if (disable) { oldShortcut.addFlags(ShortcutInfo.FLAG_DISABLED); Loading Loading @@ -602,10 +595,6 @@ class ShortcutPackage extends ShortcutPackageItem { for (int i = mShortcuts.size() - 1; i >= 0; i--) { final ShortcutInfo si = mShortcuts.valueAt(i); if (si.isFloating()) { continue; // Ignore floating shortcuts, which are not tied to any activities. } final ComponentName activity = si.getActivity(); if (checked.contains(activity)) { Loading Loading @@ -1368,10 +1357,6 @@ class ShortcutPackage extends ShortcutPackageItem { case TAG_SHORTCUT: final ShortcutInfo si = parseShortcut(parser, packageName, shortcutUser.getUserId()); // Floating shortcut used to have target activities, but not anymore. if (si.isFloating()) { // Not really needed by just in case. si.setActivity(null); } // Don't use addShortcut(), we don't need to save the icon. ret.mShortcuts.put(si.getId(), si); Loading Loading @@ -1478,6 +1463,7 @@ class ShortcutPackage extends ShortcutPackageItem { intents.clear(); intents.add(intentLegacy); } return new ShortcutInfo( userId, id, packageName, activityComponent, /* icon =*/ null, title, titleResId, titleResName, text, textResId, textResName, Loading Loading @@ -1568,17 +1554,12 @@ class ShortcutPackage extends ShortcutPackageItem { Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is both dynamic and manifest at the same time."); } if (!si.isFloating() && si.getActivity() == null) { failed = true; Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is not floating, but has null activity."); } if (si.isFloating() && si.getActivity() != null) { if (si.getActivity() == null) { failed = true; Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is floating, but has non-null activity."); + " has null activity."); } if (!si.isFloating() && !si.isEnabled()) { if ((si.isDynamic() || si.isManifestShortcut()) && !si.isEnabled()) { failed = true; Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is not floating, but is disabled."); Loading @@ -1601,7 +1582,7 @@ class ShortcutPackage extends ShortcutPackageItem { } if (failed) { mShortcutUser.mService.verifyError(); throw new IllegalStateException("See logcat for errors"); } } Loading services/core/java/com/android/server/pm/ShortcutService.java +2 −12 Original line number Diff line number Diff line Loading @@ -129,7 +129,6 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.function.Predicate; Loading Loading @@ -413,9 +412,6 @@ public class ShortcutService extends IShortcutService.Stub { @VisibleForTesting ShortcutService(Context context, Looper looper, boolean onlyForPackageManagerApis) { if (DEBUG) { Binder.LOG_RUNTIME_EXCEPTION = true; } mContext = Preconditions.checkNotNull(context); LocalServices.addService(ShortcutServiceInternal.class, new LocalService()); mHandler = new Handler(looper); Loading Loading @@ -1778,9 +1774,6 @@ public class ShortcutService extends IShortcutService.Stub { // Note copyNonNullFieldsFrom() does the "updatable with?" check too. target.copyNonNullFieldsFrom(source); if (target.isFloating()) { target.setActivity(null); } target.setTimestamp(injectCurrentTimeMillis()); if (replacingIcon) { Loading Loading @@ -2414,7 +2407,8 @@ public class ShortcutService extends IShortcutService.Stub { return false; } if (componentName != null) { if (!Objects.equals(componentName, si.getActivity())) { if (si.getActivity() != null && !si.getActivity().equals(componentName)) { return false; } } Loading Loading @@ -3934,8 +3928,4 @@ public class ShortcutService extends IShortcutService.Stub { forEachLoadedUserLocked(u -> u.forAllPackageItems(ShortcutPackageItem::verifyStates)); } } void verifyError() { Slog.e(TAG, "See logcat for errors"); } } services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +0 −6 Original line number Diff line number Diff line Loading @@ -404,7 +404,6 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { @Override boolean injectIsActivityEnabledAndExported(ComponentName activity, @UserIdInt int userId) { assertNotNull(activity); return mEnabledActivityChecker.test(activity, userId); } Loading Loading @@ -450,11 +449,6 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { // During tests, WTF is fatal. fail(message + " exception: " + th + "\n" + Log.getStackTraceString(th)); } @Override void verifyError() { fail("Verify error"); } } /** ShortcutManager with injection override methods. */ Loading services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java +1 −37 Original line number Diff line number Diff line Loading @@ -1292,43 +1292,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { /* activity =*/ null, /* flags */ 0), getCallingUser()); }); // Make sure floating shortcuts don't match with an activity. // At this point, s1 is dynamic and pinned, so it still has a target activity. runWithCaller(LAUNCHER_1, USER_0, () -> { assertWith(mLauncherApps.getShortcuts(buildQuery( /* time =*/ 0, CALLING_PACKAGE_2, /* activity =*/ new ComponentName(CALLING_PACKAGE_2, ShortcutActivity2.class.getName()), ShortcutQuery.FLAG_GET_PINNED), getCallingUser())) .haveIds("s3") .areAllPinned() .areAllDynamic() .areAllWithActivity(new ComponentName(CALLING_PACKAGE_2, ShortcutActivity2.class.getName())); }); // Now remove as a dynamic, making it floating. runWithCaller(CALLING_PACKAGE_2, USER_0, () -> { mManager.removeDynamicShortcuts(list("s3")); assertWith(mManager.getPinnedShortcuts()) .selectFloating() .areAllWithNoActivity(); }); runWithCaller(LAUNCHER_1, USER_0, () -> { // This shouldn't match now. assertWith(mLauncherApps.getShortcuts(buildQuery( /* time =*/ 0, CALLING_PACKAGE_2, /* activity =*/ new ComponentName(CALLING_PACKAGE_2, ShortcutActivity2.class.getName()), ShortcutQuery.FLAG_GET_PINNED), getCallingUser())) .isEmpty(); }); // TODO More tests: pinned but dynamic. } public void testGetShortcuts_shortcutKinds() throws Exception { Loading Loading
core/java/android/content/pm/ShortcutInfo.java +1 −6 Original line number Diff line number Diff line Loading @@ -1061,11 +1061,6 @@ public final class ShortcutInfo implements Parcelable { * Launcher apps should show the launcher icon for the returned activity alongside * this shortcut. * * <p>When a shortcut is dynamic or manifest * (i.e. either {@link #isDynamic()} or {@link #isDeclaredInManifest()} returns {@code TRUE}), * then it should always have a non-null target activity. * Otherwise it will return null. * * @see Builder#setActivity */ @Nullable Loading Loading @@ -1372,7 +1367,7 @@ public final class ShortcutInfo implements Parcelable { } /** * Return {@code TRUE} if a shortcut is pinned but neither manifest nor dynamic. * @return true if pinned but neither static nor dynamic. * @hide */ public boolean isFloating() { Loading
services/core/java/com/android/server/pm/ShortcutPackage.java +5 −24 Original line number Diff line number Diff line Loading @@ -259,11 +259,6 @@ class ShortcutPackage extends ShortcutPackageItem { for (int i = mShortcuts.size() - 1; i >= 0; i--) { final ShortcutInfo si = mShortcuts.valueAt(i); if (si.isFloating()) { si.setRank(0); si.setActivity(null); } if (si.isAlive()) continue; if (removeList == null) { Loading Loading @@ -293,7 +288,6 @@ class ShortcutPackage extends ShortcutPackageItem { si.setTimestamp(now); si.clearFlags(ShortcutInfo.FLAG_DYNAMIC); si.setRank(0); // It may still be pinned, so clear the rank. si.setActivity(null); } } if (changed) { Loading Loading @@ -361,7 +355,6 @@ class ShortcutPackage extends ShortcutPackageItem { if (oldShortcut.isPinned()) { oldShortcut.setRank(0); oldShortcut.setActivity(null); oldShortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC | ShortcutInfo.FLAG_MANIFEST); if (disable) { oldShortcut.addFlags(ShortcutInfo.FLAG_DISABLED); Loading Loading @@ -602,10 +595,6 @@ class ShortcutPackage extends ShortcutPackageItem { for (int i = mShortcuts.size() - 1; i >= 0; i--) { final ShortcutInfo si = mShortcuts.valueAt(i); if (si.isFloating()) { continue; // Ignore floating shortcuts, which are not tied to any activities. } final ComponentName activity = si.getActivity(); if (checked.contains(activity)) { Loading Loading @@ -1368,10 +1357,6 @@ class ShortcutPackage extends ShortcutPackageItem { case TAG_SHORTCUT: final ShortcutInfo si = parseShortcut(parser, packageName, shortcutUser.getUserId()); // Floating shortcut used to have target activities, but not anymore. if (si.isFloating()) { // Not really needed by just in case. si.setActivity(null); } // Don't use addShortcut(), we don't need to save the icon. ret.mShortcuts.put(si.getId(), si); Loading Loading @@ -1478,6 +1463,7 @@ class ShortcutPackage extends ShortcutPackageItem { intents.clear(); intents.add(intentLegacy); } return new ShortcutInfo( userId, id, packageName, activityComponent, /* icon =*/ null, title, titleResId, titleResName, text, textResId, textResName, Loading Loading @@ -1568,17 +1554,12 @@ class ShortcutPackage extends ShortcutPackageItem { Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is both dynamic and manifest at the same time."); } if (!si.isFloating() && si.getActivity() == null) { failed = true; Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is not floating, but has null activity."); } if (si.isFloating() && si.getActivity() != null) { if (si.getActivity() == null) { failed = true; Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is floating, but has non-null activity."); + " has null activity."); } if (!si.isFloating() && !si.isEnabled()) { if ((si.isDynamic() || si.isManifestShortcut()) && !si.isEnabled()) { failed = true; Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is not floating, but is disabled."); Loading @@ -1601,7 +1582,7 @@ class ShortcutPackage extends ShortcutPackageItem { } if (failed) { mShortcutUser.mService.verifyError(); throw new IllegalStateException("See logcat for errors"); } } Loading
services/core/java/com/android/server/pm/ShortcutService.java +2 −12 Original line number Diff line number Diff line Loading @@ -129,7 +129,6 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.function.Predicate; Loading Loading @@ -413,9 +412,6 @@ public class ShortcutService extends IShortcutService.Stub { @VisibleForTesting ShortcutService(Context context, Looper looper, boolean onlyForPackageManagerApis) { if (DEBUG) { Binder.LOG_RUNTIME_EXCEPTION = true; } mContext = Preconditions.checkNotNull(context); LocalServices.addService(ShortcutServiceInternal.class, new LocalService()); mHandler = new Handler(looper); Loading Loading @@ -1778,9 +1774,6 @@ public class ShortcutService extends IShortcutService.Stub { // Note copyNonNullFieldsFrom() does the "updatable with?" check too. target.copyNonNullFieldsFrom(source); if (target.isFloating()) { target.setActivity(null); } target.setTimestamp(injectCurrentTimeMillis()); if (replacingIcon) { Loading Loading @@ -2414,7 +2407,8 @@ public class ShortcutService extends IShortcutService.Stub { return false; } if (componentName != null) { if (!Objects.equals(componentName, si.getActivity())) { if (si.getActivity() != null && !si.getActivity().equals(componentName)) { return false; } } Loading Loading @@ -3934,8 +3928,4 @@ public class ShortcutService extends IShortcutService.Stub { forEachLoadedUserLocked(u -> u.forAllPackageItems(ShortcutPackageItem::verifyStates)); } } void verifyError() { Slog.e(TAG, "See logcat for errors"); } }
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +0 −6 Original line number Diff line number Diff line Loading @@ -404,7 +404,6 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { @Override boolean injectIsActivityEnabledAndExported(ComponentName activity, @UserIdInt int userId) { assertNotNull(activity); return mEnabledActivityChecker.test(activity, userId); } Loading Loading @@ -450,11 +449,6 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { // During tests, WTF is fatal. fail(message + " exception: " + th + "\n" + Log.getStackTraceString(th)); } @Override void verifyError() { fail("Verify error"); } } /** ShortcutManager with injection override methods. */ Loading
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java +1 −37 Original line number Diff line number Diff line Loading @@ -1292,43 +1292,7 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest { /* activity =*/ null, /* flags */ 0), getCallingUser()); }); // Make sure floating shortcuts don't match with an activity. // At this point, s1 is dynamic and pinned, so it still has a target activity. runWithCaller(LAUNCHER_1, USER_0, () -> { assertWith(mLauncherApps.getShortcuts(buildQuery( /* time =*/ 0, CALLING_PACKAGE_2, /* activity =*/ new ComponentName(CALLING_PACKAGE_2, ShortcutActivity2.class.getName()), ShortcutQuery.FLAG_GET_PINNED), getCallingUser())) .haveIds("s3") .areAllPinned() .areAllDynamic() .areAllWithActivity(new ComponentName(CALLING_PACKAGE_2, ShortcutActivity2.class.getName())); }); // Now remove as a dynamic, making it floating. runWithCaller(CALLING_PACKAGE_2, USER_0, () -> { mManager.removeDynamicShortcuts(list("s3")); assertWith(mManager.getPinnedShortcuts()) .selectFloating() .areAllWithNoActivity(); }); runWithCaller(LAUNCHER_1, USER_0, () -> { // This shouldn't match now. assertWith(mLauncherApps.getShortcuts(buildQuery( /* time =*/ 0, CALLING_PACKAGE_2, /* activity =*/ new ComponentName(CALLING_PACKAGE_2, ShortcutActivity2.class.getName()), ShortcutQuery.FLAG_GET_PINNED), getCallingUser())) .isEmpty(); }); // TODO More tests: pinned but dynamic. } public void testGetShortcuts_shortcutKinds() throws Exception { Loading