summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/input/InputManagerService.java6
-rw-r--r--services/core/jni/com_android_server_input_InputManagerService.cpp15
2 files changed, 12 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 46ccf1e18802..3b88cebddf5c 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -244,7 +244,7 @@ public class InputManagerService extends IInputManager.Stub
int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists);
private static native InputChannel nativeCreateInputChannel(long ptr, String name);
private static native InputChannel nativeCreateInputMonitor(long ptr, int displayId,
- boolean isGestureMonitor, String name);
+ boolean isGestureMonitor, String name, int pid);
private static native void nativeRemoveInputChannel(long ptr, IBinder connectionToken);
private static native void nativePilferPointers(long ptr, IBinder token);
private static native void nativeSetInputFilterEnabled(long ptr, boolean enable);
@@ -586,7 +586,7 @@ public class InputManagerService extends IInputManager.Stub
}
return nativeCreateInputMonitor(mPtr, displayId, false /* isGestureMonitor */,
- inputChannelName);
+ inputChannelName, Binder.getCallingPid());
}
/**
@@ -614,7 +614,7 @@ public class InputManagerService extends IInputManager.Stub
final long ident = Binder.clearCallingIdentity();
try {
InputChannel inputChannel = nativeCreateInputMonitor(
- mPtr, displayId, true /*isGestureMonitor*/, inputChannelName);
+ mPtr, displayId, true /*isGestureMonitor*/, inputChannelName, pid);
InputMonitorHost host = new InputMonitorHost(inputChannel.getToken());
synchronized (mGestureMonitorPidsLock) {
mGestureMonitorPidsByToken.put(inputChannel.getToken(), pid);
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index 404b182d968f..c3f4a25b8591 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -224,7 +224,8 @@ public:
const std::string& name);
base::Result<std::unique_ptr<InputChannel>> createInputMonitor(JNIEnv* env, int32_t displayId,
bool isGestureMonitor,
- const std::string& name);
+ const std::string& name,
+ int32_t pid);
status_t removeInputChannel(JNIEnv* env, const sp<IBinder>& connectionToken);
status_t pilferPointers(const sp<IBinder>& token);
@@ -456,9 +457,11 @@ base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputChann
}
base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputMonitor(
- JNIEnv* /* env */, int32_t displayId, bool isGestureMonitor, const std::string& name) {
+ JNIEnv* /* env */, int32_t displayId, bool isGestureMonitor, const std::string& name,
+ int32_t pid) {
ATRACE_CALL();
- return mInputManager->getDispatcher()->createInputMonitor(displayId, isGestureMonitor, name);
+ return mInputManager->getDispatcher()->createInputMonitor(displayId, isGestureMonitor, name,
+ pid);
}
status_t NativeInputManager::removeInputChannel(JNIEnv* /* env */,
@@ -1440,7 +1443,7 @@ static jobject nativeCreateInputChannel(JNIEnv* env, jclass /* clazz */, jlong p
}
static jobject nativeCreateInputMonitor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint displayId,
- jboolean isGestureMonitor, jstring nameObj) {
+ jboolean isGestureMonitor, jstring nameObj, jint pid) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
if (displayId == ADISPLAY_ID_NONE) {
@@ -1453,7 +1456,7 @@ static jobject nativeCreateInputMonitor(JNIEnv* env, jclass /* clazz */, jlong p
std::string name = nameChars.c_str();
base::Result<std::unique_ptr<InputChannel>> inputChannel =
- im->createInputMonitor(env, displayId, isGestureMonitor, name);
+ im->createInputMonitor(env, displayId, isGestureMonitor, name, pid);
if (!inputChannel) {
std::string message = inputChannel.error().message();
@@ -1923,7 +1926,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
{"nativeHasKeys", "(JII[I[Z)Z", (void*)nativeHasKeys},
{"nativeCreateInputChannel", "(JLjava/lang/String;)Landroid/view/InputChannel;",
(void*)nativeCreateInputChannel},
- {"nativeCreateInputMonitor", "(JIZLjava/lang/String;)Landroid/view/InputChannel;",
+ {"nativeCreateInputMonitor", "(JIZLjava/lang/String;I)Landroid/view/InputChannel;",
(void*)nativeCreateInputMonitor},
{"nativeRemoveInputChannel", "(JLandroid/os/IBinder;)V", (void*)nativeRemoveInputChannel},
{"nativePilferPointers", "(JLandroid/os/IBinder;)V", (void*)nativePilferPointers},