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

Commit 77ea683c authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix inverse lock order in AppsFilter

Bug: 199332741
Test: manual test:
$ m ComponentAliasTests
$ adb install -r $OUT/testcases/ComponentAliasTests/arm64/ComponentAliasTests.apk
$ adb shell am compat disable FILTER_APPLICATION_QUERY android.content.componentalias.tests
$ adb install -r $OUT/testcases/ComponentAliasTests/arm64/ComponentAliasTests.apk

-> This shouldn't hang up the device

Change-Id: Ie9f903e312a4e7c3e64c2aac06d9e0cb1792eecf
parent 19071521
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -300,6 +300,8 @@ public class AppsFilter implements Watchable, Snappable {
    /**
     * Provides system state to AppsFilter via {@link CurrentStateCallback} after properly guarding
     * the data with the package lock.
     *
     * Don't call {@link #runWithState} with {@link #mCacheLock} held.
     */
    @VisibleForTesting(visibility = PRIVATE)
    public interface StateProvider {
@@ -923,15 +925,16 @@ public class AppsFilter implements Watchable, Snappable {
    }

    private void updateShouldFilterCacheForPackage(String packageName) {
        synchronized (mCacheLock) {
            if (mShouldFilterCache != null) {
        mStateProvider.runWithState((settings, users) -> {
            synchronized (mCacheLock) {
                if (mShouldFilterCache == null) {
                    return;
                }
                updateShouldFilterCacheForPackage(mShouldFilterCache, null /* skipPackage */,
                        settings.get(packageName), settings, users,
                        settings.size() /*maxIndex*/);
                });
            }
            }
        });
    }

    private void updateShouldFilterCacheForPackage(WatchedSparseBooleanMatrix cache,