首页 > 其他分享 >rk3568开启双屏异显异触摸时键盘焦点及分发事件固定在主屏

rk3568开启双屏异显异触摸时键盘焦点及分发事件固定在主屏

时间:2024-09-24 10:01:14浏览次数:6  
标签:core java 双屏 rk3568 server 异显异 services android com

OS:Android11

 

需求描述:当app启用双屏异显双触摸,物理键盘只能固定在主屏有作用。

 

问题现象:双屏异显异触,带物理键盘输入。打开异显app,物理键盘的按键事件分发到主屏。 当触摸副屏的时候,物理键盘事件分发到副屏。当现再次触摸主屏,物理键盘的键事件分发到主屏。

 

问题分析:在之前3288 Android7上,没有该问题的。经了解是Android只支持一个屏的焦点事件,即默认是在主屏这边。Android10以后,支持多屏显示焦点事件,比如多个屏单独使用输入法等,这就导致触摸哪个屏,焦点事件就随着哪个屏走。

 

该需求最终实现是RK原厂提供的path:

涉及修改文件:frameworks/base
core/java/android/view/IWindowManager.aidl
core/res/res/values/config.xml
services/core/java/com/android/server/policy/PhoneWindowManager.java
services/core/java/com/android/server/wm/RootWindowContainer.java
services/core/java/com/android/server/wm/WindowManagerService.java

diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 5a32d283b17d..da90b9ca35e6 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -766,4 +766,10 @@ interface IWindowManager
      */
     void requestScrollCapture(int displayId, IBinder behindClient, int taskId,
             IScrollCaptureController controller);
+
+    /**
+     * Switch focus at defautl/external display.
+     * @hide
+     */
+    void switchFocusedScreen();
 }
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 2ebd8bb36a03..f8ccec591465 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2025,7 +2025,7 @@
 
     <!-- Whether the system enables per-display focus. If the system has the input method for each
          display, this value should be true. -->
-    <bool name="config_perDisplayFocusEnabled">false</bool>
+    <bool name="config_perDisplayFocusEnabled">true</bool>
 
     <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
          autodetected from the Configuration. -->
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 5003fca4bada..a5a1d5bc702b 100755
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -2859,6 +2859,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 mScreenshotRunnable.setScreenshotSource(SCREENSHOT_KEY_OTHER);
                 mHandler.post(mScreenshotRunnable);
             }
+            if(down){
+                try{
+                    mWindowManager.switchFocusedScreen();
+                } catch(RemoteException e){
+                    e.printStackTrace();
+                }
+            }
             return -1;
         } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP
                 || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) {
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/andr
oid/server/wm/RootWindowContainer.java
index 197e2188c346..d41cd367b1b5 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -457,6 +457,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
         int topFocusedDisplayId = INVALID_DISPLAY;
         for (int i = mChildren.size() - 1; i >= 0; --i) {
             final DisplayContent dc = mChildren.get(i);
+            if(mWindowManager.mFocusedInSecondDisplay&&dc.isDefaultDisplay){
+                continue;
+            }
+            if(!mWindowManager.mFocusedInSecondDisplay&&!dc.isDefaultDisplay){
+                continue;
+            }
             changed |= dc.updateFocusedWindowLocked(mode, updateInputWindows, topFocusedDisplayId);
             final WindowState newFocus = dc.mCurrentFocus;
             if (newFocus != null) {
@@ -467,7 +473,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                 if (topFocusedDisplayId == INVALID_DISPLAY) {
                     topFocusedDisplayId = dc.getDisplayId();
                 }
-            } else if (topFocusedDisplayId == INVALID_DISPLAY && dc.mFocusedApp != null) {
+            } else if ((topFocusedDisplayId == INVALID_DISPLAY) && dc.mFocusedApp != null) {
                 // The top-most display that has a focused app should still be the top focused
                 // display even when the app window is not ready yet (process not attached or
                 // window not added yet).
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/and
roid/server/wm/WindowManagerService.java
index 1ae8e783e21b..deb2a2cfe9db 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -754,6 +754,8 @@ public class WindowManagerService extends IWindowManager.Stub
     SettingsObserver mSettingsObserver;
     final EmbeddedWindowController mEmbeddedWindowController;
 
+    boolean mFocusedInSecondDisplay = false;
+
     @VisibleForTesting
     final class SettingsObserver extends ContentObserver {
         private final Uri mDisplayInversionEnabledUri =
@@ -8337,4 +8339,26 @@ public class WindowManagerService extends IWindowManager.Stub
             Binder.restoreCallingIdentity(origId);
         }
     }
+
+    /**
+     * Switch focus at default/second screen.
+     */
+    public void switchFocusedScreen(){
+            if (mFocusedInSecondDisplay){
+                setFocusedInSecondDisplay(false);
+            }
+            else{
+                setFocusedInSecondDisplay(true);
+            }
+        }
+    
+        /**
+         * if flag is equal to true, Focused would be at second screen.
+         * @param flag isFocusedInSecondScreen
+         */
+        private void setFocusedInSecondDisplay(boolean flag){
+            mFocusedInSecondDisplay = flag;
+            //refresh surface right now.
+            updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true);
+        }
 }
