获取设备号
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;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。