Android13 右侧滑动显示qs,左侧滑动不显示,

在处理这个定制时客户要求删除掉通知栏,同时还要只能右侧显示qs,当我们只使用之前的左侧隐藏掉qs后,会出现滑动左侧出现一个黑色页面,这个显然是不符合客户需求

之后尝试隐藏父容器也失败了,那我们就换个思路,在滑动左侧时禁用掉下拉栏

diff --git a/src/com/android/systemui/statusbar/CommandQueue.java b/src/com/android/systemui/statusbar/CommandQueue.java
index 8f059f31..c78a6170 100644
--- a/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/src/com/android/systemui/statusbar/CommandQueue.java
@@ -80,6 +80,9 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 
+import android.provider.Settings;
+import android.util.DisplayMetrics;
+
 /**
  * This class takes the functions from IStatusBar that come in on
  * binder pool threads and posts messages to get them onto the main
@@ -520,6 +523,17 @@ public class CommandQueue extends IStatusBar.Stub implements
 
     // TODO(b/118592525): add multi-display support if needed.
     public boolean panelsEnabled() {
+            DisplayMetrics metrics = new DisplayMetrics();
+    mContext.getDisplay().getMetrics(metrics);
+    int screenWidthHalf = metrics.widthPixels / 2 ;
+         Log.e("xsr_command", "screenWidthHalf"+screenWidthHalf);
+           int touchX =Settings.Global.getInt(mContext.getContentResolver(),
+                    "command_panels",0);
+          Log.e("xsr_command", "touchX"+touchX);
+     if(touchX<screenWidthHalf){
+           return false;
+         }
+         else{
         final boolean lockExpand = SecurePlugin.isSecureLocked(mContext, mdmLockExpand);
         if (lockExpand) {
             return false;
@@ -529,6 +543,9 @@ public class CommandQueue extends IStatusBar.Stub implements
         return (disabled1 & StatusBarManager.DISABLE_EXPAND) == 0
                 && (disabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) == 0
                 && !ONLY_CORE_APPS;
+         }
+       
+
     }
 
     @Override

这里通过Settings.Global.getInt(mContext.getContentResolver(),                  "command_panels",0);来获取触摸X值是,那我们就需要看他是如何给这个赋值的

@@ -4308,6 +4360,9 @@ public class NotificationPanelViewController extends PanelViewController {
 
                     // If panels aren't enabled, ignore the gesture and don't pass it down to the
                     // panel view.
+                     Log.d("xsr_command", "handleTouchEvent");
+                    Settings.Global.putInt(mView.getContext().getContentResolver(),
+                    "command_panels",(int) event.getX());
                     if (!mCommandQueue.panelsEnabled()) {
                         if (event.getAction() == MotionEvent.ACTION_DOWN) {
                             Log.v(

添加日志发现这里会在调用上面那个方法时提前执行,我们在这里进行赋值,就会到哪里进行判断

这样写完后确实可以只在右侧显示,但是测试发现滑动launcher左侧中间还是会显示qs,我们就添加一个新的补丁来解决

         public void onStatusBarMotionEvent(MotionEvent event) {
-            verifyCallerAndClearCallingIdentity("onStatusBarMotionEvent", () -> {
-                // TODO move this logic to message queue
-                mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces -> {
-                    if (event.getActionMasked() == ACTION_DOWN) {
-                        centralSurfaces.getPanelController().startExpandLatencyTracking();
-                    }
-                    mHandler.post(() -> {
-                        int action = event.getActionMasked();
-                        if (action == ACTION_DOWN) {
-                            mInputFocusTransferStarted = true;
-                            mInputFocusTransferStartY = event.getY();
-                            mInputFocusTransferStartMillis = event.getEventTime();
-                            centralSurfaces.onInputFocusTransfer(
-                                    mInputFocusTransferStarted, false /* cancel */,
-                                    0 /* velocity */);
-                        }
-                        if (action == ACTION_UP || action == ACTION_CANCEL) {
-                            mInputFocusTransferStarted = false;
-                            float velocity = (event.getY() - mInputFocusTransferStartY)
-                                    / (event.getEventTime() - mInputFocusTransferStartMillis);
-                            centralSurfaces.onInputFocusTransfer(mInputFocusTransferStarted,
-                                    action == ACTION_CANCEL,
-                                    velocity);
-                        }
-                        event.recycle();
-                    });
-                });
-            });
+            // verifyCallerAndClearCallingIdentity("onStatusBarMotionEvent", () -> {
+            //     // TODO move this logic to message queue
+            //     mCentralSurfacesOptionalLazy.get().ifPresent(centralSurfaces -> {
+            //         if (event.getActionMasked() == ACTION_DOWN) {
+            //             centralSurfaces.getPanelController().startExpandLatencyTracking();
+            //         }
+            //         mHandler.post(() -> {
+            //             int action = event.getActionMasked();
+            //             if (action == ACTION_DOWN) {
+            //                 mInputFocusTransferStarted = true;
+            //                 mInputFocusTransferStartY = event.getY();
+            //                 mInputFocusTransferStartMillis = event.getEventTime();
+            //                 centralSurfaces.onInputFocusTransfer(
+            //                         mInputFocusTransferStarted, false /* cancel */,
+            //                         0 /* velocity */);
+            //             }
+            //             if (action == ACTION_UP || action == ACTION_CANCEL) {
+            //                 mInputFocusTransferStarted = false;
+            //                 float velocity = (event.getY() - mInputFocusTransferStartY)
+            //                         / (event.getEventTime() - mInputFocusTransferStartMillis);
+            //                 centralSurfaces.onInputFocusTransfer(mInputFocusTransferStarted,
+            //                         action == ACTION_CANCEL,
+            //                         velocity);
+            //             }
+            //             event.recycle();
+            //         });
+            //     });
+            // });
         }
 
         @Override

  • 7
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值