PhoneWindowManager.java中的path主要是可以通过按键事件input keyevent 120灵活切换主副屏的焦点,由于此补丁默认是在主屏的,使用不加也可满足需求。
frameworks/base/core/java/android/view/KeyEvent.java

 



标签:core,java,双屏,rk3568,server,异显异,services,android,com
From: https://www.cnblogs.com/wmc245376374/p/18428463

相关文章

  • rk3568系统buildroot开发笔记
    编译异常infrom_bz2importBZ2Compressor,BZ2DecompressorModuleNotFoundError:Nomodulenamed‘_bz2’sudoapt-getinstalllibbz2-dev然后删掉rk356x_bsp_bak/rk356x_bsp/build-iot/buildroot_output/rockchip_rk3568_iot/build/host-python3-3.10.5重新编......
  • Openharmony软件评估指南-米尔瑞芯微RK3568开发板
    Openharmony软件评估指南用于介绍在米尔的开发板上运行Openharmony系统下的核心资源与外设资源的测试步骤与评估方法。本文可作为前期评估指南使用,也可以作为通用系统开发的测试指导书使用。本文档使用于米尔电子的MYD-LR3568系列板卡,该板卡是米尔电子的嵌入式开发平台基于瑞芯微......
  • 迅为RK3568核心板桥梁监测设备接口应用,支持桥梁全面监测,提高监测效率和准确性
    RK3568核心板以其丰富的接口扩展能力和高性能AI算力,支持桥梁全面监测,提高监测效率和准确性。同时,RK3568处理器在智能显示、工业控制等领域有广泛应用,适配系统新增双麒麟系统,增强产品竞争力。RK3568核心板具备强大的计算及高端图形处理能力,采用四核64位Cortex-A55处理器,主频最高可达......
  • 混合部署 | 在RK3568上同时部署RT-Thread和Linux系统-迅为电子
    RT-Thread是一个高安全性、实时性的操作系统,广泛应用于任务关键领域,例如电力、轨道交通、车载系统、工业控制和新能源等。它的加入让RK3568能够在保证系统实时性和安全性的同时,灵活处理复杂的任务场景。    在一般情况下,iTOP-RK3568的四个Cortex-A55核心通常运行Linux......
  • RK3568------Openharmony 4.0-Release Docker移植、部署
    RK3568------Openharmony4.0-ReleaseDocker移植、部署文章目录RK3568------Openharmony4.0-ReleaseDocker移植、部署前言一、Docker简述1.1轻量级虚拟化1.2一致性1.3可移植性1.4高效的资源利用1.5易于部署和扩展二、移植思路三、移植实例四、遇到的问题五、......
  • 北京迅为RK3568开发板嵌入式学习之Linux驱动全新更新-CAN+网络设备
    iTOP-3568开发板采用瑞芯微RK3568处理器,22nm工艺制程,集成4核A55架构处理器和MaliG522EE图形处理器,支持4K解码和1080P编码,内置独立的NPU,可用于轻量级人工智能应用。 iTOP-3568开发板连接器版本:  iTOP-3568开发板邮票版本:     关注:北京迅为电子,在线观看 ---......
  • 瑞芯微-I2S | 音频驱动调试基本命令和工具-基于rk3568-2【转】
    转自:https://www.cnblogs.com/yikoulinux/p/18102243基于Linux嵌入式设备常用调试方法很多,本文一口君把调试语音用到的工具和方法给大家做一个简单的介绍。1.procfs、sysfsLinux系统上的/proc目录是一种文件系统,即proc文件系统。与其它常见的文件系统不同的是,/proc是一种伪......
  • 【OpenHarmony】openharmony移植到RK3568------获取源码编译OpenHarmony源码
    一、源码获取源码获取有好几种方式,在这里直接在镜像网站下载源码,点击下面连接下载全量版本的OpenHarmony4.1https://repo.huaweicloud.com/openharmony/os/4.1-Release/code-v4.1-Release.tar.gz将源码放到自己建立的目录下解压,我放入的是这个目录/home/wzz/work/0H4.1......
  • 解锁RK3568能力 | 多屏显示功能全面解析-迅为电子
     多屏显示允许一台主机同时连接并控制多个显示器,使得这些显示器能够分别显示不同的内容,这种技术通过扩展电脑的显示能力,打破了传统单一显示器的限制,为用户提供了更加灵活、高效和丰富的视觉体验。 多屏显示可以用于信息发布系统,工业控制,多媒体等多种领域,提供灵活的显示方案。......
  • RK3568调试YT8531单网口千兆以太网PHY芯片,GAMC调试
    异常现象当硬件上使用YT8531替代Realtek瑞昱的RTL8211之后,出现系统能够正确识别ETHx,也能设置IP地址,但是外部无法ping成功或者重启后IP地址还会丢失的问题;硬件排查思路检查电源:输入3.3v;输出1.1v,RGMII的电平配置是否如设计预期(1.8v/2.5v/3.3v),尤其RGMII电平配置为3.3......