use of com.android.tools.idea.run.ApkInfo in project android by JetBrains.
the class DeployIapkTask method perform.
@Override
public boolean perform(@NotNull IDevice device, @NotNull LaunchStatus launchStatus, @NotNull ConsolePrinter printer) {
if (!myApks.iterator().hasNext()) {
printer.stderr("No Iapk provided.");
return false;
}
ApkInfo iapk = myApks.iterator().next();
File localFile = iapk.getFile();
if (!localFile.exists()) {
String message = "The APK file " + localFile.getPath() + " does not exist on disk.";
printer.stderr(message);
return false;
}
// This is currently the required location for uploading IAPKs and is liable to change
String remotePath = "/sdcard/instantapps/" + localFile.getName();
printer.stdout("$ adb push " + localFile + " " + remotePath);
try {
// In theory this is the only required step for running / debugging an IAPK
device.pushFile(localFile.getPath(), remotePath);
// The following commands are liable to change as the Instant App runtime matures.
CountDownLatch latch = new CountDownLatch(3);
CollectingOutputReceiver receiver = new CollectingOutputReceiver(latch);
printer.stdout("Starting / refreshing Instant App services");
device.executeShellCommand("am startservice -a \"com.google.android.instantapps.devman.iapk.LOAD\" " + "--es \"com.google.android.instantapps.devman.iapk.IAPK_PATH\" " + "\"" + remotePath + "\" -n \"com.google.android.instantapps.devman\"/.iapk.IapkLoadService", receiver);
device.executeShellCommand("pm clear com.google.android.instantapps.supervisor", receiver);
device.executeShellCommand("am force-stop com.google.android.instantapps.supervisor", receiver);
latch.await(3000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
printer.stderr(e.toString());
return false;
}
printer.stdout("IAPK upload complete");
return true;
}
use of com.android.tools.idea.run.ApkInfo 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