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

Commit aa436bc9 authored by Christopher Lais's avatar Christopher Lais
Browse files

input: Wake on natigation button without keyguard

Refactored the code a bit to handle WM_ACTION_POKE_USER_ACTIVITY
when using the navigation button wake without the KeyGuard active.

Tried to avoid code duplication, but we may want to move the
navigation button handling to a separate function in the policy to
avoid the BTN_MOUSE keyCode hack at some point.

Change-Id: I5545d99aaf4ea1ffe044c9f124d8397f25c31f3a
parent b9df5b13
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -302,7 +302,8 @@ public:

    /* Intercepts a navigation button press before queueing it
     */
    virtual void interceptNavigationButtonBeforeQueueing(nsecs_t when, uint32_t& policyFlags, bool down) = 0;
    virtual void interceptNavigationButtonBeforeQueueing(nsecs_t when, int32_t deviceId,
            int32_t action, int32_t& flags, uint32_t& policyFlags) = 0;

    /* Allows the policy a chance to intercept a key before dispatching. */
    virtual bool interceptKeyBeforeDispatching(const sp<InputChannel>& inputChannel,
+2 −2
Original line number Diff line number Diff line
@@ -2127,8 +2127,8 @@ void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t
    policyFlags |= POLICY_FLAG_TRUSTED;
    if ((source & AINPUT_SOURCE_CLASS_NAVIGATION) &&
                    (action == AMOTION_EVENT_ACTION_DOWN || action == AMOTION_EVENT_ACTION_UP)) {
            mPolicy->interceptNavigationButtonBeforeQueueing(eventTime, policyFlags,
                            action == AMOTION_EVENT_ACTION_DOWN);
            mPolicy->interceptNavigationButtonBeforeQueueing(eventTime, deviceId,
                flags, action, policyFlags);
    }
    mPolicy->interceptGenericBeforeQueueing(eventTime, /*byref*/ policyFlags);

+2 −1
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ private:
            uint32_t& policyFlags) {
    }

    virtual void interceptNavigationButtonBeforeQueueing(nsecs_t when, uint32_t& policyFlags, bool down) {
    virtual void interceptNavigationButtonBeforeQueueing(nsecs_t when,
            int32_t deviceId, int32_t action, int32_t& flags, uint32_t& policyFlags) {
    }

    virtual void interceptGenericBeforeQueueing(nsecs_t when, uint32_t& policyFlags) {
+14 −9
Original line number Diff line number Diff line
@@ -204,7 +204,9 @@ public:
            int32_t action, int32_t& flags, int32_t keyCode, int32_t scanCode,
            uint32_t& policyFlags);
    virtual void interceptGenericBeforeQueueing(nsecs_t when, uint32_t& policyFlags);
    virtual void interceptNavigationButtonBeforeQueueing(nsecs_t when, uint32_t& policyFlags, bool down);
    virtual void interceptNavigationButtonBeforeQueueing(nsecs_t when,
            int32_t deviceId, int32_t action, int32_t& flags,
            uint32_t& policyFlags);
    virtual bool interceptKeyBeforeDispatching(const sp<InputChannel>& inputChannel,
            const KeyEvent* keyEvent, uint32_t policyFlags);
    virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType);
@@ -913,18 +915,21 @@ void NativeInputManager::interceptGenericBeforeQueueing(nsecs_t when, uint32_t&
    }
}

void NativeInputManager::interceptNavigationButtonBeforeQueueing(nsecs_t when, uint32_t& policyFlags, bool down) {
void NativeInputManager::interceptNavigationButtonBeforeQueueing(nsecs_t when,
        int32_t deviceId, int32_t action, int32_t& flags,
        uint32_t& policyFlags)
{
    // Policy:
    // - Ignore untrusted events and pass them along.
    // - Allow the window manager to handle the down event if the screen is off
    //   to permit using the navigation button as a wake key
    if ((policyFlags & POLICY_FLAG_TRUSTED) && !(policyFlags & POLICY_FLAG_INJECTED)
                && down && !this->isScreenOn()) {
        JNIEnv* env = jniEnv();
        env->CallIntMethod(mCallbacksObj,
            gCallbacksClassInfo.interceptKeyBeforeQueueing,
            when, BTN_MOUSE, down, policyFlags, this->isScreenOn());
        checkAndClearExceptionFromCallback(env, "interceptKeyBeforeQueueing");
    if ((policyFlags & POLICY_FLAG_TRUSTED)
            && !(policyFlags & POLICY_FLAG_INJECTED)
            && (action == AMOTION_EVENT_ACTION_DOWN)
            && !this->isScreenOn()) {

        interceptKeyBeforeQueueing(when, deviceId,
            AKEY_EVENT_ACTION_DOWN, flags, BTN_MOUSE, BTN_MOUSE, policyFlags);
    }
}