优化锁屏解锁问题

最近在Android9.0定制上遇到锁屏时,上滑解锁很难解锁,要上滑好多次才能成功解锁,就此问题进行了优化,不逼逼,直接贴代码

vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java

         if (yDiff >= 0) {
             return false;
         }
-        return Math.abs(yDiff) >= Math.abs(xDiff);
+        if(Math.abs(yDiff) >= 10 || Math.abs(xDiff) >= 10)
+            return true;
+        else 
+            return false;
     }
 
     protected void startExpandingFromPeek() {
@@ -693,13 +696,22 @@ public abstract class PanelView extends FrameLayout {
      * @return whether a fling should expands the panel; contracts otherwise
      */
     protected boolean flingExpands(float vel, float vectorVel, float x, float y) {
-        if (isFalseTouch(x, y)) {
+        //if (isFalseTouch(x, y)) {
+        //    return true;
+        //}
+        float xDiff = x - mInitialTouchX;
+        float yDiff = y - mInitialTouchY;
+        if (yDiff >= 0) {
             return true;
         }
-        if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
-            return getExpandedFraction() > 0.5f;
-        } else {
-            return vel > 0;
+        if(mVelocityTracker.getXVelocity() >= mFlingAnimationUtils.getMinVelocityPxPerSecond() || mVelocityTracker.getYVelocity() >= mFlingAnimationUtils.getMinVelocityPxPerSecond()){
+            return false;
+        }else{
+            if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
+                return getExpandedFraction() > 0.5f;
+            } else {
+                return vel > 0;
+            }
         }
     }
 
@@ -721,7 +733,8 @@ public abstract class PanelView extends FrameLayout {
         if (mUpwardsWhenTresholdReached) {
             return false;
         }
-        return !isDirectionUpwards(x, y);
+        boolean isDirectionUpwards = isDirectionUpwards(x, y);
+        return !isDirectionUpwards;
     }
 
     protected void fling(float vel, boolean expand) {

猜你喜欢

转载自blog.csdn.net/weixin_42910727/article/details/88976574