in aswb/sdkcompat/as213/com/google/idea/blaze/android/run/runner/BlazeAndroidLaunchTasksProvider.java [70:173]
public List<LaunchTask> getTasks(
@NotNull IDevice device,
@NotNull LaunchStatus launchStatus,
@NotNull ConsolePrinter consolePrinter)
throws ExecutionException {
final List<LaunchTask> launchTasks = Lists.newArrayList();
String packageName;
try {
packageName = applicationIdProvider.getPackageName();
} catch (ApkProvisionException e) {
LOG.error(e);
launchStatus.terminateLaunch("Unable to determine application id: " + e, true);
return ImmutableList.of();
}
Integer userId = runContext.getUserId(device, consolePrinter);
String userIdFlags = UserIdHelper.getFlagsFromUserId(userId);
String skipVerification =
ApkVerifierTracker.getSkipVerificationInstallationFlag(device, packageName);
String pmInstallOption;
if (skipVerification != null) {
pmInstallOption = userIdFlags + " " + skipVerification;
} else {
pmInstallOption = userIdFlags;
}
launchOptionsBuilder.setPmInstallOptions(d -> pmInstallOption);
LaunchOptions launchOptions = launchOptionsBuilder.build();
// NOTE: Task for opening the profiler tool-window should come before deployment
// to ensure the tool-window opens correctly. This is required because starting
// the profiler session requires the tool-window to be open.
if (isProfilerLaunch(runContext.getExecutor())) {
launchTasks.add(new BlazeAndroidOpenProfilerWindowTask(project));
}
if (launchOptions.isClearLogcatBeforeStart()) {
launchTasks.add(new ClearLogcatTask(project));
}
launchTasks.add(new DismissKeyguardTask());
if (launchOptions.isDeploy()) {
ImmutableList<LaunchTask> deployTasks = runContext.getDeployTasks(device, launchOptions);
launchTasks.addAll(deployTasks);
}
if (launchStatus.isLaunchTerminated()) {
return ImmutableList.copyOf(launchTasks);
}
try {
if (launchOptions.isDebug()) {
launchTasks.add(new CheckApkDebuggableTask(runContext.getBuildStep().getDeployInfo()));
}
ImmutableList.Builder<String> amStartOptions = ImmutableList.builder();
amStartOptions.add(runContext.getAmStartOptions());
if (isProfilerLaunch(runContext.getExecutor())) {
amStartOptions.add(
AndroidProfilerLaunchTaskContributor.getAmStartOptions(
project,
packageName,
runContext.getProfileState(),
device,
runContext.getExecutor()));
launchTasks.add(
new AndroidProfilerLaunchTaskContributor.AndroidProfilerToolWindowLaunchTask(
project, packageName));
}
// Do not get debugger state directly from the debugger itself.
// See BlazeAndroidDebuggerService#getDebuggerState for an explanation.
BlazeAndroidDebuggerService debuggerService =
BlazeAndroidDebuggerService.getInstance(project);
AndroidDebugger debugger =
debuggerService.getDebugger(isNativeDebuggingEnabled(launchOptions));
AndroidDebuggerState debuggerState = debuggerService.getDebuggerState(debugger);
LaunchTask appLaunchTask =
runContext.getApplicationLaunchTask(
launchOptions,
userId,
String.join(" ", amStartOptions.build()),
debugger,
debuggerState,
launchStatus);
if (appLaunchTask != null) {
launchTasks.add(appLaunchTask);
}
} catch (ApkProvisionException e) {
LOG.error(e);
launchStatus.terminateLaunch("Unable to determine application id: " + e, true);
return ImmutableList.of();
} catch (ExecutionException e) {
launchStatus.terminateLaunch(e.getMessage(), true);
return ImmutableList.of();
}
if (!launchOptions.isDebug() && launchOptions.isOpenLogcatAutomatically()) {
launchTasks.add(new ShowLogcatTask(project, packageName));
}
return ImmutableList.copyOf(launchTasks);
}