###源码位置com.android.server.am.ActivityManagerService.java
public final class ActivityManagerService extends ActivityManagerNative
implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback {}
ActivityManagerService.java继承了ActivityManagerNative,而ActivityManagerNative实现了
IActivityManager的接口
查看startActivity方法
//caller 调用的主线程
//callingPackage 包名
//intent
//resolvedType
//resultTo
//resultWho
//requestCode
//startFlags
//profilerInfo
//bOptions
@Override
public final int startActivity(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle options) {
return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
resultWho, requestCode, startFlags, profilerInfo, options,
UserHandle.getCallingUserId());
}
接着调用了startActivityAsUser方法,多传入了一个int类型的userId参数
总得来说startActivityAsUser就是做一下调用者的基本权限的检查
@Override
public final int startActivityAsUser(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle options, int userId) {
//检查调用者是否被隔离,如果被隔离会抛出SecurityException。
enforceNotIsolatedCaller("startActivity");
//检查调用者是否有权限执行call操作
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, ALLOW_FULL_ONLY, "startActivity", null);
// TODO: Switch to user app stacks here.
return mStackSupervisor.startActivityMayWait(caller, -1, callingPackage, intent,
resolvedType, null, null, resultTo, resultWho, requestCode, startFlags,
profilerInfo, null, null, options, false, userId, null, null);
}
####SDK23会走这里 接着又调用了ActivityStackSupervisor-startActivityMayWait方法,先走API23这个流程
####SDK25会走这里 接着又调用了ActivityStarter-startActivityMayWait方法,以后再说
###参考资料
####http://blog.csdn.net/chenkai19920410/article/details/54344295