这部分的代码都@frameworks\base\services\java\com\android\server\
SystemServer.java
// We now tell the activity manager it is okay to run third party
// code. It will call back into us once it has gotten to the state
// where third party code can really run (but before it has actually
// started launching the initial applications), for us to complete our
// initialization.
ActivityManagerService.self().systemReady(new Runnable() {
...
}
注:从这里开始启动第三方代码。
ActivityManagerService.java
public void systemReady(final Runnable goingCallback) {
...
mMainStack.resumeTopActivityLocked(null);
...
}
注://恢复 top activity
ActivityStack.java
final boolean resumeTopActivityLocked(ActivityRecord prev) {
...
if (next == null) {
// There are no more activities! Let's just start up the
// Launcher...
if (mMainStack) {
return mService.startHomeActivityLocked();
}
}
...
}
注:因为现在没有任何启动的 activity, 将会启动 startHomeActivityLocked
ActivityManagerService.java
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; } Intent intent = new Intent( mTopAction, mTopData != null ? Uri.parse(mTopData) : null); intent.setComponent(mTopComponent); intent.setComponent(new ComponentName("com.amlogic.launcher", "com.amlogic.launcher.Launcher_new")); if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { intent.addCategory(Intent.CATEGORY_HOME); } 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.applicationInfo, userId); ProcessRecord app = getProcessRecordLocked(aInfo.processName, aInfo.applicationInfo.uid); if (app == null || app.instrumentationClass == null) { if(SystemProperties.getBoolean("ro.tv.source_rember", false)) { if(SystemProperties.getBoolean("persist.tv.first_start", true)) { intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); mMainStack.startActivityLocked(null, intent, null, aInfo, null, null, 0, 0, 0, 0, null, false, null); } else { Intent intent_start_tvsetup = new Intent("com.tv.TvSetup.TvSetupService") ; startService( null , intent_start_tvsetup , null ,0); Log.d(TAG, "don't start Luncher for persist.tv.source_android=false"); } } else { intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); mMainStack.startActivityLocked(null, intent, null, aInfo, null, null, 0, 0, 0, 0, null, false, null); Log.d(TAG, " {" + intent.toShortString(true, true, true, false) + "} " ); Log.d(TAG, "startActivityLocked Luncher start"); } } }
return true; } |
boolean startHomeActivityLocked() {
...
intent.addCategory(Intent.CATEGORY_HOME);
...
}
注:启动CATEGORY_HOME的activity
final void finishBooting() {
...
new Intent(Intent.ACTION_BOOT_COMPLETED, null),
...
}
注:发出ACTION_BOOT_COMPLETED的广播