summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-05-27 23:46:49 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-27 23:46:50 +0000
commit26690339e9c9a134eb4607b3381947673b1dacad (patch)
treebb4f97a74882ebf69959c2aec6ff8f6a76b55971 /services
parentdab839e0478559781fe703c83f4e8a43d34960d2 (diff)
parent7d59b4f981e24a4a446522e9b8d3d6a7115c1459 (diff)
downloadframeworks_base-26690339e9c9a134eb4607b3381947673b1dacad.zip
frameworks_base-26690339e9c9a134eb4607b3381947673b1dacad.tar.gz
frameworks_base-26690339e9c9a134eb4607b3381947673b1dacad.tar.bz2
Merge "Add and improve logged TrustAgent connection events" into lmp-preview-dev
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/trust/TrustAgentWrapper.java9
-rw-r--r--services/core/java/com/android/server/trust/TrustArchive.java14
2 files changed, 23 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/trust/TrustAgentWrapper.java b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
index 47ce3b6..f18939f 100644
--- a/services/core/java/com/android/server/trust/TrustAgentWrapper.java
+++ b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
@@ -63,6 +63,11 @@ public class TrustAgentWrapper {
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_GRANT_TRUST:
+ if (!isConnected()) {
+ Log.w(TAG, "Agent is not connected, cannot grant trust: "
+ + mName.flattenToShortString());
+ return;
+ }
mTrusted = true;
mMessage = (CharSequence) msg.obj;
boolean initiatedByUser = msg.arg1 != 0;
@@ -119,6 +124,7 @@ public class TrustAgentWrapper {
public void onServiceConnected(ComponentName name, IBinder service) {
if (DEBUG) Log.v(TAG, "TrustAgent started : " + name.flattenToString());
mTrustAgentService = ITrustAgentService.Stub.asInterface(service);
+ mTrustManagerService.mArchive.logAgentConnected(mUserId, name);
setCallback(mCallback);
}
@@ -179,7 +185,10 @@ public class TrustAgentWrapper {
public void unbind() {
if (DEBUG) Log.v(TAG, "TrustAgent unbound : " + mName.flattenToShortString());
+ mTrustManagerService.mArchive.logAgentStopped(mUserId, mName);
mContext.unbindService(mConnection);
+ mTrustAgentService = null;
+ mHandler.sendEmptyMessage(MSG_REVOKE_TRUST);
}
public boolean isConnected() {
diff --git a/services/core/java/com/android/server/trust/TrustArchive.java b/services/core/java/com/android/server/trust/TrustArchive.java
index aad156c..56950d2 100644
--- a/services/core/java/com/android/server/trust/TrustArchive.java
+++ b/services/core/java/com/android/server/trust/TrustArchive.java
@@ -33,6 +33,8 @@ public class TrustArchive {
private static final int TYPE_REVOKE_TRUST = 1;
private static final int TYPE_TRUST_TIMEOUT = 2;
private static final int TYPE_AGENT_DIED = 3;
+ private static final int TYPE_AGENT_CONNECTED = 4;
+ private static final int TYPE_AGENT_STOPPED = 5;
private static final int HISTORY_LIMIT = 200;
@@ -79,6 +81,14 @@ public class TrustArchive {
addEvent(new Event(TYPE_AGENT_DIED, userId, agent, null, 0, false));
}
+ public void logAgentConnected(int userId, ComponentName agent) {
+ addEvent(new Event(TYPE_AGENT_CONNECTED, userId, agent, null, 0, false));
+ }
+
+ public void logAgentStopped(int userId, ComponentName agent) {
+ addEvent(new Event(TYPE_AGENT_STOPPED, userId, agent, null, 0, false));
+ }
+
private void addEvent(Event e) {
if (mEvents.size() >= HISTORY_LIMIT) {
mEvents.removeFirst();
@@ -152,6 +162,10 @@ public class TrustArchive {
return "TrustTimeout";
case TYPE_AGENT_DIED:
return "AgentDied";
+ case TYPE_AGENT_CONNECTED:
+ return "AgentConnected";
+ case TYPE_AGENT_STOPPED:
+ return "AgentStopped";
default:
return "Unknown(" + type + ")";
}