android11 SystemUI入門之KeyguardPatternView解析

KeyguardViewMediator功能:

  Mediates requests related to the keyguard.  This includes queries about the
  state of the keyguard, power management events that effect whether the keyguard
  should be shown or reset, callbacks to the phone window manager to notify
  it of when the keyguard is showing, and events from the keyguard view itself
  stating that the keyguard was succesfully unlocked

view层级树为:

被包含在 keyguard_host_view.xml中 。

<?xml version="1.0" encoding="utf-8"?>
<!-- This is the host view that generally contains two sub views: the widget view
    and the security view. -->
<com.android.keyguard.KeyguardHostView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/res-auto"
    android:id="@+id/keyguard_host_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:importantForAccessibility="yes"> <!-- Needed because TYPE_WINDOW_STATE_CHANGED is sent
                                                  from this view when bouncer is shown -->

    <com.android.keyguard.KeyguardSecurityContainer
        android:id="@+id/keyguard_security_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        androidprv:layout_maxHeight="@dimen/keyguard_security_max_height"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:padding="0dp"
        android:fitsSystemWindows="true"
        android:layout_gravity="center">
        <com.android.keyguard.KeyguardSecurityViewFlipper
            android:id="@+id/view_flipper"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:paddingTop="@dimen/keyguard_security_view_top_margin"
            android:paddingStart="@dimen/keyguard_security_view_lateral_margin"
            android:paddingEnd="@dimen/keyguard_security_view_lateral_margin"
            android:gravity="center">
        </com.android.keyguard.KeyguardSecurityViewFlipper>
    </com.android.keyguard.KeyguardSecurityContainer>
</com.android.keyguard.KeyguardHostView>

而 KeyguardPatternView 是 KeyguardSecurityViewFlipper的一个孩子 。

继承接口KeyguardSecurityView。

开机显示KeyguardPatternView的方法调用堆栈:

在这里插入图片描述

开机调用KeyguardViewMediator的doKeyguardLocked方法的调用堆栈为:

KeyguardService 的binder方法 onSystemReady 调用 mKeyguardViewMediator.onSystemReady() 到 doKeyguardLocked方法 。

KeyguardPatternView:

手势验证成功的回调以及Keyguard如何消失:

最终调用到SecurityCallback的dismiss方法 然后到ViewMediatorCallback 的

 Process: com.android.systemui, PID: 649
 java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
 	at com.android.keyguard.KeyguardHostView.finish(KeyguardHostView.java:241)
 	at com.android.keyguard.KeyguardSecurityContainer.showNextSecurityScreenOrFinish(KeyguardSecurityContainer.java:753)
 	at com.android.keyguard.KeyguardHostView.dismiss(KeyguardHostView.java:214)
 	at com.android.keyguard.KeyguardSecurityContainer$3.dismiss(KeyguardSecurityContainer.java:829)
 	at com.android.keyguard.KeyguardSecurityContainer$3.dismiss(KeyguardSecurityContainer.java:823)
 	at com.android.keyguard.KeyguardPatternView$UnlockPatternListener.onPatternChecked(KeyguardPatternView.java:355)
 	at com.android.keyguard.KeyguardPatternView$UnlockPatternListener.access$1200(KeyguardPatternView.java:265)
 	at com.android.keyguard.KeyguardPatternView$UnlockPatternListener$1.onEarlyMatched(KeyguardPatternView.java:314)
 	at com.android.internal.widget.-$$Lambda$TTC7hNz7BTsLwhNRb2L5kl-7mdU.onEarlyMatched(Unknown Source:2)
 	at com.android.internal.widget.LockPatternUtils$WrappedCallback.lambda$onCredentialVerified$0$LockPatternUtils$WrappedCallback(LockPatternUtils.java:1452)
 	at com.android.internal.widget.-$$Lambda$LockPatternUtils$WrappedCallback$i9jMZqkjCdhv8ydv-FyQJHm7hSE.run(Unknown Source:2)
 	at android.os.Handler.handleCallback(Handler.java:938)
 	at android.os.Handler.dispatchMessage(Handler.java:99)
 	at android.os.Looper.loop(Looper.java:223)
 	at android.app.ActivityThread.main(ActivityThread.java:7677)
 	at java.lang.reflect.Method.invoke(Native Method)
 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)


 Process: com.android.systemui, PID: 644
 java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
 	at com.android.systemui.keyguard.KeyguardViewMediator$7.run(KeyguardViewMediator.java:1925)
 	at com.android.systemui.keyguard.KeyguardViewMediator.handleHide(KeyguardViewMediator.java:1964)
 	at com.android.systemui.keyguard.KeyguardViewMediator.handleKeyguardDone(KeyguardViewMediator.java:1749)
 	at com.android.systemui.keyguard.KeyguardViewMediator.tryKeyguardDone(KeyguardViewMediator.java:1700)
 	at com.android.systemui.keyguard.KeyguardViewMediator.lambda$new$5(KeyguardViewMediator.java:1933)
 	at com.android.systemui.keyguard.KeyguardViewMediator.lambda$new$5$KeyguardViewMediator(Unknown Source:0)
 	at com.android.systemui.keyguard.-$$Lambda$KeyguardViewMediator$QIsTwFYGBxDSDLEE3WQkiYwdaXA.run(Unknown Source:2)
 	at com.android.keyguard.KeyguardPatternView.lambda$startDisappearAnimation$1(KeyguardPatternView.java:508)
 	at com.android.keyguard.KeyguardPatternView.lambda$startDisappearAnimation$1$KeyguardPatternView(Unknown Source:0)
 	at com.android.keyguard.-$$Lambda$KeyguardPatternView$i51b4f44m8j5rvWUlLMM4eRNauI.run(Unknown Source:4)
 	at com.android.internal.widget.LockPatternView$3.onAnimationEnd(LockPatternView.java:539)
 	at android.graphics.animation.RenderNodeAnimator.onFinished(RenderNodeAnimator.java:370)
 	at android.graphics.animation.-$$Lambda$awqPSgriNRe12PWP0zkpAtPsfV4.run(Unknown Source:2)
 	at android.os.Handler.handleCallback(Handler.java:938)
 	at android.os.Handler.dispatchMessage(Handler.java:99)
 	at android.os.Looper.loop(Looper.java:223)
 	at android.app.ActivityThread.main(ActivityThread.java:7677)
 	at java.lang.reflect.Method.invoke(Native Method)
 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
  E  FATAL EXCEPTION: main
     Process: com.android.systemui, PID: 649
     java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
     	at com.android.systemui.statusbar.phone.KeyguardBouncer.hide(KeyguardBouncer.java:316)
     	at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.hideBouncer(StatusBarKeyguardViewManager.java:390)
     	at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.hide(StatusBarKeyguardViewManager.java:621)
     	at com.android.systemui.keyguard.KeyguardViewMediator.handleStartKeyguardExitAnimation(KeyguardViewMediator.java:2007)
     	at com.android.systemui.keyguard.KeyguardViewMediator.access$4500(KeyguardViewMediator.java:151)
     	at com.android.systemui.keyguard.KeyguardViewMediator$6.handleMessage(KeyguardViewMediator.java:1679)
     	at android.os.Handler.dispatchMessage(Handler.java:106)
     	at android.os.Looper.loop(Looper.java:223)
     	at android.app.ActivityThread.main(ActivityThread.java:7677)
     	at java.lang.reflect.Method.invoke(Native Method)
     	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
     	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

