blob: 377acb75e48e287ebaf124907518c535c760720a [file] [log] [blame]
Todd Poynor752faf22013-06-12 13:25:59 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "healthd"
18
Yabin Cuie98e1772016-02-17 12:21:34 -080019#include <healthd/healthd.h>
20#include <healthd/BatteryMonitor.h>
Todd Poynor752faf22013-06-12 13:25:59 -070021
22#include <dirent.h>
23#include <errno.h>
24#include <fcntl.h>
25#include <stdio.h>
26#include <stdlib.h>
Mark Salyzynacb1ddf2015-07-23 09:22:50 -070027#include <sys/types.h>
Todd Poynor752faf22013-06-12 13:25:59 -070028#include <unistd.h>
Thierry Strudelf73de6f2019-01-11 17:09:20 -080029
30#include <algorithm>
James Hawkins588a2ca2016-02-18 14:52:46 -080031#include <memory>
Yifan Hong1d4368b2019-10-07 11:18:04 -070032#include <optional>
Mark Salyzynacb1ddf2015-07-23 09:22:50 -070033
Michael Scott3217c5c2016-06-05 11:20:13 -070034#include <android-base/file.h>
Elliott Hughesda46b392016-10-11 17:09:00 -070035#include <android-base/parseint.h>
Michael Scott3217c5c2016-06-05 11:20:13 -070036#include <android-base/strings.h>
Yifan Hong1d4368b2019-10-07 11:18:04 -070037#include <android/hardware/health/2.1/types.h>
Todd Poynor752faf22013-06-12 13:25:59 -070038#include <batteryservice/BatteryService.h>
39#include <cutils/klog.h>
Todd Poynor3db03a52014-05-21 16:28:13 -070040#include <cutils/properties.h>
Todd Poynorc133b712013-08-14 17:39:13 -070041#include <utils/Errors.h>
Todd Poynor752faf22013-06-12 13:25:59 -070042#include <utils/String8.h>
43#include <utils/Vector.h>
44
45#define POWER_SUPPLY_SUBSYSTEM "power_supply"
46#define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM
Ruchi Kandoia78fc232014-07-10 15:06:21 -070047#define FAKE_BATTERY_CAPACITY 42
48#define FAKE_BATTERY_TEMPERATURE 424
Ruchi Kandoi5c09ec12016-02-25 16:19:30 -080049#define MILLION 1.0e6
Badhri Jagan Sridharan40e1df42015-10-27 10:43:53 -070050#define DEFAULT_VBUS_VOLTAGE 5000000
Todd Poynor752faf22013-06-12 13:25:59 -070051
Yifan Hong1d4368b2019-10-07 11:18:04 -070052using HealthInfo_1_0 = android::hardware::health::V1_0::HealthInfo;
53using HealthInfo_2_0 = android::hardware::health::V2_0::HealthInfo;
54using HealthInfo_2_1 = android::hardware::health::V2_1::HealthInfo;
55using android::hardware::health::V1_0::BatteryHealth;
56using android::hardware::health::V1_0::BatteryStatus;
Yifan Hong35cb0832019-10-07 13:58:29 -070057using android::hardware::health::V2_1::BatteryCapacityLevel;
Stephane Lee06846042020-02-12 17:00:24 -080058using android::hardware::health::V2_1::Constants;
Yifan Hong1d4368b2019-10-07 11:18:04 -070059
Todd Poynor752faf22013-06-12 13:25:59 -070060namespace android {
61
Yifan Hong1d4368b2019-10-07 11:18:04 -070062template <typename T>
63struct SysfsStringEnumMap {
Mark Salyzyn6f5b47f2014-05-15 15:00:59 -070064 const char* s;
Yifan Hong1d4368b2019-10-07 11:18:04 -070065 T val;
Todd Poynor752faf22013-06-12 13:25:59 -070066};
67
Yifan Hong1d4368b2019-10-07 11:18:04 -070068template <typename T>
69static std::optional<T> mapSysfsString(const char* str, SysfsStringEnumMap<T> map[]) {
Todd Poynor752faf22013-06-12 13:25:59 -070070 for (int i = 0; map[i].s; i++)
71 if (!strcmp(str, map[i].s))
72 return map[i].val;
73
Yifan Hong1d4368b2019-10-07 11:18:04 -070074 return std::nullopt;
Yabin Cuidb04a492016-02-16 17:19:23 -080075}
76
Yifan Hong6cabe9b2019-11-05 17:04:50 -080077static void initHealthInfo(HealthInfo_2_1* health_info_2_1) {
78 *health_info_2_1 = HealthInfo_2_1{};
79
80 // HIDL enum values are zero initialized, so they need to be initialized
81 // properly.
Stephane Leebab68772020-08-12 22:38:20 -070082 health_info_2_1->batteryCapacityLevel = BatteryCapacityLevel::UNSUPPORTED;
Stephane Lee06846042020-02-12 17:00:24 -080083 health_info_2_1->batteryChargeTimeToFullNowSeconds =
84 (int64_t)Constants::BATTERY_CHARGE_TIME_TO_FULL_NOW_SECONDS_UNSUPPORTED;
Yifan Hong6cabe9b2019-11-05 17:04:50 -080085 auto* props = &health_info_2_1->legacy.legacy;
86 props->batteryStatus = BatteryStatus::UNKNOWN;
87 props->batteryHealth = BatteryHealth::UNKNOWN;
88}
89
Todd Poynore030a102018-01-19 14:03:59 -080090BatteryMonitor::BatteryMonitor()
91 : mHealthdConfig(nullptr),
92 mBatteryDevicePresent(false),
93 mBatteryFixedCapacity(0),
Yifan Hong1d4368b2019-10-07 11:18:04 -070094 mBatteryFixedTemperature(0),
Yifan Hong6cabe9b2019-11-05 17:04:50 -080095 mHealthInfo(std::make_unique<HealthInfo_2_1>()) {
96 initHealthInfo(mHealthInfo.get());
97}
Yifan Hong1d4368b2019-10-07 11:18:04 -070098
99BatteryMonitor::~BatteryMonitor() {}
100
101const HealthInfo_1_0& BatteryMonitor::getHealthInfo_1_0() const {
102 return getHealthInfo_2_0().legacy;
Yabin Cuidb04a492016-02-16 17:19:23 -0800103}
104
Yifan Hong1d4368b2019-10-07 11:18:04 -0700105const HealthInfo_2_0& BatteryMonitor::getHealthInfo_2_0() const {
106 return getHealthInfo_2_1().legacy;
Hridya Valsaraju7fa72252018-01-12 17:44:33 -0800107}
108
Yifan Hong1d4368b2019-10-07 11:18:04 -0700109const HealthInfo_2_1& BatteryMonitor::getHealthInfo_2_1() const {
110 return *mHealthInfo;
111}
112
113BatteryStatus getBatteryStatus(const char* status) {
114 static SysfsStringEnumMap<BatteryStatus> batteryStatusMap[] = {
115 {"Unknown", BatteryStatus::UNKNOWN},
116 {"Charging", BatteryStatus::CHARGING},
117 {"Discharging", BatteryStatus::DISCHARGING},
118 {"Not charging", BatteryStatus::NOT_CHARGING},
119 {"Full", BatteryStatus::FULL},
120 {NULL, BatteryStatus::UNKNOWN},
Todd Poynor752faf22013-06-12 13:25:59 -0700121 };
122
Yifan Hong1d4368b2019-10-07 11:18:04 -0700123 auto ret = mapSysfsString(status, batteryStatusMap);
124 if (!ret) {
Todd Poynor752faf22013-06-12 13:25:59 -0700125 KLOG_WARNING(LOG_TAG, "Unknown battery status '%s'\n", status);
Yifan Hong1d4368b2019-10-07 11:18:04 -0700126 *ret = BatteryStatus::UNKNOWN;
Todd Poynor752faf22013-06-12 13:25:59 -0700127 }
128
Yifan Hong1d4368b2019-10-07 11:18:04 -0700129 return *ret;
Todd Poynor752faf22013-06-12 13:25:59 -0700130}
131
Stephane Lee86f9f6a2019-12-19 15:09:41 -0800132BatteryCapacityLevel getBatteryCapacityLevel(const char* capacityLevel) {
133 static SysfsStringEnumMap<BatteryCapacityLevel> batteryCapacityLevelMap[] = {
134 {"Unknown", BatteryCapacityLevel::UNKNOWN},
135 {"Critical", BatteryCapacityLevel::CRITICAL},
136 {"Low", BatteryCapacityLevel::LOW},
137 {"Normal", BatteryCapacityLevel::NORMAL},
138 {"High", BatteryCapacityLevel::HIGH},
139 {"Full", BatteryCapacityLevel::FULL},
Stephane Lee06846042020-02-12 17:00:24 -0800140 {NULL, BatteryCapacityLevel::UNSUPPORTED},
Stephane Lee86f9f6a2019-12-19 15:09:41 -0800141 };
142
143 auto ret = mapSysfsString(capacityLevel, batteryCapacityLevelMap);
144 if (!ret) {
Stephane Lee06846042020-02-12 17:00:24 -0800145 KLOG_WARNING(LOG_TAG, "Unsupported battery capacity level '%s'\n", capacityLevel);
146 *ret = BatteryCapacityLevel::UNSUPPORTED;
Stephane Lee86f9f6a2019-12-19 15:09:41 -0800147 }
148
149 return *ret;
150}
151
Yifan Hong1d4368b2019-10-07 11:18:04 -0700152BatteryHealth getBatteryHealth(const char* status) {
153 static SysfsStringEnumMap<BatteryHealth> batteryHealthMap[] = {
154 {"Unknown", BatteryHealth::UNKNOWN},
155 {"Good", BatteryHealth::GOOD},
156 {"Overheat", BatteryHealth::OVERHEAT},
157 {"Dead", BatteryHealth::DEAD},
158 {"Over voltage", BatteryHealth::OVER_VOLTAGE},
159 {"Unspecified failure", BatteryHealth::UNSPECIFIED_FAILURE},
160 {"Cold", BatteryHealth::COLD},
161 // battery health values from JEITA spec
162 {"Warm", BatteryHealth::GOOD},
163 {"Cool", BatteryHealth::GOOD},
164 {"Hot", BatteryHealth::OVERHEAT},
165 {NULL, BatteryHealth::UNKNOWN},
Todd Poynor752faf22013-06-12 13:25:59 -0700166 };
167
Yifan Hong1d4368b2019-10-07 11:18:04 -0700168 auto ret = mapSysfsString(status, batteryHealthMap);
169 if (!ret) {
Todd Poynor752faf22013-06-12 13:25:59 -0700170 KLOG_WARNING(LOG_TAG, "Unknown battery health '%s'\n", status);
Yifan Hong1d4368b2019-10-07 11:18:04 -0700171 *ret = BatteryHealth::UNKNOWN;
Todd Poynor752faf22013-06-12 13:25:59 -0700172 }
173
Yifan Hong1d4368b2019-10-07 11:18:04 -0700174 return *ret;
Todd Poynor752faf22013-06-12 13:25:59 -0700175}
176
Michael Scott3217c5c2016-06-05 11:20:13 -0700177int BatteryMonitor::readFromFile(const String8& path, std::string* buf) {
Steven Moreland2aac3352017-03-10 22:31:08 -0800178 if (android::base::ReadFileToString(path.c_str(), buf)) {
Michael Scott3217c5c2016-06-05 11:20:13 -0700179 *buf = android::base::Trim(*buf);
Todd Poynor752faf22013-06-12 13:25:59 -0700180 }
Michael Scott3217c5c2016-06-05 11:20:13 -0700181 return buf->length();
Todd Poynor752faf22013-06-12 13:25:59 -0700182}
183
184BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String8& path) {
Yifan Hong1d4368b2019-10-07 11:18:04 -0700185 static SysfsStringEnumMap<int> supplyTypeMap[] = {
186 {"Unknown", ANDROID_POWER_SUPPLY_TYPE_UNKNOWN},
187 {"Battery", ANDROID_POWER_SUPPLY_TYPE_BATTERY},
188 {"UPS", ANDROID_POWER_SUPPLY_TYPE_AC},
189 {"Mains", ANDROID_POWER_SUPPLY_TYPE_AC},
190 {"USB", ANDROID_POWER_SUPPLY_TYPE_USB},
191 {"USB_DCP", ANDROID_POWER_SUPPLY_TYPE_AC},
192 {"USB_HVDCP", ANDROID_POWER_SUPPLY_TYPE_AC},
193 {"USB_CDP", ANDROID_POWER_SUPPLY_TYPE_AC},
194 {"USB_ACA", ANDROID_POWER_SUPPLY_TYPE_AC},
195 {"USB_C", ANDROID_POWER_SUPPLY_TYPE_AC},
196 {"USB_PD", ANDROID_POWER_SUPPLY_TYPE_AC},
197 {"USB_PD_DRP", ANDROID_POWER_SUPPLY_TYPE_USB},
198 {"Wireless", ANDROID_POWER_SUPPLY_TYPE_WIRELESS},
199 {NULL, 0},
Todd Poynor752faf22013-06-12 13:25:59 -0700200 };
Yifan Hong1d4368b2019-10-07 11:18:04 -0700201 std::string buf;
Todd Poynor752faf22013-06-12 13:25:59 -0700202
Michael Scott3217c5c2016-06-05 11:20:13 -0700203 if (readFromFile(path, &buf) <= 0)
Todd Poynor752faf22013-06-12 13:25:59 -0700204 return ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
205
Yifan Hong1d4368b2019-10-07 11:18:04 -0700206 auto ret = mapSysfsString(buf.c_str(), supplyTypeMap);
John Stultz47a6bf02019-11-06 00:23:34 +0000207 if (!ret) {
Michael Scott3217c5c2016-06-05 11:20:13 -0700208 KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str());
Yifan Hong1d4368b2019-10-07 11:18:04 -0700209 *ret = ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
Johan Redestig32828612016-02-03 13:45:54 +0100210 }
Todd Poynor752faf22013-06-12 13:25:59 -0700211
Yifan Hong1d4368b2019-10-07 11:18:04 -0700212 return static_cast<BatteryMonitor::PowerSupplyType>(*ret);
Todd Poynor752faf22013-06-12 13:25:59 -0700213}
214
215bool BatteryMonitor::getBooleanField(const String8& path) {
Michael Scott3217c5c2016-06-05 11:20:13 -0700216 std::string buf;
Todd Poynor752faf22013-06-12 13:25:59 -0700217 bool value = false;
Michael Scott3217c5c2016-06-05 11:20:13 -0700218
219 if (readFromFile(path, &buf) > 0)
220 if (buf[0] != '0')
Todd Poynor752faf22013-06-12 13:25:59 -0700221 value = true;
Todd Poynor752faf22013-06-12 13:25:59 -0700222
223 return value;
224}
225
226int BatteryMonitor::getIntField(const String8& path) {
Michael Scott3217c5c2016-06-05 11:20:13 -0700227 std::string buf;
Todd Poynor752faf22013-06-12 13:25:59 -0700228 int value = 0;
Michael Scott3217c5c2016-06-05 11:20:13 -0700229
230 if (readFromFile(path, &buf) > 0)
Elliott Hughesda46b392016-10-11 17:09:00 -0700231 android::base::ParseInt(buf, &value);
Michael Scott3217c5c2016-06-05 11:20:13 -0700232
Todd Poynor752faf22013-06-12 13:25:59 -0700233 return value;
234}
235
Kazuhiro Inaba8e4d9822019-06-12 13:46:08 +0900236bool BatteryMonitor::isScopedPowerSupply(const char* name) {
237 constexpr char kScopeDevice[] = "Device";
238
239 String8 path;
240 path.appendFormat("%s/%s/scope", POWER_SUPPLY_SYSFS_PATH, name);
241 std::string scope;
242 return (readFromFile(path, &scope) > 0 && scope == kScopeDevice);
243}
244
Yifan Hong1353e702019-10-07 10:41:30 -0700245void BatteryMonitor::updateValues(void) {
Yifan Hong6cabe9b2019-11-05 17:04:50 -0800246 initHealthInfo(mHealthInfo.get());
Yifan Hong1d4368b2019-10-07 11:18:04 -0700247
248 HealthInfo_1_0& props = mHealthInfo->legacy.legacy;
Todd Poynor752faf22013-06-12 13:25:59 -0700249
Todd Poynorf5d30122013-08-12 17:03:35 -0700250 if (!mHealthdConfig->batteryPresentPath.isEmpty())
251 props.batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath);
Todd Poynor752faf22013-06-12 13:25:59 -0700252 else
Todd Poynor6dcc45e2013-10-21 20:26:25 -0700253 props.batteryPresent = mBatteryDevicePresent;
Todd Poynor752faf22013-06-12 13:25:59 -0700254
Todd Poynor3db03a52014-05-21 16:28:13 -0700255 props.batteryLevel = mBatteryFixedCapacity ?
256 mBatteryFixedCapacity :
257 getIntField(mHealthdConfig->batteryCapacityPath);
Todd Poynorf5d30122013-08-12 17:03:35 -0700258 props.batteryVoltage = getIntField(mHealthdConfig->batteryVoltagePath) / 1000;
Todd Poynorb45f1f52013-07-30 18:57:16 -0700259
Ruchi Kandoicc338802015-08-24 13:01:16 -0700260 if (!mHealthdConfig->batteryCurrentNowPath.isEmpty())
Yifan Honge5bd5f92020-04-08 16:14:45 -0700261 props.batteryCurrent = getIntField(mHealthdConfig->batteryCurrentNowPath);
Ruchi Kandoicc338802015-08-24 13:01:16 -0700262
263 if (!mHealthdConfig->batteryFullChargePath.isEmpty())
264 props.batteryFullCharge = getIntField(mHealthdConfig->batteryFullChargePath);
265
266 if (!mHealthdConfig->batteryCycleCountPath.isEmpty())
267 props.batteryCycleCount = getIntField(mHealthdConfig->batteryCycleCountPath);
268
Ruchi Kandoi3f9886b2016-04-07 12:34:40 -0700269 if (!mHealthdConfig->batteryChargeCounterPath.isEmpty())
270 props.batteryChargeCounter = getIntField(mHealthdConfig->batteryChargeCounterPath);
271
Yifan Hong35cb0832019-10-07 13:58:29 -0700272 if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty())
273 mHealthInfo->legacy.batteryCurrentAverage =
274 getIntField(mHealthdConfig->batteryCurrentAvgPath);
275
Stephane Lee86f9f6a2019-12-19 15:09:41 -0800276 if (!mHealthdConfig->batteryChargeTimeToFullNowPath.isEmpty())
277 mHealthInfo->batteryChargeTimeToFullNowSeconds =
278 getIntField(mHealthdConfig->batteryChargeTimeToFullNowPath);
279
Stephane Lee1c108ed2020-02-10 18:23:57 -0800280 if (!mHealthdConfig->batteryFullChargeDesignCapacityUahPath.isEmpty())
281 mHealthInfo->batteryFullChargeDesignCapacityUah =
282 getIntField(mHealthdConfig->batteryFullChargeDesignCapacityUahPath);
Yifan Hong35cb0832019-10-07 13:58:29 -0700283
Todd Poynor3db03a52014-05-21 16:28:13 -0700284 props.batteryTemperature = mBatteryFixedTemperature ?
285 mBatteryFixedTemperature :
286 getIntField(mHealthdConfig->batteryTemperaturePath);
Todd Poynor752faf22013-06-12 13:25:59 -0700287
Michael Scott3217c5c2016-06-05 11:20:13 -0700288 std::string buf;
Todd Poynor752faf22013-06-12 13:25:59 -0700289
Stephane Lee86f9f6a2019-12-19 15:09:41 -0800290 if (readFromFile(mHealthdConfig->batteryCapacityLevelPath, &buf) > 0)
291 mHealthInfo->batteryCapacityLevel = getBatteryCapacityLevel(buf.c_str());
292
Michael Scott3217c5c2016-06-05 11:20:13 -0700293 if (readFromFile(mHealthdConfig->batteryStatusPath, &buf) > 0)
294 props.batteryStatus = getBatteryStatus(buf.c_str());
Todd Poynor752faf22013-06-12 13:25:59 -0700295
Michael Scott3217c5c2016-06-05 11:20:13 -0700296 if (readFromFile(mHealthdConfig->batteryHealthPath, &buf) > 0)
297 props.batteryHealth = getBatteryHealth(buf.c_str());
Todd Poynor752faf22013-06-12 13:25:59 -0700298
Michael Scott3217c5c2016-06-05 11:20:13 -0700299 if (readFromFile(mHealthdConfig->batteryTechnologyPath, &buf) > 0)
300 props.batteryTechnology = String8(buf.c_str());
Todd Poynor752faf22013-06-12 13:25:59 -0700301
Badhri Jagan Sridharan40e1df42015-10-27 10:43:53 -0700302 double MaxPower = 0;
Todd Poynor752faf22013-06-12 13:25:59 -0700303
ShevT9d98a6a2018-07-26 11:47:47 +0300304 for (size_t i = 0; i < mChargerNames.size(); i++) {
Todd Poynor752faf22013-06-12 13:25:59 -0700305 String8 path;
306 path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH,
307 mChargerNames[i].string());
Michael Scott3217c5c2016-06-05 11:20:13 -0700308 if (getIntField(path)) {
309 path.clear();
310 path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH,
311 mChargerNames[i].string());
312 switch(readPowerSupplyType(path)) {
313 case ANDROID_POWER_SUPPLY_TYPE_AC:
314 props.chargerAcOnline = true;
315 break;
316 case ANDROID_POWER_SUPPLY_TYPE_USB:
317 props.chargerUsbOnline = true;
318 break;
319 case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
320 props.chargerWirelessOnline = true;
321 break;
322 default:
323 KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n",
324 mChargerNames[i].string());
325 }
326 path.clear();
327 path.appendFormat("%s/%s/current_max", POWER_SUPPLY_SYSFS_PATH,
328 mChargerNames[i].string());
Dmitry Shmidt9f6b80c2016-06-20 12:58:37 -0700329 int ChargingCurrent =
Badhri Jagan Sridharan40e1df42015-10-27 10:43:53 -0700330 (access(path.string(), R_OK) == 0) ? getIntField(path) : 0;
331
Dmitry Shmidt9f6b80c2016-06-20 12:58:37 -0700332 path.clear();
333 path.appendFormat("%s/%s/voltage_max", POWER_SUPPLY_SYSFS_PATH,
334 mChargerNames[i].string());
Badhri Jagan Sridharan40e1df42015-10-27 10:43:53 -0700335
Dmitry Shmidt9f6b80c2016-06-20 12:58:37 -0700336 int ChargingVoltage =
337 (access(path.string(), R_OK) == 0) ? getIntField(path) :
338 DEFAULT_VBUS_VOLTAGE;
Badhri Jagan Sridharan40e1df42015-10-27 10:43:53 -0700339
Dmitry Shmidt9f6b80c2016-06-20 12:58:37 -0700340 double power = ((double)ChargingCurrent / MILLION) *
341 ((double)ChargingVoltage / MILLION);
342 if (MaxPower < power) {
343 props.maxChargingCurrent = ChargingCurrent;
344 props.maxChargingVoltage = ChargingVoltage;
345 MaxPower = power;
Todd Poynor752faf22013-06-12 13:25:59 -0700346 }
347 }
348 }
Yifan Hong1353e702019-10-07 10:41:30 -0700349}
Todd Poynor752faf22013-06-12 13:25:59 -0700350
Yifan Hong1353e702019-10-07 10:41:30 -0700351void BatteryMonitor::logValues(void) {
Yifan Hong605e7d22021-02-08 15:14:48 -0800352 logValues(*mHealthInfo, *mHealthdConfig);
353}
354
355void BatteryMonitor::logValues(const android::hardware::health::V2_1::HealthInfo& health_info,
356 const struct healthd_config& healthd_config) {
Yifan Hong1353e702019-10-07 10:41:30 -0700357 char dmesgline[256];
358 size_t len;
Yifan Hong605e7d22021-02-08 15:14:48 -0800359 const HealthInfo_1_0& props = health_info.legacy.legacy;
Yifan Hong1353e702019-10-07 10:41:30 -0700360 if (props.batteryPresent) {
361 snprintf(dmesgline, sizeof(dmesgline), "battery l=%d v=%d t=%s%d.%d h=%d st=%d",
362 props.batteryLevel, props.batteryVoltage, props.batteryTemperature < 0 ? "-" : "",
363 abs(props.batteryTemperature / 10), abs(props.batteryTemperature % 10),
364 props.batteryHealth, props.batteryStatus);
Todd Poynorb45f1f52013-07-30 18:57:16 -0700365
Yifan Hong1353e702019-10-07 10:41:30 -0700366 len = strlen(dmesgline);
Yifan Hong605e7d22021-02-08 15:14:48 -0800367 if (!healthd_config.batteryCurrentNowPath.isEmpty()) {
Yifan Hong1353e702019-10-07 10:41:30 -0700368 len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d",
369 props.batteryCurrent);
Todd Poynor10b235e2013-08-07 15:25:14 -0700370 }
371
Yifan Hong605e7d22021-02-08 15:14:48 -0800372 if (!healthd_config.batteryFullChargePath.isEmpty()) {
Yifan Hong1353e702019-10-07 10:41:30 -0700373 len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d",
374 props.batteryFullCharge);
375 }
Mark Salyzynacb1ddf2015-07-23 09:22:50 -0700376
Yifan Hong605e7d22021-02-08 15:14:48 -0800377 if (!healthd_config.batteryCycleCountPath.isEmpty()) {
Yifan Hong1353e702019-10-07 10:41:30 -0700378 len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d",
379 props.batteryCycleCount);
380 }
381 } else {
382 len = snprintf(dmesgline, sizeof(dmesgline), "battery none");
Todd Poynorb45f1f52013-07-30 18:57:16 -0700383 }
384
Yifan Hong1353e702019-10-07 10:41:30 -0700385 snprintf(dmesgline + len, sizeof(dmesgline) - len, " chg=%s%s%s",
386 props.chargerAcOnline ? "a" : "", props.chargerUsbOnline ? "u" : "",
387 props.chargerWirelessOnline ? "w" : "");
388
389 KLOG_WARNING(LOG_TAG, "%s\n", dmesgline);
390}
391
392bool BatteryMonitor::isChargerOnline() {
Yifan Hong1d4368b2019-10-07 11:18:04 -0700393 const HealthInfo_1_0& props = mHealthInfo->legacy.legacy;
Todd Poynor752faf22013-06-12 13:25:59 -0700394 return props.chargerAcOnline | props.chargerUsbOnline |
395 props.chargerWirelessOnline;
396}
397
Yabin Cuiaedf6032016-02-19 18:03:23 -0800398int BatteryMonitor::getChargeStatus() {
Yifan Hong1d4368b2019-10-07 11:18:04 -0700399 BatteryStatus result = BatteryStatus::UNKNOWN;
Yabin Cuiaedf6032016-02-19 18:03:23 -0800400 if (!mHealthdConfig->batteryStatusPath.isEmpty()) {
Michael Scott3217c5c2016-06-05 11:20:13 -0700401 std::string buf;
402 if (readFromFile(mHealthdConfig->batteryStatusPath, &buf) > 0)
403 result = getBatteryStatus(buf.c_str());
Yabin Cuiaedf6032016-02-19 18:03:23 -0800404 }
Yifan Hong1d4368b2019-10-07 11:18:04 -0700405 return static_cast<int>(result);
Yabin Cuiaedf6032016-02-19 18:03:23 -0800406}
407
Todd Poynorc133b712013-08-14 17:39:13 -0700408status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
409 status_t ret = BAD_VALUE;
Jin Qian72adf112017-02-02 17:31:13 -0800410 std::string buf;
Todd Poynorc133b712013-08-14 17:39:13 -0700411
Todd Poynor8f132af2014-05-08 17:15:45 -0700412 val->valueInt64 = LONG_MIN;
413
Todd Poynorc133b712013-08-14 17:39:13 -0700414 switch(id) {
415 case BATTERY_PROP_CHARGE_COUNTER:
416 if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
Todd Poynor8f132af2014-05-08 17:15:45 -0700417 val->valueInt64 =
Todd Poynorc133b712013-08-14 17:39:13 -0700418 getIntField(mHealthdConfig->batteryChargeCounterPath);
Elliott Hughes643268f2018-10-08 11:10:11 -0700419 ret = OK;
Todd Poynorc133b712013-08-14 17:39:13 -0700420 } else {
421 ret = NAME_NOT_FOUND;
422 }
423 break;
424
425 case BATTERY_PROP_CURRENT_NOW:
426 if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
Todd Poynor8f132af2014-05-08 17:15:45 -0700427 val->valueInt64 =
Todd Poynorc133b712013-08-14 17:39:13 -0700428 getIntField(mHealthdConfig->batteryCurrentNowPath);
Elliott Hughes643268f2018-10-08 11:10:11 -0700429 ret = OK;
Todd Poynorc133b712013-08-14 17:39:13 -0700430 } else {
431 ret = NAME_NOT_FOUND;
432 }
433 break;
434
Todd Poynorbc102112013-08-27 18:11:49 -0700435 case BATTERY_PROP_CURRENT_AVG:
436 if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) {
Todd Poynor8f132af2014-05-08 17:15:45 -0700437 val->valueInt64 =
Todd Poynorbc102112013-08-27 18:11:49 -0700438 getIntField(mHealthdConfig->batteryCurrentAvgPath);
Elliott Hughes643268f2018-10-08 11:10:11 -0700439 ret = OK;
Todd Poynorbc102112013-08-27 18:11:49 -0700440 } else {
441 ret = NAME_NOT_FOUND;
442 }
443 break;
444
Paul Lawrence347c8de2014-03-19 15:04:40 -0700445 case BATTERY_PROP_CAPACITY:
446 if (!mHealthdConfig->batteryCapacityPath.isEmpty()) {
Todd Poynor8f132af2014-05-08 17:15:45 -0700447 val->valueInt64 =
Paul Lawrence347c8de2014-03-19 15:04:40 -0700448 getIntField(mHealthdConfig->batteryCapacityPath);
Elliott Hughes643268f2018-10-08 11:10:11 -0700449 ret = OK;
Paul Lawrence347c8de2014-03-19 15:04:40 -0700450 } else {
451 ret = NAME_NOT_FOUND;
452 }
453 break;
454
Todd Poynor8f132af2014-05-08 17:15:45 -0700455 case BATTERY_PROP_ENERGY_COUNTER:
Todd Poynore14b37e2014-05-20 13:54:40 -0700456 if (mHealthdConfig->energyCounter) {
457 ret = mHealthdConfig->energyCounter(&val->valueInt64);
458 } else {
459 ret = NAME_NOT_FOUND;
460 }
Todd Poynor8f132af2014-05-08 17:15:45 -0700461 break;
462
Jin Qian72adf112017-02-02 17:31:13 -0800463 case BATTERY_PROP_BATTERY_STATUS:
Todd Poynore030a102018-01-19 14:03:59 -0800464 val->valueInt64 = getChargeStatus();
Elliott Hughes643268f2018-10-08 11:10:11 -0700465 ret = OK;
Jin Qian72adf112017-02-02 17:31:13 -0800466 break;
467
Todd Poynorc133b712013-08-14 17:39:13 -0700468 default:
469 break;
470 }
471
Todd Poynorc133b712013-08-14 17:39:13 -0700472 return ret;
473}
474
Todd Poynor020369d2013-09-18 20:09:33 -0700475void BatteryMonitor::dumpState(int fd) {
476 int v;
477 char vs[128];
Yifan Hong1d4368b2019-10-07 11:18:04 -0700478 const HealthInfo_1_0& props = mHealthInfo->legacy.legacy;
Todd Poynor020369d2013-09-18 20:09:33 -0700479
Badhri Jagan Sridharan40e1df42015-10-27 10:43:53 -0700480 snprintf(vs, sizeof(vs), "ac: %d usb: %d wireless: %d current_max: %d voltage_max: %d\n",
Todd Poynor020369d2013-09-18 20:09:33 -0700481 props.chargerAcOnline, props.chargerUsbOnline,
Badhri Jagan Sridharan40e1df42015-10-27 10:43:53 -0700482 props.chargerWirelessOnline, props.maxChargingCurrent,
483 props.maxChargingVoltage);
Todd Poynor020369d2013-09-18 20:09:33 -0700484 write(fd, vs, strlen(vs));
485 snprintf(vs, sizeof(vs), "status: %d health: %d present: %d\n",
486 props.batteryStatus, props.batteryHealth, props.batteryPresent);
487 write(fd, vs, strlen(vs));
488 snprintf(vs, sizeof(vs), "level: %d voltage: %d temp: %d\n",
489 props.batteryLevel, props.batteryVoltage,
490 props.batteryTemperature);
491 write(fd, vs, strlen(vs));
492
493 if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
494 v = getIntField(mHealthdConfig->batteryCurrentNowPath);
495 snprintf(vs, sizeof(vs), "current now: %d\n", v);
496 write(fd, vs, strlen(vs));
497 }
498
499 if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) {
500 v = getIntField(mHealthdConfig->batteryCurrentAvgPath);
501 snprintf(vs, sizeof(vs), "current avg: %d\n", v);
502 write(fd, vs, strlen(vs));
503 }
504
505 if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
506 v = getIntField(mHealthdConfig->batteryChargeCounterPath);
507 snprintf(vs, sizeof(vs), "charge counter: %d\n", v);
508 write(fd, vs, strlen(vs));
509 }
Ruchi Kandoicc338802015-08-24 13:01:16 -0700510
511 if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
512 snprintf(vs, sizeof(vs), "current now: %d\n", props.batteryCurrent);
513 write(fd, vs, strlen(vs));
514 }
515
516 if (!mHealthdConfig->batteryCycleCountPath.isEmpty()) {
517 snprintf(vs, sizeof(vs), "cycle count: %d\n", props.batteryCycleCount);
518 write(fd, vs, strlen(vs));
519 }
520
521 if (!mHealthdConfig->batteryFullChargePath.isEmpty()) {
522 snprintf(vs, sizeof(vs), "Full charge: %d\n", props.batteryFullCharge);
523 write(fd, vs, strlen(vs));
524 }
Todd Poynor020369d2013-09-18 20:09:33 -0700525}
526
Todd Poynorc7464c92013-09-10 12:40:00 -0700527void BatteryMonitor::init(struct healthd_config *hc) {
Todd Poynor752faf22013-06-12 13:25:59 -0700528 String8 path;
Todd Poynor3db03a52014-05-21 16:28:13 -0700529 char pval[PROPERTY_VALUE_MAX];
Todd Poynor752faf22013-06-12 13:25:59 -0700530
Todd Poynorf5d30122013-08-12 17:03:35 -0700531 mHealthdConfig = hc;
James Hawkins588a2ca2016-02-18 14:52:46 -0800532 std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(POWER_SUPPLY_SYSFS_PATH), closedir);
Todd Poynor752faf22013-06-12 13:25:59 -0700533 if (dir == NULL) {
534 KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH);
535 } else {
536 struct dirent* entry;
537
James Hawkins588a2ca2016-02-18 14:52:46 -0800538 while ((entry = readdir(dir.get()))) {
Todd Poynor752faf22013-06-12 13:25:59 -0700539 const char* name = entry->d_name;
Thierry Strudelf73de6f2019-01-11 17:09:20 -0800540 std::vector<String8>::iterator itIgnoreName;
Todd Poynor752faf22013-06-12 13:25:59 -0700541
542 if (!strcmp(name, ".") || !strcmp(name, ".."))
543 continue;
544
Thierry Strudelf73de6f2019-01-11 17:09:20 -0800545 itIgnoreName = find(hc->ignorePowerSupplyNames.begin(),
546 hc->ignorePowerSupplyNames.end(), String8(name));
547 if (itIgnoreName != hc->ignorePowerSupplyNames.end())
548 continue;
549
Todd Poynor752faf22013-06-12 13:25:59 -0700550 // Look for "type" file in each subdirectory
551 path.clear();
552 path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, name);
553 switch(readPowerSupplyType(path)) {
554 case ANDROID_POWER_SUPPLY_TYPE_AC:
555 case ANDROID_POWER_SUPPLY_TYPE_USB:
556 case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
557 path.clear();
558 path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name);
559 if (access(path.string(), R_OK) == 0)
560 mChargerNames.add(String8(name));
561 break;
562
563 case ANDROID_POWER_SUPPLY_TYPE_BATTERY:
Kazuhiro Inaba8e4d9822019-06-12 13:46:08 +0900564 // Some devices expose the battery status of sub-component like
565 // stylus. Such a device-scoped battery info needs to be skipped
566 // in BatteryMonitor, which is intended to report the status of
567 // the battery supplying the power to the whole system.
568 if (isScopedPowerSupply(name)) continue;
Todd Poynor6dcc45e2013-10-21 20:26:25 -0700569 mBatteryDevicePresent = true;
570
Todd Poynorf5d30122013-08-12 17:03:35 -0700571 if (mHealthdConfig->batteryStatusPath.isEmpty()) {
Todd Poynor752faf22013-06-12 13:25:59 -0700572 path.clear();
Todd Poynorf5d30122013-08-12 17:03:35 -0700573 path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
574 name);
Todd Poynor752faf22013-06-12 13:25:59 -0700575 if (access(path, R_OK) == 0)
Todd Poynorf5d30122013-08-12 17:03:35 -0700576 mHealthdConfig->batteryStatusPath = path;
Todd Poynor752faf22013-06-12 13:25:59 -0700577 }
578
Todd Poynorf5d30122013-08-12 17:03:35 -0700579 if (mHealthdConfig->batteryHealthPath.isEmpty()) {
Todd Poynor752faf22013-06-12 13:25:59 -0700580 path.clear();
Todd Poynorf5d30122013-08-12 17:03:35 -0700581 path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
582 name);
Todd Poynor752faf22013-06-12 13:25:59 -0700583 if (access(path, R_OK) == 0)
Todd Poynorf5d30122013-08-12 17:03:35 -0700584 mHealthdConfig->batteryHealthPath = path;
Todd Poynor752faf22013-06-12 13:25:59 -0700585 }
586
Todd Poynorf5d30122013-08-12 17:03:35 -0700587 if (mHealthdConfig->batteryPresentPath.isEmpty()) {
588 path.clear();
589 path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
590 name);
591 if (access(path, R_OK) == 0)
592 mHealthdConfig->batteryPresentPath = path;
593 }
594
595 if (mHealthdConfig->batteryCapacityPath.isEmpty()) {
596 path.clear();
597 path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
598 name);
599 if (access(path, R_OK) == 0)
600 mHealthdConfig->batteryCapacityPath = path;
601 }
602
603 if (mHealthdConfig->batteryVoltagePath.isEmpty()) {
604 path.clear();
605 path.appendFormat("%s/%s/voltage_now",
606 POWER_SUPPLY_SYSFS_PATH, name);
607 if (access(path, R_OK) == 0) {
608 mHealthdConfig->batteryVoltagePath = path;
Todd Poynorf5d30122013-08-12 17:03:35 -0700609 }
610 }
611
Ruchi Kandoicc338802015-08-24 13:01:16 -0700612 if (mHealthdConfig->batteryFullChargePath.isEmpty()) {
613 path.clear();
614 path.appendFormat("%s/%s/charge_full",
615 POWER_SUPPLY_SYSFS_PATH, name);
616 if (access(path, R_OK) == 0)
617 mHealthdConfig->batteryFullChargePath = path;
618 }
619
Todd Poynorf5d30122013-08-12 17:03:35 -0700620 if (mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
621 path.clear();
622 path.appendFormat("%s/%s/current_now",
623 POWER_SUPPLY_SYSFS_PATH, name);
624 if (access(path, R_OK) == 0)
625 mHealthdConfig->batteryCurrentNowPath = path;
626 }
627
Ruchi Kandoicc338802015-08-24 13:01:16 -0700628 if (mHealthdConfig->batteryCycleCountPath.isEmpty()) {
629 path.clear();
630 path.appendFormat("%s/%s/cycle_count",
631 POWER_SUPPLY_SYSFS_PATH, name);
632 if (access(path, R_OK) == 0)
633 mHealthdConfig->batteryCycleCountPath = path;
634 }
635
Stephane Lee86f9f6a2019-12-19 15:09:41 -0800636 if (mHealthdConfig->batteryCapacityLevelPath.isEmpty()) {
637 path.clear();
638 path.appendFormat("%s/%s/capacity_level", POWER_SUPPLY_SYSFS_PATH, name);
639 if (access(path, R_OK) == 0) mHealthdConfig->batteryCapacityLevelPath = path;
640 }
641
642 if (mHealthdConfig->batteryChargeTimeToFullNowPath.isEmpty()) {
643 path.clear();
644 path.appendFormat("%s/%s/time_to_full_now", POWER_SUPPLY_SYSFS_PATH, name);
645 if (access(path, R_OK) == 0)
646 mHealthdConfig->batteryChargeTimeToFullNowPath = path;
647 }
648
Stephane Lee1c108ed2020-02-10 18:23:57 -0800649 if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.isEmpty()) {
650 path.clear();
651 path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
652 if (access(path, R_OK) == 0)
653 mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
654 }
655
Todd Poynorbc102112013-08-27 18:11:49 -0700656 if (mHealthdConfig->batteryCurrentAvgPath.isEmpty()) {
657 path.clear();
658 path.appendFormat("%s/%s/current_avg",
659 POWER_SUPPLY_SYSFS_PATH, name);
660 if (access(path, R_OK) == 0)
661 mHealthdConfig->batteryCurrentAvgPath = path;
662 }
663
Todd Poynorf5d30122013-08-12 17:03:35 -0700664 if (mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
665 path.clear();
666 path.appendFormat("%s/%s/charge_counter",
667 POWER_SUPPLY_SYSFS_PATH, name);
668 if (access(path, R_OK) == 0)
669 mHealthdConfig->batteryChargeCounterPath = path;
670 }
671
672 if (mHealthdConfig->batteryTemperaturePath.isEmpty()) {
673 path.clear();
674 path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
675 name);
676 if (access(path, R_OK) == 0) {
677 mHealthdConfig->batteryTemperaturePath = path;
Todd Poynorf5d30122013-08-12 17:03:35 -0700678 }
679 }
680
681 if (mHealthdConfig->batteryTechnologyPath.isEmpty()) {
682 path.clear();
683 path.appendFormat("%s/%s/technology",
684 POWER_SUPPLY_SYSFS_PATH, name);
685 if (access(path, R_OK) == 0)
686 mHealthdConfig->batteryTechnologyPath = path;
687 }
688
Todd Poynor752faf22013-06-12 13:25:59 -0700689 break;
690
691 case ANDROID_POWER_SUPPLY_TYPE_UNKNOWN:
692 break;
693 }
694 }
Todd Poynor752faf22013-06-12 13:25:59 -0700695 }
696
Ian Pedowitz585ab652015-10-12 19:01:00 -0700697 // Typically the case for devices which do not have a battery and
698 // and are always plugged into AC mains.
Todd Poynor6dcc45e2013-10-21 20:26:25 -0700699 if (!mBatteryDevicePresent) {
Todd Poynorebeb0c02014-09-23 14:54:24 -0700700 KLOG_WARNING(LOG_TAG, "No battery devices found\n");
Todd Poynor6dcc45e2013-10-21 20:26:25 -0700701 hc->periodic_chores_interval_fast = -1;
702 hc->periodic_chores_interval_slow = -1;
703 } else {
704 if (mHealthdConfig->batteryStatusPath.isEmpty())
705 KLOG_WARNING(LOG_TAG, "BatteryStatusPath not found\n");
706 if (mHealthdConfig->batteryHealthPath.isEmpty())
707 KLOG_WARNING(LOG_TAG, "BatteryHealthPath not found\n");
708 if (mHealthdConfig->batteryPresentPath.isEmpty())
709 KLOG_WARNING(LOG_TAG, "BatteryPresentPath not found\n");
710 if (mHealthdConfig->batteryCapacityPath.isEmpty())
711 KLOG_WARNING(LOG_TAG, "BatteryCapacityPath not found\n");
712 if (mHealthdConfig->batteryVoltagePath.isEmpty())
713 KLOG_WARNING(LOG_TAG, "BatteryVoltagePath not found\n");
714 if (mHealthdConfig->batteryTemperaturePath.isEmpty())
715 KLOG_WARNING(LOG_TAG, "BatteryTemperaturePath not found\n");
716 if (mHealthdConfig->batteryTechnologyPath.isEmpty())
717 KLOG_WARNING(LOG_TAG, "BatteryTechnologyPath not found\n");
Ruchi Kandoif18ec9f2015-09-28 13:35:59 -0700718 if (mHealthdConfig->batteryCurrentNowPath.isEmpty())
Ruchi Kandoicc338802015-08-24 13:01:16 -0700719 KLOG_WARNING(LOG_TAG, "BatteryCurrentNowPath not found\n");
720 if (mHealthdConfig->batteryFullChargePath.isEmpty())
721 KLOG_WARNING(LOG_TAG, "BatteryFullChargePath not found\n");
722 if (mHealthdConfig->batteryCycleCountPath.isEmpty())
723 KLOG_WARNING(LOG_TAG, "BatteryCycleCountPath not found\n");
Stephane Lee86f9f6a2019-12-19 15:09:41 -0800724 if (mHealthdConfig->batteryCapacityLevelPath.isEmpty())
725 KLOG_WARNING(LOG_TAG, "batteryCapacityLevelPath not found\n");
726 if (mHealthdConfig->batteryChargeTimeToFullNowPath.isEmpty())
727 KLOG_WARNING(LOG_TAG, "batteryChargeTimeToFullNowPath. not found\n");
Stephane Lee1c108ed2020-02-10 18:23:57 -0800728 if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.isEmpty())
729 KLOG_WARNING(LOG_TAG, "batteryFullChargeDesignCapacityUahPath. not found\n");
Todd Poynor6dcc45e2013-10-21 20:26:25 -0700730 }
Todd Poynor3db03a52014-05-21 16:28:13 -0700731
Ruchi Kandoia78fc232014-07-10 15:06:21 -0700732 if (property_get("ro.boot.fake_battery", pval, NULL) > 0
733 && strtol(pval, NULL, 10) != 0) {
734 mBatteryFixedCapacity = FAKE_BATTERY_CAPACITY;
735 mBatteryFixedTemperature = FAKE_BATTERY_TEMPERATURE;
736 }
Todd Poynor752faf22013-06-12 13:25:59 -0700737}
738
739}; // namespace android