System UI 调试方法

来源:互联网 发布:淘宝如何发布商品 编辑:程序博客网 时间:2024/05/21 05:20

工作需要想了解下SystemUi的启动流程,所以需要调试下SystemUI,这样比较高效:

1、SyStemUI是随系统启动的,所以我们先要在系统启动的时候把SystemUI的启动关掉,这个在SystemServer里面,可以如下注释:

[java] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. static final void startSystemUi(Context context) {  
  2.     Intent intent = new Intent();  
  3.     intent.setComponent(new ComponentName("com.android.systemui",  
  4.                 "com.android.systemui.SystemUIService"));  
  5.     //Slog.d(TAG, "Starting service: " + intent);  
  6.    // context.startServiceAsUser(intent, UserHandle.OWNER);  
  7. }  

这样,系统起来或就看不到systemUI了,如果系统起来后没有systemUI进程,我们最好自己做一个应用,与systemUi在同一进程,这样方便调试onCreate等

2、现在SystemUi没有起来了,我们自己做一个测试例子,在里面启动SystemService,如下:

[java] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. Intent intent = new Intent();  
  2.       intent.setComponent(new ComponentName("com.android.systemui",  
  3.                   "com.android.systemui.SystemUIService"));  
  4.   //    Slog.d(TAG, "Starting service: " + intent);  
  5.       context.startService(intent);  

这样,我们就可以调试SystemUI这个APK了

调试过程中,发现这样调试还有一个问题,就是调试不到10s左右,adb调试跟eclipse自动断开了,这个是由于startService的超时导致ANR,我们可以针对这个调试把相应的ANR注释掉,在ActivityManagerService.Java的appNotResponding方法中添加如下代码:

[java] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. if(app.processName.equalsIgnoreCase("com.example.adbtool"))  
  2.     return ;  

到这里,我们就可以正常的调试SystemUI了。
0 0