Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0311822e authored by Pinyao Ting's avatar Pinyao Ting Committed by Android (Google) Code Review
Browse files

Merge "Unblock the registration of shortcut change callbacks" into main

parents c6ef3d66 efd686af
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -320,10 +320,10 @@ public class ShortcutService extends IShortcutService.Stub {

    private final Handler mHandler;

    @GuardedBy("mServiceLock")
    @GuardedBy("itself")
    private final ArrayList<ShortcutChangeListener> mListeners = new ArrayList<>(1);

    @GuardedBy("mServiceLock")
    @GuardedBy("itself")
    private final ArrayList<LauncherApps.ShortcutChangeCallback> mShortcutChangeCallbacks =
            new ArrayList<>(1);

@@ -1847,8 +1847,10 @@ public class ShortcutService extends IShortcutService.Stub {
                        return;
                    }

                    synchronized (mListeners) {
                        copy = new ArrayList<>(mListeners);
                    }
                }
                // Note onShortcutChanged() needs to be called with the system service permissions.
                for (int i = copy.size() - 1; i >= 0; i--) {
                    copy.get(i).onShortcutChanged(packageName, userId);
@@ -1872,9 +1874,10 @@ public class ShortcutService extends IShortcutService.Stub {
                    if (!isUserUnlockedL(userId)) {
                        return;
                    }

                    synchronized (mShortcutChangeCallbacks) {
                        copy = new ArrayList<>(mShortcutChangeCallbacks);
                    }
                }
                for (int i = copy.size() - 1; i >= 0; i--) {
                    if (!CollectionUtils.isEmpty(changedList)) {
                        copy.get(i).onShortcutsAddedOrUpdated(packageName, changedList, user);
@@ -3429,7 +3432,7 @@ public class ShortcutService extends IShortcutService.Stub {

        @Override
        public void addListener(@NonNull ShortcutChangeListener listener) {
            synchronized (mServiceLock) {
            synchronized (mListeners) {
                mListeners.add(Objects.requireNonNull(listener));
            }
        }
@@ -3437,7 +3440,7 @@ public class ShortcutService extends IShortcutService.Stub {
        @Override
        public void addShortcutChangeCallback(
                @NonNull LauncherApps.ShortcutChangeCallback callback) {
            synchronized (mServiceLock) {
            synchronized (mShortcutChangeCallbacks) {
                mShortcutChangeCallbacks.add(Objects.requireNonNull(callback));
            }
        }