Loading packages/SystemUI/src/com/android/systemui/doze/DozeHost.java +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +35 −11 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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() { Loading Loading @@ -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); } Loading Loading @@ -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) { Loading @@ -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 + ")"); } } } Loading @@ -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="); Loading packages/SystemUI/src/com/android/systemui/doze/DozeService.java +17 −12 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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. Loading @@ -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 Loading @@ -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(); Loading @@ -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() { Loading @@ -245,7 +248,7 @@ public class DozeService extends DreamService { } mWakeLock.release(); // needs to be unconditional to balance acquire } }); }, reason); } private void turnDisplayOff() { Loading Loading @@ -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())) { Loading Loading @@ -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) { Loading Loading @@ -494,7 +499,7 @@ public class DozeService extends DreamService { } } requestPulse(); requestPulse(mPulseReason); mRegistered = false; updateListener(); // reregister, this sensor only fires once Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java +4 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ public class DozeScrimController { private boolean mDozing; private DozeHost.PulseCallback mPulseCallback; private int mPulseReason; private Animator mInFrontAnimator; private Animator mBehindAnimator; private float mInFrontTarget; Loading Loading @@ -82,7 +83,7 @@ public class DozeScrimController { } /** 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) { throw new IllegalArgumentException("callback must not be null"); } Loading @@ -96,6 +97,7 @@ public class DozeScrimController { // 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. mPulseCallback = callback; mPulseReason = reason; mHandler.post(mPulseIn); } Loading Loading @@ -219,7 +221,7 @@ public class DozeScrimController { public void run() { if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing); if (!mDozing) return; DozeLog.tracePulseStart(); DozeLog.tracePulseStart(mPulseReason); startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(), mPulseInInterpolator, mDozeParameters.getPulseInDelay(), mPulseInFinished); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +5 −5 Original line number Diff line number Diff line Loading @@ -4183,8 +4183,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } @Override public void pulseWhileDozing(@NonNull PulseCallback callback) { mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, callback).sendToTarget(); public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) { mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, reason, 0, callback).sendToTarget(); } @Override Loading @@ -4206,8 +4206,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, ready.run(); } private void handlePulseWhileDozing(@NonNull PulseCallback callback) { mDozeScrimController.pulse(callback); private void handlePulseWhileDozing(@NonNull PulseCallback callback, int reason) { mDozeScrimController.pulse(callback, reason); } private void handleStopDozing() { Loading @@ -4230,7 +4230,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, handleStartDozing((Runnable) msg.obj); break; case MSG_PULSE_WHILE_DOZING: handlePulseWhileDozing((PulseCallback) msg.obj); handlePulseWhileDozing((PulseCallback) msg.obj, msg.arg1); break; case MSG_STOP_DOZING: handleStopDozing(); Loading Loading
packages/SystemUI/src/com/android/systemui/doze/DozeHost.java +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading
packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +35 −11 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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() { Loading Loading @@ -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); } Loading Loading @@ -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) { Loading @@ -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 + ")"); } } } Loading @@ -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="); Loading
packages/SystemUI/src/com/android/systemui/doze/DozeService.java +17 −12 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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. Loading @@ -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 Loading @@ -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(); Loading @@ -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() { Loading @@ -245,7 +248,7 @@ public class DozeService extends DreamService { } mWakeLock.release(); // needs to be unconditional to balance acquire } }); }, reason); } private void turnDisplayOff() { Loading Loading @@ -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())) { Loading Loading @@ -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) { Loading Loading @@ -494,7 +499,7 @@ public class DozeService extends DreamService { } } requestPulse(); requestPulse(mPulseReason); mRegistered = false; updateListener(); // reregister, this sensor only fires once Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java +4 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ public class DozeScrimController { private boolean mDozing; private DozeHost.PulseCallback mPulseCallback; private int mPulseReason; private Animator mInFrontAnimator; private Animator mBehindAnimator; private float mInFrontTarget; Loading Loading @@ -82,7 +83,7 @@ public class DozeScrimController { } /** 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) { throw new IllegalArgumentException("callback must not be null"); } Loading @@ -96,6 +97,7 @@ public class DozeScrimController { // 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. mPulseCallback = callback; mPulseReason = reason; mHandler.post(mPulseIn); } Loading Loading @@ -219,7 +221,7 @@ public class DozeScrimController { public void run() { if (DEBUG) Log.d(TAG, "Pulse in, mDozing=" + mDozing); if (!mDozing) return; DozeLog.tracePulseStart(); DozeLog.tracePulseStart(mPulseReason); startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(), mPulseInInterpolator, mDozeParameters.getPulseInDelay(), mPulseInFinished); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +5 −5 Original line number Diff line number Diff line Loading @@ -4183,8 +4183,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } @Override public void pulseWhileDozing(@NonNull PulseCallback callback) { mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, callback).sendToTarget(); public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) { mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, reason, 0, callback).sendToTarget(); } @Override Loading @@ -4206,8 +4206,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, ready.run(); } private void handlePulseWhileDozing(@NonNull PulseCallback callback) { mDozeScrimController.pulse(callback); private void handlePulseWhileDozing(@NonNull PulseCallback callback, int reason) { mDozeScrimController.pulse(callback, reason); } private void handleStopDozing() { Loading @@ -4230,7 +4230,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, handleStartDozing((Runnable) msg.obj); break; case MSG_PULSE_WHILE_DOZING: handlePulseWhileDozing((PulseCallback) msg.obj); handlePulseWhileDozing((PulseCallback) msg.obj, msg.arg1); break; case MSG_STOP_DOZING: handleStopDozing(); Loading