追踪代码到这里frameworks/base/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
if (timeout <= 0) {
// Lock now
mSuppressNextLockSound = true;
doKeyguardLocked();
} else {//取消选中《电源按钮即时锁定》后,按电源关屏再开屏,程序进入这个分支处理// Lock in the future
long when = SystemClock.elapsedRealtime() + timeout;
Intent intent = new Intent(DELAYED_KEYGUARD_ACTION);
intent.putExtra("seq", mDelayedShowingSequence);
PendingIntent sender = PendingIntent.getBroadcast(mContext,
0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
mAlarmManager.set(AlarmManager.RTC_SHUTDOWN_WAKEUP, when, sender);
if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = "
+ mDelayedShowingSequence);
}
将
long when = SystemClock.elapsedRealtime() + timeout;
修改为:
long when = System.currentTimeMillis() + timeout;
生效。