KeyguardViewMediator 收到 startKeyguardExitAnimation 的 START_KEYGUARD_EXIT_ANIM,
其实这个信息是从 PowerManagerService 发出的。

 E  FATAL EXCEPTION: main
    Process: com.android.systemui, PID: 648
    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
    	at com.android.systemui.statusbar.phone.StatusBar.hideKeyguard(StatusBar.java:3190)
    	at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.hide(StatusBarKeyguardViewManager.java:649)
    	at com.android.systemui.keyguard.KeyguardViewMediator.handleStartKeyguardExitAnimation(KeyguardViewMediator.java:2007)
    	at com.android.systemui.keyguard.KeyguardViewMediator.access$4500(KeyguardViewMediator.java:151)
    	at com.android.systemui.keyguard.KeyguardViewMediator$6.handleMessage(KeyguardViewMediator.java:1679)
    	at android.os.Handler.dispatchMessage(Handler.java:106)
    	at android.os.Looper.loop(Looper.java:223)
    	at android.app.ActivityThread.main(ActivityThread.java:7677)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)


待续。

KeyguardPatternView 何时显示在界面上:

KeyguardSecurityContainer#getLayoutIdFor
放入mSecurityViewFlipper ,然后调用mSecurityViewFlipper的setDisplayedChild来显示.

最终放入NotificationShadeWindowView中.

开机是否显示Keyguard?

客户端调用 KeyguardService的onSystemReady 方法,后者调用 KeyguardViewMediator的onSystemReady()方法,
继续到doKeyguardLocked中的 LockPatternUtils.isLockScreenDisabled 来判断是否要显示锁屏界面。

何处调用KeyguardService的onSystemReady方法

WindowManagerService的systemReady调用PhoneWindowManager的systemReady ,KeyguardDelegate.onSystemReady()
然后通过binder到
KeyguardService的onSystemReady。

创建一个KeyguardBouncer的流程:

外部调用其show方法.它将自己作为一个孩子加入参数 container中.

在锁屏界面解锁的过程:

在这里插入图片描述

在以上的通知信息双击, 方法的调用堆栈如下:

主要的方法有:
StatusBar.dismissKeyguardThenExecute
StatusBarNotificationActivityStarter.onNotificationClicked:272
NotificationClicker.onClick:99

在StatusBarNotificationActivityStarter的方法handleNotificationClickAfterKeyguardDismissed中处理通知信息的点击打开.

系统如何创建一个NotificationClicker

待續.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值