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

Unverified Commit ee427ff0 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 f6cc7893
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -238,6 +238,8 @@ import com.android.server.wm.WindowManagerInternal.AppTransitionListener;

import dalvik.system.PathClassLoader;

import org.lineageos.internal.buttons.LineageButtons;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
@@ -675,6 +677,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;
@@ -4390,6 +4394,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.
@@ -5616,6 +5624,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                mKeyguardDelegate.onBootCompleted();
            }
        }
        mLineageButtons = new LineageButtons(mContext);
        mSideFpsEventHandler.onFingerprintSensorReady();
        startedWakingUp(Display.DEFAULT_DISPLAY_GROUP, PowerManager.WAKE_REASON_UNKNOWN);
        finishedWakingUp(Display.DEFAULT_DISPLAY_GROUP, PowerManager.WAKE_REASON_UNKNOWN);