トラッキング コード

1/29/2012

NavigationBar / Virtual buttons in the System Bar

NavigationBar

NavigationBar is Virtual buttons in the System Bar.




Implement of NavigationBar

NavigationBar has been implemented as part of SystemUI / StatusBar.
Show PhoneStatusBar.java.

\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone
- PhoneStatusBar.java

try {
            boolean showNav = mWindowManager.hasNavigationBar();
            if (showNav) {
                mNavigationBarView =
                    (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);

                mNavigationBarView.setDisabledFlags(mDisabled);
            }
        } catch (RemoteException ex) {
            // no window manager? good luck with that
        }

It is just View!!

Layout file is
\frameworks\base\packages\SystemUI\res\layout
- navigation_bar.xml



Case of Tablet devices.

\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\tablet
- TabletStatusBar.java

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) {
        }

If Tablet devices has NavigationBar,occurs RuntimeException!!
Tablet devices do not implement NavigationBar.


NavigationBar is enable or Diseble ?

Show PhoneWindowManager#setInitialDisplaySize().


// Determine whether the status bar can hide based on the size
        // of the screen.  We assume sizes > 600dp are tablets where we
        // will use the system bar.
        int shortSizeDp = shortSize
                * DisplayMetrics.DENSITY_DEFAULT
                / DisplayMetrics.DENSITY_DEVICE;
        mStatusBarCanHide = shortSizeDp < 600;
        mStatusBarHeight = mContext.getResources().getDimensionPixelSize(
                mStatusBarCanHide
                ? com.android.internal.R.dimen.status_bar_height
                : com.android.internal.R.dimen.system_bar_height);

        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 = false;
            else if (navBarOverride.equals("0")) mHasNavigationBar = true;
        }
To see the value of com.android.internal.R.bool.config_showNavigationBar.
It is defined in following xml

 \frameworks\base\core\res\res\values - config.xml


<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
         autodetected from the Configuration. -->
    <bool name="config_showNavigationBar">false</bool>


Standard ICS is not shown as a NavigationBar.So, Check of device folder.

\device\samsung\tuna\overlay\frameworks\base\core\res\res\values
- config.xml
This value Will be displayed on GalaxyNexus.


Key Event of NavigationBar

If Buttom of home/back is touched, send inputEvent from Java Layer to Native Layer.
KeyButtonView#sendEvent
 - WindowManagerService#injectInputEventNoWait
   - InputManager#injectInputEvent
     - InputManager#nativeInjectInputEvent
       - android_server_InputManager_nativeInjectInputEvent
       - InputDispatcher#injectInputEvent




No comments:

Post a Comment