1, launcher
2, ams :: LauncherActivity
3, ams::startProcessLocked
int pid = Process.start("android.app.ActivityThread",
mSimpleProcessManagement ? app.processName : null, uid, uid,
gids, debugFlags, null);
4, vm ?
5, ActivityThread -> main()
6, ActivityThread
public static final void main(String[] args) {
.......
ActivityThread thread = new ActivityThread();
thread.attach(false);
......
Looper.loop();
.......
thread.detach();
......
}
6.1 ActivityStack::resumeTopActivityLocked
startPausingLocked(userLeaving, false);
....
next.app.thread.scheduleResumeActivity(next.appToken,
mService.isNextTransitionForward());
....
7, ActivityStack :: startSpecificActivityLocked(next, true, true);
8,. ActivityStack.realStartActivityLocked
9, ActivityThread.handleLaunchActivity
10, onCreate
11,onResume
12, completeResumeLocked
private final void completeResumeLocked(ActivityRecord next) {
next.idle = false;
next.results = null;
next.newIntents = null;
// schedule an idle timeout in case the app doesn't do it for us.
Message msg = mHandler.obtainMessage(IDLE_TIMEOUT_MSG);
msg.obj = next;
mHandler.sendMessageDelayed(msg, IDLE_TIMEOUT);
if (false) {
// The activity was never told to pause, so just keep
// things going as-is. To maintain our own state,
// we need to emulate it coming back and saying it is
// idle.
msg = mHandler.obtainMessage(IDLE_NOW_MSG);
msg.obj = next;
mHandler.sendMessage(msg);
}
if (mMainStack) {
mService.reportResumedActivityLocked(next);
}
if (mMainStack) {
mService.setFocusedActivityLocked(next);
}
next.resumeKeyDispatchingLocked();
ensureActivitiesVisibleLocked(null, 0);
mService.mWindowManager.executeAppTransition();
mNoAnimActivities.clear();
// Mark the point when the activity is resuming
// TODO: To be more accurate, the mark should be before the onCreate,
// not after the onResume. But for subsequent starts, onResume is fine.
if (next.app != null) {
synchronized (mService.mProcessStatsThread) {
next.cpuTimeAtResume = mService.mProcessStats.getCpuTimeForPid(next.app.pid);
}
} else {
next.cpuTimeAtResume = 0; // Couldn't get the cpu time of process
}
}