summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/trust
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-05-27 20:01:31 +0200
committerAdrian Roos <roosa@google.com>2014-05-27 20:01:45 +0200
commit7d59b4f981e24a4a446522e9b8d3d6a7115c1459 (patch)
tree5df272233ce760d6bad71970a88552fc558ed768 /services/core/java/com/android/server/trust
parentbcbb75ac9d73a92632e97ab990a913ede755b176 (diff)
downloadframeworks_base-7d59b4f981e24a4a446522e9b8d3d6a7115c1459.zip
frameworks_base-7d59b4f981e24a4a446522e9b8d3d6a7115c1459.tar.gz
frameworks_base-7d59b4f981e24a4a446522e9b8d3d6a7115c1459.tar.bz2
Add and improve logged TrustAgent connection events
Adds events for when a TrustAgentService gets connected or is stopped. Also explicitly revokes trust when a trust agent gets disconnected, such that it shows up in dumpsys. Bug: 15281644 Change-Id: I5875a34da923345683279c1f755d43454ff6318d
Diffstat (limited to 'services/core/java/com/android/server/trust')
-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 + ")";
}