We use the Home button on most Android phones, the return key and the menu key are all solid touch sensitive keys. If you use Google's NEXUS4 or Nexus5 words, you will find that they do not have physical keys or touch-sensitive buttons, instead of a small black bar at the bottom of the screen, there are 3 button controls on this black bar, this setting undoubtedly makes the appearance of the mobile phone design more minimalist. But I met a guy with a Nexus 4 cell phone. This design is simple: a good screen, a section of the area used to display 3 buttons (as shown): Back, Home, recent. And it has always been used there to occupy.
In the Android source code, that area is called Navigationbar. At the same time, Google in the code also reserved a flag to control its display and hide. Navigationbar display and hidden control is placed in the SYSTEMU, the specific path is: \frameworks\base\packages\systemui. For mobile phones above android4.0, Systemui consists of two parts: StatusBar and Navigationbar. In the Systemui project there is a class Phonestatusbar.java that can be found in this class about the control Navigationbar related code:
In the start () method, you can see that Navigationbar was added at that time, but just added, deciding whether it shows or hides is controlled at the back.
<span style= "FONT-SIZE:18PX;" > @Override public void Start () {Mdisplay = ((WindowManager) Mcontext.getsystemservice (Context.window_service) ). Getdefaultdisplay (); Updatedisplaysize (); M:support Smartbook Feature. if (Simhelper.ismediateksmartbooksupport ()) {//M: [ALPS01097705] Query the plug-in state as soon as possible . Misdisplaydevice = Simhelper.issmartbookpluggedin (Mcontext); LOG.V (TAG, "Start, misdisplaydevice=" + misdisplaydevice); } super.start (); Calls Createandaddwindows () Addnavigationbar (); Lastly, call to the icon policy to install/update all the icons. Miconpolicy = new Phonestatusbarpolicy (mcontext); Mheadsupobserver.onchange (TRUE); Set up if (enable_heads_up) {mcontext.getcontentresolver (). Registercontentobserver ( Settings.Global.getUriFor (SETTING_HEADS_UP), True, Mheadsupobserver); }}</span>
The Addnavigationbar () specific implementation method is as follows:
<span style= "FONT-SIZE:18PX;" >/For Small-screen devices (read:phones), that lack hardware navigation buttons private void Addnavigationbar () { if (DEBUG) slog.v (TAG, "addnavigationbar:about to add" + Mnavigationbarview); if (Mnavigationbarview = = null) return; Preparenavigationbarview (); Mwindowmanager.addview (Mnavigationbarview, Getnavigationbarlayoutparams ()); } </span>
you can see that Navigationbar actually adds a view to the window WindowManager. The parent Method Super.start () of Start () is called back before calling the Addnavigationbar () method to determine whether to add Navigationbar. In the call to the parent class method of Super.start (), Createandaddwindows () is called, which determines whether the display Navigationbar needs to be added and then decides whether to instantiate Navigationbarview.
<span style= "FONT-SIZE:18PX;" >try { Boolean shownav = Mwindowmanagerservice.hasnavigationbar (); if (DEBUG) slog.v (TAG, "hasnavigationbar=" + shownav); if (Shownav) { Mnavigationbarview = (Navigationbarview) view.inflate (context, r.layout.navigation_bar, NULL) ; Mnavigationbarview.setdisabledflags (mdisabled); Mnavigationbarview.setbar (this); } } catch (RemoteException ex) { //No window manager? Good luck with that }</span>
The Windowmanagerservice class implements the Windowmanagerpolicy interface, so Windowmanagerservice will callback Windowmanagerpolicy's Hasnavigationbar () Interface
<span style= "FONT-SIZE:18PX;" > @Override Public boolean Hasnavigationbar () { return Mpolicy.hasnavigationbar (); } </span>
The policy down call is actually called the Hasnavigationbar method of the Phonewindowmanager implementation, and the following code is the Hasnavigationbar () method in Phonewindowmanager.
<span style= "FONT-SIZE:18PX;" >//Use this instead of checking config_shownavigationbar so the It can be consistently //overridden by qemu.hw.m Ainkeys in the emulator. public Boolean Hasnavigationbar () { return mhasnavigationbar; } </span>
The Mhasnavigationbar assignment can be setinitialdisplaysize in Phonewindowmanager (display display, int width, int height, int density ) method found in the
<span Style= "FONT-SIZE:18PX;" > if (!mhassystemnavbar) {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; }} else {Mhasnavigationbar = false; }</span>
From the above code you can see that the setting of the value of Mhasnavigationbar is determined by two places:
1. First take the set value from the system's resource file Config_shownavigationbar, the set file path of this value is frameworks/base/core/res/res/values/config.xml
<!--Whether a software navigation bar should be shown. Note:in the autodetected from the Configuration.-- <bool name= "config_shownavigationb Ar ">false</bool>
2. The system then obtains the value of "Qemu.hw.mainkeys", which may overwrite the value of the Mhasnavigationbar obtained above. Ifif the value obtained by "Qemu.hw.mainkeys" is not NULL, it is set according to the following conditions, regardless of whether the value is true or false.
So the above two settings together determine the Navigationbar display and hide.
How to control the display and hiding of Navigationbar in Android system