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

Commit e1d33db8 authored by Martin Brabham's avatar Martin Brabham Committed by Matt Garnes
Browse files

Android Policy: home answer call

Change-Id: I8a9856378fd3093284e9aae5badbbbb66ed36b63

Android Policy: power end call

Change-Id: I04c1232000982b9f2a4021bcd16c55c5b871c17c
parent ced59f59
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -2834,6 +2834,22 @@ public final class Settings {
         */
        public static final String DIALER_OPENCNAM_AUTH_TOKEN = "dialer_opencnam_auth_token";

        /**
         * Whether to answer an incoming call using the home button or not
         *
         * @hide
         */
        public static final String KEY_HOME_ANSWER_RINGING_CALL = "key_home_answer_ringing_call";

        /**
         * End the call with power key (Default is 0)
         * 0 - No
         * 1 - Yes
         *
         * @hide
         */
        public static final String KEY_POWER_END_CALL = "key_power_end_call";

        /**
         * Action to perform when the home key is long-pressed.
         * (Default can be configured via config_longPressOnHomeBehavior)
+33 −2
Original line number Diff line number Diff line
@@ -491,6 +491,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mHomePressed;
    boolean mHomeConsumed;
    boolean mHomeDoubleTapPending;
    boolean mHomeAnswerWhenRinging;
    boolean mMenuPressed;
    boolean mAppSwitchLongPressed;
    Intent mHomeIntent;
@@ -548,6 +549,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private boolean mVolumeDownKeyConsumedByScreenshotChord;
    private boolean mVolumeUpKeyTriggered;
    private boolean mPowerKeyTriggered;
    private boolean mPowerKeyEndCall;
    private long mVolumeUpKeyTime;
    private boolean mVolumeUpKeyConsumedByScreenshotChord;
    private long mPowerKeyTime;
@@ -703,6 +705,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.VOLUME_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.KEY_HOME_ANSWER_RINGING_CALL), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.KEY_POWER_END_CALL), false, this,
                    UserHandle.USER_ALL);
            updateSettings();
        }

@@ -1507,6 +1515,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mVolumeWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.VOLUME_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1);

            // Home answer call
            mHomeAnswerWhenRinging = (Settings.System.getIntForUser(resolver,
                    Settings.System.KEY_HOME_ANSWER_RINGING_CALL, 0, UserHandle.USER_CURRENT) == 1);

            // End call with power key
            mPowerKeyEndCall = (Settings.System.getIntForUser(resolver,
                    Settings.System.KEY_POWER_END_CALL, 0, UserHandle.USER_CURRENT) == 1);

            PolicyControl.reloadFromSetting(mContext);
        }
        if (updateRotation) {
@@ -2363,6 +2379,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    + " canceled=" + canceled);
        }

        if (keyCode == KeyEvent.KEYCODE_POWER) {
            if (mPowerKeyEndCall) {
                TelecomManager telecomManager = getTelecommService();
                if (telecomManager != null && telecomManager.isInCall()) {
                    telecomManager.endCall();
                }
            }
        }

        // If we think we might have a volume down & power key chord on the way
        // but we're not sure, then tell the dispatcher to wait a little while and
        // try again later before dispatching.
@@ -2432,7 +2457,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                // and his ONLY options are to answer or reject the call.)
                TelecomManager telecomManager = getTelecommService();
                if (telecomManager != null && telecomManager.isRinging()) {
                    if (mHomeAnswerWhenRinging) {
                        Log.i(TAG, "Answering call with HOME; there's a ringing incoming call.");
                        telecomManager.acceptRingingCall();
                    } else {
                        Log.i(TAG, "Ignoring HOME; there's a ringing incoming call.");
                    }
                    return -1;
                }

@@ -6452,6 +6482,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive);
        pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior);
                pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior);
                pw.print(" mHomeAnswerWhenRinging="); pw.print(mHomeAnswerWhenRinging);
                pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior);
        pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation);
                pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation);