List of usage examples for org.apache.commons.io LineIterator hasNext
public boolean hasNext()
Reader
has more lines. From source file:com.nts.alphamale.handler.DeviceHandler.java
public static String installApp(String serial, String apkPath, int timeoutSecond) { String rtnValue = ""; Map<String, Object> executorMap = new AdbShellExecutor().execute( AdbShellCommand.cmd(serial, "cmd_install_app", new String[] { apkPath }), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; }//from w ww . j a va 2s .c o m LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { rtnValue += li.nextLine().trim(); } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static String unInstallApp(String serial, String packageName, int timeoutSecond) { String rtnValue = ""; Map<String, Object> executorMap = new AdbShellExecutor().execute( AdbShellCommand.cmd(serial, "cmd_uninstall_app", new String[] { packageName }), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; }// w w w . ja v a2 s. co m LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { rtnValue += li.nextLine().trim(); } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static List<String> get3rdPartyPackageList(String serial) { List<String> pkgList = new ArrayList<String>(); Map<String, Object> executorMap = new AdbShellExecutor().execute( AdbShellCommand.cmd(serial, "cmd_3rd_party_package_list"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return pkgList; }// ww w.ja v a 2 s.c om LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String str = li.nextLine().trim(); if (str.contains("package:")) { pkgList.add(str.replace("package:", "")); } } Utils.destoryExecutor(executorMap.get("executor")); return pkgList; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static StringBuilder readDump(String serial, String dumpPath, StringBuilder hierarchy) { Map<String, Object> executorMap = new AdbShellExecutor() .execute(AdbShellCommand.cmd(serial, "cmd_cat", new String[] { dumpPath }), false, 3 * 1000); if (executorMap.isEmpty()) { return new StringBuilder(); }/*from ww w . j a va 2 s. c om*/ LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { hierarchy.append(li.nextLine().trim()); } Utils.destoryExecutor(executorMap.get("executor")); return hierarchy; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
/** * adb devices ? ?? ? ?? ? ?//from w w w . j a va 2 s.c om * * @return */ public static boolean isAdbReady(String serial) { boolean rtnValue = false; Map<String, Object> executorMap = new AdbShellExecutor().execute(AdbShellCommand.cmd("", "cmd_devices"), true, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; } LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String device = li.nextLine(); if (!device.contains("List of devices attached") && device.contains(serial)) { rtnValue = true; } } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static List<String> getDeviceList() { List<String> deviceList = new ArrayList<String>(); Map<String, Object> executorMap = new AdbShellExecutor().execute(AdbShellCommand.cmd("", "cmd_devices"), true, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return deviceList; }//from w w w . j av a 2s . com LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String device = li.nextLine(); if (device.contains("device")) { if (!device.contains("List of devices attached")) deviceList.add(device.replace("device", "").trim()); } } Utils.destoryExecutor(executorMap.get("executor")); return deviceList; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
/** * getInputManager? SurfaceOrientation? ?? * {@link #getInputManager(String)}//from w ww .j a v a 2s . c om * * @param serial * @return */ public static int getOrientation(String serial) { int rtnValue = 0; Map<String, Object> executorMap = new AdbShellExecutor() .execute(AdbShellCommand.cmd(serial, "cmd_get_orientation"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; } LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String out = li.nextLine().trim(); if (out.contains("SurfaceOrientation:")) { rtnValue = Integer.parseInt(Utils.convertRegex("(\\d)", out, 1)); } } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static Map<String, String> getProp(String serial) { Map<String, String> rtnValue = new HashMap<String, String>(); Map<String, Object> executorMap = new AdbShellExecutor().execute(AdbShellCommand.cmd(serial, "cmd_getprop"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return null; }//from w ww . j a v a 2 s .c o m LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String out = li.nextLine().trim(); if (!out.isEmpty() && !out.startsWith("[]")) { out = out.replace("]: [", ":").replace("[", "").replace("]", ""); if (out.split(":").length == 2) rtnValue.put(out.split(":")[0], out.split(":")[1]); } } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static boolean isKeyPadAppear(String serial) { Map<String, Object> executorMap = new AdbShellExecutor() .execute(AdbShellCommand.cmd(serial, "cmd_keypad_monitor"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return false; }/*from w ww . j ava2s .c o m*/ LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); if (li != null && li.hasNext()) { String str = li.nextLine().trim(); if (str.contains("HasSurface=true")) { DataQueue.IS_KEYPAD_ON = true; } else { DataQueue.IS_KEYPAD_ON = false; } } Utils.destoryExecutor(executorMap.get("executor")); return DataQueue.IS_KEYPAD_ON; }
From source file:com.nts.alphamale.handler.DeviceHandler.java
public static String getTopActivity(String serial) { String rtnValue = ""; Map<String, Object> executorMap = new AdbShellExecutor() .execute(AdbShellCommand.cmd(serial, "cmd_dumpsys_activity_top"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return rtnValue; }//from ww w .j a v a 2 s . co m LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li != null && li.hasNext()) { String output = li.nextLine(); if (output.contains("ACTIVITY")) { rtnValue = output.trim().split(" ")[1]; } } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }