Merge "AOD: Track missed AOD time ticks" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e7b581bca9
@@ -145,6 +145,11 @@ public class DozeLog {
|
|||||||
log("screenOff why=" + why);
|
log("screenOff why=" + why);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void traceMissedTick(String delay) {
|
||||||
|
if (!ENABLED) return;
|
||||||
|
log("missedTick by=" + delay);
|
||||||
|
}
|
||||||
|
|
||||||
public static void traceKeyguard(boolean showing) {
|
public static void traceKeyguard(boolean showing) {
|
||||||
if (!ENABLED) return;
|
if (!ENABLED) return;
|
||||||
log("keyguard " + showing);
|
log("keyguard " + showing);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import android.app.AlarmManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.text.format.Formatter;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.systemui.util.wakelock.WakeLock;
|
import com.android.systemui.util.wakelock.WakeLock;
|
||||||
|
|
||||||
@@ -31,6 +33,7 @@ import java.util.GregorianCalendar;
|
|||||||
*/
|
*/
|
||||||
public class DozeUi implements DozeMachine.Part {
|
public class DozeUi implements DozeMachine.Part {
|
||||||
|
|
||||||
|
private static final long TIME_TICK_DEADLINE_MILLIS = 90 * 1000; // 1.5min
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final AlarmManager mAlarmManager;
|
private final AlarmManager mAlarmManager;
|
||||||
private final DozeHost mHost;
|
private final DozeHost mHost;
|
||||||
@@ -40,6 +43,7 @@ public class DozeUi implements DozeMachine.Part {
|
|||||||
private final AlarmManager.OnAlarmListener mTimeTick;
|
private final AlarmManager.OnAlarmListener mTimeTick;
|
||||||
|
|
||||||
private boolean mTimeTickScheduled = false;
|
private boolean mTimeTickScheduled = false;
|
||||||
|
private long mLastTimeTickElapsed = 0;
|
||||||
|
|
||||||
public DozeUi(Context context, AlarmManager alarmManager, DozeMachine machine,
|
public DozeUi(Context context, AlarmManager alarmManager, DozeMachine machine,
|
||||||
WakeLock wakeLock, DozeHost host, Handler handler) {
|
WakeLock wakeLock, DozeHost host, Handler handler) {
|
||||||
@@ -103,15 +107,26 @@ public class DozeUi implements DozeMachine.Part {
|
|||||||
SystemClock.elapsedRealtime() + delta, "doze_time_tick", mTimeTick, mHandler);
|
SystemClock.elapsedRealtime() + delta, "doze_time_tick", mTimeTick, mHandler);
|
||||||
|
|
||||||
mTimeTickScheduled = true;
|
mTimeTickScheduled = true;
|
||||||
|
mLastTimeTickElapsed = SystemClock.elapsedRealtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unscheduleTimeTick() {
|
private void unscheduleTimeTick() {
|
||||||
if (!mTimeTickScheduled) {
|
if (!mTimeTickScheduled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
verifyLastTimeTick();
|
||||||
mAlarmManager.cancel(mTimeTick);
|
mAlarmManager.cancel(mTimeTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void verifyLastTimeTick() {
|
||||||
|
long millisSinceLastTick = SystemClock.elapsedRealtime() - mLastTimeTickElapsed;
|
||||||
|
if (millisSinceLastTick > TIME_TICK_DEADLINE_MILLIS) {
|
||||||
|
String delay = Formatter.formatShortElapsedTime(mContext, millisSinceLastTick);
|
||||||
|
DozeLog.traceMissedTick(delay);
|
||||||
|
Log.e(DozeMachine.TAG, "Missed AOD time tick by " + delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private long roundToNextMinute(long timeInMillis) {
|
private long roundToNextMinute(long timeInMillis) {
|
||||||
Calendar calendar = GregorianCalendar.getInstance();
|
Calendar calendar = GregorianCalendar.getInstance();
|
||||||
calendar.setTimeInMillis(timeInMillis);
|
calendar.setTimeInMillis(timeInMillis);
|
||||||
@@ -127,6 +142,7 @@ public class DozeUi implements DozeMachine.Part {
|
|||||||
// Alarm was canceled, but we still got the callback. Ignore.
|
// Alarm was canceled, but we still got the callback. Ignore.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
verifyLastTimeTick();
|
||||||
|
|
||||||
mHost.dozeTimeTick();
|
mHost.dozeTimeTick();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user