赞
踩
问题描述:在android9.0的机器上,重启设备之后,开机动画结束之后,在launcher 拉起来之前,总是会黑个几秒钟,很影响用户体验.
研究问题:
1.刚开始认为是系统或者launcher发生了crash,然后黑屏,然后launcher重启
但是抓了一份完整的log之后发现并没有相关crash的相关信息.同时我又下载了个第三方的桌面,重启之后仍然有黑屏的现象,所以说这个和launcher本身是没有关系的.
2.那接下来就继续分析log了.
12-31 11:00:01.385 2868 2868 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000100 cmp=com.android.tv.settings/.system.FallbackHome} from uid 0
…
12-31 11:00:03.831 2868 2882 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000100 cmp=com.oversea.aslauncher/.ui.main.MainActivity} from uid 0
发现系统在启动launcher之前,会先启动一下Settings里面的FallBackHome,看源码可知这是一个透明无界面的activity.然后两秒之后才会启动我们的launcher. 那按照这个线索分析,为什么会先启动这个fallbackhome呢?
先来缕一下系统启动完成之后启动launcher的流程:
1.ActivityManagerService.systemReady()
当systemserver将各项系统服务启动完成之后,这些system server会走对应的systemReady函数.而和启动launcher相关的是AMS的systemReady:
public void systemReady(final Runnable goingCallback, TimingsTraceLog traceLog) {
traceLog.traceBegin(“PhaseActivityManagerReady”);
/省略无数行代码*****/
startHomeActivityLocked(currentUserId, “systemReady”);
/省略无数行代码*****/
traceLog.traceEnd(); // PhaseActivityManagerReady
}
boolean startHomeActivityLocked(int userId, String reason) {
if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL
&& mTopAction == null) {
// We are running in factory test mode, but unable to find
// the factory test app, so just sit around displaying the
// error message and don’t try to start anything.
return false;
}
Intent intent = getHomeIntent(); //获取当前的homeIntent
ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
if (aInfo != null) {
intent.setComponent(new ComponentName(aInfo.applicationInfo.packageName, aInfo.name));
// Don’t do this if the home app is currently being
// instrumented.
aInfo = new ActivityInfo(aInfo);
aInfo.applicationInfo = getAppInfoForUser(aInfo
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。