all = Collections.list(NetworkInterface.getNetworkInterfaces());
+
+ for (NetworkInterface nif : all) {
+ if (!nif.getName().equalsIgnoreCase("wlan0")) {
+ continue;
+ }
+ byte[] macBytes = nif.getHardwareAddress();
+ StringBuilder res1 = new StringBuilder();
+ for (byte b : macBytes) {
+ res1.append(String.format("%02X:", b));
+ }
+ if (res1 != null) {
+ res1.deleteCharAt(res1.length() - 1);
+ }
+ return res1.toString();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "未获取到设备Mac地址";
+ }
// MD5 设备地址标识
public static String getMD5(Context context) {
@@ -1593,17 +1683,33 @@ public class Utils {
return Formatter.formatFileSize(context, availableSize);
}
+ /**
+ * 获取自定义版本号 或者版本号
+ * @return
+ */
public static String getCustomVersion() {
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
return Utils.getProperty("ro.build.display.id", "获取失败");
+ } else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform) {
+ return Utils.getProperty("ro.build.display.id", "获取失败");
+ } else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform) {
+ return Utils.getProperty("ro.build.display.id", "获取失败");
} else {
return Utils.getProperty("ro.custom.build.version", "获取失败");
}
}
+ /**
+ * 获取系统版本号
+ * @return
+ */
public static String getRomVersion() {
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
return getProperty("ro.build.id", "获取失败");
+ }else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform) {
+ return Utils.getProperty("ro.build.id", "获取失败");
+ } else if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform) {
+ return Utils.getProperty("ro.build.id", "获取失败");
} else {
return getProperty("ro.build.display.id", "获取失败");
}
@@ -1719,6 +1825,69 @@ public class Utils {
}
}
+ /**
+ * 当前充电电流 mA
+ *
+ * adb shell "cat /sys/class/power_supply/battery/BatteryAverageCurrent"
+ */
+ public static int getCurrentChargingCurrent() {
+ int result = 0;
+ BufferedReader br = null;
+ try {
+ String line;
+ br = new BufferedReader(new FileReader("/sys/class/power_supply/battery/BatteryAverageCurrent"));
+ if ((line = br.readLine()) != null) {
+ result = Integer.parseInt(line);
+ }
+ br.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 当前充电电压 uV
+ *
+ * adb shell "cat /sys/class/power_supply/battery/batt_vol"
+ */
+ public static int getCurrentChargingVoltage() {
+ int result = 0;
+ BufferedReader br = null;
+ try {
+ String line;
+ br = new BufferedReader(new FileReader("/sys/class/power_supply/battery/batt_vol"));
+ if ((line = br.readLine()) != null) {
+ result = Integer.parseInt(line);
+ }
+
+ br.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
}
diff --git a/app/src/main/res/layout/activity_main1.xml b/app/src/main/res/layout/activity_main1.xml
new file mode 100644
index 0000000..1daf68a
--- /dev/null
+++ b/app/src/main/res/layout/activity_main1.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index f026464..00c48d4 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -4,6 +4,9 @@
@dimen/dp_15
+ 16dp
+ 16dp
+
-60dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8e26ba6..77ed9ea 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -76,4 +76,41 @@ www.jiaoguanyi.com\n
- http://shouji.360tpcdn.com/170917/af50b75c9980cd6cba079052f4aa4e63/com.jingdong.app.mall_52563.apk
- http://shouji.360tpcdn.com/170919/1a4d1a0ca1255ae315c36394dd2b0865/com.mt.mtxx.mtxx_6860.apk
+
+
+
+ 电池状态:
+ 未知
+ 充电中
+ 放电中
+ 未充电
+ 电池满
+
+ 电池健康情况:
+ 未知
+ 良好
+ 过热
+ 没电
+ 未知错误
+ 过电压
+ 温度过低
+
+ 充电类型:
+ 充电器
+ USB
+ 其他
+ 无线充电
+
+ 当前电量:
+ 电量最大值:
+ 当前电池温度:
+ 当前电池电压:
+ 电池技术描述:
+
+ 当前充电电流:
+ 最大充电电流:
+
+ 当前充电电压:
+ 最大充电电压:
+ 发送命令: adb shell dumpsys battery \n
\ No newline at end of file