Commit graph

218 commits

Author SHA1 Message Date
Stephane Lee
f8c94a9b7c Allow batteryFullChargeDesignCapacityUah to be 0
Bug: 166841711
Test: Run VtsHalHealthV2_1TargetTest with a battery design capacity of 0
Change-Id: I48bea0e2a8e4f8eeba8874e44a9bf6aa00bfd637
Merged-In: I48bea0e2a8e4f8eeba8874e44a9bf6aa00bfd637
(cherry picked from commit 6bed2f3207)
2020-09-25 23:42:11 +00:00
Stephane Lee
30b54c45b7 Allow batteryChargeTimeToFullNowSeconds to be -1
Test: Run the test under an implementation that doesn't support
  batteryChargeTimeToFullNowSeconds
Bug: 166841711
Change-Id: I18fb11bb0a2233a9a89183a5f9ecf597e7719172
Merged-In: I18fb11bb0a2233a9a89183a5f9ecf597e7719172
(cherry picked from commit c2dc510a0a)
2020-09-24 17:31:09 +00:00
Yifan Hong
c12c576999 Fix sanitize address after scope
Test: pass
Fixes: 156199719
Change-Id: Icaf1e6d379199eec4d664494819405acc013a003
Merged-In: Icaf1e6d379199eec4d664494819405acc013a003
2020-05-13 17:20:03 +00:00
Yifan Hong
133c495d1a health 2.0 vts: add battery current test.
Require the following on battery current:
- skip health info tests if current is 0 (indicates the value is unavailable)
- when charging, positive
- when discharging / not charging, negative
- when unknown, zero
- batteryCurrentAverage should be similar to batteryCurrentNow.

All new tests are executed over
a period of time to avoid effects of fluctuation in
battery current, and ensure battery status is initialized.

Requirements are enforced on devices launching with R
only.

Require the following on battery status:
- if not charging / full / charging, must be connected
- if discharging, must not be connected.

Test: run on coral, tests are skipped
Test: run on cuttlefish, test passes

Fixes: 136717180
Change-Id: Ic5a714b830ffeca1dcd000c6cad0fbfe8a8710ed
(cherry picked from commit 94841c9df1)
Merged-In: Ic5a714b830ffeca1dcd000c6cad0fbfe8a8710ed
2020-04-10 21:51:15 +00:00
Yifan Hong
a6491f8adf health 2.0 VTS: require GTEST_SKIP to be defined
This is a hack to support the test in Android P. Now that gtest
has been updated, we no longer need this hack.

Test: run it
Bug: 118852225
Bug: 136717180
Change-Id: I81802b6fae0dc7839aa9fd1dd40cb881ff4eefdb
(cherry picked from commit 9fb96fa4b0)
Merged-In: I81802b6fae0dc7839aa9fd1dd40cb881ff4eefdb
2020-04-09 14:41:17 -07:00
Dan Shi
aad51fa000 Rename vts-core to vts
Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL update suite name vts-core to vts as
the suite name is updated. This CL won't change test logic or behavior.

Change-Id: I562b4dc50765e953800a814a8fd84a01c1b9352b
Merged-In: I562b4dc50765e953800a814a8fd84a01c1b9352b
2020-04-07 16:37:40 -07:00
Steven Moreland
0c217577e3 Remove String8(StaticLinkage) references.
These are a legacy holdover from when libutils String8 couldn't be used
at static time.

Bug: 150325737 # fixing GSI breakage
Test: N/A
Change-Id: I009b2ca53631509072b4085f3f53c0b94e71b13e
(cherry picked from commit 15f04b8af9)
Merged-In: I009b2ca53631509072b4085f3f53c0b94e71b13e
2020-02-27 17:44:23 +00:00
Stephane Lee
0b6542c17b Add UNSUPPORTED to health 2.1 types
Test: lshal debug android.hardware.health@2.1::IHealth/default
Bug: 149429835
Change-Id: I084d225d49eada022e3f2504bacdb67c0c241697
2020-02-15 17:25:18 -08:00
Treehugger Robot
0935243c44 Merge "Fix VTS test for health HAL 2.1" 2020-02-16 00:16:05 +00:00
Stephane Lee
32c4ec09d4 Fix VTS test for health HAL 2.1
Latest update on the ticket to use hard coded thresholds

