am 1a3af711: Merge "Doze: Break out proxcheck stats by pulse reason." into lmp-mr1-dev
* commit '1a3af711ab6f811a6bc4e9211cb255721fb1847d': Doze: Break out proxcheck stats by pulse reason.
This commit is contained in:
@@ -25,7 +25,7 @@ public interface DozeHost {
|
|||||||
void addCallback(@NonNull Callback callback);
|
void addCallback(@NonNull Callback callback);
|
||||||
void removeCallback(@NonNull Callback callback);
|
void removeCallback(@NonNull Callback callback);
|
||||||
void startDozing(@NonNull Runnable ready);
|
void startDozing(@NonNull Runnable ready);
|
||||||
void pulseWhileDozing(@NonNull PulseCallback callback);
|
void pulseWhileDozing(@NonNull PulseCallback callback, int reason);
|
||||||
void stopDozing();
|
void stopDozing();
|
||||||
boolean isPowerSaveActive();
|
boolean isPowerSaveActive();
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ public class DozeLog {
|
|||||||
private static final int SIZE = Build.IS_DEBUGGABLE ? 400 : 50;
|
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 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 long[] sTimes;
|
||||||
private static String[] sMessages;
|
private static String[] sMessages;
|
||||||
private static int sPosition;
|
private static int sPosition;
|
||||||
@@ -48,8 +55,7 @@ public class DozeLog {
|
|||||||
private static SummaryStats sScreenOnPulsingStats;
|
private static SummaryStats sScreenOnPulsingStats;
|
||||||
private static SummaryStats sScreenOnNotPulsingStats;
|
private static SummaryStats sScreenOnNotPulsingStats;
|
||||||
private static SummaryStats sEmergencyCallStats;
|
private static SummaryStats sEmergencyCallStats;
|
||||||
private static SummaryStats sProxNearStats;
|
private static SummaryStats[][] sProxStats; // [reason][near/far]
|
||||||
private static SummaryStats sProxFarStats;
|
|
||||||
|
|
||||||
public static void tracePickupPulse(boolean withinVibrationThreshold) {
|
public static void tracePickupPulse(boolean withinVibrationThreshold) {
|
||||||
if (!ENABLED) return;
|
if (!ENABLED) return;
|
||||||
@@ -58,10 +64,10 @@ public class DozeLog {
|
|||||||
: sPickupPulseNotNearVibrationStats).append();
|
: sPickupPulseNotNearVibrationStats).append();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tracePulseStart() {
|
public static void tracePulseStart(int reason) {
|
||||||
if (!ENABLED) return;
|
if (!ENABLED) return;
|
||||||
sPulsing = true;
|
sPulsing = true;
|
||||||
log("pulseStart");
|
log("pulseStart reason=" + pulseReasonToString(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tracePulseFinish() {
|
public static void tracePulseFinish() {
|
||||||
@@ -90,8 +96,11 @@ public class DozeLog {
|
|||||||
sScreenOnPulsingStats = new SummaryStats();
|
sScreenOnPulsingStats = new SummaryStats();
|
||||||
sScreenOnNotPulsingStats = new SummaryStats();
|
sScreenOnNotPulsingStats = new SummaryStats();
|
||||||
sEmergencyCallStats = new SummaryStats();
|
sEmergencyCallStats = new SummaryStats();
|
||||||
sProxNearStats = new SummaryStats();
|
sProxStats = new SummaryStats[PULSE_REASONS][2];
|
||||||
sProxFarStats = new SummaryStats();
|
for (int i = 0; i < PULSE_REASONS; i++) {
|
||||||
|
sProxStats[i][0] = new SummaryStats();
|
||||||
|
sProxStats[i][1] = new SummaryStats();
|
||||||
|
}
|
||||||
log("init");
|
log("init");
|
||||||
KeyguardUpdateMonitor.getInstance(context).registerCallback(sKeyguardCallback);
|
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;
|
if (!ENABLED) return;
|
||||||
log("proximityResult near=" + near + " millis=" + millis);
|
log("proximityResult reason=" + pulseReasonToString(pulseReason) + " near=" + near
|
||||||
(near ? sProxNearStats : sProxFarStats).append();
|
+ " 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) {
|
public static void dump(PrintWriter pw) {
|
||||||
@@ -164,8 +184,11 @@ public class DozeLog {
|
|||||||
sScreenOnPulsingStats.dump(pw, "Screen on (pulsing)");
|
sScreenOnPulsingStats.dump(pw, "Screen on (pulsing)");
|
||||||
sScreenOnNotPulsingStats.dump(pw, "Screen on (not pulsing)");
|
sScreenOnNotPulsingStats.dump(pw, "Screen on (not pulsing)");
|
||||||
sEmergencyCallStats.dump(pw, "Emergency call");
|
sEmergencyCallStats.dump(pw, "Emergency call");
|
||||||
sProxNearStats.dump(pw, "Proximity (near)");
|
for (int i = 0; i < PULSE_REASONS; i++) {
|
||||||
sProxFarStats.dump(pw, "Proximity (far)");
|
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) {
|
public void dump(PrintWriter pw, String type) {
|
||||||
|
if (mCount == 0) return;
|
||||||
pw.print(" ");
|
pw.print(" ");
|
||||||
pw.print(type);
|
pw.print(type);
|
||||||
pw.print(": n=");
|
pw.print(": n=");
|
||||||
|
|||||||
@@ -118,9 +118,11 @@ public class DozeService extends DreamService {
|
|||||||
|
|
||||||
mSensors = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
mSensors = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
||||||
mSigMotionSensor = new TriggerSensor(Sensor.TYPE_SIGNIFICANT_MOTION,
|
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,
|
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);
|
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mTag);
|
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mTag);
|
||||||
mWakeLock.setReferenceCounted(true);
|
mWakeLock.setReferenceCounted(true);
|
||||||
@@ -195,7 +197,7 @@ public class DozeService extends DreamService {
|
|||||||
mHost.stopDozing();
|
mHost.stopDozing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestPulse() {
|
private void requestPulse(final int reason) {
|
||||||
if (mHost != null && mDreaming && !mPulsing) {
|
if (mHost != null && mDreaming && !mPulsing) {
|
||||||
// Let the host know we want to pulse. Wait for it to be ready, then
|
// 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.
|
// turn the screen on. When finished, turn the screen off again.
|
||||||
@@ -204,7 +206,7 @@ public class DozeService extends DreamService {
|
|||||||
mPulsing = true;
|
mPulsing = true;
|
||||||
if (!mDozeParameters.getProxCheckBeforePulse()) {
|
if (!mDozeParameters.getProxCheckBeforePulse()) {
|
||||||
// skip proximity check
|
// skip proximity check
|
||||||
continuePulsing();
|
continuePulsing(reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// perform a proximity check before pulsing
|
// perform a proximity check before pulsing
|
||||||
@@ -214,7 +216,8 @@ public class DozeService extends DreamService {
|
|||||||
public void onProximityResult(int result) {
|
public void onProximityResult(int result) {
|
||||||
// avoid pulsing in pockets
|
// avoid pulsing in pockets
|
||||||
final boolean isNear = result == RESULT_NEAR;
|
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) {
|
if (isNear) {
|
||||||
mPulsing = false;
|
mPulsing = false;
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
@@ -222,13 +225,13 @@ public class DozeService extends DreamService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// not in-pocket, continue pulsing
|
// not in-pocket, continue pulsing
|
||||||
continuePulsing();
|
continuePulsing(reason);
|
||||||
}
|
}
|
||||||
}.check();
|
}.check();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void continuePulsing() {
|
private void continuePulsing(int reason) {
|
||||||
mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPulseStarted() {
|
public void onPulseStarted() {
|
||||||
@@ -245,7 +248,7 @@ public class DozeService extends DreamService {
|
|||||||
}
|
}
|
||||||
mWakeLock.release(); // needs to be unconditional to balance acquire
|
mWakeLock.release(); // needs to be unconditional to balance acquire
|
||||||
}
|
}
|
||||||
});
|
}, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void turnDisplayOff() {
|
private void turnDisplayOff() {
|
||||||
@@ -380,13 +383,13 @@ public class DozeService extends DreamService {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (PULSE_ACTION.equals(intent.getAction())) {
|
if (PULSE_ACTION.equals(intent.getAction())) {
|
||||||
if (DEBUG) Log.d(mTag, "Received pulse intent");
|
if (DEBUG) Log.d(mTag, "Received pulse intent");
|
||||||
requestPulse();
|
requestPulse(DozeLog.PULSE_REASON_INTENT);
|
||||||
}
|
}
|
||||||
if (NOTIFICATION_PULSE_ACTION.equals(intent.getAction())) {
|
if (NOTIFICATION_PULSE_ACTION.equals(intent.getAction())) {
|
||||||
final long instance = intent.getLongExtra(EXTRA_INSTANCE, -1);
|
final long instance = intent.getLongExtra(EXTRA_INSTANCE, -1);
|
||||||
if (DEBUG) Log.d(mTag, "Received notification pulse intent instance=" + instance);
|
if (DEBUG) Log.d(mTag, "Received notification pulse intent instance=" + instance);
|
||||||
DozeLog.traceNotificationPulse(instance);
|
DozeLog.traceNotificationPulse(instance);
|
||||||
requestPulse();
|
requestPulse(DozeLog.PULSE_REASON_NOTIFICATION);
|
||||||
rescheduleNotificationPulse(mNotificationLightOn);
|
rescheduleNotificationPulse(mNotificationLightOn);
|
||||||
}
|
}
|
||||||
if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) {
|
if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) {
|
||||||
@@ -434,15 +437,17 @@ public class DozeService extends DreamService {
|
|||||||
private final Sensor mSensor;
|
private final Sensor mSensor;
|
||||||
private final boolean mConfigured;
|
private final boolean mConfigured;
|
||||||
private final boolean mDebugVibrate;
|
private final boolean mDebugVibrate;
|
||||||
|
private final int mPulseReason;
|
||||||
|
|
||||||
private boolean mRequested;
|
private boolean mRequested;
|
||||||
private boolean mRegistered;
|
private boolean mRegistered;
|
||||||
private boolean mDisabled;
|
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);
|
mSensor = mSensors.getDefaultSensor(type);
|
||||||
mConfigured = configured;
|
mConfigured = configured;
|
||||||
mDebugVibrate = debugVibrate;
|
mDebugVibrate = debugVibrate;
|
||||||
|
mPulseReason = pulseReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListening(boolean listen) {
|
public void setListening(boolean listen) {
|
||||||
@@ -494,7 +499,7 @@ public class DozeService extends DreamService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPulse();
|
requestPulse(mPulseReason);
|
||||||
mRegistered = false;
|
mRegistered = false;
|
||||||
updateListener(); // reregister, this sensor only fires once
|
updateListener(); // reregister, this sensor only fires once
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class DozeScrimController {
|
|||||||
|
|
||||||
private boolean mDozing;
|
private boolean mDozing;
|
||||||
private DozeHost.PulseCallback mPulseCallback;
|
private DozeHost.PulseCallback mPulseCallback;
|
||||||
|
private int mPulseReason;
|
||||||
private Animator mInFrontAnimator;
|
private Animator mInFrontAnimator;
|
||||||
private Animator mBehindAnimator;
|
private Animator mBehindAnimator;
|
||||||
private float mInFrontTarget;
|
private float mInFrontTarget;
|
||||||
@@ -82,7 +83,7 @@ public class DozeScrimController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** When dozing, fade screen contents in and out using the front scrim. */
|
/** When dozing, fade screen contents in and out using the front scrim. */
|
||||||
public void pulse(@NonNull DozeHost.PulseCallback callback) {
|
public void pulse(@NonNull DozeHost.PulseCallback callback, int reason) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
throw new IllegalArgumentException("callback must not be null");
|
throw new IllegalArgumentException("callback must not be null");
|
||||||
}
|
}
|
||||||
@@ -96,6 +97,7 @@ public class DozeScrimController {
|
|||||||
// Begin pulse. Note that it's very important that the pulse finished callback
|
// Begin pulse. Note that it's very important that the pulse finished callback
|
||||||
// be invoked when we're done so that the caller can drop the pulse wakelock.
|
// be invoked when we're done so that the caller can drop the pulse wakelock.
|
||||||
mPulseCallback = callback;
|
mPulseCallback = callback;
|
||||||
|
mPulseReason = reason;
|
||||||
mHandler.post(mPulseIn);
|
mHandler.post(mPulseIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +221,7 @@ public class DozeScrimController {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing);
|
if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing);
|
||||||
if (!mDozing) return;
|
if (!mDozing) return;
|
||||||
DozeLog.tracePulseStart();
|
DozeLog.tracePulseStart(mPulseReason);
|
||||||
startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(),
|
startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(),
|
||||||
mPulseInInterpolator, mDozeParameters.getPulseInDelay(), mPulseInFinished);
|
mPulseInInterpolator, mDozeParameters.getPulseInDelay(), mPulseInFinished);
|
||||||
|
|
||||||
|
|||||||
@@ -4183,8 +4183,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pulseWhileDozing(@NonNull PulseCallback callback) {
|
public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) {
|
||||||
mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, callback).sendToTarget();
|
mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, reason, 0, callback).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -4206,8 +4206,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
ready.run();
|
ready.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePulseWhileDozing(@NonNull PulseCallback callback) {
|
private void handlePulseWhileDozing(@NonNull PulseCallback callback, int reason) {
|
||||||
mDozeScrimController.pulse(callback);
|
mDozeScrimController.pulse(callback, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleStopDozing() {
|
private void handleStopDozing() {
|
||||||
@@ -4230,7 +4230,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
handleStartDozing((Runnable) msg.obj);
|
handleStartDozing((Runnable) msg.obj);
|
||||||
break;
|
break;
|
||||||
case MSG_PULSE_WHILE_DOZING:
|
case MSG_PULSE_WHILE_DOZING:
|
||||||
handlePulseWhileDozing((PulseCallback) msg.obj);
|
handlePulseWhileDozing((PulseCallback) msg.obj, msg.arg1);
|
||||||
break;
|
break;
|
||||||
case MSG_STOP_DOZING:
|
case MSG_STOP_DOZING:
|
||||||
handleStopDozing();
|
handleStopDozing();
|
||||||
|
|||||||
Reference in New Issue
Block a user