Shield android4.0.3 Status Bar

Source: Internet
Author: User

Android4.0
Status Bar startup

The android4.0 system can run on tablets and mobile phones. In this way, the status bar also has different styles. I can see from the systemui code classification, google considers the display of the status bar under different circumstances,

Note the following two folders in the source code:

Com. Android. systemui. statusbar. Phone
This is the status bar for mobile phones.

Com. Android. systemui. statusbar. Tablet
This is the status bar (System
Bar)

First, how does the status bar start up?

We all know that when the system is started, various services of the system will be loaded on systemserver, And the status bar is no exception. It is created at this time. The Code is as follows:

Path: androidx86/framework/base/services/Java/COM/Android/Server/systemserver. Java

 

 

Systemserver. Java

Activitymanagerservice. Self (). systemready (New runnable (){
Public void run (){
Slog. I (TAG, "making services ready ");

Startsystemui (contextf );
Try {
If (batteryf! = NULL) batteryf. systemready ();
} Catch (throwable e ){
Reportwtf ("making battery service ready", e );
}

 

Static final void
Startsystemui (context ){
Intent intent = new intent ();
Intent. setcomponent (New componentname ("com. Android. systemui ",
"Com. Android. systemui. systemuiservice "));
Slog. D (TAG, "starting service:" + intent );
Context. startservice (intent );
}

 

Through the above code, I can see that the system has started com. Android. systemui. systemuiservice
This service will start the status bar in this service,

However, there will be an option here, which is to start the status bar.
Or start the system bar, Android decides this:

Path: androidx86/framework/base/packages/systemui. Java

Public void oncreate (){
// Pick status bar or system bar.
Iwindowmanager WM = iwindowmanager. stub. asinterface (
Servicemanager. getservice (context. window_service ));
Try {
Services [0] = WM. canstatusbarhide () (1)
? R. String. config_statusbarcomponent (2)
: R. String. config_systembarcomponent; (3)
} Catch (RemoteException e ){
Slog. W (TAG, "failing checking whether status bar can hide", e );
}

Final int n = services. length;
Mservices = new systemui [N];
For (INT I = 0; I <n; I ++ ){
Class Cl = chooseclass (services [I]);
Slog. D (TAG, "loading:" + Cl );
Try {
Mservices [I] = (systemui) Cl. newinstance ();
} Catch (illegalaccessexception ex ){
Throw new runtimeexception (Ex );
} Catch (instantiationexception ex ){
Throw new runtimeexception (Ex );
}
Mservices [I]. mcontext = this;
Slog. D (TAG, "running:" + mservices [I]);
Mservices [I]. Start ();
}
}

 

This start method is available in androidx86/framework/base/packages/systemui/statusbar. Java

In the start method, various views corresponding to the status bar interfaces will be created, including the view after the drop-down status bar. After these views are created, load the view into windowmanager, And the status bar will be displayed. The Code is as follows:

Final windowmanager. layoutparams Lp = new windowmanager. layoutparams (
Viewgroup. layoutparams. match_parent,
Height,
Windowmanager. layoutparams. type_status_bar,
Windowmanager. layoutparams. flag_not_focusable
| Windowmanager. layoutparams. flag_touchable_when_waking
| Windowmanager. layoutparams. flag_split_touch,
Pixelformat. opaque );

// The Status Bar shocould be in an overlay if possible
Final display defaultdisplay
= (Windowmanager) mcontext. getsystemservice (context. window_service ))
. Getdefadisplay display ();
If (activitymanager. ishighendgfx (defaultdisplay )){
LP. Flags | = windowmanager. layoutparams. flag_hardware_accelerated;
}

LP. Gravity = getstatusbargravity ();
LP. settitle ("statusbar ");
LP. packagename = mcontext. getpackagename ();
LP. windowanimations = R. style. animation_statusbar;
Windowmanagerimpl. getdefault (). addview (SB, LP); // Sb is the status bar view.

Because we want to block the status bar, we can block this sentence.

OK !!! Solve the problem!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.