Commit graph

324 commits

Author SHA1 Message Date
Florian Mayer
6e2276b28a Add healthd to hwasan-postsubmit
Test: Run tests under HWASan.
Bug: 193568145
Change-Id: I710628acb0fffcbf670e4e30059f3cfa284f9540
2022-03-18 21:19:00 +00:00
Bart Van Assche
095c944b48 healthd: Convert multiple private methods into static nonmember functions
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>
2022-03-03 18:46:12 +00:00
Bart Van Assche
5a7e5083e6 healthd: Fix readFromFile()
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>
2022-03-03 18:46:12 +00:00
Bart Van Assche
024e18f060 healthd: Make initHealthInfo() easier to read
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>
2022-03-03 18:46:12 +00:00
Bart Van Assche
25b2a8de53 healthd: Improve readability of BatteryMonitor::init()
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>
2022-03-03 18:46:12 +00:00
Yifan Hong
b99d15c529 healthd: batterymonitor uses AIDL HealthInfo.
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
2022-03-02 16:20:35 +08:00
Jack Wu
56540a0509 charger: support screen rotation
Bug: 191831427
Test: charging animation can show in display correctly
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: Iedcd7d6c3cd841c44bdf1116701abcbd12a26959
2022-01-27 13:27:59 +08:00
Jack Wu
3d637a9abb charger: process hall_sensor event to show charging animation
Bug: 191831427
Test: charging animation can show in display correctly
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: Id99a7401f53f647790e179e995dad9841f8284bb
2022-01-25 20:00:53 +08:00
Jack Wu
c1b171138e Charger: support secondary connector
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
2022-01-25 19:59:04 +08:00
Jack Wu
06b9041736 BatteryMonitor: support Dock charging
Bug: 194012532
Test: Show dock type correctly
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: I1698328b7b20c23d9b2571b7dbf1b907834582c8
2022-01-13 20:30:32 +08:00
Hridya Valsaraju
dcdb160411 healthd: remove hridya@ from OWNERS file
Test: N/A
Bug: N/A
Change-Id: Iffa783ea22d278c50df0c7a87f7f265c26a5c7c1
2022-01-06 16:56:57 -08:00
Yifan Hong
5771858dc0 healthd: *charger_test links to a.h.health@2.x statically.
These libraries might not be installed on the device
any more.

Fixes: 210093617
Test: run it
Change-Id: Ic1bc6ba3c78ccaad93aef00ab695f3c2acd2b367
2021-12-13 14:12:05 -08:00
Yifan Hong
ac748369bb charger: vendor charger use resources from /vendor
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
2021-11-02 13:52:40 -07:00
Yifan Hong
e3ffd1bfc2 charger: make libhealthd_charger_ui vendor_available.
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
2021-11-02 13:52:40 -07:00
Yifan Hong
8e55134f43 charger: Add API to replace ro.charger.enable_suspend
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
2021-11-01 12:38:56 -07:00
Yifan Hong
b5d7033dcc charger: separate UI and HAL access.
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
2021-11-01 12:38:56 -07:00
Xiaohui Niu
a40d872989 charger: fix charger display stuck
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.
2021-09-02 03:17:58 +00:00
Bob Badour
d69ad69a93 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Id740a7d2884556081fdb68876584b25eb95e1bef
2021-02-19 12:59:05 -08:00
Elliott Hughes
c3a206ccda Revert "[LSC] Add LOCAL_LICENSE_KINDS to system/core"
This reverts commit 187b7d1950.

Reason for revert: system/core is multiple projects, not one.

Change-Id: I790ea41741f8cd9b8b6db2f59a49e71fb0958fd6
2021-02-16 20:01:20 +00:00
Bob Badour
187b7d1950 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  Android.bp
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I5bd81adb5cdcf2b4dd4141b204eb430ff526af8f
2021-02-16 04:10:03 -08:00
Yifan Hong
605e7d20ee BatteryMonitor: Add helper of logValues()
... 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
2021-02-08 15:22:28 -08:00
Yifan Hong
d86f5b99f8 Remove healthd.
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
2021-01-11 15:44:58 -08:00
Yifan Hong
ae11855809 Merge "health: Add CAP_BLOCK_SUSPEND" 2020-10-15 20:24:17 +00:00
Inseob Kim
340d28487a Update sysprop_library API txt
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
2020-10-15 04:04:15 +00:00
Subbaraman Narayanamurthy
28ebc23625 health: Add CAP_BLOCK_SUSPEND
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
2020-10-14 12:30:19 -07:00
Stephane Lee
bab6877710 Assume UNSUPPORTED if the battery capacity level sysfs node does
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
2020-08-13 14:31:02 -07:00
Greg Kaiser
8763fd26fb charger: Avoid a couple string constructions
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
2020-08-12 07:03:50 -07:00
Yifan Hong
c2bed97e10 charger: Add tests for loading animation resources
Bug: 143907179
Test: run it

