publicvoidattach() { // Now that the status bar window encompasses the sliding panel and its // translucent backdrop, the entire thing is made TRANSLUCENT and is // hardware-accelerated. mLp = newWindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, mBarHeight, WindowManager.LayoutParams.TYPE_STATUS_BAR, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, PixelFormat.TRANSLUCENT); mLp.privateFlags |= PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC; mLp.token = newBinder(); mLp.gravity = Gravity.TOP; mLp.setFitInsetsTypes(0/* types */); mLp.setTitle("StatusBar"); mLp.packageName = mContext.getPackageName(); mLp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; mWindowManager.addView(mStatusBarView, mLp); mLpChanged.copyFrom(mLp); }
@Override protectedvoidonHeightUpdated(float expandedHeight) { if (!mQsExpanded || mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted) { // 更新时钟位置将设置顶部填充,这可能会触发新的面板高度并重新定位时钟。 // 这是一个循环依赖项,应该避免,否则会出现堆栈溢出。 if (mStackScrollerMeasuringPass > 2) { if (DEBUG) Log.d(TAG, "Unstable notification panel height. Aborting."); } else { //锁屏上的时间和通知View根据手指的移动距离进行缩小、变透明处理 positionClockAndNotifications(); } } if (mQsExpandImmediate || mQsExpanded && !mQsTracking && mQsExpansionAnimator == null && !mQsExpansionFromOverscroll) { float t; if (mKeyguardShowing) { // 在Keyguard上,将QS扩展线性插值到面板扩展 t = expandedHeight / (getMaxPanelHeight()); } else { // In Shade, interpolate linearly such that QS is closed whenever panel height is // minimum QS expansion + minStackHeight float panelHeightQsCollapsed= mNotificationStackScroller.getIntrinsicPadding() + mNotificationStackScroller.getLayoutMinHeight(); floatpanelHeightQsExpanded= calculatePanelHeightQsExpanded(); t = (expandedHeight - panelHeightQsCollapsed) / (panelHeightQsExpanded - panelHeightQsCollapsed); } float targetHeight= mQsMinExpansionHeight + t * (mQsMaxExpansionHeight - mQsMinExpansionHeight); setQsExpansion(targetHeight); } updateExpandedHeight(expandedHeight); updateHeader(); // 更新通知半透明 updateNotificationTranslucency(); updatePanelExpanded(); updateGestureExclusionRect(); if (DEBUG) { mView.invalidate(); } }
到这里了就一起看个滑动解锁的堆栈:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
12-30 08:32:48.658 1479 1479 D longzhiye : java.lang.Throwable: 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.keyguard.KeyguardSecurityContainer.showNextSecurityScreenOrFinish(KeyguardSecurityContainer.java:710) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.keyguard.KeyguardHostView.dismiss(KeyguardHostView.java:214) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.keyguard.KeyguardHostView.dismiss(KeyguardHostView.java:196) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.systemui.statusbar.phone.KeyguardBouncer.show(KeyguardBouncer.java:167) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.showBouncer(StatusBarKeyguardViewManager.java:434) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.systemui.statusbar.phone.StatusBar.showBouncerIfKeyguard(StatusBar.java:3959) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.systemui.statusbar.phone.StatusBar.makeExpandedInvisible(StatusBar.java:2506) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.systemui.statusbar.phone.PhoneStatusBarView$1.run(PhoneStatusBarView.java:65) 12-30 08:32:48.658 1479 1479 D longzhiye : at android.os.Handler.handleCallback(Handler.java:938) 12-30 08:32:48.658 1479 1479 D longzhiye : at android.os.Handler.dispatchMessage(Handler.java:99) 12-30 08:32:48.658 1479 1479 D longzhiye : at android.os.Looper.loop(Looper.java:223) 12-30 08:32:48.658 1479 1479 D longzhiye : at android.app.ActivityThread.main(ActivityThread.java:7945) 12-30 08:32:48.658 1479 1479 D longzhiye : at java.lang.reflect.Method.invoke(Native Method) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:603) 12-30 08:32:48.658 1479 1479 D longzhiye : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
再看一个滑动后到密码安全锁(即密码解锁)的堆栈
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
12-30 09:28:31.8189 1470 1470 D longzhiye: : java.lang.Throwable 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.keyguard.KeyguardSecurityContainer.showNextSecurityScreenOrFinish(KeyguardSecurityContainer.java:710) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.keyguard.KeyguardHostView.dismiss(KeyguardHostView.java:214) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.keyguard.KeyguardHostView.dismiss(KeyguardHostView.java:196) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.systemui.statusbar.phone.KeyguardBouncer.show(KeyguardBouncer.java:167) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager.onPanelExpansionChanged(StatusBarKeyguardViewManager.java:297) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.systemui.statusbar.phone.PanelViewController.notifyBarPanelExpansionChanged(PanelViewController.java:1011) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.systemui.statusbar.phone.PanelViewController.setExpandedHeightInternal(PanelViewController.java:727) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.systemui.statusbar.phone.PanelViewController$TouchHandler.onTouch(PanelViewController.java:1338) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.systemui.statusbar.phone.NotificationPanelViewController$18.onTouch(NotificationPanelViewController.java:3229) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at android.view.View.dispatchTouchEvent(View.java:14385) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2792) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3126) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2806) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at com.android.systemui.statusbar.phone.NotificationShadeWindowView.dispatchTouchEvent(NotificationShadeWindowView.java:173) 12-30 09:28:31.8189 1470 1470 D longzhiye: : at android.view.View.dispatchPointerEvent(View.java:14656) // 省略部分Log....
@Override publicvoidonPanelCollapsed() { super.onPanelCollapsed(); // Close the status bar in the next frame so we can show the end of the animation. post(mHideExpandedRunnable); mIsFullyOpenedPanel = false; } privateRunnablemHideExpandedRunnable=newRunnable() { @Override publicvoidrun() { if (mPanelFraction == 0.0f) { mBar.makeExpandedInvisible(); } } };
@Override publicvoidfinish(boolean strongAuth, int targetUserId) { // If there's a pending runnable because the user interacted with a widget // and we're leaving keyguard, then run it. booleandeferKeyguardDone=false; if (mDismissAction != null) { deferKeyguardDone = mDismissAction.onDismiss(); mDismissAction = null; mCancelAction = null; } if (mViewMediatorCallback != null) { if (deferKeyguardDone) { // deferKeyguardDone 上面设置成了 false mViewMediatorCallback.keyguardDonePending(strongAuth, targetUserId); } else { // 重点关注 mViewMediatorCallback.keyguardDone(strongAuth, targetUserId); } } }