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

Commit f9cd67b0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid potential deadlock" into sc-dev

parents 7f38c6c3 acc01ae9
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class ShortcutBitmapSaver {
     * Before saving shortcuts.xml, and returning icons to the launcher, we wait for all pending
     * saves to finish.  However if it takes more than this long, we just give up and proceed.
     */
    private final long SAVE_WAIT_TIMEOUT_MS = 30 * 1000;
    private final long SAVE_WAIT_TIMEOUT_MS = 5 * 1000;

    private final ShortcutService mService;

@@ -281,7 +281,7 @@ public class ShortcutBitmapSaver {
                }

                final String path = file.getAbsolutePath();
                mService.postValue(shortcut, si -> si.setBitmapPath(path));
                shortcut.setBitmapPath(path);

            } catch (IOException | RuntimeException e) {
                Slog.e(ShortcutService.TAG, "Unable to write bitmap to file", e);
@@ -296,14 +296,12 @@ public class ShortcutBitmapSaver {
                Slog.d(TAG, "Saved bitmap.");
            }
            if (shortcut != null) {
                mService.postValue(shortcut, si -> {
                    if (si.getBitmapPath() == null) {
                        removeIcon(si);
                if (shortcut.getBitmapPath() == null) {
                    removeIcon(shortcut);
                }

                // Whatever happened, remove this flag.
                    si.clearFlags(ShortcutInfo.FLAG_ICON_FILE_PENDING_SAVE);
                });
                shortcut.clearFlags(ShortcutInfo.FLAG_ICON_FILE_PENDING_SAVE);
            }
        }
        return true;
+0 −10
Original line number Diff line number Diff line
@@ -1208,16 +1208,6 @@ public class ShortcutService extends IShortcutService.Stub {
        }
    }

    void postValue(@NonNull final ShortcutInfo shortcutInfo,
            @NonNull final Consumer<ShortcutInfo> cb) {
        final String pkg = shortcutInfo.getPackage();
        final int userId = shortcutInfo.getUserId();
        final String id = shortcutInfo.getId();
        synchronized (mLock) {
            getPackageShortcutsLocked(pkg, userId).mutateShortcut(id, shortcutInfo, cb);
        }
    }

    /** Return the last reset time. */
    @GuardedBy("mLock")
    long getLastResetTimeLocked() {