参考链接
AMS
ActivityStarter
class ActivityStarter {
private final ActivityManagerService mService;
private final ActivityStackSupervisor mSupervisor;
private ActivityStartInterceptor mInterceptor;
private WindowManagerService mWindowManager;
// Share state variable among methods when starting an activity.
private ActivityRecord mStartActivity;
private Intent mIntent;
private ActivityStack mSourceStack;
private ActivityStack mTargetStack;
}
ActivityStackSupervisor
ActivityStackSupervisor是管理ActivityStack的重要类,操作ActivityStack
public final class ActivityStackSupervisor implements DisplayListener {
/** The stack containing the launcher app. Assumed to always be attached to
* Display.DEFAULT_DISPLAY. */
ActivityStack mHomeStack;
/** The stack currently receiving input or launching the next activity. */
ActivityStack mFocusedStack;
/** If this is the same as mFocusedStack then the activity on the top of the focused stack has
* been resumed. If stacks are changing position this will hold the old stack until the new
* stack becomes resumed after which it will be set to mFocusedStack. */
private ActivityStack mLastFocusedStack;
}
ActivityStack
//State and management of a single stack of activities.
final class ActivityStack {
/**
* The back history of all previous (and possibly still
* running) activities. It contains #TaskRecord objects.
*/
private final ArrayList<TaskRecord> mTaskHistory = new ArrayList<>();
/** Run all ActivityStacks through this */
final ActivityStackSupervisor mStackSupervisor;
}
TaskRecord
final class TaskRecord {
/** Current stack */
ActivityStack stack;
/** List of all activities in the task arranged in history order */
final ArrayList<ActivityRecord> mActivities;
}
ActivityRecord
/**
* An entry in the history stack, representing an activity.
*/
final class ActivityRecord {
TaskRecord task; // the task this is in.
}