Skip to content

Commit 84e825a

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Add hasNavigationBar() to the window manager." into ics-mr0
2 parents 62ade22 + 0c4ccff commit 84e825a

File tree

8 files changed

+45
-10
lines changed

8 files changed

+45
-10
lines changed

core/java/android/view/IWindowManager.aidl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,9 @@ interface IWindowManager
224224
* Block until the given window has been drawn to the screen.
225225
*/
226226
void waitForWindowDrawn(IBinder token, in IRemoteCallback callback);
227+
228+
/**
229+
* Device has a software navigation bar (separate from the status bar).
230+
*/
231+
boolean hasNavigationBar();
227232
}

core/java/android/view/ViewConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ private ViewConfiguration(Context context) {
292292
if (!sHasPermanentMenuKeySet) {
293293
IWindowManager wm = Display.getWindowManager();
294294
try {
295-
sHasPermanentMenuKey = wm.canStatusBarHide() && !res.getBoolean(
296-
com.android.internal.R.bool.config_showNavigationBar);
295+
sHasPermanentMenuKey = wm.canStatusBarHide() && !wm.hasNavigationBar();
297296
sHasPermanentMenuKeySet = true;
298297
} catch (RemoteException ex) {
299298
sHasPermanentMenuKey = false;

core/java/android/view/WindowManagerPolicy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,11 @@ interface OnKeyguardExitResult {
10091009
*/
10101010
public int adjustSystemUiVisibilityLw(int visibility);
10111011

1012+
/**
1013+
* Specifies whether there is an on-screen navigation bar separate from the status bar.
1014+
*/
1015+
public boolean hasNavigationBar();
1016+
10121017
/**
10131018
* Print the WindowManagerPolicy's state into the given stream.
10141019
*

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ protected View makeStatusBarView() {
297297
mStatusBarView = sb;
298298

299299
try {
300-
boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
300+
boolean showNav = mWindowManager.hasNavigationBar();
301301
if (showNav) {
302302
mNavigationBarView =
303303
(NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);
304304

305305
mNavigationBarView.setDisabledFlags(mDisabled);
306306
}
307-
} catch (Resources.NotFoundException ex) {
308-
// no nav bar for you
307+
} catch (RemoteException ex) {
308+
// no window manager? good luck with that
309309
}
310310

311311
// figure out which pixel-format to use for the status bar.

packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,14 @@ protected View makeStatusBarView() {
444444

445445
sb.setHandler(mHandler);
446446

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

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

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,14 @@ public void setInitialDisplaySize(int width, int height) {
823823

824824
mHasNavigationBar = mContext.getResources().getBoolean(
825825
com.android.internal.R.bool.config_showNavigationBar);
826+
// Allow a system property to override this. Used by the emulator.
827+
// See also hasNavigationBar().
828+
String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
829+
if (! "".equals(navBarOverride)) {
830+
if (navBarOverride.equals("1")) mHasNavigationBar = true;
831+
else if (navBarOverride.equals("0")) mHasNavigationBar = false;
832+
}
833+
826834
mNavigationBarHeight = mHasNavigationBar
827835
? mContext.getResources().getDimensionPixelSize(
828836
com.android.internal.R.dimen.navigation_bar_height)
@@ -3725,6 +3733,12 @@ public void run() {
37253733
return diff;
37263734
}
37273735

3736+
// Use this instead of checking config_showNavigationBar so that it can be consistently
3737+
// overridden by qemu.hw.mainkeys in the emulator.
3738+
public boolean hasNavigationBar() {
3739+
return mHasNavigationBar;
3740+
}
3741+
37283742
public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) {
37293743
pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);
37303744
pw.print(" mSystemReady="); pw.print(mSystemReady);

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9263,6 +9263,11 @@ boolean removeFakeWindowLocked(FakeWindow window) {
92639263
}
92649264
}
92659265

9266+
@Override
9267+
public boolean hasNavigationBar() {
9268+
return mPolicy.hasNavigationBar();
9269+
}
9270+
92669271
void dumpInput(FileDescriptor fd, PrintWriter pw, boolean dumpAll) {
92679272
pw.println("WINDOW MANAGER INPUT (dumpsys window input)");
92689273
mInputManager.dump(pw);

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,8 @@ public int getPreferredOptionsPanelGravity() throws RemoteException {
467467

468468
public void dismissKeyguard() {
469469
}
470+
471+
public boolean hasNavigationBar() {
472+
return false; // should this return something else?
473+
}
470474
}

0 commit comments

Comments
 (0)