Loading services/core/java/com/android/server/pm/ShortcutService.java +26 −0 Original line number Diff line number Diff line Loading @@ -362,6 +362,7 @@ public class ShortcutService extends IShortcutService.Stub { private List<Integer> mDirtyUserIds = new ArrayList<>(); private final AtomicBoolean mBootCompleted = new AtomicBoolean(); private final AtomicBoolean mShutdown = new AtomicBoolean(); /** * Note we use a fine-grained lock for {@link #mUnlockedUsers} due to b/64303666. Loading Loading @@ -498,6 +499,12 @@ public class ShortcutService extends IShortcutService.Stub { mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, localeFilter, null, mHandler); IntentFilter shutdownFilter = new IntentFilter(); shutdownFilter.addAction(Intent.ACTION_SHUTDOWN); shutdownFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); mContext.registerReceiverAsUser(mShutdownReceiver, UserHandle.SYSTEM, shutdownFilter, null, mHandler); injectRegisterUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE); Loading Loading @@ -1162,6 +1169,9 @@ public class ShortcutService extends IShortcutService.Stub { if (DEBUG) { Slog.d(TAG, "saveDirtyInfo"); } if (mShutdown.get()) { return; } try { synchronized (mLock) { for (int i = mDirtyUserIds.size() - 1; i >= 0; i--) { Loading Loading @@ -3494,6 +3504,22 @@ public class ShortcutService extends IShortcutService.Stub { } }; private final BroadcastReceiver mShutdownReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // Since it cleans up the shortcut directory and rewrite the ShortcutPackageItems // in odrder during saveToXml(), it could lead to shortcuts missing when shutdown. // We need it so that it can finish up saving before shutdown. synchronized (mLock) { if (mHandler.hasCallbacks(mSaveDirtyInfoRunner)) { mHandler.removeCallbacks(mSaveDirtyInfoRunner); saveDirtyInfo(); } mShutdown.set(true); } } }; /** * Called when a user is unlocked. * - Check all known packages still exist, and otherwise perform cleanup. Loading Loading
services/core/java/com/android/server/pm/ShortcutService.java +26 −0 Original line number Diff line number Diff line Loading @@ -362,6 +362,7 @@ public class ShortcutService extends IShortcutService.Stub { private List<Integer> mDirtyUserIds = new ArrayList<>(); private final AtomicBoolean mBootCompleted = new AtomicBoolean(); private final AtomicBoolean mShutdown = new AtomicBoolean(); /** * Note we use a fine-grained lock for {@link #mUnlockedUsers} due to b/64303666. Loading Loading @@ -498,6 +499,12 @@ public class ShortcutService extends IShortcutService.Stub { mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, localeFilter, null, mHandler); IntentFilter shutdownFilter = new IntentFilter(); shutdownFilter.addAction(Intent.ACTION_SHUTDOWN); shutdownFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); mContext.registerReceiverAsUser(mShutdownReceiver, UserHandle.SYSTEM, shutdownFilter, null, mHandler); injectRegisterUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE); Loading Loading @@ -1162,6 +1169,9 @@ public class ShortcutService extends IShortcutService.Stub { if (DEBUG) { Slog.d(TAG, "saveDirtyInfo"); } if (mShutdown.get()) { return; } try { synchronized (mLock) { for (int i = mDirtyUserIds.size() - 1; i >= 0; i--) { Loading Loading @@ -3494,6 +3504,22 @@ public class ShortcutService extends IShortcutService.Stub { } }; private final BroadcastReceiver mShutdownReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // Since it cleans up the shortcut directory and rewrite the ShortcutPackageItems // in odrder during saveToXml(), it could lead to shortcuts missing when shutdown. // We need it so that it can finish up saving before shutdown. synchronized (mLock) { if (mHandler.hasCallbacks(mSaveDirtyInfoRunner)) { mHandler.removeCallbacks(mSaveDirtyInfoRunner); saveDirtyInfo(); } mShutdown.set(true); } } }; /** * Called when a user is unlocked. * - Check all known packages still exist, and otherwise perform cleanup. Loading