Search in sources :

Example 1 with InstantRunArtifact

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;
}
Also used : InstantRunBuildInfo(com.android.tools.fd.client.InstantRunBuildInfo) RetryingInstaller(com.android.tools.idea.run.RetryingInstaller) InstantRunArtifact(com.android.tools.fd.client.InstantRunArtifact) File(java.io.File)

Example 2 with InstantRunArtifact

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;
}
Also used : InstantRunBuildInfo(com.android.tools.fd.client.InstantRunBuildInfo) HashMap(java.util.HashMap) InstantRunArtifact(com.android.tools.fd.client.InstantRunArtifact) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with InstantRunArtifact

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;
}
Also used : ApkInfo(com.android.tools.idea.run.ApkInfo) InstantRunArtifact(com.android.tools.fd.client.InstantRunArtifact) SmartList(com.intellij.util.SmartList) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

InstantRunArtifact (com.android.tools.fd.client.InstantRunArtifact)3 InstantRunBuildInfo (com.android.tools.fd.client.InstantRunBuildInfo)2 ApkInfo (com.android.tools.idea.run.ApkInfo)1 RetryingInstaller (com.android.tools.idea.run.RetryingInstaller)1 ExecutionException (com.intellij.execution.ExecutionException)1 SmartList (com.intellij.util.SmartList)1 File (java.io.File)1 HashMap (java.util.HashMap)1 NotNull (org.jetbrains.annotations.NotNull)1