SystemUI入门之KeyguardService解析

onFinishedGoingToSleep方法的调用流程:

1 外部调用KeyguardService的setKeyguardEnabled方法。

com.android.server.policy.keyguard.KeyguardServiceWrapper

com.android.server.policy.keyguard.KeyguardServiceDelegate在其 bindService 中 bind 了 KeyguardService 并封装到一个KeyguardServiceWrapper对象中,

SystemServer 的方法 startSystemUi 启动 SystemUi 之后会在PhoneWindowManager 调用 bindKeyguard ,

SystemServer -> PhoneWindowManager -> KeyguardServiceDelegate

PhoneWindowManager 的 mKeyguardDelegate

Called when the device has finished going to sleep

在这里插入图片描述

以下是对PowerManagerService的分析:

启动时的流程:
在这里插入图片描述
在这里插入图片描述

Notifier#onWakefulnessChangeStarted

PowerManagerService

继承 SystemService ,在 SystemServer 中被启动,并注册了以下:

 publishBinderService(Context.POWER_SERVICE, mBinderService, /* allowIsolated= */ false,
                DUMP_FLAG_PRIORITY_DEFAULT | DUMP_FLAG_PRIORITY_CRITICAL);
    /**
     * Wakefulness: The device is asleep.  It can only be awoken by a call to wakeUp().
     * The screen should be off or in the process of being turned off by the display controller.
     * The device typically passes through the dozing state first.
     */
    public static final int WAKEFULNESS_ASLEEP = 0;

    /**
     * Wakefulness: The device is fully awake.  It can be put to sleep by a call to goToSleep().
     * When the user activity timeout expires, the device may start dreaming or go to sleep.
     */
    public static final int WAKEFULNESS_AWAKE = 1;

    /**
     * Wakefulness: The device is dreaming.  It can be awoken by a call to wakeUp(),
     * which ends the dream.  The device goes to sleep when goToSleep() is called, when
     * the dream ends or when unplugged.
     * User activity may brighten the screen but does not end the dream.
     */
    public static final int WAKEFULNESS_DREAMING = 2;

    /**
     * Wakefulness: The device is dozing.  It is almost asleep but is allowing a special
     * low-power "doze" dream to run which keeps the display on but lets the application
     * processor be suspended.  It can be awoken by a call to wakeUp() which ends the dream.
     * The device fully goes to sleep if the dream cannot be started or ends on its own.
     */
    public static final int WAKEFULNESS_DOZING = 3;

系统开机会先进入WAKEFULNESS_DOZING ,

要理解清楚 MSG_USER_ACTIVITY_TIMEOUT的处理:

在 updateUserActivitySummaryLocked 中发送一个延迟的信息 MSG_USER_ACTIVITY_TIMEOUT ,如果后面没有取消这个信息,则会执行 updateWakefulnessLocked -》 goToSleepNoUpdateLocked 然后到 setWakefulnessLocked(WAKEFULNESS_DOZING, reason, eventTime);

mNotifier.onWakefulnessChangeStarted(wakefulness, reason, eventTime);

取消MSG_USER_ACTIVITY_TIMEOUT 需要dirty满足以下条件任意之一:

DIRTY_WAKE_LOCKS
DIRTY_USER_ACTIVITY
DIRTY_WAKEFULNESS
DIRTY_SETTINGS

How to show or hide keyguard:

you can call PhoneWindowManager#enableKeyguard()

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值