因为跟launcher相关~~所以从startHomeActivityLocked开始,=.=
boolean startHomeActivityLocked(int userId) {
if (mHeadless) {
// Added because none of the other calls to ensureBootCompleted seem to fire
// when running headless.
ensureBootCompleted();
return false;
}
if (mFactoryTest == SystemServer.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;
}
// YUNOS BEGIN for OSUPATE on OTT
// @author lijing.lj@alibaba-inc.com
// Since set AliTvHomeshell as default home launcher, so that add osupdate support at here
// YUNOS BEGIN for OSUPATE on OTT
// @author lijing.lj@alibaba-inc.com
// Since set AliTvHomeshell as default home launcher, so that add osupdate support at here
/* android code
Intent intent = new Intent(
mTopAction,
mTopData != null ? Uri.parse(mTopData) : null);
intent.setComponent(mTopComponent);
if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
intent.addCategory(Intent.CATEGORY_HOME);
}
ActivityInfo aInfo =
resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
*/
Intent intent = new Intent(
mTopAction,
mTopData != null ? Uri.parse(mTopData) : null);
ActivityInfo aInfo = null;
if (mBooting) {
Slog.i(TAG, "check if com.yunos.osupdate RebootUpdateActivity exists");
intent.setComponent(new ComponentName("com.yunos.osupdate", "com.yunos.osupdate.front.RebootUpdateActivity"));
aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
}
if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
intent.addCategory(Intent.CATEGORY_HOME);
}
if (aInfo == null) {
if (mBooting) {
Slog.i(TAG, "no com.yunos.osupdate RebootUpdateActivity, start homeshell");
}
intent.setComponent(mTopComponent);
aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
}
// YUNOS END for OSUPATE on OTT
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.applicationInfo, userId);
ProcessRecord app = getProcessRecordLocked(aInfo.processName,
aInfo.applicationInfo.uid, true);
if (app == null || app.instrumentationClass == null) {
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
mStackSupervisor.startHomeActivity(intent, aInfo);
}
}
return true;
}
private ActivityInfo resolveActivityInfo(Intent intent, int flags, int userId) {
ActivityInfo ai = null;
ComponentName comp = intent.getComponent();
try {
if (comp != null) {
ai = AppGlobals.getPackageManager().getActivityInfo(comp, flags, userId);
} else {
ResolveInfo info = AppGlobals.getPackageManager().resolveIntent(
intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
flags, userId);
if (info != null) {
ai = info.activityInfo;
}
}
} catch (RemoteException e) {
// ignore
}
return ai;
}
新建带MAIN action的Intent--->resolveActivityInfo()进行隐式Intent匹配获取Activity,mStackSupervisor.startHomeActivity()进入Launcher