Change-Id: I1b1dfe4947210932c674657689e396ae909013c2
2020-08-07 17:07:09 -07:00
Yifan Hong
5109c8ce04 charger: Move built-in resources to /system
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
2020-08-07 17:07:09 -07:00
Yifan Hong
abda7153fe charger: Load default resources from /system
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
2020-08-07 17:07:09 -07:00
Yifan Hong
186b4d9ddd Add libhealthd_charger_test to presubmit.
Test: atest --test_mapping
Change-Id: Idae68e575f66b53c8b587405856b4a1c532ecadc
2020-08-05 20:00:09 -07:00
Yifan Hong
12d15750fe Convert healthd_test to Soong
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
2020-08-05 20:00:09 -07:00
Yifan Hong
2a06ae8299 Fix AnimationParser remove_prefix test
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
2020-08-05 20:00:09 -07:00
Yifan Hong
e5bd5f914f BatteryMonitor: report current_now in uA
/sys/class/power_supply/*/current_now should return uA and the HAL
expects uA too.

Test: VtsHalHealthV2_0TargetTest
Bug: 136717180
Change-Id: I675be1ae645413b9494af4a5d49955aad5bd4f2e
2020-04-08 16:24:17 -07:00
Kazuhiro Inaba
8e4d982d52 healthd: Don't take device-scoped battery as the main system battery.
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
2020-03-16 12:50:42 +09:00
Stephane Lee
06846044fe Add UNSUPPORTED to health HAL 2.1 values
Bug: 149429835
Test: lshal debug android.hardware.health@2.1::IHealth/default
Change-Id: Ibbcd89f38ed9ec2966b31854ab1cbe218c8e19cb
2020-02-15 16:51:02 -08:00
Stephane Lee
1c108edc74 Consume design capacity in health HAL 2.1
Bug: 149121450
Test: lshal debug <health hal 2.1>
Change-Id: I005fa47bda7e58f6636fdc87293227622d74187a
2020-02-13 15:14:40 -08:00
Stephane Lee
d43724d0b3 Initialize key structure to zero in charger
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
2020-02-10 16:38:04 -08:00
Yifan Hong
3aa3b3c627 charger: uses health HAL service.
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
2020-01-31 13:29:21 -08:00
Stephane Lee
86f9f6aed5 Populate fields for health HAL 2.1
+ batteryCapacityLevel
+ batteryChargeTimeToFullNow

Bug: 137790244
Test: lshal debug (health service)
Change-Id: Ieb0b42e6cdded5974f01198ee151453367f82579
2020-01-22 10:50:05 -08:00
Treehugger Robot
ec56c59dbb Merge "healthd: Fix incorrect return check" 2019-11-07 21:18:59 +00:00
John Stultz
47a6bf014d healthd: Fix incorrect return check
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>
2019-11-06 01:40:18 +00:00
Yifan Hong
6cabe9bbc7 BatteryMonitor: init health info properly.
HIDL enum values are zero initialized, not the first value
of the enum. They need to be initialized properly.

Test: pass
Change-Id: I2adb8b851e6ac607ac4f547a6a6600604d07816f
2019-11-06 01:37:01 +00:00
Yifan Hong
7dcf7b0639 healthd: Remove libhealthd dependency from charger
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
2019-10-30 13:48:08 -07:00
Yifan Hong
35cb0838f6 healthd: partially fill in health 2.1 HAL fields
- 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
2019-10-23 14:55:35 -07:00
Yifan Hong
1d4368b494 [REFACTOR] healthd: BatteryMonitor use health 2.1 types
... 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
2019-10-23 14:55:35 -07:00
Yifan Hong
1353e70278 [REFACTOR] healthd: BatteryMonitor::update split into 3 funcs
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
2019-10-14 14:07:13 -07:00
Steven Moreland
a4eaf64de8 Remove libhwbinder/libhidltransport deps
Since these were combined into libhidlbase.

Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: I0bdffced6af52695c0ef98c9dd659348e56f7aa6
2019-09-05 14:17:42 -07:00
Inseob Kim
34114e3df3 Implement sysprop_library API stability check
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)
2019-08-20 16:16:40 +09:00
Yifan Hong
958216c97f Merge changes from topic "charger_props"
am: 7cea50acd8

Change-Id: Ie5eeaa55a3749e2a155010aecf37ecacb43a7e88
2019-07-25 11:35:44 -07:00