summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adrian Roos <roosa@google.com> 2017-05-03 11:33:51 -0700
committer Adrian Roos <roosa@google.com> 2017-05-03 11:33:53 -0700
commitb884bb28b1416f8d0d93403eeac11af74b9f9968 (patch)
treef213cd53f562f110bf68f36f9c7108e0d7694c19
parent9870d0bef78949f0429de4f62532d98f2537c258 (diff)
TrustManagerService: Fix service binding leak
Fixes an issue where TrustAgentWrapper was created too early. If we later decide to not actually start that agent, it is already bound to, and then we just drop the TrustAgentWrapper class, never unbinding. In addition, this can also create a rebind loop where we are constantly trying to rebind to the trust agent. Bug: 37853858 Test: force-lock, observe that trust agents are properly unbound and not constantly trying to rebind Change-Id: I4d383f9cb499874803a7f024915baf85b3682631
-rw-r--r--services/core/java/com/android/server/trust/TrustManagerService.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index f4f7e2403f0c..8e06a51238ee 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -325,8 +325,6 @@ public class TrustManagerService extends SystemService {
agentInfo.label = resolveInfo.loadLabel(pm);
agentInfo.icon = resolveInfo.loadIcon(pm);
agentInfo.settings = getSettingsAttrs(pm, resolveInfo);
- agentInfo.agent = new TrustAgentWrapper(mContext, this,
- new Intent().setComponent(name), userInfo.getUserHandle());
} else {
int index = mActiveAgents.indexOf(agentInfo);
agentInfo = mActiveAgents.valueAt(index);
@@ -363,6 +361,11 @@ public class TrustManagerService extends SystemService {
}
}
+ if (agentInfo.agent == null) {
+ agentInfo.agent = new TrustAgentWrapper(mContext, this,
+ new Intent().setComponent(name), userInfo.getUserHandle());
+ }
+
if (!mActiveAgents.contains(agentInfo)) {
mActiveAgents.add(agentInfo);
} else {