Android 6.0 BatteryManager分析
来源:互联网 发布:python 遍历字符串 编辑:程序博客网 时间:2024/06/05 18:59
BatteryManager.java
BatteryManager
构造函数
public BatteryManager() { mBatteryStats = IBatteryStats.Stub.asInterface( ServiceManager.getService(BatteryStats.SERVICE_NAME)); mBatteryPropertiesRegistrar = IBatteryPropertiesRegistrar.Stub.asInterface( ServiceManager.getService("batteryproperties"));//healthd中add到service manager中的 }
queryProperty
/** * Query a battery property from the batteryproperties service. * * Returns the requested value, or Long.MIN_VALUE if property not * supported on this system or on other error. */ private long queryProperty(int id) { long ret; if (mBatteryPropertiesRegistrar == null) { return Long.MIN_VALUE; } try { BatteryProperty prop = new BatteryProperty(); if (mBatteryPropertiesRegistrar.getProperty(id, prop) == 0) ret = prop.getLong(); else ret = Long.MIN_VALUE; } catch (RemoteException e) { ret = Long.MIN_VALUE; } return ret; }
healthd_mode_android.cpp
void healthd_mode_android_init(struct healthd_config* /*config*/) { ProcessState::self()->setThreadPoolMaxThreadCount(0); IPCThreadState::self()->disableBackgroundScheduling(true); IPCThreadState::self()->setupPolling(&gBinderFd); if (gBinderFd >= 0) { if (healthd_register_event(gBinderFd, binder_event)) KLOG_ERROR(LOG_TAG, "Register for binder events failed\n"); } gBatteryPropertiesRegistrar = new BatteryPropertiesRegistrar(); gBatteryPropertiesRegistrar->publish();}
getProperty
status_t BatteryPropertiesRegistrar::getProperty(int id, struct BatteryProperty *val) { return healthd_get_property(id, val);}
BatteryMonitor.cpp
getProperty
status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { status_t ret = BAD_VALUE; val->valueInt64 = LONG_MIN; switch(id) { case BATTERY_PROP_CHARGE_COUNTER: if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryChargeCounterPath); ret = NO_ERROR; } else { ret = NAME_NOT_FOUND; } break; case BATTERY_PROP_CURRENT_NOW: if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryCurrentNowPath); ret = NO_ERROR; } else { ret = NAME_NOT_FOUND; } break; case BATTERY_PROP_CURRENT_AVG: if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryCurrentAvgPath); ret = NO_ERROR; } else { ret = NAME_NOT_FOUND; } break; case BATTERY_PROP_CAPACITY: if (!mHealthdConfig->batteryCapacityPath.isEmpty()) { val->valueInt64 = getIntField(mHealthdConfig->batteryCapacityPath); ret = NO_ERROR; } else { ret = NAME_NOT_FOUND; } break; case BATTERY_PROP_ENERGY_COUNTER: if (mHealthdConfig->energyCounter) { ret = mHealthdConfig->energyCounter(&val->valueInt64); } else { ret = NAME_NOT_FOUND; } break; default: break; } return ret;}
0 0
- Android 6.0 BatteryManager分析
- android.os.BatteryManager
- android BatteryManager电池管理
- Android之PowerManager&BatteryManager
- Android BatteryManager类
- BatteryManager
- BatteryManager
- andjroid5.1 BatteryManager深入分析
- BatteryManager--获取电量
- Android 6.0 BatteryService分析
- Android 6.0 源码分析
- Android 6.0 inflate过程分析
- Android 6.0 telephony 状态分析
- Android 6.0 PowerManagerService状态分析
- android 分析
- android 分析
- Android 6.0 分析 (一位网友的分析,不错)
- android 6.0架构下wpa_supplicant分析
- Mac开启或关闭显示隐藏文件命令
- JS APPLY CALL 理解 【转】
- java是否存在内存泄漏
- build Variants创建不同配置的app(图文详解)
- Touch----初识
- Android 6.0 BatteryManager分析
- Bitmap图像分析
- Android的.so文件、ABI和CPU的关系
- 洛谷 P1546 最短网络 Agri-Net
- Tomcat中 日志(控制台)中文乱码解决方法
- stellarium
- 各种文件对应的MIMEType
- 如何使用Erlang port 和外部程序交互
- 小弟个人对IO的字符流的看法