feat(debug): 扩展 DebugActivity 系统控制功能
新增进程管理、默认桌面设置、通知渠道、快捷方式及多种系统配置接口
This commit is contained in:
@@ -1570,7 +1570,15 @@ public class Utils {
|
||||
public static int getBattery(Context context) {
|
||||
try {
|
||||
BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
|
||||
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
if (batteryManager == null) {
|
||||
return 0;
|
||||
}
|
||||
int capacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
// -1 表示设备无法获取电量(无电池或底层未上报),归一到 0 避免下游误判
|
||||
if (capacity < 0 || capacity > 100) {
|
||||
return 0;
|
||||
}
|
||||
return capacity;
|
||||
} catch (Exception e) {
|
||||
Log.e("getBattery", "getBattery" + e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user