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

Commit 848ae4a3 authored by Kyrylo Mikos's avatar Kyrylo Mikos Committed by Steve Kondik
Browse files

frameworks/base: Don't report existing menu key if it was remapped.

Change-Id: Iabad06cd42cebecdff6f0440899432513681b063
parent 7bf64fc7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ interface IWindowManager
     * Device has a software navigation bar (separate from the status bar).
     */
    boolean hasNavigationBar();
    boolean hasPermanentMenuKey();

    /**
     * Device needs a software navigation bar (because it has no hardware keys).
+1 −1
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ public class ViewConfiguration {
                case HAS_PERMANENT_MENU_KEY_AUTODETECT: {
                    IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
                    try {
                        sHasPermanentMenuKey = !wm.hasNavigationBar();
                        sHasPermanentMenuKey = wm.hasPermanentMenuKey();
                        sHasPermanentMenuKeySet = true;
                    } catch (RemoteException ex) {
                        sHasPermanentMenuKey = false;
+1 −0
Original line number Diff line number Diff line
@@ -1237,6 +1237,7 @@ public interface WindowManagerPolicy {
     * Specifies whether there is an on-screen navigation bar separate from the status bar.
     */
    public boolean hasNavigationBar();
    public boolean hasPermanentMenuKey();

    /**
     * Specifies whether the device needs a navigation bar (because it has no hardware buttons)
+23 −0
Original line number Diff line number Diff line
@@ -694,6 +694,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mWifiDisplayConnected = false;
    int mWifiDisplayCustomRotation = -1;

    private boolean mHasPermanentMenuKey;

    private class PolicyHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
@@ -1733,6 +1735,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mDoubleTapOnHomeBehavior = KEY_ACTION_NOTHING;
        }

        boolean hasPermanentMenu = false;

        // Check for custom assignments and whether KEY_ACTION_MENU is assigned.
        if (hasHome) {
            mLongPressOnHomeBehavior = Settings.System.getIntForUser(resolver,
@@ -1741,6 +1745,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mDoubleTapOnHomeBehavior = Settings.System.getIntForUser(resolver,
                    Settings.System.KEY_HOME_DOUBLE_TAP_ACTION,
                    mDoubleTapOnHomeBehavior, UserHandle.USER_CURRENT);

            hasPermanentMenu = mLongPressOnHomeBehavior == KEY_ACTION_MENU
                    || mDoubleTapOnHomeBehavior == KEY_ACTION_MENU;
        }
        if (hasMenu) {
            mPressOnMenuBehavior = Settings.System.getIntForUser(resolver,
@@ -1749,6 +1756,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mLongPressOnMenuBehavior = Settings.System.getIntForUser(resolver,
                    Settings.System.KEY_MENU_LONG_PRESS_ACTION,
                    mLongPressOnMenuBehavior, UserHandle.USER_CURRENT);

            hasPermanentMenu |= mPressOnMenuBehavior == KEY_ACTION_MENU
                    || mLongPressOnMenuBehavior == KEY_ACTION_MENU;
        }
        if (hasAssist) {
            mPressOnAssistBehavior = Settings.System.getIntForUser(resolver,
@@ -1757,6 +1767,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mLongPressOnAssistBehavior = Settings.System.getIntForUser(resolver,
                    Settings.System.KEY_ASSIST_LONG_PRESS_ACTION,
                    mLongPressOnAssistBehavior, UserHandle.USER_CURRENT);

            hasPermanentMenu |= mPressOnAssistBehavior == KEY_ACTION_MENU
                    || mLongPressOnAssistBehavior == KEY_ACTION_MENU;
        }
        if (hasAppSwitch) {
            mPressOnAppSwitchBehavior = Settings.System.getIntForUser(resolver,
@@ -1765,7 +1778,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mLongPressOnAppSwitchBehavior = Settings.System.getIntForUser(resolver,
                    Settings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION,
                    mLongPressOnAppSwitchBehavior, UserHandle.USER_CURRENT);

            hasPermanentMenu |= mPressOnAppSwitchBehavior == KEY_ACTION_MENU
                    || mLongPressOnAppSwitchBehavior == KEY_ACTION_MENU;
        }

        mHasPermanentMenuKey = hasPermanentMenu;
    }

    @Override
@@ -7099,6 +7117,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return mHasNavigationBar || mDevForceNavbar;
    }

    @Override
    public boolean hasPermanentMenuKey() {
        return !hasNavigationBar() && mHasPermanentMenuKey;
    }

    public boolean needsNavigationBar() {
        return mHasNavigationBar;
    }
+5 −0
Original line number Diff line number Diff line
@@ -11096,6 +11096,11 @@ public class WindowManagerService extends IWindowManager.Stub
        return mPolicy.hasNavigationBar();
    }

    @Override
    public boolean hasPermanentMenuKey() {
        return mPolicy.hasPermanentMenuKey();
    }

    @Override 
    public boolean needsNavigationBar() {
        return mPolicy.needsNavigationBar();