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

Commit 68e112d4 authored by Simon Shields's avatar Simon Shields Committed by Michael Bestas
Browse files

PhoneWindowManager: add LineageButtons volumekey hook

We can't use a generic DeviceKeyHandler here, because we don't want to
override some of the AOSP logic (silencing incoming calls, screenshots)
and we need to know if the device is interactive or not (for screen-off
music controls)

Change-Id: I485c2f6006c5bbd358ba0cbd32917689826c5c6d
parent 7bd4f459
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -232,6 +232,7 @@ import dalvik.system.PathClassLoader;

import lineageos.providers.LineageSettings;

import org.lineageos.internal.buttons.LineageButtons;
import org.lineageos.internal.util.ActionUtils;

import java.io.File;
@@ -634,6 +635,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    private final List<DeviceKeyHandler> mDeviceKeyHandlers = new ArrayList<>();

    private LineageButtons mLineageButtons;

    private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
    private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4;
    private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5;
@@ -3959,6 +3962,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    // {@link interceptKeyBeforeDispatching()}.
                    result |= ACTION_PASS_TO_USER;
                } else if ((result & ACTION_PASS_TO_USER) == 0) {
                    if (mLineageButtons.handleVolumeKey(event, interactive)) {
                        break;
                    }

                    // If we aren't passing to the user and no one else
                    // handled it send it to the session manager to
                    // figure out.
@@ -4975,6 +4982,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }
        }

        mLineageButtons = new LineageButtons(mContext);

        mAutofillManagerInternal = LocalServices.getService(AutofillManagerInternal.class);
    }