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);
}
Aggregations