先看接口定义
public void userActivity (long when, boolean noChangeLights)
Since: API Level 1 User activity happened.
Turns the device from whatever state it's in to full on, and resets the auto-off timer.
Parameters
when is used to order this correctly with the wake lock calls. This time should be in the SystemClock.uptimeMillis() time base.
noChangeLights should be true if you don't want the lights to turn on because of this event. This is set when the power key goes down. We want the device to stay on while the button is down, but we're about to turn off. Otherwise the lights flash on and then off and it looks weird.
这个方法在我们抓了wakeup锁释放后希望切换成系统设置的显示超时时间时用到。
锁屏里用到了这个方法:
在进入锁屏界面的时候LockScreen抓了一个带超时的锁,超时后,在用户没有任何动作的情况下释放锁从而灭屏。
在用户解锁的时候LockScreen调用了userActivity(SystemClock.uptimeMillis, true)然后释放锁,从而重设了系统auto-off的时间。
|