Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1e54095 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass monitor pid to InputDispatcher"

parents 03bc8d50 f83aa56d
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -259,7 +259,7 @@ public class InputManagerService extends IInputManager.Stub
            int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists);
            int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists);
    private static native InputChannel nativeCreateInputChannel(long ptr, String name);
    private static native InputChannel nativeCreateInputChannel(long ptr, String name);
    private static native InputChannel nativeCreateInputMonitor(long ptr, int displayId,
    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 nativeRemoveInputChannel(long ptr, IBinder connectionToken);
    private static native void nativePilferPointers(long ptr, IBinder token);
    private static native void nativePilferPointers(long ptr, IBinder token);
    private static native void nativeSetInputFilterEnabled(long ptr, boolean enable);
    private static native void nativeSetInputFilterEnabled(long ptr, boolean enable);
@@ -607,7 +607,7 @@ public class InputManagerService extends IInputManager.Stub
        }
        }


        return nativeCreateInputMonitor(mPtr, displayId, false /* isGestureMonitor */,
        return nativeCreateInputMonitor(mPtr, displayId, false /* isGestureMonitor */,
                inputChannelName);
                inputChannelName, Binder.getCallingPid());
    }
    }


    /**
    /**
@@ -635,7 +635,7 @@ public class InputManagerService extends IInputManager.Stub
        final long ident = Binder.clearCallingIdentity();
        final long ident = Binder.clearCallingIdentity();
        try {
        try {
            InputChannel inputChannel = nativeCreateInputMonitor(
            InputChannel inputChannel = nativeCreateInputMonitor(
                    mPtr, displayId, true /*isGestureMonitor*/, inputChannelName);
                    mPtr, displayId, true /*isGestureMonitor*/, inputChannelName, pid);
            InputMonitorHost host = new InputMonitorHost(inputChannel.getToken());
            InputMonitorHost host = new InputMonitorHost(inputChannel.getToken());
            synchronized (mGestureMonitorPidsLock) {
            synchronized (mGestureMonitorPidsLock) {
                mGestureMonitorPidsByToken.put(inputChannel.getToken(), pid);
                mGestureMonitorPidsByToken.put(inputChannel.getToken(), pid);
+9 −6
Original line number Original line Diff line number Diff line
@@ -249,7 +249,8 @@ public:
                                                                   const std::string& name);
                                                                   const std::string& name);
    base::Result<std::unique_ptr<InputChannel>> createInputMonitor(JNIEnv* env, int32_t displayId,
    base::Result<std::unique_ptr<InputChannel>> createInputMonitor(JNIEnv* env, int32_t displayId,
                                                                   bool isGestureMonitor,
                                                                   bool isGestureMonitor,
                                                                   const std::string& name);
                                                                   const std::string& name,
                                                                   int32_t pid);
    status_t removeInputChannel(JNIEnv* env, const sp<IBinder>& connectionToken);
    status_t removeInputChannel(JNIEnv* env, const sp<IBinder>& connectionToken);
    status_t pilferPointers(const sp<IBinder>& token);
    status_t pilferPointers(const sp<IBinder>& token);


@@ -487,9 +488,11 @@ base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputChann
}
}


base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputMonitor(
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();
    ATRACE_CALL();
    return mInputManager->getDispatcher()->createInputMonitor(displayId, isGestureMonitor, name);
    return mInputManager->getDispatcher()->createInputMonitor(displayId, isGestureMonitor, name,
                                                              pid);
}
}


status_t NativeInputManager::removeInputChannel(JNIEnv* /* env */,
status_t NativeInputManager::removeInputChannel(JNIEnv* /* env */,
@@ -1503,7 +1506,7 @@ static jobject nativeCreateInputChannel(JNIEnv* env, jclass /* clazz */, jlong p
}
}


static jobject nativeCreateInputMonitor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint displayId,
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);
    NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);


    if (displayId == ADISPLAY_ID_NONE) {
    if (displayId == ADISPLAY_ID_NONE) {
@@ -1516,7 +1519,7 @@ static jobject nativeCreateInputMonitor(JNIEnv* env, jclass /* clazz */, jlong p
    std::string name = nameChars.c_str();
    std::string name = nameChars.c_str();


    base::Result<std::unique_ptr<InputChannel>> inputChannel =
    base::Result<std::unique_ptr<InputChannel>> inputChannel =
            im->createInputMonitor(env, displayId, isGestureMonitor, name);
            im->createInputMonitor(env, displayId, isGestureMonitor, name, pid);


    if (!inputChannel) {
    if (!inputChannel) {
        std::string message = inputChannel.error().message();
        std::string message = inputChannel.error().message();
@@ -2092,7 +2095,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
        {"nativeHasKeys", "(JII[I[Z)Z", (void*)nativeHasKeys},
        {"nativeHasKeys", "(JII[I[Z)Z", (void*)nativeHasKeys},
        {"nativeCreateInputChannel", "(JLjava/lang/String;)Landroid/view/InputChannel;",
        {"nativeCreateInputChannel", "(JLjava/lang/String;)Landroid/view/InputChannel;",
         (void*)nativeCreateInputChannel},
         (void*)nativeCreateInputChannel},
        {"nativeCreateInputMonitor", "(JIZLjava/lang/String;)Landroid/view/InputChannel;",
        {"nativeCreateInputMonitor", "(JIZLjava/lang/String;I)Landroid/view/InputChannel;",
         (void*)nativeCreateInputMonitor},
         (void*)nativeCreateInputMonitor},
        {"nativeRemoveInputChannel", "(JLandroid/os/IBinder;)V", (void*)nativeRemoveInputChannel},
        {"nativeRemoveInputChannel", "(JLandroid/os/IBinder;)V", (void*)nativeRemoveInputChannel},
        {"nativePilferPointers", "(JLandroid/os/IBinder;)V", (void*)nativePilferPointers},
        {"nativePilferPointers", "(JLandroid/os/IBinder;)V", (void*)nativePilferPointers},