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

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

Merge "Get carrier-privileged app bookkeeping out of the main standby lock"

parents 4a21b8ec 7f31e5e8
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -222,12 +222,19 @@ public class AppStandbyController implements AppStandbyInternal {
    @GuardedBy("mPackageAccessListeners")
    private final ArrayList<AppIdleStateChangeListener> mPackageAccessListeners = new ArrayList<>();

    /**
     * Lock specifically for bookkeeping around the carrier-privileged app set.
     * Do not acquire any other locks while holding this one.  Methods that
     * require this lock to be held are named with a "CPL" suffix.
     */
    private final Object mCarrierPrivilegedLock = new Lock();

    /** Whether we've queried the list of carrier privileged apps. */
    @GuardedBy("mAppIdleLock")
    @GuardedBy("mCarrierPrivilegedLock")
    private boolean mHaveCarrierPrivilegedApps;

    /** List of carrier-privileged apps that should be excluded from standby */
    @GuardedBy("mAppIdleLock")
    @GuardedBy("mCarrierPrivilegedLock")
    private List<String> mCarrierPrivilegedApps;

    @GuardedBy("mActiveAdminApps")
@@ -1594,9 +1601,9 @@ public class AppStandbyController implements AppStandbyInternal {
    }

    private boolean isCarrierApp(String packageName) {
        synchronized (mAppIdleLock) {
        synchronized (mCarrierPrivilegedLock) {
            if (!mHaveCarrierPrivilegedApps) {
                fetchCarrierPrivilegedAppsLocked();
                fetchCarrierPrivilegedAppsCPL();
            }
            if (mCarrierPrivilegedApps != null) {
                return mCarrierPrivilegedApps.contains(packageName);
@@ -1610,14 +1617,14 @@ public class AppStandbyController implements AppStandbyInternal {
        if (DEBUG) {
            Slog.i(TAG, "Clearing carrier privileged apps list");
        }
        synchronized (mAppIdleLock) {
        synchronized (mCarrierPrivilegedLock) {
            mHaveCarrierPrivilegedApps = false;
            mCarrierPrivilegedApps = null; // Need to be refetched.
        }
    }

    @GuardedBy("mAppIdleLock")
    private void fetchCarrierPrivilegedAppsLocked() {
    @GuardedBy("mCarrierPrivilegedLock")
    private void fetchCarrierPrivilegedAppsCPL() {
        TelephonyManager telephonyManager =
                mContext.getSystemService(TelephonyManager.class);
        mCarrierPrivilegedApps =
@@ -1858,7 +1865,7 @@ public class AppStandbyController implements AppStandbyInternal {

    @Override
    public void dumpState(String[] args, PrintWriter pw) {
        synchronized (mAppIdleLock) {
        synchronized (mCarrierPrivilegedLock) {
            pw.println("Carrier privileged apps (have=" + mHaveCarrierPrivilegedApps
                    + "): " + mCarrierPrivilegedApps);
        }