FileDocCategorySizeDatePackage
TrustArchive.javaAPI DocAndroid 5.1 API6549Thu Mar 12 22:22:42 GMT 2015com.android.server.trust

TrustArchive

public 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
Constructors Summary
Methods Summary
private voidaddEvent(com.android.server.trust.TrustArchive$Event e)

        if (mEvents.size() >= HISTORY_LIMIT) {
            mEvents.removeFirst();
        }
        mEvents.addLast(e);
    
public voiddump(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.StringdumpType(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.StringformatDuration(long duration)

        StringBuilder sb = new StringBuilder();
        TimeUtils.formatDuration(duration, sb);
        return sb.toString();
    
private static java.lang.StringformatElapsed(long elapsed)

        long delta = elapsed - SystemClock.elapsedRealtime();
        long wallTime = delta + System.currentTimeMillis();
        return TimeUtils.logTimeOfDay(wallTime);
    
static java.lang.StringgetSimpleName(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 voidlogAgentConnected(int userId, android.content.ComponentName agent)

        addEvent(new Event(TYPE_AGENT_CONNECTED, userId, agent, null, 0, false, false));
    
public voidlogAgentDied(int userId, android.content.ComponentName agent)

        addEvent(new Event(TYPE_AGENT_DIED, userId, agent, null, 0, false, false));
    
public voidlogAgentStopped(int userId, android.content.ComponentName agent)

        addEvent(new Event(TYPE_AGENT_STOPPED, userId, agent, null, 0, false, false));
    
public voidlogGrantTrust(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 voidlogManagingTrust(int userId, android.content.ComponentName agent, boolean managing)

        addEvent(new Event(TYPE_MANAGING_TRUST, userId, agent, null, 0, false, managing));
    
public voidlogRevokeTrust(int userId, android.content.ComponentName agent)

        addEvent(new Event(TYPE_REVOKE_TRUST, userId, agent, null, 0, false, false));
    
public voidlogTrustTimeout(int userId, android.content.ComponentName agent)

        addEvent(new Event(TYPE_TRUST_TIMEOUT, userId, agent, null, 0, false, false));