Pass monitor pid to InputDispatcher
To help identify the owner of the monitor, pass its pid to InputDispatcher. This pid will later be used to report ANRs. Bug: 175593831 Test: atest inputflinger_tests Change-Id: Ic8e6e86cc2a8592b797fa19154e5a7fe246b7231
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user