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

Commit 8296b8ae authored by Oleksandr Byelkin's avatar Oleksandr Byelkin Committed by Bruno Martins
Browse files

PhoneWindowManager: Implement press home to answer call

Change-Id: I7662b593f5ba52cafe3d7ba7cf2099b29b8d308b
parent 997fe2e6
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -578,6 +578,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    DisplayRotation mDefaultDisplayRotation;
    DisplayPolicy mDefaultDisplayPolicy;

    // Behavior of HOME button during an incoming call.
    // (See LineageSettings.Secure.RING_HOME_BUTTON_BEHAVIOR.)
    int mRingHomeBehavior;

    // Allowed theater mode wake actions
    private boolean mAllowTheaterModeWakeFromKey;
    private boolean mAllowTheaterModeWakeFromPowerKey;
@@ -805,6 +809,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(LineageSettings.Secure.getUriFor(
                    LineageSettings.Secure.RING_HOME_BUTTON_BEHAVIOR), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.WAKE_GESTURE_ENABLED), false, this,
                    UserHandle.USER_ALL);
@@ -1806,6 +1813,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    return -1;
                }

                if ((mRingHomeBehavior
                        & LineageSettings.Secure.RING_HOME_BUTTON_BEHAVIOR_ANSWER) != 0) {
                    final TelecomManager telecomManager = getTelecommService();
                    if (telecomManager != null && telecomManager.isRinging()) {
                        telecomManager.acceptRingingCall();
                        return -1;
                    }
                }

                // Delay handling home if a double-tap is possible.
                if (mHomeDoubleTapAction != Action.NOTHING) {
                    mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case
@@ -2275,6 +2291,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR,
                    Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT,
                    UserHandle.USER_CURRENT);
            mRingHomeBehavior = LineageSettings.Secure.getIntForUser(resolver,
                    LineageSettings.Secure.RING_HOME_BUTTON_BEHAVIOR,
                    LineageSettings.Secure.RING_HOME_BUTTON_BEHAVIOR_DEFAULT,
                    UserHandle.USER_CURRENT);
            mSystemNavigationKeysEnabled = Settings.Secure.getIntForUser(resolver,
                    Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED,
                    0, UserHandle.USER_CURRENT) == 1;