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

Commit aff53ed0 authored by Song Chun Fan's avatar Song Chun Fan
Browse files

[AccountManagerService] hold PackageMonitor object

System server only holds a weak reference to PackageMonitor though PackageMonitorCallback. If there's nothing else holding on to PackageMonitor, it will get GC'd and following callbacks to it will be discarded.

BUG: 398759145 
TEST: manual
FLAG: EXEMPT bug fix
Change-Id: If487b9e39a647ee464a5d3b73a2f967a5704e09c
parent 4d1f7dba
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ public class AccountManagerService
    }

    final Context mContext;
    final PackageMonitor mPackageMonitor;

    private static final int[] INTERESTING_APP_OPS = new int[] {
        AppOpsManager.OP_GET_ACCOUNTS,
@@ -373,7 +374,7 @@ public class AccountManagerService
        }, UserHandle.ALL, userFilter, null, null);

        // Need to cancel account request notifications if the update/install can access the account
        new PackageMonitor() {
        mPackageMonitor = new PackageMonitor() {
            @Override
            public void onPackageAdded(String packageName, int uid) {
                // Called on a handler, and running as the system
@@ -397,7 +398,8 @@ public class AccountManagerService
                    return;
                }
            }
        }.register(mContext, mHandler.getLooper(), UserHandle.ALL, true);
        };
        mPackageMonitor.register(mContext, mHandler.getLooper(), UserHandle.ALL, true);

        // Cancel account request notification if an app op was preventing the account access
        for (int i = 0; i < INTERESTING_APP_OPS.length; ++i) {