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

Commit ffc409d0 authored by Jeongsik Mun's avatar Jeongsik Mun Committed by Songchun Fan
Browse files

Fix a subtle timing issue in AppsFilter

See b/285831656#comment16 and b/285831656#comment17 for discussion.

There could be a timing issue between mCacheReady and
mNeedToUpdateCacheForImplicitAccess.

This CL moves them under the same lock for writing.

Bug: 285831656
Test: atest PackageManagerServiceServerTests:AppsFilterImplTest
Change-Id: I261a80b86bcbd2892d80f0388a30fc9b9ef8197a
parent f644d43f
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -834,12 +834,6 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
            }

            updateEntireShouldFilterCacheInner(snapshot, settings, usersRef[0], USER_ALL);
            synchronized (mImplicitlyQueryableLock) {
                if (mNeedToUpdateCacheForImplicitAccess) {
                    updateShouldFilterCacheForImplicitAccess();
                    mNeedToUpdateCacheForImplicitAccess = false;
                }
            }
            logCacheRebuilt(reason, SystemClock.currentTimeMicro() - currentTimeUs,
                    users.length, settings.size());

@@ -850,7 +844,14 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
                return;
            }

            synchronized (mImplicitlyQueryableLock) {
                if (mNeedToUpdateCacheForImplicitAccess) {
                    updateShouldFilterCacheForImplicitAccess();
                    mNeedToUpdateCacheForImplicitAccess = false;
                }
                mCacheReady = true;
            }

            onChanged();
        }, delayMs);
    }