diff options
author | John Spurlock <jspurlock@google.com> | 2014-11-29 11:33:49 -0500 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-11-29 11:45:31 -0500 |
commit | eab28e660223b6e02f2fbd8dc31c8bde3ce5b22d (patch) | |
tree | efcd2c9bf5e1878e0a009b036dbdf4c49aae7c92 /packages/SystemUI/src/com/android/systemui/doze | |
parent | c1de25d8ebaecff697c1d5dfaa445e18ee07fa2d (diff) | |
download | frameworks_base-eab28e660223b6e02f2fbd8dc31c8bde3ce5b22d.zip frameworks_base-eab28e660223b6e02f2fbd8dc31c8bde3ce5b22d.tar.gz frameworks_base-eab28e660223b6e02f2fbd8dc31c8bde3ce5b22d.tar.bz2 |
Doze: Break out proxcheck stats by pulse reason.
Enumerate all possible reasons for doze pulses, and subdivide
the proxcheck stats (near/far) by reason. Include reason in
doze log when starting a pulse.
Bug: 18373928
Change-Id: I4ebc2df082f51d47e3b2f0cb3999faeb582ef8dc
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/doze')
3 files changed, 53 insertions, 24 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java index e92f988..6ea5c70 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java @@ -25,7 +25,7 @@ public interface DozeHost { void addCallback(@NonNull Callback callback); void removeCallback(@NonNull Callback callback); void startDozing(@NonNull Runnable ready); - void pulseWhileDozing(@NonNull PulseCallback callback); + void pulseWhileDozing(@NonNull PulseCallback callback, int reason); void stopDozing(); boolean isPowerSaveActive(); diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java index fcdbfc1..7eb9c6e 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java @@ -35,6 +35,13 @@ public class DozeLog { private static final int SIZE = Build.IS_DEBUGGABLE ? 400 : 50; private static final SimpleDateFormat FORMAT = new SimpleDateFormat("MM-dd HH:mm:ss.SSS"); + private static final int PULSE_REASONS = 4; + + public static final int PULSE_REASON_INTENT = 0; + public static final int PULSE_REASON_NOTIFICATION = 1; + public static final int PULSE_REASON_SENSOR_SIGMOTION = 2; + public static final int PULSE_REASON_SENSOR_PICKUP = 3; + private static long[] sTimes; private static String[] sMessages; private static int sPosition; @@ -48,8 +55,7 @@ public class DozeLog { private static SummaryStats sScreenOnPulsingStats; private static SummaryStats sScreenOnNotPulsingStats; private static SummaryStats sEmergencyCallStats; - private static SummaryStats sProxNearStats; - private static SummaryStats sProxFarStats; + private static SummaryStats[][] sProxStats; // [reason][near/far] public static void tracePickupPulse(boolean withinVibrationThreshold) { if (!ENABLED) return; @@ -58,10 +64,10 @@ public class DozeLog { : sPickupPulseNotNearVibrationStats).append(); } - public static void tracePulseStart() { + public static void tracePulseStart(int reason) { if (!ENABLED) return; sPulsing = true; - log("pulseStart"); + log("pulseStart reason=" + pulseReasonToString(reason)); } public static void tracePulseFinish() { @@ -90,8 +96,11 @@ public class DozeLog { sScreenOnPulsingStats = new SummaryStats(); sScreenOnNotPulsingStats = new SummaryStats(); sEmergencyCallStats = new SummaryStats(); - sProxNearStats = new SummaryStats(); - sProxFarStats = 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); } @@ -137,10 +146,21 @@ public class DozeLog { } } - public static void traceProximityResult(boolean near, long millis) { + public static void traceProximityResult(boolean near, long millis, int pulseReason) { if (!ENABLED) return; - log("proximityResult near=" + near + " millis=" + millis); - (near ? sProxNearStats : sProxFarStats).append(); + log("proximityResult reason=" + pulseReasonToString(pulseReason) + " near=" + near + + " millis=" + millis); + sProxStats[pulseReason][near ? 0 : 1].append(); + } + + private static String pulseReasonToString(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 void dump(PrintWriter pw) { @@ -164,8 +184,11 @@ public class DozeLog { sScreenOnPulsingStats.dump(pw, "Screen on (pulsing)"); sScreenOnNotPulsingStats.dump(pw, "Screen on (not pulsing)"); sEmergencyCallStats.dump(pw, "Emergency call"); - sProxNearStats.dump(pw, "Proximity (near)"); - sProxFarStats.dump(pw, "Proximity (far)"); + 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 + ")"); + } } } @@ -188,6 +211,7 @@ public class DozeLog { } public void dump(PrintWriter pw, String type) { + if (mCount == 0) return; pw.print(" "); pw.print(type); pw.print(": n="); diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java index 89b3e5b..1e29476 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java @@ -118,9 +118,11 @@ public class DozeService extends DreamService { mSensors = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); mSigMotionSensor = new TriggerSensor(Sensor.TYPE_SIGNIFICANT_MOTION, - mDozeParameters.getPulseOnSigMotion(), mDozeParameters.getVibrateOnSigMotion()); + mDozeParameters.getPulseOnSigMotion(), mDozeParameters.getVibrateOnSigMotion(), + DozeLog.PULSE_REASON_SENSOR_SIGMOTION); mPickupSensor = new TriggerSensor(Sensor.TYPE_PICK_UP_GESTURE, - mDozeParameters.getPulseOnPickup(), mDozeParameters.getVibrateOnPickup()); + mDozeParameters.getPulseOnPickup(), mDozeParameters.getVibrateOnPickup(), + DozeLog.PULSE_REASON_SENSOR_PICKUP); mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mTag); mWakeLock.setReferenceCounted(true); @@ -195,7 +197,7 @@ public class DozeService extends DreamService { mHost.stopDozing(); } - private void requestPulse() { + private void requestPulse(final int reason) { if (mHost != null && mDreaming && !mPulsing) { // Let the host know we want to pulse. Wait for it to be ready, then // turn the screen on. When finished, turn the screen off again. @@ -204,7 +206,7 @@ public class DozeService extends DreamService { mPulsing = true; if (!mDozeParameters.getProxCheckBeforePulse()) { // skip proximity check - continuePulsing(); + continuePulsing(reason); return; } // perform a proximity check before pulsing @@ -214,7 +216,8 @@ public class DozeService extends DreamService { public void onProximityResult(int result) { // avoid pulsing in pockets final boolean isNear = result == RESULT_NEAR; - DozeLog.traceProximityResult(isNear, SystemClock.uptimeMillis() - start); + final long end = SystemClock.uptimeMillis(); + DozeLog.traceProximityResult(isNear, end - start, reason); if (isNear) { mPulsing = false; mWakeLock.release(); @@ -222,13 +225,13 @@ public class DozeService extends DreamService { } // not in-pocket, continue pulsing - continuePulsing(); + continuePulsing(reason); } }.check(); } } - private void continuePulsing() { + private void continuePulsing(int reason) { mHost.pulseWhileDozing(new DozeHost.PulseCallback() { @Override public void onPulseStarted() { @@ -245,7 +248,7 @@ public class DozeService extends DreamService { } mWakeLock.release(); // needs to be unconditional to balance acquire } - }); + }, reason); } private void turnDisplayOff() { @@ -380,13 +383,13 @@ public class DozeService extends DreamService { public void onReceive(Context context, Intent intent) { if (PULSE_ACTION.equals(intent.getAction())) { if (DEBUG) Log.d(mTag, "Received pulse intent"); - requestPulse(); + requestPulse(DozeLog.PULSE_REASON_INTENT); } if (NOTIFICATION_PULSE_ACTION.equals(intent.getAction())) { final long instance = intent.getLongExtra(EXTRA_INSTANCE, -1); if (DEBUG) Log.d(mTag, "Received notification pulse intent instance=" + instance); DozeLog.traceNotificationPulse(instance); - requestPulse(); + requestPulse(DozeLog.PULSE_REASON_NOTIFICATION); rescheduleNotificationPulse(mNotificationLightOn); } if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { @@ -434,15 +437,17 @@ public class DozeService extends DreamService { private final Sensor mSensor; private final boolean mConfigured; private final boolean mDebugVibrate; + private final int mPulseReason; private boolean mRequested; private boolean mRegistered; private boolean mDisabled; - public TriggerSensor(int type, boolean configured, boolean debugVibrate) { + public TriggerSensor(int type, boolean configured, boolean debugVibrate, int pulseReason) { mSensor = mSensors.getDefaultSensor(type); mConfigured = configured; mDebugVibrate = debugVibrate; + mPulseReason = pulseReason; } public void setListening(boolean listen) { @@ -494,7 +499,7 @@ public class DozeService extends DreamService { } } - requestPulse(); + requestPulse(mPulseReason); mRegistered = false; updateListener(); // reregister, this sensor only fires once |