The private methods in class BatteryMonitor do not use the 'this'
pointer. Hence convert these into static nonmember functions.
Test: Compile-tested only.
Change-Id: I4b9b76c9697f1db894ba9fb939ce096ee6b7ff3b
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Not all readFromFile() callers pass an empty string. Make sure that
readFromFile() returns 0 (failure) if the *buf argument is not empty and
if reading fails.
Fixes: 3217c5c7d9 ("batterymonitor: simplify readFromFile and use std::string buffers")
Test: Compile-tested only.
Change-Id: I6f329491f8aa4a6d378eb7c3cbc17038eb6aa64d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Use aggregate initialization instead of memberwise initialization. This
patch does not change any functionality.
Test: Compile-tested only.
Change-Id: I9c7831936e449aec8a48336b1ee76d26638e4f72
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Declare and assign in a single statement instead of in two separate
statements. This patch does not change any functionality.
Test: Compile-tested only.
Change-Id: I0798cc940f5f2ca329548568ab68e96891521dd8
Signed-off-by: Bart Van Assche <bvanassche@google.com>
This change cleans up technical debt. As a side
effect, this change also exposes chargerDockOnline
properly to health HAL implementations.
Test: TH
Bug: 222120465
Change-Id: I306bd0538d94b310a69befb93b5862dd7208447f
Bug: 191831427
Test: charging animation can show in display correctly
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: Iedcd7d6c3cd841c44bdf1116701abcbd12a26959
Bug: 191831427
Test: charging animation can show in display correctly
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: Id99a7401f53f647790e179e995dad9841f8284bb
set first connector as default
Test: charging animation can show in correct display
Bug: 191831427
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: Ia79981569e799f01db0036f0ecbdaca36a539ac6
For the vendor variant of libhealthd_mode_charger, read resources
from /vendor. The core variant continues to read resources from
/product, /system, and /res.
Test: run charger from /vendor manually
Bug: 203246116
Change-Id: Ia9df1d081a51783409b5dbd3e3d4719efc3cb6a7
This is a prerequisite to move charger to vendor partition.
Because vendor domains can't read ro.charger.*, they are all assumed
to be the default value. They aren't set in the ecosystem anyway,
so it is time to deprecate them.
Test: builds
Bug: 203246116
Change-Id: I0b17e62ab3ac5a89df091333fd9f24e33bdfd49a
The system property is set by vendor partition but owned by platform,
hence vendor domains can't read this value. Add an API in
ChargerConfigurationInterface so that HAL implementations can override
its value.
Other ro.charger.* sysprops are unused, hence no APIs are created for
them.
Test: manual
Bug: 203246116
Change-Id: I583c21e58ed3d912b156e253d6a4b46a0378f11e
Abstract all the HIDL-ness from charger so an AIDL HAL
can later replace the HIDL HAL.
Created libhealthd_charger_ui that is responsible for
UI stuff in charger. Then libhealthd_charger is now the
charger library backed by HIDL HAL.
Bug: 170338625
Bug: 203246116
Test: charger_test
Change-Id: I193bb76afa18b3367f24796ac53b1760650e8683
1.Retry charger when gr init fail caused
by display not ready.
2.Remove meaningless logs which occupy log lines,
the logs that really need to be printed cannot be
output due to printk suppresses kernel logs.
Bug: 197604278
Change-Id: Id9465a0a9c994986192fd39c124d05aed8caa862
Test: Manual. Power off charging.
... that logs values for an arbitrary health info and
health config.
This allows health 2.1 HAL implementation to log the
updated health info struct, which is not stored in
BatteryMonitor.
Test: healthd kernel log has correct values
Bug: 179326883
Change-Id: I394ef3f317229f94f4db82de5635d9380c183394
It is replaced by health HIDL HAL 2.0. Devices launching
with Android P and above must always have health HAL 2.0,
so health HAL is no longer needed for Android S.
Test: TH
Bug: 171260613
Change-Id: I7d94af36a880d7c658e879a3986924a786e58de9
Internal props are no longer stored in the txt file.
Exempt-From-Owner-Approval: cherry pick
Bug: 170693240
Test: m
Change-Id: I8d30b21a18759e35382f25a0706962cebbdeb096
Merged-In: I8d30b21a18759e35382f25a0706962cebbdeb096
Add CAP_BLOCK_SUSPEND to android.hardware.health@2.0 service so
that when epoll_wait() is waiting on uevents and timer_fd events
it can block suspend to take the necessary action. Without this
permission, eventpoll is going to ignore the flags EPOLLWAKEUP
used in health HAL or healthloop.
Bug: 169873088
Change-Id: I50d84dd853f718d46fb4f15113da032b60c34b0d
not exist.
Bug: 163382088
Test: Ensure that, if the ./capacity_level does not exist,
that the device will shut down at 0 % SOC in an Health 2.1
implementation
Change-Id: I00822b4bfba5d823c1a30163ea6824e59d3aae32
With a couple recent changes to APIs taking a const std::string&,
instead of a const char *, we switch to directly passing in a
reference to our string.
Test: TreeHugger
Change-Id: Id9f832dd5e3def28cfeaa0d3cda7da323332b16c
Convert rules to build charger resources to Soong
assuming BOARD_CHARGER_NO_UI is not set. As of now,
no devices in the source tree sets this variable. Also,
these images should be installed to the system image
regardless of this variable.
This change moves battery_fail and battery_scale to
/system/etc/res/images/charger.
Test: build and inspect system/etc/res/images/charger
Fixes: 143907179
Change-Id: Idccf5631371c7520cbfcfa6e92d1e88d0f3f95e7
When charger resources are missing from /product, before this change,
images are loaded from /res/images/charger. After this change, charger
first checks if the resource exists at that location, and if not, use
resource under /system/etc/res/images/charger.
On devices that uses resources from /product, this change has no effect.
On devices that uses resources from /res,
- if an old image is mounted at /, charger continues to load resources
from /res.
- if a new image is mounted at /, that is, battery_fail and
battery_scale may not exist under /res, charger loads them from /system.
There are no font files installed by modules defined here, so any
device-specific font files stay at /res.
Also create virtual function wrappers over minui APIs to be mocked
later.
See next change on moving battery_scale and battery_fail images to
/system.
Test: build and inspect system/etc/res/images/charger
Bug: 143907179
Change-Id: I4895b9602274fa4a1ebb4d7d3b842622b81b7b51
This makefile is not included before, so it was never built. Also do
the following changes to make sure it works:
- Remove non-existing libhealthd_internal dep
- Add necessary libhealthd_charger dep because it tests AnimationParser
- Since it tests AnimationParser, change its name to
libhealthd_charger_test
Test: run it
Change-Id: If7f91de4b910024f27d09a25ca801e67b98221db
The test fails because TEST_STRING, a char[], is silently
converted to a std::string, passed to remove_prefix, then
the string is destroyed, but a pointer to the string is
returned.
Fix it by changing the signature of remove_prefix to use
std::string_view to be more robust in handling raw char*.
Test: run it
Change-Id: I553c066907f09cf330c8b7a4659db5a1fee82cac
/sys/class/power_supply/*/current_now should return uA and the HAL
expects uA too.
Test: VtsHalHealthV2_0TargetTest
Bug: 136717180
Change-Id: I675be1ae645413b9494af4a5d49955aad5bd4f2e
Some devices expose the battery state of stylus etc in sysfs,
in addition to the whole system's main battery. Android only
recognizes the first battery enumerated here. We need to
filter out such HID-specific battery to let Android correctly
monitor the main battery status.
Bug: 136111013
Test: CtsBatterySavingTestCases on arcada
Change-Id: I4cbf6e3bf883fb3d107bedd2849d8ad525538629
This is necessary because the key callback may not
be called before the states are checked.
Bug: 149107347
Test: Ensure charger does not reboot
Change-Id: I08d9e4b4046768eb0c0ca6171a2e5b7e5409d073
hwservicemanager starts in charger, so directly get the health HAL
service.
Also sets up Android base kernel logging.
Bug: 142674987
Test: turn off device and charge, health HAL starts before charger, and inspect logs
to confirm charger is reading from health HAL
Test: make health HAL start after charger, and inspect logs to confirm
charger is reading from health HAL.
Change-Id: I5ba50a4b931735d1d14a50940e37c1e407dda34d
In commit 1d4368b494 ("[REFACTOR] healthd: BatteryMonitor
use health 2.1 types"), the mapSysfsString() function was
changed to return NULL instead of -1 on error.
Everywher else that function is used commit 1d4368b494
tweaked the return value check from (ret < 0) to (!ret),
but one spot was missed.
This patch corrects the one missed check so that we compare
against null rather then negative value, since the return
value can no longer be negative.
This issue was found by inspection, and I've not seen an actual
problem with it, but thought it should be corrected.
Change-Id: I0a6564274d01276352a5dc0660b8ffbe748b5fde
Signed-off-by: John Stultz <john.stultz@linaro.org>
HIDL enum values are zero initialized, not the first value
of the enum. They need to be initialized properly.
Test: pass
Change-Id: I2adb8b851e6ac607ac4f547a6a6600604d07816f
Clean up charger's libhealthd dependency.
- Charger uses libhealthloop to maintain an infinite
loop, similar to all health 2.x services.
- Charger tries to open up health 2.1 HAL implementation
to retrieve health info. If it failed, it falls back
to the legacy code path where a default BatteryMonitor
is used, *except* that it won't depend on libhealthd's
healthd_board_init() and healthd_board_battery_update()
anymore.
- Remove global static variables because they are hard to
track.
- Modernize code by converting charger_state in to a C++
Charger class, transforming all functions into methods,
and moving all other global states into the class.
- Devices that matches all of the following:
- have a customized libhealthd (search for modules
named libhealthd.xxxx)
- uses charger from system image (look for "class charger"
in device init.rc scripts; if you see the binary is named
"/charger" or "/system/bin/charger" then you are using
charger from system image)
... must implement health 2.1 passthrough implementation
properly in order to have charger continue to work.
See hardware/interfaces/health/2.1/README.md for details.
Test: charger test
Test: manual charger mode
Bug: 127677771
Bug: 142286265
Change-Id: I0f26e5c1fe2be6b5952fc019224457c8419e43e4
- batteryCurrentAverage
- batteryCapacityLevel
- batteryChargeTimeToFullNowSeconds
- batteryFullCapacityUah
Some of the fields are left 0 / UNKNOWN and will be
implemented in b/142260281.
Bug: 142260281
Test: lshal debug health 2.1 HAL shows these values
Change-Id: I8e462d612b39c16cfb3ae1b63b3e293153585c28
... instead of BatteryProperties. HealthInfo contains
much more information and is easy for health HAL impl
to use it.
Also add getHealthInfo* functions for health HAL
implentations to use.
Test: health VTS 2.0 test
Bug: 142260281
Change-Id: I188276788fd8f11e69f8e046b91a873afaa23457
split bool update() into three functions:
void update()
void logValues()
bool isChargerOnline
... so that it doesn't depend on healthd_board_battery_update and
healthd_mode_ops, which are deprecated.
Test: health 2.0 VTS test
Bug: 142260281
Change-Id: I65908a04bae00654213efb4b5569ced0a7e76076
Since these were combined into libhidlbase.
Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: I0bdffced6af52695c0ef98c9dd659348e56f7aa6
sysprop_library now checks the API stability itself, cutting dependency
on java_sdk_library. Under the directory {module_dir}/api,
{module_name}-current.txt and {module_name}-latest.txt hold API
signatures.
When sysprop_library is built, or a user run "m {module_name}-check-api"
command, API check is performed. First, current.txt must have exactly
same signature with built sysprop_library module. Second, current.txt
must be compatible with latest.txt.
Build system emits a handy error message to generate/update those API
files, in case of missing or mismatching. Also, a script file for
freezing API files is introduced.
Bug: 131637873
Test: 1) m && boot blueline
Test: 2) m {sysprop_library} performs API check
Test: 3) manual test for check-api, freezing api
Change-Id: I6b95eebafaf88ad326be5d7c890e000cbdb79cb5
Merged-In: I6b95eebafaf88ad326be5d7c890e000cbdb79cb5
(cherry picked from commit f711999132)