diff options
| author | 2022-12-21 20:20:54 +0000 | |
|---|---|---|
| committer | 2022-12-21 20:20:54 +0000 | |
| commit | ffc1ced6608de03c818fcc8fbb12977636bdd48d (patch) | |
| tree | 05ccebbde107e18ca2aed7f66e374143ed30dae9 | |
| parent | 953e263779816b51916ee0a8fea459861775dab6 (diff) | |
| parent | 293469e45e132d092d69cd6e675e3ddd28c06a58 (diff) | |
Merge "Revert "Implement a global maximum on number of shortcuts an app can publish"" into tm-dev am: fb4be8c37d am: 8a0fe06579 am: 42153dae5a am: 293469e45e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20750338
Change-Id: I55f67d1cb040d48910d2a2e66490ea4fe0ea320d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | services/core/java/com/android/server/pm/ShortcutPackage.java | 8 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/ShortcutService.java | 49 |
2 files changed, 8 insertions, 49 deletions
diff --git a/services/core/java/com/android/server/pm/ShortcutPackage.java b/services/core/java/com/android/server/pm/ShortcutPackage.java index 4fddc9c17b62..0362dddf09a8 100644 --- a/services/core/java/com/android/server/pm/ShortcutPackage.java +++ b/services/core/java/com/android/server/pm/ShortcutPackage.java @@ -1470,15 +1470,9 @@ class ShortcutPackage extends ShortcutPackageItem { } // Then make sure none of the activities have more than the max number of shortcuts. - int total = 0; for (int i = counts.size() - 1; i >= 0; i--) { - int count = counts.valueAt(i); - service.enforceMaxActivityShortcuts(count); - total += count; + service.enforceMaxActivityShortcuts(counts.valueAt(i)); } - - // Finally make sure that the app doesn't have more than the max number of shortcuts. - service.enforceMaxAppShortcuts(total); } /** diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java index 12a33ee488bb..83720f1445fa 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -181,9 +181,6 @@ public class ShortcutService extends IShortcutService.Stub { static final int DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY = 15; @VisibleForTesting - static final int DEFAULT_MAX_SHORTCUTS_PER_APP = 60; - - @VisibleForTesting static final int DEFAULT_MAX_ICON_DIMENSION_DP = 96; @VisibleForTesting @@ -260,11 +257,6 @@ public class ShortcutService extends IShortcutService.Stub { String KEY_MAX_SHORTCUTS = "max_shortcuts"; /** - * Key name for the max dynamic shortcuts per app. (int) - */ - String KEY_MAX_SHORTCUTS_PER_APP = "max_shortcuts_per_app"; - - /** * Key name for icon compression quality, 0-100. */ String KEY_ICON_QUALITY = "icon_quality"; @@ -337,14 +329,9 @@ public class ShortcutService extends IShortcutService.Stub { new SparseArray<>(); /** - * Max number of dynamic + manifest shortcuts that each activity can have at a time. - */ - private int mMaxShortcutsPerActivity; - - /** * Max number of dynamic + manifest shortcuts that each application can have at a time. */ - private int mMaxShortcutsPerApp; + private int mMaxShortcuts; /** * Max number of updating API calls that each application can make during the interval. @@ -817,12 +804,9 @@ public class ShortcutService extends IShortcutService.Stub { mMaxUpdatesPerInterval = Math.max(0, (int) parser.getLong( ConfigConstants.KEY_MAX_UPDATES_PER_INTERVAL, DEFAULT_MAX_UPDATES_PER_INTERVAL)); - mMaxShortcutsPerActivity = Math.max(0, (int) parser.getLong( + mMaxShortcuts = Math.max(0, (int) parser.getLong( ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_ACTIVITY)); - mMaxShortcutsPerApp = Math.max(0, (int) parser.getLong( - ConfigConstants.KEY_MAX_SHORTCUTS_PER_APP, DEFAULT_MAX_SHORTCUTS_PER_APP)); - final int iconDimensionDp = Math.max(1, injectIsLowRamDevice() ? (int) parser.getLong( ConfigConstants.KEY_MAX_ICON_DIMENSION_DP_LOWRAM, @@ -1762,33 +1746,16 @@ public class ShortcutService extends IShortcutService.Stub { * {@link #getMaxActivityShortcuts()}. */ void enforceMaxActivityShortcuts(int numShortcuts) { - if (numShortcuts > mMaxShortcutsPerActivity) { + if (numShortcuts > mMaxShortcuts) { throw new IllegalArgumentException("Max number of dynamic shortcuts exceeded"); } } /** - * @throws IllegalArgumentException if {@code numShortcuts} is bigger than - * {@link #getMaxAppShortcuts()}. - */ - void enforceMaxAppShortcuts(int numShortcuts) { - if (numShortcuts > mMaxShortcutsPerApp) { - throw new IllegalArgumentException("Max number of dynamic shortcuts per app exceeded"); - } - } - - /** * Return the max number of dynamic + manifest shortcuts for each launcher icon. */ int getMaxActivityShortcuts() { - return mMaxShortcutsPerActivity; - } - - /** - * Return the max number of dynamic + manifest shortcuts for each launcher icon. - */ - int getMaxAppShortcuts() { - return mMaxShortcutsPerApp; + return mMaxShortcuts; } /** @@ -2221,8 +2188,6 @@ public class ShortcutService extends IShortcutService.Stub { ps.ensureNotImmutable(shortcut.getId(), /*ignoreInvisible=*/ true); fillInDefaultActivity(Arrays.asList(shortcut)); - enforceMaxAppShortcuts(ps.getShortcutCount()); - if (!shortcut.hasRank()) { shortcut.setRank(0); } @@ -2610,7 +2575,7 @@ public class ShortcutService extends IShortcutService.Stub { throws RemoteException { verifyCaller(packageName, userId); - return mMaxShortcutsPerActivity; + return mMaxShortcuts; } @Override @@ -4759,7 +4724,7 @@ public class ShortcutService extends IShortcutService.Stub { pw.print(" maxUpdatesPerInterval: "); pw.println(mMaxUpdatesPerInterval); pw.print(" maxShortcutsPerActivity: "); - pw.println(mMaxShortcutsPerActivity); + pw.println(mMaxShortcuts); pw.println(); mStatLogger.dump(pw, " "); @@ -5246,7 +5211,7 @@ public class ShortcutService extends IShortcutService.Stub { @VisibleForTesting int getMaxShortcutsForTest() { - return mMaxShortcutsPerActivity; + return mMaxShortcuts; } @VisibleForTesting |