System UI 调试方法

来源:互联网 发布:大华淘宝客助手 编辑:程序博客网 时间:2024/05/21 04:43

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

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

    static final void startSystemUi(Context context) {        Intent intent = new Intent();        intent.setComponent(new ComponentName("com.android.systemui",                    "com.android.systemui.SystemUIService"));        //Slog.d(TAG, "Starting service: " + intent);       // context.startServiceAsUser(intent, UserHandle.OWNER);    }

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

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

 Intent intent = new Intent();        intent.setComponent(new ComponentName("com.android.systemui",                    "com.android.systemui.SystemUIService"));    //    Slog.d(TAG, "Starting service: " + intent);        context.startService(intent);

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

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

        if(app.processName.equalsIgnoreCase("com.example.adbtool"))        return ;

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

1 1
原创粉丝点击