Detailed solutions related to android multi-screen touch - Android framework development mobile phone and car system development course

background

Live free video course address: https://www.bilibili.com/video/BV1hN4y1R7t2/

In the process of developing dual-screen related requirements, there are often scenarios where both screens are required to be touched correctly. However, the dual screens currently created by our simulator by default cannot be touched.
Insert image description here

Modification 1

Static modification plan:
Use the command to view the information of display2, that is, the secondary screen,
adb shell dumpsys display

  Display 2:
    mDisplayId=2
    mPhase=1
    mLayerStack=2
    mHasContent=true
    mDesiredDisplayModeSpecs={
    
    baseModeId=2 allowGroupSwitching=false primaryRefreshRateRange=[0 Infinity] appRequestRefreshRateRange=[0 Infinity]}
    mRequestedColorMode=0
    mDisplayOffset=(0, 0)
    mDisplayScalingDisabled=false
    mPrimaryDisplayDevice=HDMI Screen
    mBaseDisplayInfo=DisplayInfo{
    
    "HDMI Screen", displayId 2", displayGroupId 0, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, FLAG_PRESENTATION, FLAG_TRUSTED, real 1440 x 2960, largest app 1440 x 2960, smallest app 1440 x 2960, appVsyncOff 2000000, presDeadline 75, mode 2, defaultMode 2, modes [{id=2, width=1440, height=2960, fps=1.3333333E7, alternativeRefreshRates=[]}], hdrCapabilities HdrCapabilities{mSupportedHdrTypes=[], mMaxLuminance=500.0, mMaxAverageLuminance=500.0, mMinLuminance=0.0}, userDisabledHdrTypes [], minimalPostProcessingSupported false, rotation 0, state ON, type EXTERNAL, uniqueId "local:4619827551948147201", app 1440 x 2960, density 560 (215152.0 x 214811.02) dpi, layerStack 2, colorMode 0, supportedColorModes [0], address {
    
    port=1, model=0x401cecae7d6e8a}, deviceProductInfo DeviceProductInfo{
    
    name=EMU_display_1, manufacturerPnpId=GGL, productId=4660, modelYear=null, manufactureDate=ManufactureDate{
    
    week=12, year=2021}, connectionToSinkType=0}, removeMode 0, refreshRateOverride 0.0, brightnessMinimum 0.0, brightnessMaximum 1.0, brightnessDefault 0.5, installOrientation ROTATION_0}

Here we mainly look at the corresponding uniqueId "local:4619827551948147201"

Then combine the uniqueId required in the input and update the place:


2: virtio_input_multi_touch_7
      Classes: TOUCH | TOUCH_MT | SWITCH
      Path: /dev/input/event8
      Enabled: true
      Descriptor: e1c836c7be888adb29ca6646292e486f96461e97
      Location: virtio17/input0
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0006, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: 
      KeyCharacterMapFile: 
      ConfigurationFile: /vendor/usr/idc/virtio_input_multi_touch_7.idc
      VideoDevice: <none>

This is the ConfigurationFile: /vendor/usr/idc/virtio_input_multi_touch_7.idc

Go to the out path of the source code and modify /aosp/out/target/product/emulator_x86_64/vendor/usr/idc/virtio_input_multi_touch_7.idc
mainly to change touch.displayId into the local obtained above: 4619827551948147201

device.internal = 1

touch.deviceType = touchScreen
touch.orientationAware = 1

cursor.mode = navigation
cursor.orientationAware = 1

# This displayID matches the unique ID of the virtual display created for Emulator.
# This will indicate to input flinger than it should link this input device
# with the virtual display.
touch.displayId = local:4619827551948147201  

Then compile it as a whole

Modification 2

The idea of ​​dynamic modification scheme
is to make relevant modifications to config by calling the relevant methods in input.
The corresponding methods are as follows:
Insert image description here

That is, you only need to use this method to specify the input of the touch—"corresponding to the display for mapping.
Note that the port is used here, not the displayId port.
You can also check it through dumpsys display:
there is a corresponding port value in the corresponding address, which is generally the first. One screen 0, second screen 1

address {
    
    port=1, model=0x401cecae7d6e8a}, deviceProductInfo DeviceProductInfo{
    
    name=EMU_display_1, manufacturerPnpId=GGL, productId=4660, modelYear=null, manufactureDate=ManufactureDate{
    
    week=12, year=2021}

After confirming the display port and an input-related inputPort parameter, this can be obtained directly through dumpsy input, and the event corresponding to the screen can be found in dumpsys to find the corresponding Device

 2: virtio_input_multi_touch_7
      Classes: TOUCH | TOUCH_MT | SWITCH
      Path: /dev/input/event8
      Enabled: true
      Descriptor: e1c836c7be888adb29ca6646292e486f96461e97
      Location: virtio17/input0
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0006, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: 
      KeyCharacterMapFile: 
      ConfigurationFile: /vendor/usr/idc/virtio_input_multi_touch_7.idc
      VideoDevice: <none>

This is the Location here: virtio17/input0, virtio17/input0 is what we want

To make a dynamic call trigger, use the dumpsys input command directly here:

commit 72193cfb966307940457148bedc793c316d67af5 (HEAD)
Author: Your Name <[email protected]>
Date:   Fri Aug 25 17:23:22 2023 +0800

    add displayfortouch modify

diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 72612a0468cd..587a7b313b8f 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -2678,6 +2678,14 @@ public class InputManagerService extends IInputManager.Stub
         if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
 
         pw.println("INPUT MANAGER (dumpsys input)\n");
+        pw.println("INPUT MANAGER args size = "+args.length + "\n");
+        if (args.length == 3 && args[0].equals("displayForInput")) {
    
    
+            String location = args[1];
+            int port = Integer.parseInt(args[2]);
+            addPortAssociation(location,port);
+            pw.println("INPUT MANAGER addPortAssociation location= "+location +" port = " +port+ " \n");
+            return;
+        }
         String dumpStr = mNative.dump();
         if (dumpStr != null) {
    
    
             pw.println(dumpStr);


Finally use the command:
adb shell dumpsys input displayForInput virtio17/input0 1

Guess you like

Origin blog.csdn.net/learnframework/article/details/132508306