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

Commit 9806a230 authored by Jeff Brown's avatar Jeff Brown
Browse files

Ignore broken input channel when finishing input event.

There are occasional races during application shut down where the
input dispatcher will close an input channel before the application
has finished its last event.  So just ignore EPIPE.

Also tweak the logging for failed input event injection to make
it clearer which pid was trying to perform the injection.

Bug: 6013004
Change-Id: I7bbb01441d41762b03eafd4d39dcf0323e1cadf3
parent b503f1ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -264,7 +264,7 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr,
    sp<NativeInputEventReceiver> receiver =
            reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
    status_t status = receiver->finishInputEvent(seq, handled);
    if (status) {
    if (status && status != DEAD_OBJECT) {
        String8 message;
        message.appendFormat("Failed to finish input event.  status=%d", status);
        jniThrowRuntimeException(env, message.string());
+8 −9
Original line number Diff line number Diff line
@@ -6377,7 +6377,7 @@ public class WindowManagerService extends IWindowManager.Stub
                INJECTION_TIMEOUT_MILLIS);
        
        Binder.restoreCallingIdentity(ident);
        return reportInjectionResult(result);
        return reportInjectionResult(result, pid);
    }

    /**
@@ -6407,7 +6407,7 @@ public class WindowManagerService extends IWindowManager.Stub
                INJECTION_TIMEOUT_MILLIS);
        
        Binder.restoreCallingIdentity(ident);
        return reportInjectionResult(result);
        return reportInjectionResult(result, pid);
    }

    /**
@@ -6437,7 +6437,7 @@ public class WindowManagerService extends IWindowManager.Stub
                INJECTION_TIMEOUT_MILLIS);
        
        Binder.restoreCallingIdentity(ident);
        return reportInjectionResult(result);
        return reportInjectionResult(result, pid);
    }
    
    /**
@@ -6458,24 +6458,23 @@ public class WindowManagerService extends IWindowManager.Stub
                INJECTION_TIMEOUT_MILLIS);
        
        Binder.restoreCallingIdentity(ident);
        return reportInjectionResult(result);
        return reportInjectionResult(result, pid);
    }
    
    private boolean reportInjectionResult(int result) {
    private boolean reportInjectionResult(int result, int pid) {
        switch (result) {
            case InputManager.INPUT_EVENT_INJECTION_PERMISSION_DENIED:
                Slog.w(TAG, "Input event injection permission denied.");
                Slog.w(TAG, "Input event injection from pid " + pid + " permission denied.");
                throw new SecurityException(
                        "Injecting to another application requires INJECT_EVENTS permission");
            case InputManager.INPUT_EVENT_INJECTION_SUCCEEDED:
                //Slog.v(TAG, "Input event injection succeeded.");
                return true;
            case InputManager.INPUT_EVENT_INJECTION_TIMED_OUT:
                Slog.w(TAG, "Input event injection timed out.");
                Slog.w(TAG, "Input event injection from pid " + pid + " timed out.");
                return false;
            case InputManager.INPUT_EVENT_INJECTION_FAILED:
            default:
                Slog.w(TAG, "Input event injection failed.");
                Slog.w(TAG, "Input event injection from pid " + pid + " failed.");
                return false;
        }
    }