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.
*/
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) {
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;

View File

@ -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.
*

View File

@ -297,15 +297,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.

View File

@ -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);

View File

@ -823,6 +823,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHasNavigationBar = mContext.getResources().getBoolean(
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
? mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_height)
@ -3725,6 +3733,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
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) {
pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);
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) {
pw.println("WINDOW MANAGER INPUT (dumpsys window input)");
mInputManager.dump(pw);

View File

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