8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
因为项目需要,所以对 Android 源码中的 SystemUI 做了点基本分析。
平台
Android 5.1
源代码路径
/frameworks/base/packages/SystemUI/src/com/android/systemui/
什么是SystemUI
其实就是Android的系统界面,包括状态栏Status Bar,导航栏Navigation Bar,锁屏界面Keyguard,电源界面PowerUI,最近任务管理Recents 等等。
启动流程
SystemServer.java:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26public static void main(String[] args){
new SystemServer().run()
}
private void (){
startBootstrapServices(); // 启动系统启动所需的关键服务
startCoreServices(); // 启动基本服务
startOtherServices(); // 启动其他服务
}
private void startOtherServices(){
mActivityManagerService.systemReady(new Runnable() {
public void (){
startSystemUi();
}
});
}
static final void startSystemUi(Context context){
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",
"com.android.systemui.SystemUIService"));
context.startServiceAsUser(intent, UserHandle.OWNER);
}
然后我们进入设置启动 systemui 程序的 SystemUIService.java:1
2
3
4
5public void onCreate(){
super.onCreate();
((SystemUIApplication) getApplication()).startServicesIfNeeded();
}
SystemUIApplication.java:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26private final Class>[] SERVICES = new Class[] {
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
};
// 这里是拿到每个和 SystemUI 相关的类的反射,存到了 service[] 里,然后赋值给cl,紧接着将通过反射将其转化为具体类的对象,存到了mService[i]数组里,最后对象调 start() 方法启动相关类的服务,启动完成后,回调 onBootCompleted( ) 方法
public void startServicesIfNeeded(){
final int N = SERVICES.length;
for (int i=0; i
Class> cl = SERVICES[i];
mServices[i] = (SystemUI)cl.newInstance();
mServices[i].mContext = this;
mServices[i].mComponents = mComponents;
mServices[i].start();
if (mBootCompleted) {
mServices[i].onBootCompleted();
}
}
}
// 以 SystemBars 的 start() 为例,所以mService[i].start() 先认为是 SystemBars.start()
SystemBars.java:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22public void start(){
mServiceMonitor = new ServiceMonitor(TAG, DEBUG,
mContext, Settings.Secure.BAR_SERVICE_COMPONENT, this);
mServiceMonitor.start(); // will call onNoService if no remote service is found
}
public void onNoService(){
createStatusBarFromConfig(); // fallback to using an in-process implementation
}
private void createStatusBarFromConfig(){
// R.string.config_statusBarComponent: com.android.systemui.statusbar.phone.PhoneStatusBar
final String clsName = mContext.getString(R.string.config_statusBarComponent);
Class> cls = null;
cls = mContext.getClassLoader().loadClass(clsName);
mStatusBar = (BaseStatusBar) cls.newInstance();
mStatusBar.mContext = mContext;
mStatusBar.mComponents = mComponents;
mStatusBar.start();
}
PhoneStatusBar.java:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19public void start(){
super.start(); // calls createAndAddWindows()
}
@Override
public void createAndAddWindows(){
addStatusBarWindow();
}
private void addStatusBarWindow(){
makeStatusBarView();
}
// Constructing the view
protected PhoneStatusBarView makeStatusBarView(){
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
R.layout.super_status_bar, null);
}
通过 super_status_bar.xml 的分析 SystemBars 的大致视图构成了:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
status_bar
PhoneStatusBarView 即为手机最上方的状态栏,主要用于显示系统状态,通知等,主要包括 notification icons 和 status bar icons。status_bar.xml 即对应状态栏的视图如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
PanelHolder
PanelHolder是用户下拉 status bar 后得到的 view。它主要包含 QuickSettings 和 Notification panel 两个部分。
status_bar_expanded.xml:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Network.EmergencyOnly" />
SystemUI启动流程图