Loading services/core/java/com/android/server/pm/ShortcutPackage.java +43 −7 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; /** * Package information used by {@link ShortcutService}. Loading Loading @@ -721,7 +722,7 @@ class ShortcutPackage extends ShortcutPackageItem { // If not reset yet, then reset. if (mLastResetTime < last) { if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("%s: last reset=%d, now=%d, last=%d: resetting", getPackageName(), mLastResetTime, now, last)); } Loading Loading @@ -1101,7 +1102,7 @@ class ShortcutPackage extends ShortcutPackageItem { } final int manifestShortcutSize = newManifestShortcutList == null ? 0 : newManifestShortcutList.size(); if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("Package %s has %d manifest shortcut(s), and %d share target(s)", getPackageName(), manifestShortcutSize, mShareTargets.size())); Loading @@ -1113,7 +1114,7 @@ class ShortcutPackage extends ShortcutPackageItem { // disabled. return false; } if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("Package %s %s, version %d -> %d", getPackageName(), (isNewApp ? "added" : "updated"), getPackageInfo().getVersionCode(), pi.getLongVersionCode())); Loading Loading @@ -1202,7 +1203,7 @@ class ShortcutPackage extends ShortcutPackageItem { } private boolean publishManifestShortcuts(List<ShortcutInfo> newManifestShortcutList) { if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format( "Package %s: publishing manifest shortcuts", getPackageName())); } Loading Loading @@ -1879,7 +1880,7 @@ class ShortcutPackage extends ShortcutPackageItem { final int depth = parser.getDepth(); final String tag = parser.getName(); if (ShortcutService.DEBUG_LOAD) { if (ShortcutService.DEBUG_LOAD || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("depth=%d type=%d name=%s", depth, type, tag)); } if ((depth == 1) && TAG_ROOT.equals(tag)) { Loading Loading @@ -2015,7 +2016,7 @@ class ShortcutPackage extends ShortcutPackageItem { } final int depth = parser.getDepth(); final String tag = parser.getName(); if (ShortcutService.DEBUG_LOAD) { if (ShortcutService.DEBUG_LOAD || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format(" depth=%d type=%d name=%s", depth, type, tag)); } Loading Loading @@ -2099,7 +2100,7 @@ class ShortcutPackage extends ShortcutPackageItem { } final int depth = parser.getDepth(); final String tag = parser.getName(); if (ShortcutService.DEBUG_LOAD) { if (ShortcutService.DEBUG_LOAD || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format(" depth=%d type=%d name=%s", depth, type, tag)); } Loading Loading @@ -2302,6 +2303,12 @@ class ShortcutPackage extends ShortcutPackageItem { // No need to invoke AppSearch when there's nothing to save. return; } if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Saving shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName() + " ids=[" + shortcuts.stream().map(ShortcutInfo::getId) .collect(Collectors.joining(",")) + "]"); } awaitInAppSearch("Saving shortcuts", session -> { final AndroidFuture<Boolean> future = new AndroidFuture<>(); session.put(new PutDocumentsRequest.Builder() Loading Loading @@ -2374,6 +2381,10 @@ class ShortcutPackage extends ShortcutPackageItem { shortcutIds.add(id); } } if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Getting shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName() + " ids: [" + String.join(",", ids) + "]"); } return awaitInAppSearch("Getting shortcut by id", session -> { final AndroidFuture<List<ShortcutInfo>> future = new AndroidFuture<>(); session.getByUri( Loading Loading @@ -2418,6 +2429,10 @@ class ShortcutPackage extends ShortcutPackageItem { private void forEachShortcutMutateIf(@NonNull final String query, @NonNull final Function<ShortcutInfo, Boolean> cb) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Changing shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } final SearchResults res = awaitInAppSearch("Mutating shortcuts", session -> AndroidFuture.completedFuture(session.search(query, getSearchSpec()))); if (res == null) return; Loading @@ -2439,6 +2454,10 @@ class ShortcutPackage extends ShortcutPackageItem { private void forEachShortcutStopWhen( @NonNull final String query, @NonNull final Function<ShortcutInfo, Boolean> cb) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Iterating shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } final SearchResults res = awaitInAppSearch("Iterating shortcuts", session -> AndroidFuture.completedFuture(session.search(query, getSearchSpec()))); if (res == null) return; Loading @@ -2452,6 +2471,10 @@ class ShortcutPackage extends ShortcutPackageItem { } private List<ShortcutInfo> getNextPage(@NonNull final SearchResults res) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Get next page for search result for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } final AndroidFuture<List<ShortcutInfo>> future = new AndroidFuture<>(); final List<ShortcutInfo> ret = new ArrayList<>(); final long callingIdentity = Binder.clearCallingIdentity(); Loading Loading @@ -2529,6 +2552,10 @@ class ShortcutPackage extends ShortcutPackageItem { @NonNull private AndroidFuture<AppSearchSession> setupSchema( @NonNull final AppSearchSession session) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Setup Schema for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } SetSchemaRequest.Builder schemaBuilder = new SetSchemaRequest.Builder() .addSchemas(AppSearchPerson.SCHEMA, AppSearchShortcutInfo.SCHEMA) .setForceOverride(true); Loading Loading @@ -2569,6 +2596,15 @@ class ShortcutPackage extends ShortcutPackageItem { } private void restoreParsedShortcuts(final boolean replace) { if (ShortcutService.DEBUG_REBOOT) { if (replace) { Slog.d(TAG, "Replacing all shortcuts with the ones parsed from xml for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } else { Slog.d(TAG, "Restoring pinned shortcuts from xml for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } } if (replace) { removeShortcuts(); } Loading services/core/java/com/android/server/pm/ShortcutService.java +29 −21 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ public class ShortcutService extends IShortcutService.Stub { static final boolean DEBUG = false; // STOPSHIP if true static final boolean DEBUG_LOAD = false; // STOPSHIP if true static final boolean DEBUG_PROCSTATE = false; // STOPSHIP if true static final boolean DEBUG_REBOOT = true; @VisibleForTesting static final long DEFAULT_RESET_INTERVAL_SEC = 24 * 60 * 60; // 1 day Loading Loading @@ -659,7 +660,7 @@ public class ShortcutService extends IShortcutService.Stub { /** lifecycle event */ void onBootPhase(int phase) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "onBootPhase: " + phase); } switch (phase) { Loading @@ -674,7 +675,7 @@ public class ShortcutService extends IShortcutService.Stub { /** lifecycle event */ void handleUnlockUser(int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "handleUnlockUser: user=" + userId); } synchronized (mUnlockedUsers) { Loading @@ -699,7 +700,7 @@ public class ShortcutService extends IShortcutService.Stub { /** lifecycle event */ void handleStopUser(int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "handleStopUser: user=" + userId); } synchronized (mLock) { Loading @@ -713,7 +714,7 @@ public class ShortcutService extends IShortcutService.Stub { @GuardedBy("mLock") private void unloadUserLocked(int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "unloadUserLocked: user=" + userId); } // Save all dirty information. Loading Loading @@ -945,7 +946,7 @@ public class ShortcutService extends IShortcutService.Stub { @VisibleForTesting void saveBaseStateLocked() { final AtomicFile file = getBaseStateFile(); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Saving to " + file.getBaseFile()); } Loading Loading @@ -978,7 +979,7 @@ public class ShortcutService extends IShortcutService.Stub { mRawLastResetTime = 0; final AtomicFile file = getBaseStateFile(); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Loading from " + file.getBaseFile()); } try (FileInputStream in = file.openRead()) { Loading Loading @@ -1028,7 +1029,7 @@ public class ShortcutService extends IShortcutService.Stub { @GuardedBy("mLock") private void saveUserLocked(@UserIdInt int userId) { final File path = getUserFile(userId); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Saving to " + path); } Loading Loading @@ -1086,7 +1087,7 @@ public class ShortcutService extends IShortcutService.Stub { @Nullable private ShortcutUser loadUserLocked(@UserIdInt int userId) { final File path = getUserFile(userId); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Loading from " + path); } final AtomicFile file = new AtomicFile(path); Loading @@ -1095,7 +1096,7 @@ public class ShortcutService extends IShortcutService.Stub { try { in = file.openRead(); } catch (FileNotFoundException e) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Not found " + path); } return null; Loading Loading @@ -1132,7 +1133,7 @@ public class ShortcutService extends IShortcutService.Stub { final int depth = parser.getDepth(); final String tag = parser.getName(); if (DEBUG_LOAD) { if (DEBUG_LOAD || DEBUG_REBOOT) { Slog.d(TAG, String.format("depth=%d type=%d name=%s", depth, type, tag)); } Loading @@ -1157,7 +1158,7 @@ public class ShortcutService extends IShortcutService.Stub { private final Runnable mSaveDirtyInfoRunner = this::saveDirtyInfo; private void scheduleSaveInner(@UserIdInt int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Scheduling to save for " + userId); } synchronized (mLock) { Loading @@ -1172,7 +1173,7 @@ public class ShortcutService extends IShortcutService.Stub { @VisibleForTesting void saveDirtyInfo() { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "saveDirtyInfo"); } if (mShutdown.get()) { Loading Loading @@ -2942,6 +2943,10 @@ public class ShortcutService extends IShortcutService.Stub { @Nullable String packageName, @Nullable List<String> shortcutIds, @Nullable List<LocusId> locusIds, @Nullable ComponentName componentName, int queryFlags, int userId, int callingPid, int callingUid) { if (DEBUG_REBOOT) { Slog.d(TAG, "Getting shortcuts for launcher= " + callingPackage + "user=" + userId + " pkg=" + packageName); } final ArrayList<ShortcutInfo> ret = new ArrayList<>(); int flags = ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER; Loading Loading @@ -3639,7 +3644,7 @@ public class ShortcutService extends IShortcutService.Stub { */ @VisibleForTesting void checkPackageChanges(@UserIdInt int ownerUserId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "checkPackageChanges() ownerUserId=" + ownerUserId); } if (injectIsSafeModeEnabled()) { Loading Loading @@ -3685,6 +3690,9 @@ public class ShortcutService extends IShortcutService.Stub { @GuardedBy("mLock") private void rescanUpdatedPackagesLocked(@UserIdInt int userId, long lastScanTime) { if (DEBUG_REBOOT) { Slog.d(TAG, "rescan updated package user=" + userId + " last scanned=" + lastScanTime); } final ShortcutUser user = getUserShortcutsLocked(userId); // Note after each OTA, we'll need to rescan all system apps, as their lastUpdateTime Loading @@ -3708,7 +3716,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageAdded(String packageName, @UserIdInt int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageAdded: %s user=%d", packageName, userId)); } synchronized (mLock) { Loading @@ -3720,7 +3728,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageUpdateFinished(String packageName, @UserIdInt int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageUpdateFinished: %s user=%d", packageName, userId)); } Loading @@ -3736,7 +3744,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageRemoved(String packageName, @UserIdInt int packageUserId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageRemoved: %s user=%d", packageName, packageUserId)); } Loading @@ -3746,7 +3754,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageDataCleared(String packageName, int packageUserId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageDataCleared: %s user=%d", packageName, packageUserId)); } Loading @@ -3761,7 +3769,7 @@ public class ShortcutService extends IShortcutService.Stub { handlePackageRemoved(packageName, packageUserId); return; } if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageChanged: %s user=%d", packageName, packageUserId)); } Loading Loading @@ -3948,7 +3956,7 @@ public class ShortcutService extends IShortcutService.Stub { private void forUpdatedPackages(@UserIdInt int userId, long lastScanTime, boolean afterOta, Consumer<ApplicationInfo> callback) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "forUpdatedPackages for user " + userId + ", lastScanTime=" + lastScanTime + " afterOta=" + afterOta); } Loading @@ -3960,7 +3968,7 @@ public class ShortcutService extends IShortcutService.Stub { // Also if it's right after an OTA, always re-scan all apps anyway, since the // shortcut parser might have changed. if (afterOta || (pi.lastUpdateTime >= lastScanTime)) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Found updated package " + pi.packageName + " updateTime=" + pi.lastUpdateTime); } Loading Loading @@ -4313,7 +4321,7 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void applyRestore(byte[] payload, @UserIdInt int userId) { enforceSystem(); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Restoring user " + userId); } synchronized (mLock) { Loading services/core/java/com/android/server/pm/ShortcutUser.java +5 −1 Original line number Diff line number Diff line Loading @@ -328,6 +328,10 @@ class ShortcutUser { public void rescanPackageIfNeeded(@NonNull String packageName, boolean forceRescan) { final boolean isNewApp = !mPackages.containsKey(packageName); if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "rescanPackageIfNeeded " + getUserId() + "@" + packageName + ", forceRescan=" + forceRescan + " , isNewApp=" + isNewApp); } final ShortcutPackage shortcutPackage = getPackageShortcuts(packageName); Loading Loading @@ -397,7 +401,7 @@ class ShortcutUser { } else { // Save each ShortcutPackageItem in a separate Xml file. final File path = getShortcutPackageItemFile(spi); if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Saving package item " + spi.getPackageName() + " to " + path); } Loading Loading
services/core/java/com/android/server/pm/ShortcutPackage.java +43 −7 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; /** * Package information used by {@link ShortcutService}. Loading Loading @@ -721,7 +722,7 @@ class ShortcutPackage extends ShortcutPackageItem { // If not reset yet, then reset. if (mLastResetTime < last) { if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("%s: last reset=%d, now=%d, last=%d: resetting", getPackageName(), mLastResetTime, now, last)); } Loading Loading @@ -1101,7 +1102,7 @@ class ShortcutPackage extends ShortcutPackageItem { } final int manifestShortcutSize = newManifestShortcutList == null ? 0 : newManifestShortcutList.size(); if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("Package %s has %d manifest shortcut(s), and %d share target(s)", getPackageName(), manifestShortcutSize, mShareTargets.size())); Loading @@ -1113,7 +1114,7 @@ class ShortcutPackage extends ShortcutPackageItem { // disabled. return false; } if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("Package %s %s, version %d -> %d", getPackageName(), (isNewApp ? "added" : "updated"), getPackageInfo().getVersionCode(), pi.getLongVersionCode())); Loading Loading @@ -1202,7 +1203,7 @@ class ShortcutPackage extends ShortcutPackageItem { } private boolean publishManifestShortcuts(List<ShortcutInfo> newManifestShortcutList) { if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format( "Package %s: publishing manifest shortcuts", getPackageName())); } Loading Loading @@ -1879,7 +1880,7 @@ class ShortcutPackage extends ShortcutPackageItem { final int depth = parser.getDepth(); final String tag = parser.getName(); if (ShortcutService.DEBUG_LOAD) { if (ShortcutService.DEBUG_LOAD || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("depth=%d type=%d name=%s", depth, type, tag)); } if ((depth == 1) && TAG_ROOT.equals(tag)) { Loading Loading @@ -2015,7 +2016,7 @@ class ShortcutPackage extends ShortcutPackageItem { } final int depth = parser.getDepth(); final String tag = parser.getName(); if (ShortcutService.DEBUG_LOAD) { if (ShortcutService.DEBUG_LOAD || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format(" depth=%d type=%d name=%s", depth, type, tag)); } Loading Loading @@ -2099,7 +2100,7 @@ class ShortcutPackage extends ShortcutPackageItem { } final int depth = parser.getDepth(); final String tag = parser.getName(); if (ShortcutService.DEBUG_LOAD) { if (ShortcutService.DEBUG_LOAD || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format(" depth=%d type=%d name=%s", depth, type, tag)); } Loading Loading @@ -2302,6 +2303,12 @@ class ShortcutPackage extends ShortcutPackageItem { // No need to invoke AppSearch when there's nothing to save. return; } if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Saving shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName() + " ids=[" + shortcuts.stream().map(ShortcutInfo::getId) .collect(Collectors.joining(",")) + "]"); } awaitInAppSearch("Saving shortcuts", session -> { final AndroidFuture<Boolean> future = new AndroidFuture<>(); session.put(new PutDocumentsRequest.Builder() Loading Loading @@ -2374,6 +2381,10 @@ class ShortcutPackage extends ShortcutPackageItem { shortcutIds.add(id); } } if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Getting shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName() + " ids: [" + String.join(",", ids) + "]"); } return awaitInAppSearch("Getting shortcut by id", session -> { final AndroidFuture<List<ShortcutInfo>> future = new AndroidFuture<>(); session.getByUri( Loading Loading @@ -2418,6 +2429,10 @@ class ShortcutPackage extends ShortcutPackageItem { private void forEachShortcutMutateIf(@NonNull final String query, @NonNull final Function<ShortcutInfo, Boolean> cb) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Changing shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } final SearchResults res = awaitInAppSearch("Mutating shortcuts", session -> AndroidFuture.completedFuture(session.search(query, getSearchSpec()))); if (res == null) return; Loading @@ -2439,6 +2454,10 @@ class ShortcutPackage extends ShortcutPackageItem { private void forEachShortcutStopWhen( @NonNull final String query, @NonNull final Function<ShortcutInfo, Boolean> cb) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Iterating shortcuts for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } final SearchResults res = awaitInAppSearch("Iterating shortcuts", session -> AndroidFuture.completedFuture(session.search(query, getSearchSpec()))); if (res == null) return; Loading @@ -2452,6 +2471,10 @@ class ShortcutPackage extends ShortcutPackageItem { } private List<ShortcutInfo> getNextPage(@NonNull final SearchResults res) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Get next page for search result for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } final AndroidFuture<List<ShortcutInfo>> future = new AndroidFuture<>(); final List<ShortcutInfo> ret = new ArrayList<>(); final long callingIdentity = Binder.clearCallingIdentity(); Loading Loading @@ -2529,6 +2552,10 @@ class ShortcutPackage extends ShortcutPackageItem { @NonNull private AndroidFuture<AppSearchSession> setupSchema( @NonNull final AppSearchSession session) { if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Setup Schema for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } SetSchemaRequest.Builder schemaBuilder = new SetSchemaRequest.Builder() .addSchemas(AppSearchPerson.SCHEMA, AppSearchShortcutInfo.SCHEMA) .setForceOverride(true); Loading Loading @@ -2569,6 +2596,15 @@ class ShortcutPackage extends ShortcutPackageItem { } private void restoreParsedShortcuts(final boolean replace) { if (ShortcutService.DEBUG_REBOOT) { if (replace) { Slog.d(TAG, "Replacing all shortcuts with the ones parsed from xml for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } else { Slog.d(TAG, "Restoring pinned shortcuts from xml for user=" + mShortcutUser.getUserId() + " pkg=" + getPackageName()); } } if (replace) { removeShortcuts(); } Loading
services/core/java/com/android/server/pm/ShortcutService.java +29 −21 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ public class ShortcutService extends IShortcutService.Stub { static final boolean DEBUG = false; // STOPSHIP if true static final boolean DEBUG_LOAD = false; // STOPSHIP if true static final boolean DEBUG_PROCSTATE = false; // STOPSHIP if true static final boolean DEBUG_REBOOT = true; @VisibleForTesting static final long DEFAULT_RESET_INTERVAL_SEC = 24 * 60 * 60; // 1 day Loading Loading @@ -659,7 +660,7 @@ public class ShortcutService extends IShortcutService.Stub { /** lifecycle event */ void onBootPhase(int phase) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "onBootPhase: " + phase); } switch (phase) { Loading @@ -674,7 +675,7 @@ public class ShortcutService extends IShortcutService.Stub { /** lifecycle event */ void handleUnlockUser(int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "handleUnlockUser: user=" + userId); } synchronized (mUnlockedUsers) { Loading @@ -699,7 +700,7 @@ public class ShortcutService extends IShortcutService.Stub { /** lifecycle event */ void handleStopUser(int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "handleStopUser: user=" + userId); } synchronized (mLock) { Loading @@ -713,7 +714,7 @@ public class ShortcutService extends IShortcutService.Stub { @GuardedBy("mLock") private void unloadUserLocked(int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "unloadUserLocked: user=" + userId); } // Save all dirty information. Loading Loading @@ -945,7 +946,7 @@ public class ShortcutService extends IShortcutService.Stub { @VisibleForTesting void saveBaseStateLocked() { final AtomicFile file = getBaseStateFile(); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Saving to " + file.getBaseFile()); } Loading Loading @@ -978,7 +979,7 @@ public class ShortcutService extends IShortcutService.Stub { mRawLastResetTime = 0; final AtomicFile file = getBaseStateFile(); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Loading from " + file.getBaseFile()); } try (FileInputStream in = file.openRead()) { Loading Loading @@ -1028,7 +1029,7 @@ public class ShortcutService extends IShortcutService.Stub { @GuardedBy("mLock") private void saveUserLocked(@UserIdInt int userId) { final File path = getUserFile(userId); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Saving to " + path); } Loading Loading @@ -1086,7 +1087,7 @@ public class ShortcutService extends IShortcutService.Stub { @Nullable private ShortcutUser loadUserLocked(@UserIdInt int userId) { final File path = getUserFile(userId); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Loading from " + path); } final AtomicFile file = new AtomicFile(path); Loading @@ -1095,7 +1096,7 @@ public class ShortcutService extends IShortcutService.Stub { try { in = file.openRead(); } catch (FileNotFoundException e) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Not found " + path); } return null; Loading Loading @@ -1132,7 +1133,7 @@ public class ShortcutService extends IShortcutService.Stub { final int depth = parser.getDepth(); final String tag = parser.getName(); if (DEBUG_LOAD) { if (DEBUG_LOAD || DEBUG_REBOOT) { Slog.d(TAG, String.format("depth=%d type=%d name=%s", depth, type, tag)); } Loading @@ -1157,7 +1158,7 @@ public class ShortcutService extends IShortcutService.Stub { private final Runnable mSaveDirtyInfoRunner = this::saveDirtyInfo; private void scheduleSaveInner(@UserIdInt int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Scheduling to save for " + userId); } synchronized (mLock) { Loading @@ -1172,7 +1173,7 @@ public class ShortcutService extends IShortcutService.Stub { @VisibleForTesting void saveDirtyInfo() { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "saveDirtyInfo"); } if (mShutdown.get()) { Loading Loading @@ -2942,6 +2943,10 @@ public class ShortcutService extends IShortcutService.Stub { @Nullable String packageName, @Nullable List<String> shortcutIds, @Nullable List<LocusId> locusIds, @Nullable ComponentName componentName, int queryFlags, int userId, int callingPid, int callingUid) { if (DEBUG_REBOOT) { Slog.d(TAG, "Getting shortcuts for launcher= " + callingPackage + "user=" + userId + " pkg=" + packageName); } final ArrayList<ShortcutInfo> ret = new ArrayList<>(); int flags = ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER; Loading Loading @@ -3639,7 +3644,7 @@ public class ShortcutService extends IShortcutService.Stub { */ @VisibleForTesting void checkPackageChanges(@UserIdInt int ownerUserId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "checkPackageChanges() ownerUserId=" + ownerUserId); } if (injectIsSafeModeEnabled()) { Loading Loading @@ -3685,6 +3690,9 @@ public class ShortcutService extends IShortcutService.Stub { @GuardedBy("mLock") private void rescanUpdatedPackagesLocked(@UserIdInt int userId, long lastScanTime) { if (DEBUG_REBOOT) { Slog.d(TAG, "rescan updated package user=" + userId + " last scanned=" + lastScanTime); } final ShortcutUser user = getUserShortcutsLocked(userId); // Note after each OTA, we'll need to rescan all system apps, as their lastUpdateTime Loading @@ -3708,7 +3716,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageAdded(String packageName, @UserIdInt int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageAdded: %s user=%d", packageName, userId)); } synchronized (mLock) { Loading @@ -3720,7 +3728,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageUpdateFinished(String packageName, @UserIdInt int userId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageUpdateFinished: %s user=%d", packageName, userId)); } Loading @@ -3736,7 +3744,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageRemoved(String packageName, @UserIdInt int packageUserId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageRemoved: %s user=%d", packageName, packageUserId)); } Loading @@ -3746,7 +3754,7 @@ public class ShortcutService extends IShortcutService.Stub { } private void handlePackageDataCleared(String packageName, int packageUserId) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageDataCleared: %s user=%d", packageName, packageUserId)); } Loading @@ -3761,7 +3769,7 @@ public class ShortcutService extends IShortcutService.Stub { handlePackageRemoved(packageName, packageUserId); return; } if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, String.format("handlePackageChanged: %s user=%d", packageName, packageUserId)); } Loading Loading @@ -3948,7 +3956,7 @@ public class ShortcutService extends IShortcutService.Stub { private void forUpdatedPackages(@UserIdInt int userId, long lastScanTime, boolean afterOta, Consumer<ApplicationInfo> callback) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "forUpdatedPackages for user " + userId + ", lastScanTime=" + lastScanTime + " afterOta=" + afterOta); } Loading @@ -3960,7 +3968,7 @@ public class ShortcutService extends IShortcutService.Stub { // Also if it's right after an OTA, always re-scan all apps anyway, since the // shortcut parser might have changed. if (afterOta || (pi.lastUpdateTime >= lastScanTime)) { if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Found updated package " + pi.packageName + " updateTime=" + pi.lastUpdateTime); } Loading Loading @@ -4313,7 +4321,7 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void applyRestore(byte[] payload, @UserIdInt int userId) { enforceSystem(); if (DEBUG) { if (DEBUG || DEBUG_REBOOT) { Slog.d(TAG, "Restoring user " + userId); } synchronized (mLock) { Loading
services/core/java/com/android/server/pm/ShortcutUser.java +5 −1 Original line number Diff line number Diff line Loading @@ -328,6 +328,10 @@ class ShortcutUser { public void rescanPackageIfNeeded(@NonNull String packageName, boolean forceRescan) { final boolean isNewApp = !mPackages.containsKey(packageName); if (ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "rescanPackageIfNeeded " + getUserId() + "@" + packageName + ", forceRescan=" + forceRescan + " , isNewApp=" + isNewApp); } final ShortcutPackage shortcutPackage = getPackageShortcuts(packageName); Loading Loading @@ -397,7 +401,7 @@ class ShortcutUser { } else { // Save each ShortcutPackageItem in a separate Xml file. final File path = getShortcutPackageItemFile(spi); if (ShortcutService.DEBUG) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, "Saving package item " + spi.getPackageName() + " to " + path); } Loading