Search in sources :

Example 1 with LaunchTasksProvider

use of com.android.tools.idea.run.tasks.LaunchTasksProvider in project android by JetBrains.

the class AndroidRunState method execute.

@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    ProcessHandler processHandler;
    ConsoleView console;
    String applicationId;
    try {
        applicationId = myApplicationIdProvider.getPackageName();
    } catch (ApkProvisionException e) {
        throw new ExecutionException("Unable to obtain application id", e);
    }
    // TODO: this class is independent of gradle, except for this hack
    AndroidModuleModel model = AndroidModuleModel.get(myModule);
    if (InstantRunSettings.isInstantRunEnabled() && InstantRunGradleUtils.getIrSupportStatus(model, null) == InstantRunGradleSupport.SUPPORTED) {
        assert model != null;
        InstantRunBuildInfo info = InstantRunGradleUtils.getBuildInfo(model);
        if (info != null && !info.isCompatibleFormat()) {
            throw new ExecutionException("This version of Android Studio is incompatible with the Gradle Plugin used. " + "Try disabling Instant Run (or updating either the IDE or the Gradle plugin to " + "the latest version)");
        }
    }
    LaunchTasksProvider launchTasksProvider = myLaunchTasksProviderFactory.get();
    if (launchTasksProvider.createsNewProcess()) {
        // and the new one).
        if (myPreviousSessionProcessHandler != null) {
            myPreviousSessionProcessHandler.detachProcess();
        }
        processHandler = new AndroidProcessHandler(applicationId, launchTasksProvider.monitorRemoteProcess());
        console = attachConsole(processHandler, executor);
    } else {
        assert myPreviousSessionProcessHandler != null : "No process handler from previous session, yet current tasks don't create one";
        processHandler = myPreviousSessionProcessHandler;
        console = null;
    }
    LaunchInfo launchInfo = new LaunchInfo(executor, runner, myEnv, myConsoleProvider);
    LaunchTaskRunner task = new LaunchTaskRunner(myModule.getProject(), myLaunchConfigName, launchInfo, processHandler, myDeviceFutures, launchTasksProvider);
    ProgressManager.getInstance().run(task);
    return console == null ? null : new DefaultExecutionResult(console, processHandler);
}
Also used : InstantRunBuildInfo(com.android.tools.fd.client.InstantRunBuildInfo) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ConsoleView(com.intellij.execution.ui.ConsoleView) LaunchTasksProvider(com.android.tools.idea.run.tasks.LaunchTasksProvider) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionException(com.intellij.execution.ExecutionException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

InstantRunBuildInfo (com.android.tools.fd.client.InstantRunBuildInfo)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 LaunchTasksProvider (com.android.tools.idea.run.tasks.LaunchTasksProvider)1 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)1 ExecutionException (com.intellij.execution.ExecutionException)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 Nullable (org.jetbrains.annotations.Nullable)1