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

Commit 07e6e328 authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge "[AppsFilter] read sysprop only when it's changed"

parents 82886182 9edad83f
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.pm.SigningDetails;
import android.os.Binder;
import android.os.Handler;
import android.os.Process;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -199,6 +198,7 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot {
    protected SnapshotCache<WatchedSparseBooleanMatrix> mShouldFilterCacheSnapshot;

    protected volatile boolean mCacheReady = false;
    protected volatile boolean mCacheEnabled = true;

    protected static final boolean CACHE_VALID = true;
    protected static final boolean CACHE_INVALID = false;
@@ -342,8 +342,7 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot {
                      && !isImplicitlyQueryable(callingAppId, targetPkgSetting.getAppId());
            }
            // use cache
            if (mCacheReady && SystemProperties.getBoolean("debug.pm.use_app_filter_cache",
                    true)) {
            if (mCacheReady && mCacheEnabled) {
                if (!shouldFilterApplicationUsingCache(callingUid,
                        targetPkgSetting.getAppId(),
                        userId)) {
+7 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.pm.PackageManagerInternal;
import android.content.pm.SigningDetails;
import android.content.pm.UserInfo;
import android.os.Handler;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.provider.DeviceConfig;
@@ -223,6 +224,12 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
                return new AppsFilterSnapshotImpl(AppsFilterImpl.this);
            }
        };
        readCacheEnabledSysProp();
        SystemProperties.addChangeCallback(this::readCacheEnabledSysProp);
    }

    private void readCacheEnabledSysProp() {
        mCacheEnabled = SystemProperties.getBoolean("debug.pm.use_app_filter_cache", true);
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public final class AppsFilterSnapshotImpl extends AppsFilterBase {
            // cache is not ready, use an empty cache for the snapshot
            mShouldFilterCache = new WatchedSparseBooleanMatrix();
        }
        mCacheEnabled = orig.mCacheEnabled;
        mShouldFilterCacheSnapshot = new SnapshotCache.Sealed<>();

        mBackgroundHandler = null;