android修改息屏到锁屏的时间

本文解析了如何在Android系统中修改自动息屏到锁屏的默认等待时间,涉及KeyguardViewMediator.java中的KEYGUARD_LOCK_AFTER_DELAY_DEFAULT变量,并利用AlarmManager实现定时通知来控制锁屏过程。
摘要由CSDN通过智能技术生成

记录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();
    }
  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值