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

Commit 23b6d46e authored by Michael Wright's avatar Michael Wright Committed by android-build-merger
Browse files

Prevent media keys from waking the device, even if they're external.

am: 58ba9884

Change-Id: I38150eff6b1a84ba2cb216ebf5b430887cab2700
parents 799298f4 58ba9884
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -2329,6 +2329,35 @@ bool KeyboardInputMapper::isKeyboardOrGamepadKey(int32_t scanCode) {
        || (scanCode >= BTN_JOYSTICK && scanCode < BTN_DIGI);
}

bool KeyboardInputMapper::isMediaKey(int32_t keyCode) {
    switch (keyCode) {
    case AKEYCODE_MEDIA_PLAY:
    case AKEYCODE_MEDIA_PAUSE:
    case AKEYCODE_MEDIA_PLAY_PAUSE:
    case AKEYCODE_MUTE:
    case AKEYCODE_HEADSETHOOK:
    case AKEYCODE_MEDIA_STOP:
    case AKEYCODE_MEDIA_NEXT:
    case AKEYCODE_MEDIA_PREVIOUS:
    case AKEYCODE_MEDIA_REWIND:
    case AKEYCODE_MEDIA_RECORD:
    case AKEYCODE_MEDIA_FAST_FORWARD:
    case AKEYCODE_MEDIA_SKIP_FORWARD:
    case AKEYCODE_MEDIA_SKIP_BACKWARD:
    case AKEYCODE_MEDIA_STEP_FORWARD:
    case AKEYCODE_MEDIA_STEP_BACKWARD:
    case AKEYCODE_MEDIA_AUDIO_TRACK:
    case AKEYCODE_VOLUME_UP:
    case AKEYCODE_VOLUME_DOWN:
    case AKEYCODE_VOLUME_MUTE:
    case AKEYCODE_TV_AUDIO_DESCRIPTION:
    case AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP:
    case AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN:
        return true;
    }
    return false;
}

void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode,
        int32_t usageCode) {
    int32_t keyCode;
@@ -2402,7 +2431,7 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode,
    // For internal keyboards, the key layout file should specify the policy flags for
    // each wake key individually.
    // TODO: Use the input device configuration to control this behavior more finely.
    if (down && getDevice()->isExternal()) {
    if (down && getDevice()->isExternal() && !isMediaKey(keyCode)) {
        policyFlags |= POLICY_FLAG_WAKE;
    }

+1 −0
Original line number Diff line number Diff line
@@ -1128,6 +1128,7 @@ private:
    void dumpParameters(String8& dump);

    bool isKeyboardOrGamepadKey(int32_t scanCode);
    bool isMediaKey(int32_t keyCode);

    void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode);