当前位置:首页 » Android开发技术

Android 5.1 SystemUi 之 StatusBar的简单分析

2015-09-10 20:52 本站整理 浏览(3926)

最近被这个StatusBar搞的烦死了,各种要求改,咱求人不如求己,但是呢,我也是baidu了一把,毕竟有一句话说的很对,我们往往是站在巨人的JJ上,这名话很值得回味,

不扯了

我参考的博客是博客参考,但是,但是,我个人不会搞这么优秀的图,只能叹息一声,巨人的

JJ也是有高度的~SystemServer.java启动SystemUIService

[code]staticfinalvoidstartSystemUi(Contextcontext){
Intentintent=newIntent();
intent.setComponent(newComponentName("com.android.systemui",
"com.android.systemui.SystemUIService"));
//Slog.d(TAG,"Startingservice:"+intent);
context.startServiceAsUser(intent,UserHandle.OWNER);
}
[/code]SystemUIService.java

[code]publicvoidonCreate(){
super.onCreate();
((SystemUIApplication)getApplication()).startServicesIfNeeded();
}
[/code]SystemUIApplication.java

mServices[i].start()启动了各种Service,但是它们并不是真正的Service,继承了SystemUI.java这个抽象类,复写了start()方法

[code]privatefinalClass<?>[]SERVICES=newClass[]{
com.android.systemui.keyguard.KeyguardViewMediator.class,
com.android.systemui.recent.Recents.class,
com.android.systemui.volume.VolumeUI.class,
com.android.systemui.statusbar.SystemBars.class,
com.android.systemui.usb.StorageNotification.class,
com.android.systemui.power.PowerUI.class,
com.android.systemui.media.RingtonePlayer.class
};
publicvoidstartServicesIfNeeded(){
if(mServicesStarted){
return;
}
if(!mBootCompleted){
//checktoseeifmaybeitwasalreadycompletedlongbeforewebegan
//seeActivityManagerService.finishBooting()
if("1".equals(SystemProperties.get("sys.boot_completed"))){
mBootCompleted=true;
if(DEBUG)Log.v(TAG,"BOOT_COMPLETEDwasalreadysent");
}
}
Log.v(TAG,"StartingSystemUIservices.");
finalintN=SERVICES.length;
for(inti=0;i<N;i++){
Class<?>cl=SERVICES[i];
if(DEBUG)Log.d(TAG,"loading:"+cl);
try{
mServices[i]=(SystemUI)cl.newInstance();
}catch(IllegalAccessExceptionex){
thrownewRuntimeException(ex);
}catch(InstantiationExceptionex){
thrownewRuntimeException(ex);
}
mServices[i].mContext=this;
mServices[i].mComponents=mComponents;
if(DEBUG)Log.d(TAG,"running:"+mServices[i]);
//调用所有的service的start方法
mServices[i].start();
//手机启动完成后,完成的事
if(mBootCompleted){
mServices[i].onBootCompleted();
}
}
mServicesStarted=true;
}
[/code]因为我现在要分析statusbar,所以关注SystemBar.java的start()方法

[code]@Override
publicvoidstart(){
if(DEBUG)Log.d(TAG,"start");
//ServiceMonitor是个监听器,这里就是监听这个BAR_SERVICE_COMPONENT是否改变
mServiceMonitor=newServiceMonitor(TAG,DEBUG,
mContext,Settings.Secure.BAR_SERVICE_COMPONENT,this);
//这里看到注释,如果Service不存在,就调用onNoService->createStatusBarFromConfig();
mServiceMonitor.start();//willcallonNoServiceifnoremoteserviceisfound
}
[/code]ServiceMonitor.java

[code]publicServiceMonitor(StringownerTag,booleandebug,
Contextcontext,StringsettingKey,Callbackscallbacks){
mTag=ownerTag+".ServiceMonitor";
mDebug=debug;
mContext=context;
mSettingKey=settingKey;
mCallbacks=callbacks;
}
publicvoidstart(){
//listenforsettingchanges
ContentResolvercr=mContext.getContentResolver();
cr.registerContentObserver(Settings.Secure.getUriFor(mSettingKey),
false/*notifyForDescendents*/,mSettingObserver,UserHandle.USER_ALL);
//listenforpackage/componentchanges
IntentFilterfilter=newIntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
mContext.registerReceiver(mBroadcastReceiver,filter);
mHandler.sendEmptyMessage(MSG_START_SERVICE);
}
[/code]这个类就是来监听这个Settings.Secure.BAR_SERVICE_COMPONENT的改变,并看情况如何启动Service。再看mHandler的处理

[code]privatefinalHandlermHandler=newHandler(){
publicvoidhandleMessage(Messagemsg){
switch(msg.what){
caseMSG_START_SERVICE:
startService();
break;
caseMSG_CONTINUE_START_SERVICE:
continueStartService();
break;
caseMSG_STOP_SERVICE:
stopService();
break;
caseMSG_PACKAGE_INTENT:
packageIntent((Intent)msg.obj);
break;
caseMSG_CHECK_BOUND:
checkBound();
break;
caseMSG_SERVICE_DISCONNECTED:
serviceDisconnected((ComponentName)msg.obj);
break;
}
}
};
privatevoidstartService(){
//获取Service的ComponentName
mServiceName=getComponentNameFromSetting();
if(mDebug)Log.d(mTag,"startServicemServiceName="+mServiceName);
if(mServiceName==null){
mBound=false;
//如果没有Service,就回调,从之前的看,就是startPhoneStatusBar
mCallbacks.onNoService();
}else{
//喜闻乐见的bindService,说破天就是在启动PhoneStatusBar
longdelay=mCallbacks.onServiceStartAttempt();
mHandler.sendEmptyMessageDelayed(MSG_CONTINUE_START_SERVICE,delay);
}
}
privateComponentNamegetComponentNameFromSetting(){
Stringcn=Settings.Secure.getStringForUser(mContext.getContentResolver(),
mSettingKey,UserHandle.USER_CURRENT);
returncn==null?null:ComponentName.unflattenFromString(cn);
}
[/code]这里就是通过getComponentNameFromSetting()获取sevice的Component

name,如果不存在就回调onNoservice方法,这个跟前面的注释实际就产生对应

SystemBar.java实现了这个回调接口,可以查到R.string.config_statusBarComponent的值,就是PhoneStatusBar

[code]@Override
publicvoidonNoService(){
if(DEBUG)Log.d(TAG,"onNoService");
createStatusBarFromConfig();//fallbacktousinganin-processimplementation
}
privatevoidcreateStatusBarFromConfig(){
if(DEBUG)Log.d(TAG,"createStatusBarFromConfig");
//<stringname="config_statusBarComponent"translatable="false">com.android.systemui.statusbar.phone.PhoneStatusBar</string>
finalStringclsName=mContext.getString(R.string.config_statusBarComponent);
if(clsName==null||clsName.length()==0){
throwandLog("Nostatusbarcomponentconfigured",null);
}
Class<?>cls=null;
try{
cls=mContext.getClassLoader().loadClass(clsName);
}catch(Throwablet){
throwandLog("Errorloadingstatusbarcomponent:"+clsName,t);
}
try{
mStatusBar=(BaseStatusBar)cls.newInstance();
}catch(Throwablet){
throwandLog("Errorcreatingstatusbarcomponent:"+clsName,t);
}
mStatusBar.mContext=mContext;
mStatusBar.mComponents=mComponents;
mStatusBar.start();
if(DEBUG)Log.d(TAG,"started"+mStatusBar.getClass().getSimpleName());
}
[/code]说破天,最终就是为了PhoneStatusBar.java的start()方法

PhoneStatusBar.java

[code]publicvoidstart(){
mDisplay=((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
updateDisplaySize();
mScrimSrcModeEnabled=mContext.getResources().getBoolean(
R.bool.config_status_bar_scrim_behind_use_src);
///M:[SystemUI]SupportSmartbookFeature.@{
if(SIMHelper.isMtkSmartBookSupport()){
///M:[ALPS01097705]Querytheplug-instateassoonaspossible.
mIsDisplayDevice=SIMHelper.isSmartBookPluggedIn(mContext);
Log.v(TAG,"start,mIsDisplayDevice="+mIsDisplayDevice);
}
///@}
super.start();//callscreateAndAddWindows()
mMediaSessionManager
=(MediaSessionManager)mContext.getSystemService(Context.MEDIA_SESSION_SERVICE);
//TODO:useMediaSessionManager.SessionListenertohookusuptofutureupdates
//insessionstate
//添加NavigationBar
addNavigationBar();
//Lastly,calltotheiconpolicytoinstall/updatealltheicons.
mIconPolicy=newPhoneStatusBarPolicy(mContext,mCastController,mHotspotController);
mSettingsObserver.onChange(false);//setup
mHeadsUpObserver.onChange(true);//setup
if(ENABLE_HEADS_UP){
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED),true,
mHeadsUpObserver);
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(SETTING_HEADS_UP_TICKER),true,
mHeadsUpObserver);
}
mUnlockMethodCache=UnlockMethodCache.getInstance(mContext);
mUnlockMethodCache.addListener(this);
//启动锁屏
startKeyguard();
mDozeServiceHost=newDozeServiceHost();
putComponent(DozeHost.class,mDozeServiceHost);
putComponent(PhoneStatusBar.class,this);
setControllerUsers();
notifyUserAboutHiddenNotifications();
mScreenPinningRequest=newScreenPinningRequest(mContext);
}
[/code]现在要看的是StatusBar,所以看super.start(),也就是BaseStatusBar.java的start()

BaseStatusBar.java

