Search in sources :

Example 1 with ShowLogcatTask

use of com.android.tools.idea.run.tasks.ShowLogcatTask in project intellij by bazelbuild.

the class BlazeAndroidLaunchTasksProvider method getTasks.

@NotNull
@Override
public List<LaunchTask> getTasks(@NotNull IDevice device, @NotNull LaunchStatus launchStatus, @NotNull ConsolePrinter consolePrinter) throws ExecutionException {
    final List<LaunchTask> launchTasks = Lists.newArrayList();
    Integer userId = runContext.getUserId(device, consolePrinter);
    launchOptionsBuilder.setPmInstallOptions(UserIdHelper.getFlagsFromUserId(userId));
    LaunchOptions launchOptions = launchOptionsBuilder.build();
    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 launchTasks;
    }
    String packageName;
    try {
        packageName = applicationIdProvider.getPackageName();
        ProcessHandlerLaunchStatus processHandlerLaunchStatus = (ProcessHandlerLaunchStatus) launchStatus;
        LaunchTask appLaunchTask = runContext.getApplicationLaunchTask(launchOptions, userId, debuggerManager.getAndroidDebugger(), debuggerManager.getAndroidDebuggerState(project), processHandlerLaunchStatus);
        if (appLaunchTask != null) {
            launchTasks.add(appLaunchTask);
        }
    } catch (ApkProvisionException e) {
        LOG.error(e);
        launchStatus.terminateLaunch("Unable to determine application id: " + e);
        return ImmutableList.of();
    } catch (ExecutionException e) {
        launchStatus.terminateLaunch(e.getMessage());
        return ImmutableList.of();
    }
    if (!launchOptions.isDebug() && launchOptions.isOpenLogcatAutomatically()) {
        launchTasks.add(new ShowLogcatTask(project, packageName));
    }
    return launchTasks;
}
Also used : ShowLogcatTask(com.android.tools.idea.run.tasks.ShowLogcatTask) LaunchOptions(com.android.tools.idea.run.LaunchOptions) ProcessHandlerLaunchStatus(com.android.tools.idea.run.util.ProcessHandlerLaunchStatus) ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) ClearLogcatTask(com.android.tools.idea.run.tasks.ClearLogcatTask) LaunchTask(com.android.tools.idea.run.tasks.LaunchTask) ExecutionException(com.intellij.execution.ExecutionException) DismissKeyguardTask(com.android.tools.idea.run.tasks.DismissKeyguardTask) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ApkProvisionException (com.android.tools.idea.run.ApkProvisionException)1 LaunchOptions (com.android.tools.idea.run.LaunchOptions)1 ClearLogcatTask (com.android.tools.idea.run.tasks.ClearLogcatTask)1 DismissKeyguardTask (com.android.tools.idea.run.tasks.DismissKeyguardTask)1 LaunchTask (com.android.tools.idea.run.tasks.LaunchTask)1 ShowLogcatTask (com.android.tools.idea.run.tasks.ShowLogcatTask)1 ProcessHandlerLaunchStatus (com.android.tools.idea.run.util.ProcessHandlerLaunchStatus)1 ExecutionException (com.intellij.execution.ExecutionException)1 NotNull (org.jetbrains.annotations.NotNull)1