Test: atest VtsHalHealthV2_1TargetTest
Bug: 149428646
Change-Id: Id7f86ba05a203a926e8d316bf7af4d24c7e0e2f0
2020-02-14 15:30:17 -08:00
Stephane Lee
45f8ab3477 Fix logging in Health HAL 2.0
Bug: 149577800
Test: Ensure logging works as expected
Change-Id: I79b78593ee6bdbda59e49a27e70076184a30668d
2020-02-14 11:56:48 -08:00
Stephane Lee
34714688d5 Use design capacity instead of full charge capacity
Full charge capacity is already included as part of
health HAL 1.0. Concluded in b/149121450 to add a value
that is valuable.

Bug: 149428646
Bug: 149121450
Test: lshal debug android.hardware.health@2.1::IHealth/default
Change-Id: Iadf3c14850df57034378dcc10cdbab0eb43c3aae
2020-02-13 15:19:56 -08:00
Yifan Hong
c6e3fd118a Fix health.storage test
- fix root
- fix test timeout

Test: adb unroot and atest

Fixes: 149044321

Change-Id: Icc34af149641f7fe5035cee1fe9685b395adc22f
2020-02-07 22:49:07 +00:00
Treehugger Robot
98a05a0bbb Merge "Revert "Update health 2.1 readme for file_contexts"" 2020-02-03 19:18:25 +00:00
Yifan Hong
056ffd93ed Merge changes from topic "health_charger"
* changes:
  Update health 2.1 README for non A/B devices.
  Add default health 2.1 service to class charger
2020-02-03 18:12:23 +00:00
Yifan Hong
aafba97a5a Revert "Update health 2.1 readme for file_contexts"
This reverts commit ca44707aea.

Reason for revert: charger uses hwbinder health HAL now

Bug: 142674987
Test: none

Change-Id: I2be2d393331ad3c377e0b144cfe0c92d3ab59689
2020-02-01 01:33:27 +00:00
Yifan Hong
b9c4082061 Update health 2.1 README for non A/B devices.
Non A/B devices should install the passthrough health impl
to recovery for IsBatteryOk() check during OTA updates.

Test: pass
Change-Id: Ib83518fd5f8f55f693be88a55fa708459a22417f
2020-01-31 17:20:08 -08:00
Yifan Hong
b6f7e58a64 Add default health 2.1 service to class charger
... so that it starts up in charger mode.

Test: boot charger and look at serial log
Bug: 142674987
Change-Id: Ic535b86840df1408b76e556f942aebdd9aaba111
2020-01-31 13:26:55 -08:00
Yifan Hong
8ae16915ac Merge "health 2.1 VTS: fix test on batteryFullCapacityUah" 2020-01-29 20:30:57 +00:00
Yifan Hong
3f91f296ba health 2.1 VTS: fix test on batteryFullCapacityUah
getHealthInfo_2_1 reports batteryFullCapacityUah:
- 0 if value is unknown. In such case, no requirement is enforced.
- positive if value is known. In such case, require it to be 50%~120% of
  batteryFullCharge.

Test: run on cuttlefish
Bug: 144948996

Change-Id: I7856729aafa3a19a3bfcc00e6e0ad5162f22afea
2020-01-28 19:00:53 -08:00
Treehugger Robot
c9d0f25cfa Merge "health 2.0 vts: Allow for battery-less devices" 2020-01-28 21:16:01 +00:00
Yifan Hong
5ac6f5bc99 health 2.0 vts: Allow for battery-less devices
Battery-less devices reports UNKNOWN for getChargeStatus.
Allow it.

Test: on cuttlefish
Change-Id: I06dd2841d43cab9528209d0bfd61969a8f2409c8
2020-01-27 16:22:07 -08:00
Yifan Hong
7474381275 Add health 2.1 to vts-core.
Test: TH
Bug: 144948996
Change-Id: Icc58506841c7a3b754661b36788d2acdae168109
2020-01-27 16:15:48 -08:00
Stephane Lee
8bc403e1e2 Initialize paths for health 2.1
+ batteryCapacityLevelPath
+ batteryChargeTimeToFullNowPath

Bug: 137790244
Test: lshal debug (health service)
Change-Id: I219ecc3dc77be70073761d9da5f5ee39ad76387d
2020-01-17 15:57:33 -08:00
Yifan Hong
ca44707aea Update health 2.1 readme for file_contexts
-impl file needs to be marked as same_process_hal_file
for charger to work.