[code]publicvoidstart(){
mWindowManager=(WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
mWindowManagerService=WindowManagerGlobal.getWindowManagerService();
mDisplay=mWindowManager.getDefaultDisplay();
mDevicePolicyManager=(DevicePolicyManager)mContext.getSystemService(
Context.DEVICE_POLICY_SERVICE);
mNotificationColorUtil=NotificationColorUtil.getInstance(mContext);
mNotificationData=newNotificationData(this);
mAccessibilityManager=(AccessibilityManager)
mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
mDreamManager=IDreamManager.Stub.asInterface(
ServiceManager.checkService(DreamService.DREAM_SERVICE));
mPowerManager=(PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
mSettingsObserver.onChange(false);//setup
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED),true,
mSettingsObserver);
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.ZEN_MODE),false,
mSettingsObserver);
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS),false,
mSettingsObserver,
UserHandle.USER_ALL);
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS),
true,
mLockscreenSettingsObserver,
UserHandle.USER_ALL);
//加载statusbarservice
mBarService=IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
//
mRecents=getComponent(RecentsComponent.class);
mRecents.setCallback(this);
finalConfigurationcurrentConfig=mContext.getResources().getConfiguration();
mLocale=currentConfig.locale;
mLayoutDirection=TextUtils.getLayoutDirectionFromLocale(mLocale);
mFontScale=currentConfig.fontScale;
mUserManager=(UserManager)mContext.getSystemService(Context.USER_SERVICE);
mLinearOutSlowIn=AnimationUtils.loadInterpolator(mContext,
android.R.interpolator.linear_out_slow_in);
mFastOutLinearIn=AnimationUtils.loadInterpolator(mContext,
android.R.interpolator.fast_out_linear_in);
//Connectintothestatusbarmanagerservice
StatusBarIconListiconList=newStatusBarIconList();
mCommandQueue=newCommandQueue(this,iconList);
int[]switches=newint[8];
ArrayList<IBinder>binders=newArrayList<IBinder>();
try{
mBarService.registerStatusBar(mCommandQueue,iconList,switches,binders);
}catch(RemoteExceptionex){
//Ifthesystemprocessisn'ttherewe'redoomedanyway.
}
//就是为了调用这里,加载statusbar
createAndAddWindows();
disable(switches[0],false/*animate*/);
setSystemUiVisibility(switches[1],0xffffffff);
topAppWindowChanged(switches[2]!=0);
//StatusBarManagerServicehasabackupofIMEtokenandit'srestoredhere.
setImeWindowStatus(binders.get(0),switches[3],switches[4],switches[5]!=0);
//Setuptheinitialiconstate
intN=iconList.size();
intviewIndex=0;
for(inti=0;i<N;i++){
StatusBarIconicon=iconList.getIcon(i);
if(icon!=null){
addIcon(iconList.getSlot(i),i,viewIndex,icon);
viewIndex++;
}
}
//Setuptheinitialnotificationstate.
try{
mNotificationListener.registerAsSystemService(mContext,
newComponentName(mContext.getPackageName(),getClass().getCanonicalName()),
UserHandle.USER_ALL);
}catch(RemoteExceptione){
Log.e(TAG,"Unabletoregisternotificationlistener",e);
}
if(DEBUG){
Log.d(TAG,String.format(
"init:icons=%ddisabled=0x%08xlights=0x%08xmenu=0x%08ximeButton=0x%08x",
iconList.size(),
switches[0],
switches[1],
switches[2],
switches[3]
));
}
mCurrentUserId=ActivityManager.getCurrentUser();
setHeadsUpUser(mCurrentUserId);
IntentFilterfilter=newIntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
filter.addAction(Intent.ACTION_USER_ADDED);
filter.addAction(BANNER_ACTION_CANCEL);
filter.addAction(BANNER_ACTION_SETUP);
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
mContext.registerReceiver(mBroadcastReceiver,filter);
updateCurrentProfilesCache();
}
[/code]这里搞了一大堆,其实是就为了createAndAddWindows();createAndAddWindows在PhoneStatusBar中实现

