int startActivityLocked(int userId, Intent intent, ActivityInfo info, IBinder resultTo, Bundle options, String resultWho, int requestCode) { optimizeTasksLocked(); ActivityRecord sourceRecord = findActivityByToken(userId, resultTo); TaskRecord sourceTask = sourceRecord != null ? sourceRecord.task : null; boolean clearTop = containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TOP); boolean clearTask = containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK); removeFlags(intent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); clearTarget = ClearTarget.TOP; if (containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { clearTarget = ClearTarget.TASK; } else { removeFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK); case LAUNCH_SINGLE_TOP: { singleTop = true; if (containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; clearTop = false; clearTarget = ClearTarget.TOP; reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY;
@Override public ComponentName getActivityClassForToken(int userId, IBinder token) { return mMainStack.getActivityClassForToken(userId, token); }
@Override public ComponentName getCallingActivity(int userId, IBinder token) { return mMainStack.getCallingActivity(userId, token); }
void onActivityResumed(int userId, IBinder token) { synchronized (mHistory) { optimizeTasksLocked(); ActivityRecord r = findActivityByToken(userId, token); if (r != null) { synchronized (r.task.activities) { r.task.activities.remove(r); r.task.activities.add(r); } } } }
int startActivitiesLocked(int userId, Intent[] intents, ActivityInfo[] infos, String[] resolvedTypes, IBinder token, Bundle options) { optimizeTasksLocked(); ReuseTarget reuseTarget = ReuseTarget.CURRENT; Intent intent = intents[0]; ActivityInfo info = infos[0]; ActivityRecord resultTo = findActivityByToken(userId, token); if (resultTo != null && resultTo.launchMode == LAUNCH_SINGLE_INSTANCE) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TOP)) { removeFlags(intent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); if (containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK) && !containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { removeFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK); if (containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; } else if (info.launchMode == LAUNCH_SINGLE_TASK) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; TaskRecord reuseTask = null; if (reuseTarget == ReuseTarget.AFFINITY) { reuseTask = findTaskByAffinityLocked(userId, affinity); } else if (reuseTarget == ReuseTarget.CURRENT) { reuseTask = resultTo.task; } else if (reuseTarget == ReuseTarget.DOCUMENT) { reuseTask = findTaskByIntentLocked(userId, intent); Intent[] destIntents = startActivitiesProcess(userId, intents, infos, resultTo); if (reuseTask == null) {
ComponentName getCallingActivity(int userId, IBinder token) { synchronized (mHistory) { ActivityRecord r = findActivityByToken(userId, token); if (r != null) { return r.caller != null ? r.caller : r.component; } return null; } }
@Override public String getPackageForToken(int userId, IBinder token) { return mMainStack.getPackageForToken(userId, token); }
@Override public String getCallingPackage(int userId, IBinder token) { return mMainStack.getCallingPackage(userId, token); }
private Intent startActivityProcess(int userId, ActivityRecord sourceRecord, Intent intent, ActivityInfo info) { intent = new Intent(intent); ProcessRecord targetApp = mService.startProcessIfNeedLocked(info.processName, userId, info.packageName); if (targetApp == null) { return null; } Intent targetIntent = new Intent(); targetIntent.setClassName(VirtualCore.get().getHostPkg(), fetchStubActivity(targetApp.vpid, info)); ComponentName component = intent.getComponent(); if (component == null) { component = ComponentUtils.toComponentName(info); } targetIntent.setType(component.flattenToString()); StubActivityRecord saveInstance = new StubActivityRecord(intent, info, sourceRecord != null ? sourceRecord.component : null, userId); saveInstance.saveToIntent(targetIntent); return targetIntent; }
int startActivitiesLocked(int userId, Intent[] intents, ActivityInfo[] infos, String[] resolvedTypes, IBinder token, Bundle options) { optimizeTasksLocked(); ReuseTarget reuseTarget = ReuseTarget.CURRENT; Intent intent = intents[0]; ActivityInfo info = infos[0]; ActivityRecord resultTo = findActivityByToken(userId, token); if (resultTo != null && resultTo.launchMode == LAUNCH_SINGLE_INSTANCE) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TOP)) { removeFlags(intent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); if (containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK) && !containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { removeFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK); if (containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; } else if (info.launchMode == LAUNCH_SINGLE_TASK) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; TaskRecord reuseTask = null; if (reuseTarget == ReuseTarget.AFFINITY) { reuseTask = findTaskByAffinityLocked(userId, affinity); } else if (reuseTarget == ReuseTarget.CURRENT) { reuseTask = resultTo.task; } else if (reuseTarget == ReuseTarget.DOCUMENT) { reuseTask = findTaskByIntentLocked(userId, intent); Intent[] destIntents = startActivitiesProcess(userId, intents, infos, resultTo); if (reuseTask == null) {
ActivityRecord onActivityDestroyed(int userId, IBinder token) { synchronized (mHistory) { optimizeTasksLocked(); ActivityRecord r = findActivityByToken(userId, token); if (r != null) { synchronized (r.task.activities) { r.task.activities.remove(r); // We shouldn't remove task at this point, // it will be removed by optimizeTasksLocked(). } } return r; } }
ComponentName getActivityClassForToken(int userId, IBinder token) { synchronized (mHistory) { ActivityRecord r = findActivityByToken(userId, token); if (r != null) { return r.component; } return null; } }
@Override public String getPackageForToken(int userId, IBinder token) { return mMainStack.getPackageForToken(userId, token); }
@Override public String getCallingPackage(int userId, IBinder token) { return mMainStack.getCallingPackage(userId, token); }
private Intent startActivityProcess(int userId, ActivityRecord sourceRecord, Intent intent, ActivityInfo info) { intent = new Intent(intent); ProcessRecord targetApp = mService.startProcessIfNeedLocked(info.processName, userId, info.packageName); if (targetApp == null) { return null; } Intent targetIntent = new Intent(); targetIntent.setClassName(VirtualCore.get().getHostPkg(), fetchStubActivity(targetApp.vpid, info)); ComponentName component = intent.getComponent(); if (component == null) { component = ComponentUtils.toComponentName(info); } targetIntent.setType(component.flattenToString()); StubActivityRecord saveInstance = new StubActivityRecord(intent, info, sourceRecord != null ? sourceRecord.component : null, userId); saveInstance.saveToIntent(targetIntent); return targetIntent; }
int startActivityLocked(int userId, Intent intent, ActivityInfo info, IBinder resultTo, Bundle options, String resultWho, int requestCode) { optimizeTasksLocked(); ActivityRecord sourceRecord = findActivityByToken(userId, resultTo); TaskRecord sourceTask = sourceRecord != null ? sourceRecord.task : null; boolean clearTop = containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TOP); boolean clearTask = containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK); removeFlags(intent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); clearTarget = ClearTarget.TOP; if (containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { clearTarget = ClearTarget.TASK; } else { removeFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK); case LAUNCH_SINGLE_TOP: { singleTop = true; if (containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; clearTop = false; clearTarget = ClearTarget.TOP; reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY;
int startActivitiesLocked(int userId, Intent[] intents, ActivityInfo[] infos, String[] resolvedTypes, IBinder token, Bundle options) { optimizeTasksLocked(); ReuseTarget reuseTarget = ReuseTarget.CURRENT; Intent intent = intents[0]; ActivityInfo info = infos[0]; ActivityRecord resultTo = findActivityByToken(userId, token); if (resultTo != null && resultTo.launchMode == LAUNCH_SINGLE_INSTANCE) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TOP)) { removeFlags(intent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); if (containFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK) && !containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { removeFlags(intent, Intent.FLAG_ACTIVITY_CLEAR_TASK); if (containFlags(intent, Intent.FLAG_ACTIVITY_NEW_TASK)) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; } else if (info.launchMode == LAUNCH_SINGLE_TASK) { reuseTarget = containFlags(intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK) ? ReuseTarget.MULTIPLE : ReuseTarget.AFFINITY; TaskRecord reuseTask = null; if (reuseTarget == ReuseTarget.AFFINITY) { reuseTask = findTaskByAffinityLocked(userId, affinity); } else if (reuseTarget == ReuseTarget.CURRENT) { reuseTask = resultTo.task; } else if (reuseTarget == ReuseTarget.DOCUMENT) { reuseTask = findTaskByIntentLocked(userId, intent); Intent[] destIntents = startActivitiesProcess(userId, intents, infos, resultTo); if (reuseTask == null) {
ActivityRecord onActivityDestroyed(int userId, IBinder token) { synchronized (mHistory) { optimizeTasksLocked(); ActivityRecord r = findActivityByToken(userId, token); if (r != null) { synchronized (r.task.activities) { r.task.activities.remove(r); // We shouldn't remove task at this point, // it will be removed by optimizeTasksLocked(). } } return r; } }
public String getCallingPackage(int userId, IBinder token) { synchronized (mHistory) { ActivityRecord r = findActivityByToken(userId, token); if (r != null) { return r.caller != null ? r.caller.getPackageName() : "android"; } return "android"; } }
@Override public String getPackageForToken(int userId, IBinder token) { return mMainStack.getPackageForToken(userId, token); }