public static String formatDate(long date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return formatter.format(date);
}
/**
* get result of command, after execute dos command
* 通过执行dos命令获取结果
*
* @param :dos command,String
* @return List<String>
*/
public static List<String> execCmdConsole(String cmdString) {
List<String> dosRes = new ArrayList<String>();
Process process = null;
try {
LogUtil.info(cmdString);
if (osName.toLowerCase().contains("mac")) {
String[] command = {"/bin/sh", "-c", cmdString};
process = Runtime.getRuntime().exec(command);
} else if (osName.toLowerCase().contains("win")) {
process = Runtime.getRuntime().exec("cmd /c " + cmdString);
}
InputStream in = process.getInputStream();
BufferedReader inr = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = inr.readLine()) != null) {
dosRes.add(line);
}
try {
process.waitFor();
process.destroy();
} catch (InterruptedException e) {
e.printStackTrace();
}
log.debug("get result of command after execute dos command " + cmdString + " Succeed ");
} catch (IOException e) {
log.error("get result of command after execute dos command " + cmdString + " Failure", e);
}
return dosRes;
}
/**
* 获取手机版本
*
* @return
*/
public static String getMobileModel() {
/**
* 获取手机版本
*/
String mobileModel = "adb shell getprop ro.product.model";
String s = OperationalCmd.execReturnAndWait(mobileModel);
return s;
}
/**
* 获取手机系统版本
* 版本号
*
* @return
*/
public static String getVersionNameInfo() {
/**
* 版本号
*/
String versionName = "adb shell dumpsys package com.jingdong.th.app | findstr versionName";
/**
* 获取手机系统版本
*/
String versionRelease = "adb shell getprop ro.build.version.release";
List<String> devList = OperationalCmd.execCmdConsole(versionName);
String s = devList.get(0).split("=")[1] + "/Android:" + OperationalCmd.execReturnAndWait(versionRelease);
return s;
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。