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

Commit 7d4f59cb authored by Oleksandr Byelkin's avatar Oleksandr Byelkin Committed by Gerrit Code Review
Browse files

Adds ability to answer call with hardware HOME button (preparation to winter time)

Change-Id: I5d10da25360067dd443ffc83ec408e0b3001ad6b
parent 5852c191
Loading
Loading
Loading
Loading
+30 −0
Original line number Original line Diff line number Diff line
@@ -4959,6 +4959,36 @@ public final class Settings {
        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;


        /**
         * What happens when the user presses the Home button when the
         * phone is ringing.<br/>
         * <b>Values:</b><br/>
         * 1 - Nothing happens. (Default behavior)<br/>
         * 2 - The Home button answer the current call.<br/>
         *
         * @hide
         */
        public static final String RING_HOME_BUTTON_BEHAVIOR = "ring_home_button_behavior";

        /**
         * RING_HOME_BUTTON_BEHAVIOR value for "do nothing".
         * @hide
         */
        public static final int RING_HOME_BUTTON_BEHAVIOR_DO_NOTHING = 0x1;

        /**
         * RING_HOME_BUTTON_BEHAVIOR value for "answer".
         * @hide
         */
        public static final int RING_HOME_BUTTON_BEHAVIOR_ANSWER = 0x2;

        /**
         * RING_HOME_BUTTON_BEHAVIOR default value.
         * @hide
         */
        public static final int RING_HOME_BUTTON_BEHAVIOR_DEFAULT =
                RING_HOME_BUTTON_BEHAVIOR_DO_NOTHING;

        /**
        /**
         * The current night mode that has been selected by the user.  Owned
         * The current night mode that has been selected by the user.  Owned
         * and controlled by UiModeManagerService.  Constants are as per
         * and controlled by UiModeManagerService.  Constants are as per
+14 −0
Original line number Original line Diff line number Diff line
@@ -558,6 +558,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {


    Display mDisplay;
    Display mDisplay;


    // Behavior of HOME button during incomming call ring.
    // (See Settings.Secure.RING_HOME_BUTTON_BEHAVIOR.)
    int mRingHomeBehavior;

    int mLandscapeRotation = 0;  // default landscape rotation
    int mLandscapeRotation = 0;  // default landscape rotation
    int mSeascapeRotation = 0;   // "other" landscape rotation, 180 degrees from mLandscapeRotation
    int mSeascapeRotation = 0;   // "other" landscape rotation, 180 degrees from mLandscapeRotation
    int mPortraitRotation = 0;   // default portrait rotation
    int mPortraitRotation = 0;   // default portrait rotation
@@ -1353,6 +1357,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mIncallPowerBehavior = Settings.Secure.getInt(resolver,
            mIncallPowerBehavior = Settings.Secure.getInt(resolver,
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
            mRingHomeBehavior = Settings.Secure.getInt(resolver,
                    Settings.Secure.RING_HOME_BUTTON_BEHAVIOR,
                    Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_DEFAULT);
            mVolumeWakeScreen = (Settings.System.getInt(resolver,
            mVolumeWakeScreen = (Settings.System.getInt(resolver,
                    Settings.System.VOLUME_WAKE_SCREEN, 0) == 1);
                    Settings.System.VOLUME_WAKE_SCREEN, 0) == 1);
            mVolBtnMusicControls = (Settings.System.getInt(resolver,
            mVolBtnMusicControls = (Settings.System.getInt(resolver,
@@ -2129,6 +2136,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            if (telephonyService != null) {
                            if (telephonyService != null) {
                                incomingRinging = telephonyService.isRinging();
                                incomingRinging = telephonyService.isRinging();
                            }
                            }
                            if ((mRingHomeBehavior
                                 & Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_ANSWER) != 0
                                 && incomingRinging) {
                               Log.i(TAG, "Answering with HOME button.");
                               telephonyService.answerRingingCall();
                            }
                        } catch (RemoteException ex) {
                        } catch (RemoteException ex) {
                            Log.w(TAG, "RemoteException from getPhoneInterface()", ex);
                            Log.w(TAG, "RemoteException from getPhoneInterface()", ex);
                        }
                        }
@@ -4980,6 +4993,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive);
                pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive);
        pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior);
        pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior);
                pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior);
                pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior);
                pw.print(" mRingHomeBehavior="); pw.print(mRingHomeBehavior);
                pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior);
                pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior);
        pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation);
        pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation);
                pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation);
                pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation);