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

Commit 10656747 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 693832f6
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -231,6 +231,7 @@ interface IWindowManager
     * Device has a software navigation bar (separate from the status bar).
     * Device has a software navigation bar (separate from the status bar).
     */
     */
    boolean hasNavigationBar();
    boolean hasNavigationBar();
    boolean hasPermanentMenuKey();


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


    /**
    /**
     * Specifies whether the device needs a navigation bar (because it has no hardware buttons)
     * Specifies whether the device needs a navigation bar (because it has no hardware buttons)
+22 −0
Original line number Original line Diff line number Diff line
@@ -610,6 +610,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12;
    private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12;
    boolean mWifiDisplayConnected = false;
    boolean mWifiDisplayConnected = false;
    int     mWifiDisplayCustomRotation = -1;
    int     mWifiDisplayCustomRotation = -1;
    private boolean mHasPermanentMenuKey;


    private class PolicyHandler extends Handler {
    private class PolicyHandler extends Handler {
        @Override
        @Override
@@ -1427,6 +1428,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mDoubleTapOnHomeBehavior = KEY_ACTION_NOTHING;
            mDoubleTapOnHomeBehavior = KEY_ACTION_NOTHING;
        }
        }


        boolean hasPermanentMenu = false;

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

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

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

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

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

        mHasPermanentMenuKey = hasPermanentMenu;
    }
    }


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


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

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


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

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