In native Android system code, the event entity touched already contains a member called displayId.
This shows that Android is basically a two-touch framework, and if the display ID of the touch event corresponds to the home screen, then it does.
The event is sent to the TouchdedWindow on the home screen. Similarly, if the display ID of the touch event corresponds to the secondary screen,
Then it sends the event to TouchedWindow on the secondary screen. So the key point is how this displayId works.
Assigned, in the Eventhub.cpp code of inputflinger, the openDeviceLocked function passes ioctl()
Get device information, and judge the type of device according to the information obtained, assign the corresponding attributes in device.classes.
INPUT_DEVICE_CLASS_EXTERNAL identifies whether the device is an external device. When there is a USB or Bluetooth interface
Touch screen, the touch device will set INPUT_DEVICE_CLASS_EXTERNAL property, the input framework is based on
This property eventually sends its event to the TouchedWindow on the secondary screen.
\frameworks\native\services\inputflinger\EventHub.cpp
//Determine whether the device is external or internal. i f (isExternalDeviceLocked(device)) { device->classes |= INPUT_DEVICE_CLASS_EXTERNAL; }
So if you use touch screen, the home screen uses I2C interface, and the secondary screen uses USB or Bluetooth interface, then you can
To achieve double touch. If both use I2C, or both use USB (Bluetooth), just change the code to ensure the home screen.
The touch device on the sub-screen does not have the INPUT_DEVICE_CLASS_EXTERNAL attribute, and the touch device on the sub-screen does.
Sex can also realize double touch function.
Ideas:
1) The code is to judge the USBTP port of the main screen without the attribute of INPUT_DEVICE_CLASS_EXTERNAL. Therefore, the USBTP interface of the main screen on the hardware must be the interface of the USBTP port of the main screen. This is very important, as shown in the following figure:
2) At that time, because the USB TP interface of the main screen was not connected to this interface on the hardware of another machine, the main screen TP was judged to be a secondary screen TP, and the investigation lasted for a long time, as shown in the figure below.
3) Use the adb command to view the USB Location of the main and secondary screen TP, and use the shell dumpsys command to get the Location of TP.
adb shell dumpsys input > C:\Users\Caozhaoyang\Desktop\shell.txt
The above command means to redirect the shell dumpsys command access information to the file in this path C: Users Caozhaoyang Desktop shell. TXT
4) Find our information on the desktop and print it to the shell.txt file.
5) Open the shell.txt file and see the relevant information of the main and secondary screen USB TP. We mainly get the location information of the Location USB to determine which is the USB interface of the main screen TP through the location information of the Location USB in the code. In my code, I use Location: usb-ff500000.usb-1.3/input0 as the interface of the main screen USBTP.
6) Choose the code of the USB TP interface of the home screen in the file of frameworks native services inputflinger EventHub. CPP with the path frameworks native services inputflinger EventHub.
dongsy@build-server-100:~/work/dsy/rk3288-Android-7.0/frameworks/native((4e55453...))$ git diff services/inputflinger/EventHub.cpp diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp old mode 100644 new mode 100755 index 03de939..9233c18 --- a/services/inputflinger/EventHub.cpp +++ b/services/inputflinger/EventHub.cpp @@ -1465,6 +1465,11 @@ status_t EventHub::loadKeyMapLocked(Device* device) { } bool EventHub::isExternalDeviceLocked(Device* device) { + const char *USB_DEVICE_LOCATION ="usb-ff500000.usb-1.3/input0";//Using Location: usb-ff500000.usb-1.3/input0 as the main screen USB TP interface + if(strcmp(device->identifier.location.string(),USB_DEVICE_LOCATION)==0){ + ALOGE("usb touch device ILITEK ILITEK-TP id:%d set primary device",device->id); + return false; + } if (device->configuration) { bool value; if (device->configuration->tryGetProperty(String8("device.internal"), value)) {
7) At the same time, the relevant patches for RK contact scheme are listed below.
7.1 Make the following patches on the path frameworks base services core java com android server input InputWindows Handle. Java
dongsy@build-server-100:~/work/dsy/rk3288-Android-7.0/frameworks/base(m_android_7_0)$ git diff services/core/java/com/android/server/input/InputWindowHandle.java diff --git a/services/core/java/com/android/server/input/InputWindowHandle.java b/servic old mode 100644 new mode 100755 index eb3581a..3b8a187 --- a/services/core/java/com/android/server/input/InputWindowHandle.java +++ b/services/core/java/com/android/server/input/InputWindowHandle.java @@ -88,7 +88,7 @@ public final class InputWindowHandle { public int inputFeatures; // Display this input is on. - public final int displayId; + public int displayId; private native void nativeDispose();
7.2 Make the following patches on the path frameworks base services core java com android server wm Windows Manager Service. Java
dongsy@build-server-100:~/work/dsy/rk3288-Android-7.0/frameworks/base(m_android_7_0)$ git diff services/core/java/com/android/server/wm/WindowManagerService.java diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/Window index f4ba143..36d1c79 100755 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1236,6 +1236,7 @@ public class WindowManagerService extends IWindowManager.Stub } } defaultWindows.add(win); + win.mInputWindowHandle.displayId=defaultContent.getDisplayId(); } if(DEBUG) Log.i(TAG_DUALSCREEN, "primaryWindows:"+primaryWindows); @@ -1348,6 +1349,7 @@ public class WindowManagerService extends IWindowManager.Stub if(DEBUG) Log.i(TAG_DUALSCREEN, "moveTransitionToSecondDisplay->add win:" + win); defaultWindows.remove(win); mTempWindowList.add(win); + win.mInputWindowHandle.displayId=displayId; win.mDisplayContent = secondDisplayContent; if(DEBUG) Log.i(TAG_DUALSCREEN,"win.mDisplayContent = "+win.mDisplayContent+ " seco if(win.mWinAnimator != null){
7.3 Make the following patches on the path frameworks base services core java com android server wm Windows State. Java
dongsy@build-server-100:~/work/dsy/rk3288-Android-7.0/frameworks/base(m_android_7_0)$ git diff services/core/java/com/android/server/wm/WindowState.java diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.jav index bcbb4bc..5be2803 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1725,8 +1725,12 @@ final class WindowState implements WindowManagerPolicy.WindowState { RESIZE_HANDLE_WIDTH_IN_DP, displayMetrics); mTmpRect.inset(-delta, -delta); } - region.set(mTmpRect); - cropRegionToStackBoundsIfNeeded(region); + if(mDisplayContent.getDisplayId()==0) { + region.set(mTmpRect); + cropRegionToStackBoundsIfNeeded(region); + }else{ + region.set(new Rect(0,0,mDisplayContent.mBaseDisplayWidth,mDisplayContent.mBaseDisplayHeight)); + } } else { // Not modal or full screen modal getTouchableRegion(region);
7.4 Make the following patch on the path frameworks base services core jni com_android_server_input_InputManagerService. CPP
dongsy@build-server-100:~/work/dsy/rk3288-Android-7.0/frameworks/base(m_android_7_0)$ git diff services/core/jni/com_android_server_input_InputManagerService.cpp diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_Inpu index b9abb79..a60083f 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -383,7 +383,8 @@ void NativeInputManager::setDisplayViewport(bool external, const DisplayViewport DisplayViewport convertViewport; convertViewport.copyFrom(viewport); + if(!external) convertViewport.orientation = (mLocked.hardwareRotation + convertViewport.orientation) % 4; DisplayViewport& v = external ? mLocked.externalViewport : mLocked.internalViewport;