use of com.android.tools.fd.client.InstantRunBuildInfo in project android by JetBrains.
the class InstantRunStatsService method notifyDeployType.
public void notifyDeployType(@NotNull DeployType type, @NotNull InstantRunContext context, @NotNull IDevice device) {
BuildSelection selection = context.getBuildSelection();
BuildCause buildCause = selection == null ? null : selection.why;
InstantRunBuildInfo buildInfo = context.getInstantRunBuildInfo();
String verifierStatus = buildInfo == null ? "unknown" : buildInfo.getVerifierStatus();
notifyDeployType(type, buildCauseToProto(buildCause), verifierStatusToProto(verifierStatus), context.getGradlePluginVersion().toString(), device);
}
use of com.android.tools.fd.client.InstantRunBuildInfo 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);
}
use of com.android.tools.fd.client.InstantRunBuildInfo in project android by JetBrains.
the class AndroidLaunchTasksProviderFactory method get.
@NotNull
@Override
public LaunchTasksProvider get() {
Project project = myEnv.getProject();
InstantRunStatsService.get(project).notifyDeployStarted();
InstantRunBuildAnalyzer analyzer = null;
InstantRunBuildInfo instantRunBuildInfo = myInstantRunContext != null ? myInstantRunContext.getInstantRunBuildInfo() : null;
if (instantRunBuildInfo != null) {
analyzer = new InstantRunBuildAnalyzer(project, myInstantRunContext, myPreviousSessionProcessHandler);
if (InstantRunSettings.isRecorderEnabled()) {
if (!myDeviceFutures.getDevices().isEmpty()) {
// Instant Run is guaranteed to be for exactly 1 device
FlightRecorder.get(project).setLaunchTarget(myDeviceFutures.getDevices().get(0));
}
FlightRecorder.get(project).saveBuildInfo(instantRunBuildInfo);
}
}
if (analyzer != null && analyzer.canReuseProcessHandler()) {
return new UpdateSessionTasksProvider(analyzer);
}
return new AndroidLaunchTasksProvider(myRunConfig, myEnv, myFacet, analyzer, myApplicationIdProvider, myApkProvider, myLaunchOptions);
}
use of com.android.tools.fd.client.InstantRunBuildInfo in project android by JetBrains.
the class InstantRunBuilder method buildTimestampsMatch.
/**
* Returns whether the device has the same timestamp as the existing build on disk.
*/
private boolean buildTimestampsMatch(@NotNull IDevice device, @Nullable Integer userId) {
InstantRunBuildInfo instantRunBuildInfo = myInstantRunContext.getInstantRunBuildInfo();
String localTimestamp = instantRunBuildInfo == null ? null : instantRunBuildInfo.getTimeStamp();
if (StringUtil.isEmpty(localTimestamp)) {
InstantRunManager.LOG.info("Local build timestamp is empty!");
return false;
}
// https://code.google.com/p/android/issues/detail?id=198715
if (!isAppInstalledForUser(device, myInstantRunContext.getApplicationId(), userId)) {
return false;
}
String deviceBuildTimestamp = myInstantRunClientDelegate.getDeviceBuildTimestamp(device, myInstantRunContext);
InstantRunManager.LOG.info(String.format("Build timestamps: Local: %1$s, Device: %2$s", localTimestamp, deviceBuildTimestamp));
return localTimestamp.equals(deviceBuildTimestamp);
}
use of com.android.tools.fd.client.InstantRunBuildInfo in project android by JetBrains.
the class SplitApkDeployTask method perform.
@Override
public boolean perform(@NotNull IDevice device, @NotNull LaunchStatus launchStatus, @NotNull ConsolePrinter printer) {
InstantRunBuildInfo buildInfo = myInstantRunContext.getInstantRunBuildInfo();
assert buildInfo != null;
List<InstantRunArtifact> artifacts = buildInfo.getArtifacts();
// TODO: should we pass in pm install options?
List<String> installOptions = Lists.newArrayList();
if (buildInfo.isPatchBuild()) {
// partial install
installOptions.add("-p");
installOptions.add(myInstantRunContext.getApplicationId());
}
List<File> apks = Lists.newArrayListWithExpectedSize(artifacts.size());
for (InstantRunArtifact artifact : artifacts) {
if (artifact.type == InstantRunArtifactType.SPLIT_MAIN || artifact.type == InstantRunArtifactType.SPLIT) {
apks.add(artifact.file);
}
}
RetryingInstaller.Installer installer = new SplitApkInstaller(printer, apks, installOptions);
RetryingInstaller retryingInstaller = new RetryingInstaller(myProject, device, installer, myInstantRunContext.getApplicationId(), printer, launchStatus);
boolean status = retryingInstaller.install();
if (status) {
printer.stdout("Split APKs installed");
}
assert myInstantRunContext.getBuildSelection() != null;
InstantRunStatsService.get(myProject).notifyDeployType(DeployType.SPLITAPK, myInstantRunContext, device);
return status;
}
Aggregations