Test: none
Change-Id: I998493949284362fbd1dcb8e2a1d48958feb1324
2020-01-09 17:20:10 -08:00
nelsonli
4da3ca57ab [vts-core] add VtsHalHealthV2_0TargetTest to vts-core
Convert VtsHalHealthV2_0TargetTest to be parameterized test
and add it to vts-core

Bug: 142397658
Test: $atest VtsHalHealthV2_0TargetTest
Change-Id: I415a494243536f931f168665e1b9196fc83c8de7
2019-12-11 14:32:55 +08:00
Yifan Hong
b808bd7d46 health 1.0: add helper library for -impl
Now that libhealthd is no longer recognized as a HAL_STATIC_LIBRARY,
vendors must define their own android.hardware.health@1.0-impl module.
Add a helper and README.md for them to explain this transition.

Test: builds
Bug: 127677771
Change-Id: I65c162e7b5caed93c39a4a1cb6a2893fbb25724b
2019-12-03 12:51:45 -08:00
Yifan Hong
891220af48 health 1.0 default -> Soong
Now that HAL_STATIC_LIBS are removed, convert to Soong.
Also, avoid using global includes and use libbase_headers instead.

Test: builds
Change-Id: I50ef691e049ed0943de6f384ce7ddba96c0345a5
2019-12-03 12:51:45 -08:00
Yifan Hong
16273aea66 health 1.0 does not use HAL_STATIC_LIBS
BOARD_HAL_STATIC_LIBRARIES is deprecated / obsolete. No devices
in our internal tree uses it. Devices that uses it should build
their own HALs and link to the correct libhealthd.(board) in
that vendor-specific module.

Test: pass
Bug: 127677771

Change-Id: I289d020960331e2dc2225ccbd378a73ccc51a056
2019-12-03 12:51:45 -08:00
Yifan Hong
b68a055c68 Merge "health 2.0: Check health_loop status for passthrough usage" 2019-11-26 00:25:03 +00:00
Hridya Valsaraju
55f1a1f3f6 health 2.0: Check health_loop status for passthrough usage
health HAL is used as passthrough in recovery mode and hence
healthd_main() is not invoked. Add checks in
healthd_battery_update_internal() and healthd_register_event()
to return when health_loop is NULL.

Test: fastboot getvar battery-voltage works in fastbootd.
Bug: 144299329

Change-Id: I0a975a4bfe942813f9c5b3936df91cc3d8fa9674
2019-11-23 02:07:08 +00:00
Treehugger Robot
7a83bc5d27 Merge "[vts-core] add VtsHalHealthStorageV1_0TargetTest to vts-core" 2019-11-13 01:48:21 +00:00
Haibo Huang
83b4c1e3e1 Fix build with new googletest
The new googletest requires prefix to be non-empty.

Change-Id: I3ebd13861c4803b53dbeb4ac5f247984814bef45
2019-11-08 12:17:34 -08:00
nelsonli
d93a6ccf5b [vts-core] add VtsHalHealthStorageV1_0TargetTest to vts-core
Convert VtsHalHealthStorageV1_0TargetTest to be parameterized test
and add it to vts-core

Bug: 142397658
Test: $atest VtsHalHealthStorageV1_0TargetTest
Change-Id: I0e91e0958c2dc351a0e9af03fd977f55f418d1f5
2019-11-07 10:05:34 +08:00
Yifan Hong
e438211a0f health 2.1 implementation.
Test: VTS health 2.1 test
Bug: 137670450

Change-Id: I04ea74facbaa534eee00a51474a013db3b6eb212
2019-10-30 11:15:24 -07:00
Treehugger Robot
c280f899c3 Merge "[vts-core] add VtsHalHealthV1_0TargetTest to vts-core" 2019-10-30 01:55:23 +00:00
Treehugger Robot
d57bd9622a Merge "[REFACTOR] health 2.0: battery monitor returns health info 2.0" 2019-10-29 03:52:54 +00:00
nelsonli
cb460b6dae [vts-core] add VtsHalHealthV1_0TargetTest to vts-core
Convert VtsHalHealthV1_0TargetTest. to be parameterized test
and add it to vts-core

Bug: 142397658
Test: $atest VtsHalHealthV1_0TargetTest.
Change-Id: I3abfbfe0c20a5fe595f32c4793b2c53f6ad13e28
2019-10-28 07:25:51 +00:00
Yifan Hong
a1e654d8f1 Merge changes from topic "health21"
* changes:
  Require health 2.1 on R devices
  health 2.1
