Add type to DisplayViewport
Refactor DisplayViewport to treat internal, external, and virtual
display viewports more equally. Now stored in single array, and mLocked
contains the most up-to-date copy of these. Still enforce the
requirement that there can only be 1 internal and 1 external viewport.
We should remove this requirement in the future.
Bug: 111108021
Test: atest DisplayManagerServiceTest
Change-Id: I6fca9725f6e4180063c86f3c2bc34906ac1d0024
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 0f28439..5bd095d 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -16,9 +16,6 @@
package com.android.server.input;
-import static android.hardware.display.DisplayViewport.VIEWPORT_INTERNAL;
-import static android.hardware.display.DisplayViewport.VIEWPORT_EXTERNAL;
-
import android.annotation.NonNull;
import android.app.IInputForwarder;
import android.app.Notification;
@@ -188,13 +185,8 @@
private static native long nativeInit(InputManagerService service,
Context context, MessageQueue messageQueue);
private static native void nativeStart(long ptr);
- private static native void nativeSetVirtualDisplayViewports(long ptr,
+ private static native void nativeSetDisplayViewports(long ptr,
DisplayViewport[] viewports);
- private static native void nativeSetDisplayViewport(long ptr, int viewportType,
- int displayId, int rotation,
- int logicalLeft, int logicalTop, int logicalRight, int logicalBottom,
- int physicalLeft, int physicalTop, int physicalRight, int physicalBottom,
- int deviceWidth, int deviceHeight, String uniqueId);
private static native int nativeGetScanCodeState(long ptr,
int deviceId, int sourceMask, int scanCode);
@@ -409,31 +401,8 @@
nativeReloadDeviceAliases(mPtr);
}
- private void setDisplayViewportsInternal(DisplayViewport defaultViewport,
- DisplayViewport externalTouchViewport,
- List<DisplayViewport> virtualTouchViewports) {
- if (defaultViewport.valid) {
- setDisplayViewport(VIEWPORT_INTERNAL, defaultViewport);
- }
-
- if (externalTouchViewport.valid) {
- setDisplayViewport(VIEWPORT_EXTERNAL, externalTouchViewport);
- } else if (defaultViewport.valid) {
- setDisplayViewport(VIEWPORT_EXTERNAL, defaultViewport);
- }
-
- nativeSetVirtualDisplayViewports(mPtr,
- virtualTouchViewports.toArray(new DisplayViewport[0]));
- }
-
- private void setDisplayViewport(int viewportType, DisplayViewport viewport) {
- nativeSetDisplayViewport(mPtr, viewportType,
- viewport.displayId, viewport.orientation,
- viewport.logicalFrame.left, viewport.logicalFrame.top,
- viewport.logicalFrame.right, viewport.logicalFrame.bottom,
- viewport.physicalFrame.left, viewport.physicalFrame.top,
- viewport.physicalFrame.right, viewport.physicalFrame.bottom,
- viewport.deviceWidth, viewport.deviceHeight, viewport.uniqueId);
+ private void setDisplayViewportsInternal(List<DisplayViewport> viewports) {
+ nativeSetDisplayViewports(mPtr, viewports.toArray(new DisplayViewport[0]));
}
/**
@@ -2203,11 +2172,8 @@
private final class LocalService extends InputManagerInternal {
@Override
- public void setDisplayViewports(DisplayViewport defaultViewport,
- DisplayViewport externalTouchViewport,
- List<DisplayViewport> virtualTouchViewports) {
- setDisplayViewportsInternal(defaultViewport, externalTouchViewport,
- virtualTouchViewports);
+ public void setDisplayViewports(List<DisplayViewport> viewports) {
+ setDisplayViewportsInternal(viewports);
}
@Override