RK3288 手動設定電池電量

tt7643066發表於2020-02-13

系統版本: RK3288 android 5.1 (與參考的變數和宏有點區別)

裝置沒有電池,在進行 Fota 升級時,提示電量不能低於 30% ,外接電源,可是讀出來的電量是 0% ,無法進行升級,只能手動設定電池電量。

$ adb shell dumpsys battery   // 透過 adb 查詢電池資訊
Current Battery Service state:
   AC powered: false
   USB powered: false
   Wireless powered: false
   status: 1
   health: 1
   present: true
   level: 0   // 電池電量
   scale: 100
   voltage: 0
   temperature: 0
   technology:

diff --git a/system/core/healthd/BatteryMonitor.cpp b/system/core/healthd/BatteryMonitor.cpp

old mode 100644

new mode 100755

index d317b28..6b37dee

--- a/system/core/healthd/BatteryMonitor.cpp

+++ b/system/core/healthd/BatteryMonitor.cpp

@@ - 35 , 7 + 35 , 7 @@

 

  #define POWER_SUPPLY_SUBSYSTEM "power_supply"

  #define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM

- #define FAKE_BATTERY_CAPACITY 42

+ #define FAKE_BATTERY_CAPACITY 100

  #define FAKE_BATTERY_TEMPERATURE 424

 

  namespace android {

@@ - 513 , 8 + 513 , 14 @@ void BatteryMonitor::init( struct healthd_config *hc) {

         closedir(dir);

     }

 

-    if (!mChargerNames.size())

+    if (!mChargerNames.size())  {

         KLOG_ERROR(LOG_TAG, "No charger supplies found\n" );

+               /*------------ 電池電量一直顯示 100%------------*/

+               mBatteryFixedCapacity = FAKE_BATTERY_CAPACITY;    // 電量 level

+               mBatteryFixedTemperature = FAKE_BATTERY_TEMPERATURE;    // 溫度 temperature

+               mBatteryDevicePresent = true ;

+               /*------------------------------------------------*/

+       }

     if (!mBatteryDevicePresent) {

         KLOG_WARNING(LOG_TAG, "No battery devices found\n" );

         hc->periodic_chores_interval_fast = - 1 ;

$ adb shell dumpsys battery
Current Battery Service state:
   AC powered: false
   USB powered: false
   Wireless powered: false
   status: 1
   health: 1
   present: true
   level: 100   // 電池電量
   scale: 100
   voltage: 0
   temperature: 424
   technology:

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69948385/viewspace-2675448/,如需轉載,請註明出處,否則將追究法律責任。

相關文章