2019-10-24 01:03:09 +00:00
Yifan Hong
17fad82187 Merge "[REFACTOR] health 2.0: BatteryMonitor::update split into 3 funcs" 2019-10-22 22:47:40 +00:00
Treehugger Robot
9a41dd7f5a Merge changes from topic "libhealthloop"
* changes:
  [REFACTOR] health 2.0: healthd_common -> libhealthloop
  health 2.0: Move healthd_common.cpp
2019-10-21 20:01:48 +00:00
Yifan Hong
00ebc75aef [REFACTOR] health 2.0: battery monitor returns health info 2.0
BatteryMonitor returns HealthInfo structs directly. Modify
code to adapt to this behavior.

Test: health VTS test 2.0
Bug: 142260281
Change-Id: I5e6605e46bb4f8bb08c1356e5f2233880e6f9d14
2019-10-15 17:38:40 -07:00
Yifan Hong
ed0fead8e4 health 2.1
Test: builds
Bug: 137670450

Change-Id: Ie8ec2733ee5338fef3639ab4deda47c9e5ce2179
2019-10-15 17:38:40 -07:00
Robin Lee
ac5a0d316b health VTS: Status::UNKNOWN is OK if not present
Documentation: https://source.android.com/devices/tech/power/batteryless

If a battery device is not detected, the following battery-related
defaults are used on Android 9 and higher:

* Present:              false
* Status:               unknown
* Remaining capacity:   0
* Health:               unknown
* AC charger online:    not modified

The previous version of the test failed devices if the vendor HAL
reported BatteryStatus::UNKNOWN. However, the tests were skipped if the
default HAL was the one being used, so this has not come up before for
other batteryless devices.

Bug: 142081126
Test: vts-tradefed run vts -m VtsHalHealthV2_0
Change-Id: I8ca758677478b47511e24990fee545fafa6c7f83
2019-10-15 20:44:07 +02:00
Yifan Hong
9521b9d458 [REFACTOR] health 2.0: BatteryMonitor::update split into 3 funcs
BatteryMonitor::update no longer calls healthd_board_battery_update
and callback for us.

Test: VTS health HAL 2.0 test
Change-Id: I05fbf60b7e2c38f82e019d2fec2b5f535defaeae
2019-10-14 15:24:21 -07:00
Yifan Hong
50c9e25251 [REFACTOR] health 2.0: healthd_common -> libhealthloop
This change converts the original healthd_common.cpp to a
C++ class, HealthLoop, that manages the infinite loop in health-related
modules (charger, health HAL, healthd, etc.). By doing so, the global
static variables (including FDs and healthd_mode_ops) are cleaned up.

This helps us implement health HAL 2.1.

In order to support legacy modules (namely, healthd, charger, health HAL
2.0, which all depends on android.hardware.health@2.0-impl), a
healthd_common_adapter.cpp file is added to
android.hardware.health@2.0-impl, so that the following functions
in healthd/healthd.h continues to be implemented using the global
healthd_mode_ops:
    - healthd_register_event
    - healthd_battery_update_internal

Test: boot up the device and run VTS test on health HAL.
Bug: 137670450
Bug: 142260281
Change-Id: Iadcfc1315155404a3600f0e1219b5bc370d96409
2019-10-14 15:24:21 -07:00
Yifan Hong
c04b0a3e20 health 2.0: Move healthd_common.cpp
... so that the next CL has less diff.

Test: see next CL.
Change-Id: I5be187ab859a0b26d615b5ba7af9a26a07880181
2019-10-14 15:24:21 -07:00
Steven Moreland
b3a4d3832e Remove libhwbinder/libhidltransport deps
Since these were combined into libhidlbase.

Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: I075670b64eebbbbd6a6ae0e84ad51bf1c6f5ba36
2019-09-06 01:07:02 +00:00
Peter Kalauskas
0c7812c7f5 Merge "Convert LazyServiceRegistrar usage to singleton"
am: f71728f04b

Change-Id: Ia9c99cc1b986f266f0239aefcd74600d0c3485da
2019-08-16 11:54:24 -07:00
Peter Kalauskas
701e7f6616 Convert LazyServiceRegistrar usage to singleton
Test: lshal
Bug: 139376253
Change-Id: Ib1cbfabec23a488868e807a4a9c2b29cd960cc1e
2019-08-14 13:53:14 -07:00