Merge "Add hasNavigationBar() to the window manager." into ics-mr0

This commit is contained in:
Daniel Sandler
2011-10-19 18:05:20 -07:00
committed by Android (Google) Code Review
8 changed files with 45 additions and 10 deletions

View File

@ -224,4 +224,9 @@ interface IWindowManager
* Block until the given window has been drawn to the screen. * Block until the given window has been drawn to the screen.
*/ */
void waitForWindowDrawn(IBinder token, in IRemoteCallback callback); void waitForWindowDrawn(IBinder token, in IRemoteCallback callback);
/**
* Device has a software navigation bar (separate from the status bar).
*/
boolean hasNavigationBar();
} }

View File

@ -292,8 +292,7 @@ public class ViewConfiguration {
if (!sHasPermanentMenuKeySet) { if (!sHasPermanentMenuKeySet) {
IWindowManager wm = Display.getWindowManager(); IWindowManager wm = Display.getWindowManager();
try { try {
sHasPermanentMenuKey = wm.canStatusBarHide() && !res.getBoolean( sHasPermanentMenuKey = wm.canStatusBarHide() && !wm.hasNavigationBar();
com.android.internal.R.bool.config_showNavigationBar);
sHasPermanentMenuKeySet = true; sHasPermanentMenuKeySet = true;
} catch (RemoteException ex) { } catch (RemoteException ex) {
sHasPermanentMenuKey = false; sHasPermanentMenuKey = false;

View File

@ -1009,6 +1009,11 @@ public interface WindowManagerPolicy {
*/ */
public int adjustSystemUiVisibilityLw(int visibility); 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. * Print the WindowManagerPolicy's state into the given stream.
* *

View File

@ -297,15 +297,15 @@ public class PhoneStatusBar extends StatusBar {
mStatusBarView = sb; mStatusBarView = sb;
try { try {
boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); boolean showNav = mWindowManager.hasNavigationBar();
if (showNav) { if (showNav) {
mNavigationBarView = mNavigationBarView =
(NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);
mNavigationBarView.setDisabledFlags(mDisabled); mNavigationBarView.setDisabledFlags(mDisabled);
} }
} catch (Resources.NotFoundException ex) { } catch (RemoteException ex) {
// no nav bar for you // no window manager? good luck with that
} }
// figure out which pixel-format to use for the status bar. // figure out which pixel-format to use for the status bar.

View File

@ -444,11 +444,14 @@ public class TabletStatusBar extends StatusBar implements
sb.setHandler(mHandler); sb.setHandler(mHandler);
// Sanity-check that someone hasn't set up the config wrong and asked for a navigation bar try {
// on a tablet that has only the system bar // Sanity-check that someone hasn't set up the config wrong and asked for a navigation
if (mContext.getResources().getBoolean( // bar on a tablet that has only the system bar
com.android.internal.R.bool.config_showNavigationBar)) { if (mWindowManager.hasNavigationBar()) {
throw new RuntimeException("Tablet device cannot show navigation bar and system bar"); throw new RuntimeException(
"Tablet device cannot show navigation bar and system bar");
}
} catch (RemoteException ex) {
} }
mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents); mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents);

View File

@ -823,6 +823,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHasNavigationBar = mContext.getResources().getBoolean( mHasNavigationBar = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_showNavigationBar); com.android.internal.R.bool.config_showNavigationBar);
// Allow a system property to override this. Used by the emulator.
// See also hasNavigationBar().
String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
if (! "".equals(navBarOverride)) {
if (navBarOverride.equals("1")) mHasNavigationBar = true;
else if (navBarOverride.equals("0")) mHasNavigationBar = false;
}
mNavigationBarHeight = mHasNavigationBar mNavigationBarHeight = mHasNavigationBar
? mContext.getResources().getDimensionPixelSize( ? mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_height) com.android.internal.R.dimen.navigation_bar_height)
@ -3725,6 +3733,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return diff; return diff;
} }
// Use this instead of checking config_showNavigationBar so that it can be consistently
// overridden by qemu.hw.mainkeys in the emulator.
public boolean hasNavigationBar() {
return mHasNavigationBar;
}
public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) {
pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);
pw.print(" mSystemReady="); pw.print(mSystemReady); pw.print(" mSystemReady="); pw.print(mSystemReady);

View File

@ -9263,6 +9263,11 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
@Override
public boolean hasNavigationBar() {
return mPolicy.hasNavigationBar();
}
void dumpInput(FileDescriptor fd, PrintWriter pw, boolean dumpAll) { void dumpInput(FileDescriptor fd, PrintWriter pw, boolean dumpAll) {
pw.println("WINDOW MANAGER INPUT (dumpsys window input)"); pw.println("WINDOW MANAGER INPUT (dumpsys window input)");
mInputManager.dump(pw); mInputManager.dump(pw);

View File

@ -467,4 +467,8 @@ public class BridgeWindowManager implements IWindowManager {
public void dismissKeyguard() { public void dismissKeyguard() {
} }
public boolean hasNavigationBar() {
return false; // should this return something else?
}
} }