use of com.taobao.android.builder.tools.command.CommandExecutor in project atlas by alibaba.
the class AwoInstaller method notifyApppatching.
/**
* todo how know which app will be debugged?
* just support taobao.apk now
*/
private static void notifyApppatching(AndroidBuilder androidBuilder, String patchPkg, Logger logger) {
CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger(logger);
executor.setCaptureStdOut(true);
executor.setCaptureStdErr(true);
// List<String> killCmd = Arrays.asList("shell", "am", "force-stop", packageNameForPatch);
// List<String> startCmd = Arrays.asList("shell", "am", "start", packageNameForPatch + "/" + launcherActivityForPatch);
List<String> patchCmd = Arrays.asList("shell", "am", "broadcast", "-a", "com.taobao.atlas.intent.PATCH_APP", "-e", "pkg", patchPkg);
try {
executor.executeCommand(androidBuilder.getSdkInfo().getAdb().getAbsolutePath(), patchCmd, false);
} catch (Exception e) {
throw new RuntimeException("error while restarting app,you can also restart by yourself", e);
}
}
use of com.taobao.android.builder.tools.command.CommandExecutor in project atlas by alibaba.
the class AwoInstaller method installPatchIfDeviceConnected.
/**
* no device or too many device make install fail
*
* @param patch
* @return
*/
private static boolean installPatchIfDeviceConnected(AndroidBuilder androidBuilder, File patch, String patchPkg, Logger logger) {
final AndroidDebugBridge androidDebugBridge = initAndroidDebugBridge(androidBuilder);
if (!androidDebugBridge.isConnected()) {
throw new RuntimeException("Android Debug Bridge is not connected.");
}
waitForInitialDeviceList(androidDebugBridge, logger);
List<IDevice> devices = Arrays.asList(androidDebugBridge.getDevices());
String PATCH_INSTALL_DIRECTORY = String.format("%s%s%s", PATCH_INSTALL_DIRECTORY_PREFIX, patchPkg, PATCH_INSTALL_DIRECTORY_SUFFIX);
if (devices.size() == 0) {
throw new RuntimeException(String.format("%s%s%s%s%s", "no device connected,please check whether the connection is successful or copy ", patch, " in build/outputs/awbs/libxxx.so ", PATCH_INSTALL_DIRECTORY, " and restart you app"));
}
if (devices.size() > 1) {
throw new RuntimeException("too much devices be connected,please disconnect the others and try again");
}
CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger(logger);
executor.setCaptureStdOut(true);
executor.setCaptureStdErr(true);
List<String> cmd = Arrays.asList("push", patch.getAbsolutePath(), PATCH_INSTALL_DIRECTORY + patch.getName());
try {
executor.executeCommand(androidBuilder.getSdkInfo().getAdb().getAbsolutePath(), cmd, false);
return true;
} catch (ExecutionException e) {
throw new RuntimeException("Error while trying to push patch to device ", e);
} finally {
String errout = executor.getStandardError();
if ((errout != null) && (errout.trim().length() > 0)) {
logger.error(errout);
}
}
}
Aggregations