记录android修改息屏到锁屏的时间
在自动息屏后系统默认5s后进入锁屏。在自动息屏后在5s内按power键亮屏显示的是息屏前的界面,并不是锁屏界面,息屏后超过5s再次点亮屏幕显示的就是锁屏界面,想要修改这个时间就需要修改SystemUI下的KeyguardViewMediator.java中KEYGUARD_LOCK_AFTER_DELAY_DEFAULT
/**
* How long to wait after the screen turns off due to timeout before
* turning on the keyguard (i.e, the user has this much time to turn
* the screen back on without having to face the keyguard).
*/
private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000;
通过AlarmManager的setExactAndAllowWhileIdle实现定时通知
private void doKeyguardLaterLocked(long timeout) {
// Lock in the future
long when = SystemClock.elapsedRealtime() + timeout;
Intent intent = new Intent(DELAYED_KEYGUARD_ACTION);
intent.putExtra("seq", mDelayedShowingSequence);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
PendingIntent sender = PendingIntent.getBroadcast(mContext,
0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender);
if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = "
+ mDelayedShowingSequence);
doKeyguardLaterForChildProfilesLocked();
}