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

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


import dalvik.system.PathClassLoader;
import dalvik.system.PathClassLoader;


import org.lineageos.internal.buttons.LineageButtons;

import java.io.File;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileReader;
@@ -760,6 +762,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {


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


    private LineageButtons mLineageButtons;

    private final boolean mVisibleBackgroundUsersEnabled = isVisibleBackgroundUsersEnabled();
    private final boolean mVisibleBackgroundUsersEnabled = isVisibleBackgroundUsersEnabled();


    private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
    private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
@@ -5464,6 +5468,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    // {@link interceptKeyBeforeDispatching()}.
                    // {@link interceptKeyBeforeDispatching()}.
                    result |= ACTION_PASS_TO_USER;
                    result |= ACTION_PASS_TO_USER;
                } else if ((result & ACTION_PASS_TO_USER) == 0) {
                } 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
                    // If we aren't passing to the user and no one else
                    // handled it send it to the session manager to
                    // handled it send it to the session manager to
                    // figure out.
                    // figure out.
@@ -6725,6 +6733,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                mKeyguardDelegate.onBootCompleted();
                mKeyguardDelegate.onBootCompleted();
            }
            }
        }
        }
        mLineageButtons = new LineageButtons(mContext);
        mSideFpsEventHandler.onFingerprintSensorReady();
        mSideFpsEventHandler.onFingerprintSensorReady();
        startedWakingUp(Display.DEFAULT_DISPLAY_GROUP, PowerManager.WAKE_REASON_UNKNOWN);
        startedWakingUp(Display.DEFAULT_DISPLAY_GROUP, PowerManager.WAKE_REASON_UNKNOWN);
        finishedWakingUp(Display.DEFAULT_DISPLAY_GROUP, PowerManager.WAKE_REASON_UNKNOWN);
        finishedWakingUp(Display.DEFAULT_DISPLAY_GROUP, PowerManager.WAKE_REASON_UNKNOWN);