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

Commit 0c4ccff3 authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Add hasNavigationBar() to the window manager.

It is no longer sufficient to check the value of
internal.R.bool.config_showNavigationBar to determine if a
navigation bar (separate from the status bar) is shown on a
device, because the emulator needs to be able to override
this value (now possible by setting qemu.hw.mainkeys to "1"
or "0", for navbar or no navbar, respectively).

This logic is now contained in PhoneWindowManager, and any
clients wishing to know whether the system has a software
nav bar should consult the new hasNavigationBar() method.

Bug: 5404945
Change-Id: I119d32a8c84b88b2ef46f63244e7f11dc5de0359
parent 70ac412b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -224,4 +224,9 @@ interface IWindowManager
     * Block until the given window has been drawn to the screen.
     */
    void waitForWindowDrawn(IBinder token, in IRemoteCallback callback);

    /**
     * Device has a software navigation bar (separate from the status bar).
     */
    boolean hasNavigationBar();
}
+1 −2
Original line number Diff line number Diff line
@@ -292,8 +292,7 @@ public class ViewConfiguration {
        if (!sHasPermanentMenuKeySet) {
            IWindowManager wm = Display.getWindowManager();
            try {
                sHasPermanentMenuKey = wm.canStatusBarHide() && !res.getBoolean(
                        com.android.internal.R.bool.config_showNavigationBar);
                sHasPermanentMenuKey = wm.canStatusBarHide() && !wm.hasNavigationBar();
                sHasPermanentMenuKeySet = true;
            } catch (RemoteException ex) {
                sHasPermanentMenuKey = false;
+5 −0
Original line number Diff line number Diff line
@@ -1009,6 +1009,11 @@ public interface WindowManagerPolicy {
     */
    public int adjustSystemUiVisibilityLw(int visibility);

    /**
     * Specifies whether there is an on-screen navigation bar separate from the status bar.
     */
    public boolean hasNavigationBar();

    /**
     * Print the WindowManagerPolicy's state into the given stream.
     *
+3 −3
Original line number Diff line number Diff line
@@ -295,15 +295,15 @@ public class PhoneStatusBar extends StatusBar {
        mStatusBarView = sb;

        try {
            boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
            boolean showNav = mWindowManager.hasNavigationBar();
            if (showNav) {
                mNavigationBarView = 
                    (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);

                mNavigationBarView.setDisabledFlags(mDisabled);
            }
        } catch (Resources.NotFoundException ex) {
            // no nav bar for you
        } catch (RemoteException ex) {
            // no window manager? good luck with that
        }

        // figure out which pixel-format to use for the status bar.
+8 −5
Original line number Diff line number Diff line
@@ -444,11 +444,14 @@ public class TabletStatusBar extends StatusBar implements

        sb.setHandler(mHandler);

        // Sanity-check that someone hasn't set up the config wrong and asked for a navigation bar
        // on a tablet that has only the system bar
        if (mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_showNavigationBar)) {
            throw new RuntimeException("Tablet device cannot show navigation bar and system bar");
        try {
            // Sanity-check that someone hasn't set up the config wrong and asked for a navigation
            // bar on a tablet that has only the system bar
            if (mWindowManager.hasNavigationBar()) {
                throw new RuntimeException(
                        "Tablet device cannot show navigation bar and system bar");
            }
        } catch (RemoteException ex) {
        }

        mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents);
Loading