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

Commit e681c27d authored by Adrian Roos's avatar Adrian Roos
Browse files

Only unbind agents of the user that is being refreshed

Follow-up to I470261f659a573400b2eb1421eeb953c87e58b66.

Bug: 17416492
Change-Id: If0da5f163049540476d84d147c0e733fab1ae6d5
parent e51d6a3a
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -159,6 +159,11 @@ public class TrustManagerService extends SystemService {

    void refreshAgentList(int userId) {
        if (DEBUG) Slog.d(TAG, "refreshAgentList()");
        if (userId != UserHandle.USER_ALL && userId < UserHandle.USER_OWNER) {
            Log.e(TAG, "refreshAgentList(userId=" + userId + "): Invalid user handle,"
                    + " must be USER_ALL or a specific user.", new Throwable("here"));
            userId = UserHandle.USER_ALL;
        }
        PackageManager pm = mContext.getPackageManager();

        List<UserInfo> userInfos;
@@ -228,12 +233,14 @@ public class TrustManagerService extends SystemService {
        boolean trustMayHaveChanged = false;
        for (int i = 0; i < obsoleteAgents.size(); i++) {
            AgentInfo info = obsoleteAgents.valueAt(i);
            if (userId == UserHandle.USER_ALL || userId == info.userId) {
                if (info.agent.isManagingTrust()) {
                    trustMayHaveChanged = true;
                }
                info.agent.unbind();
                mActiveAgents.remove(info);
            }
        }

        if (trustMayHaveChanged) {
            updateTrustAll();