TrustArchivepublic class TrustArchive extends Object An archive of trust events. |
Fields Summary |
---|
private static final int | TYPE_GRANT_TRUST | private static final int | TYPE_REVOKE_TRUST | private static final int | TYPE_TRUST_TIMEOUT | private static final int | TYPE_AGENT_DIED | private static final int | TYPE_AGENT_CONNECTED | private static final int | TYPE_AGENT_STOPPED | private static final int | TYPE_MANAGING_TRUST | private static final int | HISTORY_LIMIT | ArrayDeque | mEvents |
Methods Summary |
---|
private void | addEvent(com.android.server.trust.TrustArchive$Event e)
if (mEvents.size() >= HISTORY_LIMIT) {
mEvents.removeFirst();
}
mEvents.addLast(e);
| public void | dump(java.io.PrintWriter writer, int limit, int userId, java.lang.String linePrefix, boolean duplicateSimpleNames)
int count = 0;
Iterator<Event> iter = mEvents.descendingIterator();
while (iter.hasNext() && count < limit) {
Event ev = iter.next();
if (userId != UserHandle.USER_ALL && userId != ev.userId) {
continue;
}
writer.print(linePrefix);
writer.printf("#%-2d %s %s: ", count, formatElapsed(ev.elapsedTimestamp),
dumpType(ev.type));
if (userId == UserHandle.USER_ALL) {
writer.print("user="); writer.print(ev.userId); writer.print(", ");
}
writer.print("agent=");
if (duplicateSimpleNames) {
writer.print(ev.agent.flattenToShortString());
} else {
writer.print(getSimpleName(ev.agent));
}
switch (ev.type) {
case TYPE_GRANT_TRUST:
writer.printf(", message=\"%s\", duration=%s, initiatedByUser=%d",
ev.message, formatDuration(ev.duration), ev.userInitiated ? 1 : 0);
break;
case TYPE_MANAGING_TRUST:
writer.printf(", managingTrust=" + ev.managingTrust);
break;
default:
}
writer.println();
count++;
}
| private java.lang.String | dumpType(int type)
switch (type) {
case TYPE_GRANT_TRUST:
return "GrantTrust";
case TYPE_REVOKE_TRUST:
return "RevokeTrust";
case TYPE_TRUST_TIMEOUT:
return "TrustTimeout";
case TYPE_AGENT_DIED:
return "AgentDied";
case TYPE_AGENT_CONNECTED:
return "AgentConnected";
case TYPE_AGENT_STOPPED:
return "AgentStopped";
case TYPE_MANAGING_TRUST:
return "ManagingTrust";
default:
return "Unknown(" + type + ")";
}
| public static java.lang.String | formatDuration(long duration)
StringBuilder sb = new StringBuilder();
TimeUtils.formatDuration(duration, sb);
return sb.toString();
| private static java.lang.String | formatElapsed(long elapsed)
long delta = elapsed - SystemClock.elapsedRealtime();
long wallTime = delta + System.currentTimeMillis();
return TimeUtils.logTimeOfDay(wallTime);
| static java.lang.String | getSimpleName(android.content.ComponentName cn)
String name = cn.getClassName();
int idx = name.lastIndexOf('.");
if (idx < name.length() && idx >= 0) {
return name.substring(idx + 1);
} else {
return name;
}
| public void | logAgentConnected(int userId, android.content.ComponentName agent)
addEvent(new Event(TYPE_AGENT_CONNECTED, userId, agent, null, 0, false, false));
| public void | logAgentDied(int userId, android.content.ComponentName agent)
addEvent(new Event(TYPE_AGENT_DIED, userId, agent, null, 0, false, false));
| public void | logAgentStopped(int userId, android.content.ComponentName agent)
addEvent(new Event(TYPE_AGENT_STOPPED, userId, agent, null, 0, false, false));
| public void | logGrantTrust(int userId, android.content.ComponentName agent, java.lang.String message, long duration, boolean userInitiated)
addEvent(new Event(TYPE_GRANT_TRUST, userId, agent, message, duration,
userInitiated, false));
| public void | logManagingTrust(int userId, android.content.ComponentName agent, boolean managing)
addEvent(new Event(TYPE_MANAGING_TRUST, userId, agent, null, 0, false, managing));
| public void | logRevokeTrust(int userId, android.content.ComponentName agent)
addEvent(new Event(TYPE_REVOKE_TRUST, userId, agent, null, 0, false, false));
| public void | logTrustTimeout(int userId, android.content.ComponentName agent)
addEvent(new Event(TYPE_TRUST_TIMEOUT, userId, agent, null, 0, false, false));
|
|