Home | History | Annotate | Download | only in healthd
      1 /*
      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 #ifndef HEALTHD_BATTERYMONITOR_H
     18 #define HEALTHD_BATTERYMONITOR_H
     19 
     20 #include <binder/IInterface.h>
     21 #include <utils/String8.h>
     22 #include <utils/Vector.h>
     23 
     24 #include "healthd.h"
     25 #include "BatteryPropertiesRegistrar.h"
     26 
     27 namespace android {
     28 
     29 class BatteryPropertiesRegistrar;
     30 
     31 class BatteryMonitor {
     32   public:
     33 
     34     enum PowerSupplyType {
     35         ANDROID_POWER_SUPPLY_TYPE_UNKNOWN = 0,
     36         ANDROID_POWER_SUPPLY_TYPE_AC,
     37         ANDROID_POWER_SUPPLY_TYPE_USB,
     38         ANDROID_POWER_SUPPLY_TYPE_WIRELESS,
     39         ANDROID_POWER_SUPPLY_TYPE_BATTERY
     40     };
     41 
     42     void init(struct healthd_config *hc, bool nosvcmgr);
     43     bool update(void);
     44 
     45   private:
     46     struct healthd_config *mHealthdConfig;
     47     Vector<String8> mChargerNames;
     48 
     49     sp<BatteryPropertiesRegistrar> mBatteryPropertiesRegistrar;
     50 
     51     int getBatteryStatus(const char* status);
     52     int getBatteryHealth(const char* status);
     53     int readFromFile(const String8& path, char* buf, size_t size);
     54     PowerSupplyType readPowerSupplyType(const String8& path);
     55     bool getBooleanField(const String8& path);
     56     int getIntField(const String8& path);
     57 };
     58 
     59 }; // namespace android
     60 
     61 #endif // HEALTHD_BATTERY_MONTIOR_H
     62