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

Commit 27fd3420 authored by Jeff Brown's avatar Jeff Brown
Browse files

Fix lid switch interpretation.

Also remove unnecessary permission check for method that is
only called internally.

Change-Id: I32f63fc3e96b06709d18b046ee2d3c8f310de70d
parent eca3cf58
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -4807,10 +4807,13 @@ public class WindowManagerService extends IWindowManager.Stub
        final int SW_LID = 0x00;
        int sw = mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_LID);
        if (sw > 0) {
            return LID_OPEN;
        } else if (sw == 0) {
            // Switch state: AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL.
            return LID_CLOSED;
        } else if (sw == 0) {
            // Switch state: AKEY_STATE_UP.
            return LID_OPEN;
        } else {
            // Switch state: AKEY_STATE_UNKNOWN.
            return LID_ABSENT;
        }
    }
@@ -4818,10 +4821,6 @@ public class WindowManagerService extends IWindowManager.Stub
    // Called by window manager policy.  Not exposed externally.
    @Override
    public InputChannel monitorInput(String inputChannelName) {
        if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
                "monitorInput()")) {
            throw new SecurityException("Requires READ_INPUT_STATE permission");
        }
        return mInputManager.monitorInput(inputChannelName);
    }

+2 −1
Original line number Diff line number Diff line
@@ -510,8 +510,9 @@ void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode,

    switch (switchCode) {
    case SW_LID:
        // When switch value is set indicates lid is closed.
        env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyLidSwitchChanged,
                when, switchValue == 0);
                when, switchValue == 0 /*lidOpen*/);
        checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged");
        break;
    }