[code]@Override
publicvoidcreateAndAddWindows(){
addStatusBarWindow();
}
privatevoidaddStatusBarWindow(){
makeStatusBarView();
mStatusBarWindowManager=newStatusBarWindowManager(mContext);
mStatusBarWindowManager.add(mStatusBarWindow,getStatusBarHeight());
}
[/code]
[code]protectedPhoneStatusBarViewmakeStatusBarView(){
finalContextcontext=mContext;
Xlog.d(TAG,"makeStatusBarView:Start");
Resourcesres=context.getResources();
updateDisplaySize();//populatesmDisplayMetrics
updateResources();
mIconSize=res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
///M:Support"Changefontsizeofphone".
Configurationconfig=res.getConfiguration();
///M:[SystemUI]SupportSmartbookFeature.@{
Log.v(TAG,"makeStatusBarViewdumpconfiginformationstart");
Log.v(TAG,"widthPixels="+mDisplayMetrics.widthPixels);
Log.v(TAG,"heightPixels="+mDisplayMetrics.heightPixels);
Log.v(TAG,"orientation="+config.orientation);
Log.v(TAG,"config="+config.toString());
Log.v(TAG,"makeStatusBarViewdumpconfiginformationend");
///@}
Xlog.d(TAG,"makeStatusBarView:inflatesuper_status_bar+");
//加载布局了
mStatusBarWindow=(StatusBarWindowView)View.inflate(context,
R.layout.super_status_bar,null);
Xlog.d(TAG,"makeStatusBarView:inflatesuper_status_bar-");
//这个mStatusBarWindow就是statusbar视图的根布局,监听事件,下拉
mStatusBarWindow.mService=this;
mStatusBarWindow.setOnTouchListener(newView.OnTouchListener(){
@Override
publicbooleanonTouch(Viewv,MotionEventevent){
checkUserAutohide(v,event);
if(event.getAction()==MotionEvent.ACTION_DOWN){
if(mExpandedVisible){
animateCollapsePanels();
}
}
returnmStatusBarWindow.onTouchEvent(event);
}});
//statusbar开始加载
mStatusBarView=(PhoneStatusBarView)mStatusBarWindow.findViewById(R.id.status_bar);
mStatusBarView.setBar(this);
PanelHolderholder=(PanelHolder)mStatusBarWindow.findViewById(R.id.panel_holder);
mStatusBarView.setPanelHolder(holder);
mNotificationPanel=(NotificationPanelView)mStatusBarWindow.findViewById(
R.id.notification_panel);
mNotificationPanel.setStatusBar(this);
//M:setBackgroundin512lowramdevice
if(!ActivityManager.isHighEndGfx()&&!SystemProperties.getBoolean("ro.config.low_ram",true)){
mStatusBarWindow.setBackground(null);
mNotificationPanel.setBackground(newFastColorDrawable(context.getResources().getColor(
R.color.notification_panel_solid_background)));
}
if(ENABLE_HEADS_UP){
mHeadsUpNotificationView=
(HeadsUpNotificationView)View.inflate(context,R.layout.heads_up,null);
mHeadsUpNotificationView.setVisibility(View.GONE);
mHeadsUpNotificationView.setBar(this);
}
if(MULTIUSER_DEBUG){
mNotificationPanelDebugText=(TextView)mNotificationPanel.findViewById(
R.id.header_debug_info);
mNotificationPanelDebugText.setVisibility(View.VISIBLE);
}
updateShowSearchHoldoff();
try{
booleanshowNav=mWindowManagerService.hasNavigationBar();
if(DEBUG)Log.v(TAG,"hasNavigationBar="+showNav);
if(showNav){
///M:addformultiwindow@{
intlayoutId=R.layout.navigation_bar;
if(RecentsActivity.FLOAT_WINDOW_SUPPORT){
layoutId=R.layout.navigation_bar_float_window;
}
mNavigationBarView=
(NavigationBarView)View.inflate(context,/*R.layout.navigation_bar*/layoutId,null);
///@}
mNavigationBarView.setDisabledFlags(mDisabled);
mNavigationBarView.setBar(this);
mNavigationBarView.setOnVerticalChangedListener(
newNavigationBarView.OnVerticalChangedListener(){
@Override
publicvoidonVerticalChanged(booleanisVertical){
if(mSearchPanelView!=null){
mSearchPanelView.setHorizontal(isVertical);
}
mNotificationPanel.setQsScrimEnabled(!isVertical);
}
});
mNavigationBarView.setOnTouchListener(newView.OnTouchListener(){
@Override
publicbooleanonTouch(Viewv,MotionEventevent){
checkUserAutohide(v,event);
returnfalse;
}});
}
}catch(RemoteExceptionex){
//nowindowmanager?goodluckwiththat
}
//figureoutwhichpixel-formattouseforthestatusbar.
mPixelFormat=PixelFormat.OPAQUE;
//整个系统图标的根布局
mSystemIconArea=(LinearLayout)mStatusBarView.findViewById(R.id.system_icon_area);
//整个系统图标的第二人父布局
mSystemIcons=(LinearLayout)mStatusBarView.findViewById(R.id.system_icons);
//状态图标,蓝牙,耳机
mStatusIcons=(LinearLayout)mStatusBarView.findViewById(R.id.statusIcons);
//通知一块的图标,如运行时候出现的qq音乐
mNotificationIconArea=mStatusBarView.findViewById(R.id.notification_icon_area_inner);
mNotificationIcons=(IconMerger)mStatusBarView.findViewById(R.id.notificationIcons);
mMoreIcon=mStatusBarView.findViewById(R.id.moreIcon);
mNotificationIcons.setOverflowIndicator(mMoreIcon);
//整个statusbar的根布局
mStatusBarContents=(LinearLayout)mStatusBarView.findViewById(R.id.status_bar_contents);
/*addcallingcodehere*/
/*callingthepluginforplmndisplayfororange*/
///M:callingthepluginforplmndisplayfororange
Xlog.d(TAG,"overthecalltopluginfactory");
mPlmnDisplay=PluginFactory.getStatusBarPlmnPlugin(mContext).getPlmnTextView(mContext);
if(mPlmnDisplay!=null){
mPlmnDisplay.setVisibility(View.VISIBLE);
Stringstr=(String)mPlmnDisplay.getText();
if(str==null)
Xlog.d(TAG,"Notextinframework");
Xlog.d(TAG,"textofTextView="+str);
mStatusBarContents.addView(mPlmnDisplay,0);
mNotificationIcons.setCarrierText(mPlmnDisplay);
}
//下拉通知栏
mStackScroller=(NotificationStackScrollLayout)mStatusBarWindow.findViewById(
R.id.notification_stack_scroller);
mStackScroller.setLongPressListener(getNotificationLongClicker());
mStackScroller.setPhoneStatusBar(this);
mKeyguardIconOverflowContainer=
(NotificationOverflowContainer)LayoutInflater.from(mContext).inflate(
R.layout.status_bar_notification_keyguard_overflow,mStackScroller,false);
mKeyguardIconOverflowContainer.setOnActivatedListener(this);
mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener);
mStackScroller.addView(mKeyguardIconOverflowContainer);
SpeedBumpViewspeedBump=(SpeedBumpView)LayoutInflater.from(mContext).inflate(
R.layout.status_bar_notification_speed_bump,mStackScroller,false);
mStackScroller.setSpeedBumpView(speedBump);
mEmptyShadeView=(EmptyShadeView)LayoutInflater.from(mContext).inflate(
R.layout.status_bar_no_notifications,mStackScroller,false);
mStackScroller.setEmptyShadeView(mEmptyShadeView);
//下拉通知栏的清除按键
mDismissView=(DismissView)LayoutInflater.from(mContext).inflate(
R.layout.status_bar_notification_dismiss_all,mStackScroller,false);
mDismissView.setOnButtonClickListener(newView.OnClickListener(){
@Override
publicvoidonClick(Viewv){
clearAllNotifications();
}
});
mStackScroller.setDismissView(mDismissView);
mExpandedContents=mStackScroller;
mBackdrop=(BackDropView)mStatusBarWindow.findViewById(R.id.backdrop);
mBackdropFront=(ImageView)mBackdrop.findViewById(R.id.backdrop_front);
mBackdropBack=(ImageView)mBackdrop.findViewById(R.id.backdrop_back);
ScrimViewscrimBehind=(ScrimView)mStatusBarWindow.findViewById(R.id.scrim_behind);
ScrimViewscrimInFront=(ScrimView)mStatusBarWindow.findViewById(R.id.scrim_in_front);
mScrimController=newScrimController(scrimBehind,scrimInFront,mScrimSrcModeEnabled);
mScrimController.setBackDropView(mBackdrop);
mStatusBarView.setScrimController(mScrimController);
mDozeScrimController=newDozeScrimController(mScrimController,context);
mHeader=(StatusBarHeaderView)mStatusBarWindow.findViewById(R.id.header);
mHeader.setActivityStarter(this);
//下面一系列的加载锁屏的statusbaricon
mKeyguardStatusBar=(KeyguardStatusBarView)mStatusBarWindow.findViewById(R.id.keyguard_header);
mStatusIconsKeyguard=(LinearLayout)mKeyguardStatusBar.findViewById(R.id.statusIcons);
mKeyguardStatusView=mStatusBarWindow.findViewById(R.id.keyguard_status_view);
mKeyguardBottomArea=
(KeyguardBottomAreaView)mStatusBarWindow.findViewById(R.id.keyguard_bottom_area);
mKeyguardBottomArea.setActivityStarter(this);
mKeyguardIndicationController=newKeyguardIndicationController(mContext,
(KeyguardIndicationTextView)mStatusBarWindow.findViewById(
R.id.keyguard_indication_text));
mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController);
mTickerEnabled=res.getBoolean(R.bool.enable_ticker);
if(mTickerEnabled){
finalViewStubtickerStub=(ViewStub)mStatusBarView.findViewById(R.id.ticker_stub);
if(tickerStub!=null){
mTickerView=tickerStub.inflate();
mTicker=newMyTicker(context,mStatusBarView);
TickerViewtickerView=(TickerView)mStatusBarView.findViewById(R.id.tickerText);
tickerView.mTicker=mTicker;
}
}
mEdgeBorder=res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
//settheinitalviewvisibility
setAreThereNotifications();
//Backgroundthreadforanycontrollersthatneedit.
mHandlerThread=newHandlerThread(TAG,Process.THREAD_PRIORITY_BACKGROUND);
mHandlerThread.start();
//Othericons
Xlog.d(TAG,"makeStatusBarView:LocationControllerImpl");
mLocationController=newLocationControllerImpl(mContext);//willpostanotification
Xlog.d(TAG,"makeStatusBarView:BatteryController");
mBatteryController=newBatteryController(mContext);
mBatteryController.addStateChangedCallback(newBatteryStateChangeCallback(){
@Override
publicvoidonPowerSaveChanged(){
mHandler.post(mCheckBarModes);
if(mDozeServiceHost!=null){
mDozeServiceHost.firePowerSaveChanged(mBatteryController.isPowerSave());
}
}
});
Xlog.d(TAG,"makeStatusBarView:NetworkControllerImpl");
mNetworkController=newNetworkControllerImpl(mContext);
Xlog.d(TAG,"makeStatusBarView:HotspotControllerImpl");
mHotspotController=newHotspotControllerImpl(mContext);
Xlog.d(TAG,"makeStatusBarView:BluetoothControllerImpl");
mBluetoothController=newBluetoothControllerImpl(mContext,mHandlerThread.getLooper());
Xlog.d(TAG,"makeStatusBarView:SecurityControllerImpl");
mSecurityController=newSecurityControllerImpl(mContext);
///M:addHotKnotinquicksetting@{
if(SIMHelper.isMtkHotKnotSupport()){
Xlog.d(TAG,"makeStatusBarView:HotKnotControllerImpl");
mHotKnotController=newHotKnotControllerImpl(mContext);
}else{
mHotKnotController=null;
}
///addHotKnotinquicksetting@}
///M:addAudioProfileinquicksetting@{
if(SIMHelper.isMtkAudioProfilesSupport()){
Xlog.d(TAG,"makeStatusBarView:AudioProfileControllerImpl");
mAudioProfileController=newAudioProfileControllerImpl(mContext);
}else{
mAudioProfileController=null;
}
///M:addAudioProfileinquicksetting@}
///M:addDataConnectioninquicksetting@{
SIMHelper.setContext(mContext);
if(!SIMHelper.isWifiOnlyDevice()){
Xlog.d(TAG,"makeStatusBarView:DataConnectionControllerImpl");
mDataConnectionController=newDataConnectionControllerImpl(mContext);
}else{
mDataConnectionController=null;
}
///M:addDataConnectioninquicksetting@}
if(mContext.getResources().getBoolean(R.bool.config_showRotationLock)){
Xlog.d(TAG,"makeStatusBarView:RotationLockControllerImpl");
mRotationLockController=newRotationLockControllerImpl(mContext);
}
Xlog.d(TAG,"makeStatusBarView:UserInfoController+");
mUserInfoController=newUserInfoController(mContext);
Xlog.d(TAG,"makeStatusBarView:UserInfoController-");
mVolumeComponent=getComponent(VolumeComponent.class);
if(mVolumeComponent!=null){
mZenModeController=mVolumeComponent.getZenController();
}
//M:RemoveCastTilewhenWFDisnotsupportinquicksetting
if(SIMHelper.isWifiDisplaySupport()){
Xlog.d(TAG,"makeStatusBarView:CastControllerImpl+");
mCastController=newCastControllerImpl(mContext);
Xlog.d(TAG,"makeStatusBarView:CastControllerImpl-");
}
//信号图标:vpnwifisim
finalSignalClusterViewsignalCluster=
(SignalClusterView)mStatusBarView.findViewById(R.id.signal_cluster);
finalSignalClusterViewsignalClusterKeyguard=
(SignalClusterView)mKeyguardStatusBar.findViewById(R.id.signal_cluster);
finalSignalClusterViewsignalClusterQs=
(SignalClusterView)mHeader.findViewById(R.id.signal_cluster);
mNetworkController.addSignalCluster(signalCluster);
mNetworkController.addSignalCluster(signalClusterKeyguard);
mNetworkController.addSignalCluster(signalClusterQs);
signalCluster.setSecurityController(mSecurityController);
signalCluster.setNetworkController(mNetworkController);
signalClusterKeyguard.setSecurityController(mSecurityController);
signalClusterKeyguard.setNetworkController(mNetworkController);
signalClusterQs.setSecurityController(mSecurityController);
signalClusterQs.setNetworkController(mNetworkController);
///M:[ALPS01967373]setEmergencyCallsOnlytext@{
mNetworkController.addEmergencyListener(newNetworkControllerImpl.EmergencyListener(){
@Override
publicvoidsetEmergencyCallsOnly(booleanemergencyOnly){
finalbooleanisAPhone=mNetworkController.hasVoiceCallingFeature();
if(DEBUG){
Xlog.d(TAG,"setEmergencyCallsOnly:"+emergencyOnly+
",voiceFeature:"+isAPhone);
}
if(isAPhone||emergencyOnly==false){
mHeader.setShowEmergencyCallsOnly(emergencyOnly);
}
}
});
///M:[ALPS01967373]setEmergencyCallsOnlytext@}
//运营商图标
mCarrierLabel=(TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
mShowCarrierInPanel=(mCarrierLabel!=null);
if(DEBUG)Log.v(TAG,"carrierlabel="+mCarrierLabel+"show="+mShowCarrierInPanel);
///M:Support"Operatorplugin-CustomizeCarrierLabelforPLMN"@{
mStatusBarPlmnPlugin=PluginFactory.getStatusBarPlmnPlugin(context);
///M:Support"Operatorplugin-CustomizeCarrierLabelforPLMN"@}
if(mShowCarrierInPanel){
mCarrierLabel.setVisibility(mCarrierLabelVisible?View.VISIBLE:View.INVISIBLE);
mNetworkController.addCarrierLabel(newNetworkControllerImpl.CarrierLabelListener(){
@Override
publicvoidsetCarrierLabel(Stringlabel){
mCarrierLabel.setText(label);
if(mNetworkController.hasMobileDataFeature()){
if(TextUtils.isEmpty(label)){
mCarrierLabel.setVisibility(View.GONE);
}else{
///M:Support"Operatorplugin-CustomizeCarrierLabelforPLMN"@{
if(!(mStatusBarPlmnPlugin!=null
&&mStatusBarPlmnPlugin.supportCustomizeCarrierLabel())){
mCarrierLabel.setVisibility(View.VISIBLE);
}
///M:Support"Operatorplugin-CustomizeCarrierLabelforPLMN"@}
}
}
}
});
}
///M:Support"Operatorplugin-CustomizeCarrierLabelforPLMN".@{
if(supportCustomizeCarrierLabel()){
mCustomizeCarrierLabel=mStatusBarPlmnPlugin.customizeCarrierLabel(
mNotificationPanel,mCarrierLabel);
}
///M:Support"Operatorplugin-CustomizeCarrierLabelforPLMN".@}
Xlog.d(TAG,"makeStatusBarView:FlashlightController+");
mFlashlightController=newFlashlightController(mContext);
Xlog.d(TAG,"makeStatusBarView:FlashlightController-");
mKeyguardBottomArea.setFlashlightController(mFlashlightController);
mKeyguardBottomArea.setPhoneStatusBar(this);
Xlog.d(TAG,"makeStatusBarView:AccessibilityController");
mAccessibilityController=newAccessibilityController(mContext);
mKeyguardBottomArea.setAccessibilityController(mAccessibilityController);
Xlog.d(TAG,"makeStatusBarView:NextAlarmController+");
mNextAlarmController=newNextAlarmController(mContext);
Xlog.d(TAG,"makeStatusBarView:NextAlarmController-");
mKeyguardMonitor=newKeyguardMonitor();
if(UserSwitcherController.isUserSwitcherAvailable(UserManager.get(mContext))){
Xlog.d(TAG,"makeStatusBarView:UserSwitcherController+");
mUserSwitcherController=newUserSwitcherController(mContext,mKeyguardMonitor);
Xlog.d(TAG,"makeStatusBarView:UserSwitcherController-");
}
mKeyguardUserSwitcher=newKeyguardUserSwitcher(mContext,
(ViewStub)mStatusBarWindow.findViewById(R.id.keyguard_user_switcher),
mKeyguardStatusBar,mNotificationPanel,mUserSwitcherController);
//Setupthequicksettingstilepanel
mQSPanel=(QSPanel)mStatusBarWindow.findViewById(R.id.quick_settings_panel);
if(mQSPanel!=null){
finalQSTileHostqsh=newQSTileHost(mContext,this,
mBluetoothController,mLocationController,mRotationLockController,
mNetworkController,mZenModeController,mHotspotController,
mCastController,mFlashlightController,
mUserSwitcherController,mKeyguardMonitor,
mSecurityController,
///M:addHotKnotinquicksetting
mHotKnotController,
///M:addAudioProfileinquicksetting
mAudioProfileController,
///M:addDataConnectioninquicksetting
mDataConnectionController
);
mQSPanel.setHost(qsh);
mQSPanel.setTiles(qsh.getTiles());
mBrightnessMirrorController=newBrightnessMirrorController(mStatusBarWindow);
mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
mHeader.setQSPanel(mQSPanel);
qsh.setCallback(newQSTileHost.Callback(){
@Override
publicvoidonTilesChanged(){
mQSPanel.setTiles(qsh.getTiles());
}
});
}
//Userinfo.Triggerfirstload.
mHeader.setUserInfoController(mUserInfoController);
mKeyguardStatusBar.setUserInfoController(mUserInfoController);
mUserInfoController.reloadUserInfo();
mHeader.setBatteryController(mBatteryController);
((BatteryMeterView)mStatusBarView.findViewById(R.id.battery)).setBatteryController(
mBatteryController);
//锁屏界面的设置battery改变的监听器
mKeyguardStatusBar.setBatteryController(mBatteryController);
mHeader.setNextAlarmController(mNextAlarmController);
PowerManagerpm=(PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
mBroadcastReceiver.onReceive(mContext,
newIntent(pm.isScreenOn()?Intent.ACTION_SCREEN_ON:Intent.ACTION_SCREEN_OFF));
//receivebroadcasts
IntentFilterfilter=newIntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
if(DEBUG_MEDIA_FAKE_ARTWORK){
filter.addAction("fake_artwork");
}
filter.addAction(ACTION_DEMO);
context.registerReceiverAsUser(mBroadcastReceiver,UserHandle.ALL,filter,null,null);
///M:[SystemUI]SupportSmartbookFeature.@{
if(SIMHelper.isMtkSmartBookSupport()){
IntentFiltermFilter=newIntentFilter(Intent.ACTION_SMARTBOOK_PLUG);
context.registerReceiver(mDisplayDevicePluginReceiver,mFilter);
Log.v(TAG,"makeStatusBarView,isSmartBookPluggedIn="
+SIMHelper.isSmartBookPluggedIn(context));
}
///@}
//listenforUSER_SETUP_COMPLETEsetting(per-user)
resetUserSetupObserver();
startGlyphRasterizeHack();
Xlog.d(TAG,"makeStatusBarView:End");
returnmStatusBarView;
}
[/code]

mStatusBarWindow=(StatusBarWindowView)View.inflate(context,
R.layout.super_status_bar,null);

这个super_status_bar.xml文件加载了

[code]
<com.android.systemui.statusbar.phone.StatusBarWindowView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.android.systemui.statusbar.BackDropView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
>
<ImageViewandroid:id="@+id/backdrop_back"
android:layout_width="match_parent"
android:scaleType="centerCrop"
android:layout_height="match_parent"/>
<ImageViewandroid:id="@+id/backdrop_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:visibility="invisible"/>
</com.android.systemui.statusbar.BackDropView>
<com.android.systemui.statusbar.ScrimViewandroid:id="@+id/scrim_behind"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:importantForAccessibility="no"/>
<includelayout="@layout/status_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/status_bar_height"/>
<FrameLayoutandroid:id="@+id/brightness_mirror"
android:layout_width="@dimen/notification_panel_width"
android:layout_height="wrap_content"
android:layout_gravity="@integer/notification_panel_layout_gravity"
android:paddingLeft="@dimen/notification_side_padding"
android:paddingRight="@dimen/notification_side_padding"
android:visibility="gone">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="2dp"
android:background="@drawable/brightness_mirror_background">
<includelayout="@layout/quick_settings_brightness_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
</FrameLayout>
<!--加载锁屏界面的statusbar-->
<com.android.systemui.statusbar.phone.PanelHolder
android:id="@+id/panel_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent">
<includelayout="@layout/status_bar_expanded"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</com.android.systemui.statusbar.phone.PanelHolder>
<com.android.systemui.statusbar.ScrimViewandroid:id="@+id/scrim_in_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:importantForAccessibility="no"/>
</com.android.systemui.statusbar.phone.StatusBarWindowView>
[/code]<includelayout="@layout/status_bar"

android:layout_width="match_parent"

android:layout_height="@dimen/status_bar_height"/>

这就是我们的statusbar的图标了

status_bar.xml

[code]<com.android.systemui.statusbar.phone.PhoneStatusBarView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
android:id="@+id/status_bar"
android:background="@drawable/system_bar_background"
android:orientation="vertical"
android:focusable="true"
android:descendantFocusability="afterDescendants"
>
<ImageView
android:id="@+id/notification_lights_out"
android:layout_width="@dimen/status_bar_icon_size"
android:layout_height="match_parent"
android:paddingStart="6dip"
android:paddingBottom="2dip"
android:src="@drawable/ic_sysbar_lights_out_dot_small"
android:scaleType="center"
android:visibility="gone"
/>
<LinearLayoutandroid:id="@+id/status_bar_contents"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="6dp"
android:paddingEnd="8dp"
android:orientation="horizontal"
>
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/notification_icon_area"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
>
<!--ThealphaofthisareaisbothcontrolledfromPhoneStatusBarTransitionsand
PhoneStatusBar(DISABLE_NOTIFICATION_ICONS),soweneedtwoviewshere.-->
<com.android.keyguard.AlphaOptimizedLinearLayout
android:id="@+id/notification_icon_area_inner"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.android.systemui.statusbar.StatusBarIconViewandroid:id="@+id/moreIcon"
android:layout_width="@dimen/status_bar_icon_size"
android:layout_height="match_parent"
android:src="@drawable/stat_notify_more"
android:visibility="gone"
/>
<com.android.systemui.statusbar.phone.IconMergerandroid:id="@+id/notificationIcons"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:gravity="center_vertical"
android:orientation="horizontal"/>
</com.android.keyguard.AlphaOptimizedLinearLayout>
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
<com.android.keyguard.AlphaOptimizedLinearLayoutandroid:id="@+id/system_icon_area"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<includelayout="@layout/system_icons"/>
<com.android.systemui.statusbar.policy.Clock
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="7dp"
android:gravity="center_vertical|start"
/>
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
<ViewStub
android:id="@+id/ticker_stub"
android:inflatedId="@+id/ticker"
android:layout="@layout/status_bar_ticker"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
[/code]notification_icon_area_inner是通知图标,例如听QQ音乐的时候,会在手机左边区域显示QQ音乐的图标

system_icon_area里面有个clock,当然就是最右边的时间了

中间<includelayout="@layout/system_icons"/>就是系统的图标了

system_icon.xml

[code]<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/system_icons"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical">
<com.android.keyguard.AlphaOptimizedLinearLayout
android:id="@+id/statusIcons"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"/>
<includelayout="@layout/signal_cluster_view"
android:id="@+id/signal_cluster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2.5dp"/>
<!--batterymustbepaddedbelowtomatchassets-->
<com.android.systemui.BatteryMeterViewandroid:id="@+id/battery"
android:layout_height="14.5dp"
android:layout_width="9.5dp"
android:layout_marginBottom="@dimen/battery_margin_bottom"/>
</LinearLayout>
[/code]第一个,statusIcons,状态图标,就是蓝牙,耳机的图标

第二个,signal_cluster_view,信号图标,也就是vpnwifi,SIM

signal_cluster_view.xml

[code]<com.android.systemui.statusbar.SignalClusterView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingEnd="@dimen/signal_cluster_battery_padding"
>
<ImageView
android:id="@+id/vpn"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingEnd="6dp"
android:src="@drawable/stat_sys_vpn_ic"
/>
<FrameLayout
android:id="@+id/wifi_combo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
<ImageView
android:id="@+id/wifi_signal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</FrameLayout>
<View
android:id="@+id/wifi_signal_spacer"
android:layout_width="4dp"
android:layout_height="4dp"
android:visibility="gone"
/>
<!--M:Support"SystemUI-VoLTEicon".@{-->
<ImageView
android:id="@+id/volte_icon"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
/>
<!--M:Support"SystemUI-VoLTEicon".}@-->
<!--M:Support"DefaultSIMIndicator".@{-->
<ImageView
android:id="@+id/sim_indicator_internet_or_alwaysask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginEnd="3dip"
/>
<!--M:Support"DefaultSIMIndicator".}@-->
<LinearLayout
android:id="@+id/mobile_signal_group"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
</LinearLayout>
<ImageView
android:id="@+id/no_sims"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/stat_sys_no_sims"
/>
<View
android:id="@+id/wifi_airplane_spacer"
android:layout_width="4dp"
android:layout_height="4dp"
android:visibility="gone"
/>
<ImageView
android:id="@+id/airplane"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</com.android.systemui.statusbar.SignalClusterView>
[/code]最后一个@+id/battery当然就是电池了

但是,但是,我们看手机的时候,居然没有电量百分比显示出来,这让很多客户就有点恼火,后面再说

再看super_status_bar.xml最后一个布局

[code]<!--加载锁屏界面的statusbar-->
<com.android.systemui.statusbar.phone.PanelHolder
android:id="@+id/panel_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent">
<includelayout="@layout/status_bar_expanded"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</com.android.systemui.statusbar.phone.PanelHolder>
[/code]status_bar_expanded.xml

[code]<include
layout="@layout/keyguard_status_bar"
android:visibility="invisible"/>
[/code]keyguard_status_bar.xml

[code]<?xmlversion="1.0"encoding="utf-8"?>
<!--
~Copyright(C)2014TheAndroidOpenSourceProject
~
~LicensedundertheApacheLicense,Version2.0(the"License");
~youmaynotusethisfileexceptincompliancewiththeLicense.
~YoumayobtainacopyoftheLicenseat
~
~
'target='_blank'>http://www.apache.org/licenses/LICENSE-2.0
~
~Unlessrequiredbyapplicablelaworagreedtoinwriting,software
~distributedundertheLicenseisdistributedonan"ASIS"BASIS,
~WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
~SeetheLicenseforthespecificlanguagegoverningpermissionsand
~limitationsundertheLicense
-->
<!--ExtendsRelativeLayout-->
<com.android.systemui.statusbar.phone.KeyguardStatusBarView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
android:id="@+id/keyguard_header"
android:layout_width="match_parent"
android:layout_height="@dimen/status_bar_header_height_keyguard"
android:baselineAligned="false"
>
<com.android.systemui.statusbar.phone.MultiUserSwitchandroid:id="@+id/multi_user_switch"
android:layout_width="@dimen/multi_user_switch_width_keyguard"
android:layout_height="@dimen/status_bar_header_height_keyguard"
android:layout_alignParentEnd="true"
android:background="@drawable/ripple_drawable"
android:layout_marginEnd="@dimen/multi_user_switch_keyguard_margin">
<ImageViewandroid:id="@+id/multi_user_avatar"
android:layout_width="@dimen/multi_user_avatar_keyguard_size"
android:layout_height="@dimen/multi_user_avatar_keyguard_size"
android:layout_gravity="center"
android:scaleType="centerInside"/>
</com.android.systemui.statusbar.phone.MultiUserSwitch>
<LinearLayoutandroid:id="@+id/system_icons_super_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/status_bar_header_height"
android:layout_toStartOf="@id/multi_user_switch"
android:layout_alignWithParentIfMissing="true"
android:layout_marginStart="16dp"
android:paddingEnd="@dimen/system_icons_keyguard_padding_end">
<FrameLayoutandroid:id="@+id/system_icons_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/status_bar_height"
android:layout_gravity="center_vertical"
>
<includelayout="@layout/system_icons"/>
</FrameLayout>
<TextViewandroid:id="@+id/battery_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/header_battery_margin_keyguard"
android:paddingEnd="@dimen/battery_level_padding_end"
android:textColor="#ffffff"
android:visibility="gone"
android:textSize="@dimen/battery_level_text_size"
android:importantForAccessibility="noHideDescendants"/>
</LinearLayout>
<com.android.keyguard.CarrierText
android:id="@+id/keyguard_carrier_text"
android:layout_width="match_parent"
android:layout_height="@dimen/status_bar_header_height_keyguard"
android:layout_marginStart="@dimen/keyguard_carrier_text_margin"
android:layout_toStartOf="@id/system_icons_super_container"
android:gravity="center_vertical"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffffff"
android:singleLine="true"/>
</com.android.systemui.statusbar.phone.KeyguardStatusBarView>
[/code]看看手机,就知道这是什么图标了,但是但是,这里他妈的居然出现了@+id/battery_level,但是这个battery_level可不是你想显示就显示的,它要在充电状态下才显示电量到底有多少,fuck~,

真是他妈的看不懂这个设计,难道就是为了简化不必要的设计