电池电量android

Eclair中电池电量的读取首先需要Kernel的支持,kernel将所得到的电池信息放到/sys/class/power_supply/Battery 中,由Eclair中frameworks/base/services/jni文件夹下的com_android_server_BatteryService.cpp进行读取。总路径的定义:#define POWER_SUPPLY_PATH "/sys/class/power_supply"在int register_android_server_BatteryService(JNIEnv* env)中对每个特定路径赋值如给定batteryCapacityPath的路径:snprintf(path, sizeof(path), "%s/%s/capacity", POWER_SUPPLY_PATH, name);                if (access(path, R_OK) == 0)

你可能感兴趣的:(电池电量android)