Android7.1 锁屏滑动无法解锁 Notification Keyguard 显示通知锁屏

问题:屏幕太大,滑动距离太大,并且滑动不流畅导致无法解锁

Notification Keyguard 显示通知锁屏 显示分析

一般情况下解锁根据滑动Y距离的长度和速度,再根据一些因数处理,通过阀值完成解锁。

一.PaneView.java

frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\PanelView.java

public boolean onTouchEvent(MotionEvent event) {  

          private int getFalsingThreshold() {

                      protected void loadDimens() {

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mInstantExpanding || mTouchDisabled
            || (mMotionAborted && event.getActionMasked() != MotionEvent.ACTION_DOWN)) {
        return false;
    }
 
    // On expanding, single mouse click expands the panel instead of dragging.
    String platform = SystemProperties.get("ro.board.platform");
    if (isFullyCollapsed() && event.isFromSource(InputDevice.SOURCE_MOUSE)
            && !"rk312x".equals(platform) && !"rk3126c".equals(platform)
    && !"rk3399".equals(platform)) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            expand(true);
        }
        return true;
    }
 
    /*
     * We capture touch events here and update the expand height here in case according to
     * the users fingers. This also handles multi-touch.
     *
     * If the user just clicks shortly, we show a quick peek of the shade.
     *
     * Flinging is also enabled in order to open or close the shade.
     */
 
    int pointerIndex = event.findPointerIndex(mTrackingPointer);
    if (pointerIndex < 0) {
        pointerIndex = 0;
        mTrackingPointer = event.getPointerId(pointerIndex);
    }
    final float x = event.getX(pointerIndex);
    final float y = event.getY(pointerIndex);
 
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mGestureWaitForTouchSlop = isFullyCollapsed() || hasConflictingGestures();
        mIgnoreXTouchSlop = isFullyCollapsed() || shouldGestureIgnoreXTouchSlop(x, y);
    }
 
    switch (event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            startExpandMotion(x, y, false /* startTracking */, mExpandedHeight);
            mJustPeeked = false;
            mPanelClosedOnDown = isFullyCollapsed();
            mHasLayoutedSinceDown = false;
            mUpdateFlingOnLayout = false;
            mMotionAborted = false;
            mPeekTouching = mPanelClosedOnDown;
            mTouchAboveFalsingThreshold = false;
            mCollapsedAndHeadsUpOnDown = isFullyCollapsed()
                    && mHeadsUpManager.hasPinnedHeadsUp();
            if (mVelocityTracker == null) {
                initVelocityTracker();
            }
            trackMovement(event);
            if (!mGestureWaitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning) ||
                    mPeekPending || mPeekAnimator != null) {
                cancelHeightAnimator();
                cancelPeek();
                mTouchSlopExceeded = (mHeightAnimator != null && !mHintAnimationRunning)
                        || mPeekPending || mPeekAnimator != null;
                onTrackingStarted();
            }
            if (isFullyCollapsed() && !mHeadsUpManager.hasPinnedHeadsUp()) {
                schedulePeek();
            }
            break;
 
        case MotionEvent.ACTION_POINTER_UP:
            final int upPointer = event.getPointerId(event.getActionIndex());
            if (mTrackingPointer == upPointer) {
                // gesture is ongoing, find a new pointer to track
                final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1;
                final float newY = event.getY(newIndex);
                final float newX = event.getX(newIndex);
                mTrackingPointer = event.getPointerId(newIndex);
                startExpandMotion(newX, newY, true /* startTracking */, mExpandedHeight);
            }
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
                mMotionAborted = true;
                endMotionEvent(event, x, y, true /* forceCancel */);
                return false;
            }
            break;
        case MotionEvent.ACTION_MOVE:
            float h = y - mInitialTouchY;
 
            // If the panel was collapsed when touching, we only need to check for the
            // y-component of the gesture, as we have no conflicting horizontal gesture.
            if (Math.abs(h) > mTouchSlop
                    && (Math.abs(h) > Math.abs(x - mInitialTouchX)
                            || mIgnoreXTouchSlop)) {
                mTouchSlopExceeded = true;
                if (mGestureWaitForTouchSlop && !mTracking && !mCollapsedAndHeadsUpOnDown) {
                    if (!mJustPeeked && mInitialOffsetOnTouch != 0f) {
                        startExpandMotion(x, y, false /* startTracking */, mExpandedHeight);
                        h = 0;
                    }
                    cancelHeightAnimator();
                    removeCallbacks(mPeekRunnable);
                    mPeekPending = false;
                    onTrackingStarted();
                }
            }
            final float newHeight = Math.max(0, h + mInitialOffsetOnTouch);
            if (newHeight > mPeekHeight) {
                if (mPeekAnimator != null) {
                    mPeekAnimator.cancel();
                }
                mJustPeeked = false;
            }
            Log.d("gatsby","-h ->"+-h+" getFalsingThreshold()->"+getFalsingThreshold());//This
            if (-h >= getFalsingThreshold()) {
                mTouchAboveFalsingThreshold = true;
                mUpwardsWhenTresholdReached = isDirectionUpwards(x, y);
            }
            if (!mJustPeeked && (!mGestureWaitForTouchSlop || mTracking) && !isTrackingBlocked()) {
                setExpandedHeightInternal(newHeight);
            }
 
            trackMovement(event);
            break;
 
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            trackMovement(event);
            endMotionEvent(event, x, y, false /* forceCancel */);
            break;
    }
    return !mGestureWaitForTouchSlop || mTracking;
}

 这个阈值是在如下文件中定义的, 它是用下面的值乘以一个因子(1.5)之后得到这个Y-距离.

1
2
3
4
private int getFalsingThreshold() {
    float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
    return (int) (mUnlockFalsingThreshold * factor);
}

 解析配置文件

1
2
3
4
5
6
7
protected void loadDimens() {
    final Resources res = getContext().getResources();
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mHintDistance = res.getDimension(R.dimen.hint_move_distance);
    mUnlockFalsingThreshold = res.getDimensionPixelSize(R.dimen.unlock_falsing_threshold);
}

 二.Gatsby patch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
diff --git a/frameworks/base/packages/SystemUI/res/values/dimens.xml b/frameworks/base/packages/SystemUI/res/values/dimens.xml
old mode 100644
new mode 100755
index e159501..630257c
--- a/frameworks/base/packages/SystemUI/res/values/dimens.xml
+++ b/frameworks/base/packages/SystemUI/res/values/dimens.xml
@@ -272,7 +272,7 @@
     <dimen name="speed_bump_height">16dp</dimen>
  
     <!-- Lockscreen unlocking falsing threshold. -->
-    <dimen name="unlock_falsing_threshold">80dp</dimen>
+    <dimen name="unlock_falsing_threshold">30dp</dimen>
  
     <!-- Lockscreen falsing threshold for quick settings. -->
     <dimen name="qs_falsing_threshold">60dp</dimen>
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 6587520..3c1bc53 100755
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -331,6 +331,7 @@ public abstract class PanelView extends FrameLayout {
                     }
                     mJustPeeked = false;
                 }
+               Log.d("gatsby","-h ->"+-h+" getFalsingThreshold()->"+getFalsingThreshold());
                 if (-h >= getFalsingThreshold()) {
                     mTouchAboveFalsingThreshold = true;
                     mUpwardsWhenTresholdReached = isDirectionUpwards(x, y);

 

posted @   CrushGirl  阅读(630)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
点击右上角即可分享
微信分享提示