FileDocCategorySizeDatePackage
DozeLog.javaAPI DocAndroid 5.1 API9347Thu Mar 12 22:22:42 GMT 2015com.android.systemui.doze

DozeLog

public class DozeLog extends Object

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
private static final boolean
ENABLED
private static final int
SIZE
private static final SimpleDateFormat
FORMAT
private static final int
PULSE_REASONS
public static final int
PULSE_REASON_INTENT
public static final int
PULSE_REASON_NOTIFICATION
public static final int
PULSE_REASON_SENSOR_SIGMOTION
public static final int
PULSE_REASON_SENSOR_PICKUP
private static long[]
sTimes
private static String[]
sMessages
private static int
sPosition
private static int
sCount
private static boolean
sPulsing
private static long
sSince
private static SummaryStats
sPickupPulseNearVibrationStats
private static SummaryStats
sPickupPulseNotNearVibrationStats
private static SummaryStats
sNotificationPulseStats
private static SummaryStats
sScreenOnPulsingStats
private static SummaryStats
sScreenOnNotPulsingStats
private static SummaryStats
sEmergencyCallStats
private static SummaryStats[]
sProxStats
private static final com.android.keyguard.KeyguardUpdateMonitorCallback
sKeyguardCallback
Constructors Summary
Methods Summary
public static voiddump(java.io.PrintWriter pw)

        synchronized (DozeLog.class) {
            if (sMessages == null) return;
            pw.println("  Doze log:");
            final int start = (sPosition - sCount + SIZE) % SIZE;
            for (int i = 0; i < sCount; i++) {
                final int j = (start + i) % SIZE;
                pw.print("    ");
                pw.print(FORMAT.format(new Date(sTimes[j])));
                pw.print(' ");
                pw.println(sMessages[j]);
            }
            pw.print("  Doze summary stats (for ");
            TimeUtils.formatDuration(System.currentTimeMillis() - sSince, pw);
            pw.println("):");
            sPickupPulseNearVibrationStats.dump(pw, "Pickup pulse (near vibration)");
            sPickupPulseNotNearVibrationStats.dump(pw, "Pickup pulse (not near vibration)");
            sNotificationPulseStats.dump(pw, "Notification pulse");
            sScreenOnPulsingStats.dump(pw, "Screen on (pulsing)");
            sScreenOnNotPulsingStats.dump(pw, "Screen on (not pulsing)");
            sEmergencyCallStats.dump(pw, "Emergency call");
            for (int i = 0; i < PULSE_REASONS; i++) {
                final String reason = pulseReasonToString(i);
                sProxStats[i][0].dump(pw, "Proximity near (" + reason + ")");
                sProxStats[i][1].dump(pw, "Proximity far (" + reason + ")");
            }
        }
    
private static voidlog(java.lang.String msg)

        synchronized (DozeLog.class) {
            if (sMessages == null) return;
            sTimes[sPosition] = System.currentTimeMillis();
            sMessages[sPosition] = msg;
            sPosition = (sPosition + 1) % SIZE;
            sCount = Math.min(sCount + 1, SIZE);
        }
        if (DEBUG) Log.d(TAG, msg);
    
public static java.lang.StringpulseReasonToString(int pulseReason)

        switch (pulseReason) {
            case PULSE_REASON_INTENT: return "intent";
            case PULSE_REASON_NOTIFICATION: return "notification";
            case PULSE_REASON_SENSOR_SIGMOTION: return "sigmotion";
            case PULSE_REASON_SENSOR_PICKUP: return "pickup";
            default: throw new IllegalArgumentException("bad reason: " + pulseReason);
        }
    
public static voidtraceDozing(android.content.Context context, boolean dozing)

        if (!ENABLED) return;
        sPulsing = false;
        synchronized (DozeLog.class) {
            if (dozing && sMessages == null) {
                sTimes = new long[SIZE];
                sMessages = new String[SIZE];
                sSince = System.currentTimeMillis();
                sPickupPulseNearVibrationStats = new SummaryStats();
                sPickupPulseNotNearVibrationStats = new SummaryStats();
                sNotificationPulseStats = new SummaryStats();
                sScreenOnPulsingStats = new SummaryStats();
                sScreenOnNotPulsingStats = new SummaryStats();
                sEmergencyCallStats = new SummaryStats();
                sProxStats = new SummaryStats[PULSE_REASONS][2];
                for (int i = 0; i < PULSE_REASONS; i++) {
                    sProxStats[i][0] = new SummaryStats();
                    sProxStats[i][1] = new SummaryStats();
                }
                log("init");
                KeyguardUpdateMonitor.getInstance(context).registerCallback(sKeyguardCallback);
            }
        }
        log("dozing " + dozing);
    
public static voidtraceEmergencyCall()

        if (!ENABLED) return;
        log("emergencyCall");
        sEmergencyCallStats.append();
    
public static voidtraceFling(boolean expand, boolean aboveThreshold, boolean thresholdNeeded, boolean screenOnFromTouch)

        if (!ENABLED) return;
        log("fling expand=" + expand + " aboveThreshold=" + aboveThreshold + " thresholdNeeded="
                + thresholdNeeded + " screenOnFromTouch=" + screenOnFromTouch);
    
public static voidtraceKeyguard(boolean showing)

        if (!ENABLED) return;
        log("keyguard " + showing);
        if (!showing) {
            sPulsing = false;
        }
    
public static voidtraceKeyguardBouncerChanged(boolean showing)

        if (!ENABLED) return;
        log("bouncer " + showing);
    
public static voidtraceNotificationPulse(long instance)

        if (!ENABLED) return;
        log("notificationPulse instance=" + instance);
        sNotificationPulseStats.append();
    
public static voidtracePickupPulse(boolean withinVibrationThreshold)

 // [reason][near/far]

         
        if (!ENABLED) return;
        log("pickupPulse withinVibrationThreshold=" + withinVibrationThreshold);
        (withinVibrationThreshold ? sPickupPulseNearVibrationStats
                : sPickupPulseNotNearVibrationStats).append();
    
public static voidtraceProximityResult(boolean near, long millis, int pulseReason)

        if (!ENABLED) return;
        log("proximityResult reason=" + pulseReasonToString(pulseReason) + " near=" + near
                + " millis=" + millis);
        sProxStats[pulseReason][near ? 0 : 1].append();
    
public static voidtracePulseFinish()

        if (!ENABLED) return;
        sPulsing = false;
        log("pulseFinish");
    
public static voidtracePulseStart(int reason)

        if (!ENABLED) return;
        sPulsing = true;
        log("pulseStart reason=" + pulseReasonToString(reason));
    
public static voidtraceScreenOff(int why)

        if (!ENABLED) return;
        log("screenOff why=" + why);
    
public static voidtraceScreenOn()

        if (!ENABLED) return;
        log("screenOn pulsing=" + sPulsing);
        (sPulsing ? sScreenOnPulsingStats : sScreenOnNotPulsingStats).append();
        sPulsing = false;