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

Commit d1e3a1bc authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "Fix ordering of home keypress handling" into cm-10.2

parents 8039d6b2 c971f221
Loading
Loading
Loading
Loading
+26 −29
Original line number Diff line number Diff line
@@ -2341,44 +2341,39 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // If we have released the home key, and didn't do anything else
            // while it was pressed, then it is time to go home!
            if (!down && mHomePressed) {
                final boolean homeWasLongPressed = mHomeLongPressed;
                mHomeLongPressed = false;
                if (mRecentAppsPreloaded) {
                    cancelPreloadRecentApps();
                }
                mHomePressed = false;
                if (mHomeConsumed) {
                    mHomeConsumed = false;
                    return -1;
                }

                if (!homeWasLongPressed) {
                    if (mRecentAppsPreloaded) {
                        cancelPreloadRecentApps();
                if (canceled) {
                    Log.i(TAG, "Ignoring HOME; event canceled.");
                    return -1;
                }
                    mHomePressed = false;
                    if (!canceled) {
                        boolean incomingRinging = false;

                // If an incoming call is ringing, HOME is totally disabled.
                // (The user is already on the InCallScreen at this point,
                // and his ONLY options are to answer or reject the call.)
                try {
                    ITelephony telephonyService = getTelephonyService();
                            if (telephonyService != null) {
                                incomingRinging = telephonyService.isRinging();
                            }
                            if (incomingRinging) {
                    if (telephonyService != null && telephonyService.isRinging()) {
                        if ((mRingHomeBehavior
                                     & Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_ANSWER) != 0) {
                            Log.i(TAG, "Answering with HOME button.");
                            telephonyService.answerRingingCall();
                            return -1;
                        } else {
                            Log.i(TAG, "Ignoring HOME; there's a ringing incoming call.");
                            return -1;
                        }
                            } else {
                                launchHomeFromHotKey();
                    }
                } catch (RemoteException ex) {
                    Log.w(TAG, "RemoteException from getPhoneInterface()", ex);
                }
                    } else {
                        Log.i(TAG, "Ignoring HOME; event canceled.");
                    }
                }

                // Delay handling home if a double-tap is possible.
                if (mDoubleTapOnHomeBehavior != KEY_ACTION_NOTHING) {
@@ -2389,6 +2384,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    return -1;
                }

                // Go home!
                launchHomeFromHotKey();
                return -1;
            }