use of com.android.tools.fd.client.InstantRunArtifact 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;
}
use of com.android.tools.fd.client.InstantRunArtifact in project android by JetBrains.
the class InstantRunBuildAnalyzer method getIrDebugSignals.
@NotNull
private Map<String, String> getIrDebugSignals(@NotNull DeployType deployType) {
Map<String, String> m = new HashMap<>();
m.put("deployType", deployType.toString());
m.put("canReuseProcessHandler", Boolean.toString(canReuseProcessHandler()));
m.put("androidGradlePluginVersion", myContext.getGradlePluginVersion().toString());
BuildSelection selection = myContext.getBuildSelection();
if (selection != null) {
m.put("buildSelection.mode", selection.getBuildMode().toString());
m.put("buildSelection.why", selection.why.toString());
}
InstantRunBuildInfo buildInfo = myContext.getInstantRunBuildInfo();
if (buildInfo != null) {
m.put("buildinfo.buildMode", buildInfo.getBuildMode());
m.put("buildinfo.verifierStatus", buildInfo.getVerifierStatus());
m.put("buildinfo.format", Integer.toString(buildInfo.getFormat()));
List<InstantRunArtifact> artifacts = buildInfo.getArtifacts();
m.put("buildinfo.nArtifacts", Integer.toString(artifacts.size()));
for (int i = 0; i < artifacts.size(); i++) {
InstantRunArtifact artifact = artifacts.get(i);
String prefix = "buildInfo.artifact[" + i + "]";
m.put(prefix + ".type", artifact.type.toString());
m.put(prefix + ".file", artifact.file.getName());
}
}
return m;
}
use of com.android.tools.fd.client.InstantRunArtifact in project android by JetBrains.
the class InstantRunBuildAnalyzer method getApks.
private static Collection<ApkInfo> getApks(@NotNull InstantRunBuildInfo buildInfo, @NotNull InstantRunContext context) throws ExecutionException {
List<ApkInfo> apks = new SmartList<>();
for (InstantRunArtifact artifact : buildInfo.getArtifacts()) {
if (artifact.type != MAIN) {
String msg = "Expected to only find apks, but got : " + artifact.type + "\n";
BuildSelection buildSelection = context.getBuildSelection();
assert buildSelection != null : "Build must have completed before apks are obtained";
if (buildSelection.getBuildMode() == BuildMode.HOT) {
msg += "Could not use hot-swap artifacts when there is no existing session.";
} else {
msg += "Unexpected artifacts for build mode: " + buildSelection.getBuildMode();
}
InstantRunManager.LOG.error(msg);
throw new ExecutionException(msg);
}
apks.add(new ApkInfo(artifact.file, context.getApplicationId()));
}
return apks;
}
Aggregations