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

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

Merge "Fixes an edge case which leads to deadlock in ShortcutService" into tm-qpr-dev

parents d76f695c 30fed8c2
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -280,6 +280,7 @@ public class ShortcutService extends IShortcutService.Stub {

    private final Object mLock = new Object();
    private final Object mNonPersistentUsersLock = new Object();
    private final Object mWtfLock = new Object();

    private static List<ResolveInfo> EMPTY_RESOLVE_INFO = new ArrayList<>(0);

@@ -444,10 +445,10 @@ public class ShortcutService extends IShortcutService.Stub {
    @interface ShortcutOperation {
    }

    @GuardedBy("mLock")
    @GuardedBy("mWtfLock")
    private int mWtfCount = 0;

    @GuardedBy("mLock")
    @GuardedBy("mWtfLock")
    private Exception mLastWtfStacktrace;

    @GuardedBy("mLock")
@@ -4727,6 +4728,7 @@ public class ShortcutService extends IShortcutService.Stub {

                mStatLogger.dump(pw, "  ");

                synchronized (mWtfLock) {
                    pw.println();
                    pw.print("  #Failures: ");
                    pw.println(mWtfCount);
@@ -4735,6 +4737,7 @@ public class ShortcutService extends IShortcutService.Stub {
                        pw.print("  Last failure stack trace: ");
                        pw.println(Log.getStackTraceString(mLastWtfStacktrace));
                    }
                }

                pw.println();
            }
@@ -5148,7 +5151,7 @@ public class ShortcutService extends IShortcutService.Stub {
        if (e == null) {
            e = new RuntimeException("Stacktrace");
        }
        synchronized (mLock) {
        synchronized (mWtfLock) {
            mWtfCount++;
            mLastWtfStacktrace = new Exception("Last failure was logged here:");
        }