summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2019-04-03 16:04:03 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-04-03 16:04:03 +0000
commit89df2a72f76c44657f4eba9f3f812e29c61e0639 (patch)
tree68f049c215a0806581c4c9a5d8cc584907b6c4c4 /core/java/android
parent934a49270f49cf8b64895c5c78d1b712e74993e4 (diff)
parentc7995239efbaa6d0a933c399577fe4759fce3591 (diff)
Merge "Expose input region monitoring to system components."
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/hardware/input/IInputManager.aidl5
-rw-r--r--core/java/android/hardware/input/InputManager.java14
-rw-r--r--core/java/android/view/IInputMonitorHost.aidl25
-rw-r--r--core/java/android/view/InputChannel.java22
-rw-r--r--core/java/android/view/InputMonitor.aidl19
-rw-r--r--core/java/android/view/InputMonitor.java127
6 files changed, 201 insertions, 11 deletions
diff --git a/core/java/android/hardware/input/IInputManager.aidl b/core/java/android/hardware/input/IInputManager.aidl
index 2923bbf14c30..0daf30f25d59 100644
--- a/core/java/android/hardware/input/IInputManager.aidl
+++ b/core/java/android/hardware/input/IInputManager.aidl
@@ -16,6 +16,7 @@
package android.hardware.input;
+import android.graphics.Rect;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.KeyboardLayout;
import android.hardware.input.IInputDevicesChangedListener;
@@ -24,6 +25,7 @@ import android.hardware.input.TouchCalibration;
import android.os.IBinder;
import android.view.InputDevice;
import android.view.InputEvent;
+import android.view.InputMonitor;
import android.view.PointerIcon;
/** @hide */
@@ -82,4 +84,7 @@ interface IInputManager {
void setCustomPointerIcon(in PointerIcon icon);
void requestPointerCapture(IBinder windowToken, boolean enabled);
+
+ /** Create an input monitor for gestures. */
+ InputMonitor monitorGestureInput(String name, int displayId);
}
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index fec5c34fab28..2a59be28a937 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -41,6 +41,7 @@ import android.util.Log;
import android.util.SparseArray;
import android.view.InputDevice;
import android.view.InputEvent;
+import android.view.InputMonitor;
import android.view.MotionEvent;
import android.view.PointerIcon;
@@ -933,6 +934,19 @@ public final class InputManager {
}
}
+ /**
+ * Monitor input on the specified display for gestures.
+ *
+ * @hide
+ */
+ public InputMonitor monitorGestureInput(String name, int displayId) {
+ try {
+ return mIm.monitorGestureInput(name, displayId);
+ } catch (RemoteException ex) {
+ throw ex.rethrowFromSystemServer();
+ }
+ }
+
private void populateInputDevicesLocked() {
if (mInputDevicesChangedListener == null) {
final InputDevicesChangedListener listener = new InputDevicesChangedListener();
diff --git a/core/java/android/view/IInputMonitorHost.aidl b/core/java/android/view/IInputMonitorHost.aidl
new file mode 100644
index 000000000000..bde737d9a65b
--- /dev/null
+++ b/core/java/android/view/IInputMonitorHost.aidl
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2019, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view;
+
+/**
+ * @hide
+ */
+oneway interface IInputMonitorHost {
+ void pilferPointers();
+ void dispose();
+}
diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java
index af2b992ccba2..ecb727c79016 100644
--- a/core/java/android/view/InputChannel.java
+++ b/core/java/android/view/InputChannel.java
@@ -17,8 +17,8 @@
package android.view;
import android.annotation.UnsupportedAppUsage;
-import android.os.Parcel;
import android.os.IBinder;
+import android.os.Parcel;
import android.os.Parcelable;
import android.util.Slog;
@@ -31,9 +31,9 @@ import android.util.Slog;
*/
public final class InputChannel implements Parcelable {
private static final String TAG = "InputChannel";
-
+
private static final boolean DEBUG = false;
-
+
@UnsupportedAppUsage
public static final @android.annotation.NonNull Parcelable.Creator<InputChannel> CREATOR
= new Parcelable.Creator<InputChannel>() {
@@ -42,12 +42,12 @@ public final class InputChannel implements Parcelable {
result.readFromParcel(source);
return result;
}
-
+
public InputChannel[] newArray(int size) {
return new InputChannel[size];
}
};
-
+
@SuppressWarnings("unused")
@UnsupportedAppUsage
private long mPtr; // used by native code
@@ -81,7 +81,7 @@ public final class InputChannel implements Parcelable {
super.finalize();
}
}
-
+
/**
* Creates a new input channel pair. One channel should be provided to the input
* dispatcher and the other to the application's input queue.
@@ -100,7 +100,7 @@ public final class InputChannel implements Parcelable {
}
return nativeOpenInputChannelPair(name);
}
-
+
/**
* Gets the name of the input channel.
* @return The input channel name.
@@ -118,7 +118,7 @@ public final class InputChannel implements Parcelable {
public void dispose() {
nativeDispose(false);
}
-
+
/**
* Transfers ownership of the internal state of the input channel to another
* instance and invalidates this instance. This is used to pass an input channel
@@ -129,7 +129,7 @@ public final class InputChannel implements Parcelable {
if (outParameter == null) {
throw new IllegalArgumentException("outParameter must not be null");
}
-
+
nativeTransferTo(outParameter);
}
@@ -151,7 +151,7 @@ public final class InputChannel implements Parcelable {
if (in == null) {
throw new IllegalArgumentException("in must not be null");
}
-
+
nativeReadFromParcel(in);
}
@@ -160,7 +160,7 @@ public final class InputChannel implements Parcelable {
if (out == null) {
throw new IllegalArgumentException("out must not be null");
}
-
+
nativeWriteToParcel(out);
if ((flags & PARCELABLE_WRITE_RETURN_VALUE) != 0) {
diff --git a/core/java/android/view/InputMonitor.aidl b/core/java/android/view/InputMonitor.aidl
new file mode 100644
index 000000000000..bdd14fef392a
--- /dev/null
+++ b/core/java/android/view/InputMonitor.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view;
+
+parcelable InputMonitor;
diff --git a/core/java/android/view/InputMonitor.java b/core/java/android/view/InputMonitor.java
new file mode 100644
index 000000000000..693f2873522c
--- /dev/null
+++ b/core/java/android/view/InputMonitor.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.os.RemoteException;
+
+/**
+ * @hide
+ */
+public final class InputMonitor implements Parcelable {
+ private static final String TAG = "InputMonitor";
+
+ private static final boolean DEBUG = false;
+
+ public static final Parcelable.Creator<InputMonitor> CREATOR =
+ new Parcelable.Creator<InputMonitor>() {
+
+ public InputMonitor createFromParcel(Parcel source) {
+ return new InputMonitor(source);
+ }
+
+ public InputMonitor[] newArray(int size) {
+ return new InputMonitor[size];
+ }
+ };
+
+ @NonNull
+ private final String mName;
+ @NonNull
+ private final InputChannel mChannel;
+ @NonNull
+ private final IInputMonitorHost mHost;
+
+ public InputMonitor(@NonNull String name, @NonNull InputChannel channel,
+ @NonNull IInputMonitorHost host) {
+ mName = name;
+ mChannel = channel;
+ mHost = host;
+ }
+
+ public InputMonitor(Parcel in) {
+ mName = in.readString();
+ mChannel = in.readParcelable(null);
+ mHost = IInputMonitorHost.Stub.asInterface(in.readStrongBinder());
+ }
+
+ /**
+ * Get the {@link InputChannel} corresponding to this InputMonitor
+ */
+ public InputChannel getInputChannel() {
+ return mChannel;
+ }
+
+ /**
+ * Get the name of this channel.
+ */
+ public String getName() {
+ return mName;
+ }
+
+
+ /**
+ * Takes all of the current pointer events streams that are currently being sent to this
+ * monitor and generates appropriate cancellations for the windows that would normally get
+ * them.
+ *
+ * This method should be used with caution as unexpected pilfering can break fundamental user
+ * interactions.
+ */
+ public void pilferPointers() {
+ try {
+ mHost.pilferPointers();
+ } catch (RemoteException e) {
+ e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Disposes the input monitor.
+ *
+ * Explicitly release all of the resources this monitor is holding on to (e.g. the
+ * InputChannel). Once this method is called, this monitor and any resources it's provided may
+ * no longer be used.
+ */
+ public void dispose() {
+ mChannel.dispose();
+ try {
+ mHost.dispose();
+ } catch (RemoteException e) {
+ e.rethrowFromSystemServer();
+ }
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeString(mName);
+ out.writeParcelable(mChannel, flags);
+ out.writeStrongBinder(mHost.asBinder());
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "InputMonitor{mName=" + mName + ", mChannel=" + mChannel + ", mHost=" + mHost + "}";
+ }
+}