Commit graph

291 commits

Author SHA1 Message Date
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
Yifan Hong
dbaa477a70 healthd: Convert libhealthd_{draw,charger} to Soong.
Converting charger to Soong, one step at a time.

In the meantime, drop the use of BOARD_*/TARGET_* variables
in Android.mk because runtime sysprops will be used instead.
Libraries / binaries will always link to libminui / libpng /
libsuspend.

charger{.recovery,} can't be converted to Soong yet because
of the use of HAL_STATIC_LIBRARIES (Bug 127677771).

charger_test isn't converted because of the shared list
of CHARGER_{STATIC,SHARED}_LIBRARIES.

Bug: 124118169
Test: run charger on walleye

Change-Id: I355deda14e5b5c9938256ff0b778590ac0191095
2019-07-24 17:01:40 -07:00
Yifan Hong
97eecdc875 healthd: charger use runtime sysprops instead.
Bug: 124118169
Test: run off-mode charging
Change-Id: Ib71f84f1c93d1566f4e3101920d98b1d39184390
2019-07-24 17:01:40 -07:00
Yifan Hong
dcbaeef6e3 healthd: remove unused variable.
Test: builds
Change-Id: If12cfd31353cd26b41c1c07f44761cea3c46c34a
2019-07-24 17:01:40 -07:00
Steven Moreland
451e764bdc Merge "libhwbinder users use libhidlbase" into qt-dev
am: 490f1cf074

Change-Id: Ib20f4dc87cb2aea1350af98be9bb65eb7575a6fd
2019-06-20 13:09:55 -07:00
Steven Moreland
aedef73b9c libhwbinder users use libhidlbase
libhwbinder symbols are being moved into libhidlbase in order to
optimize linking/memory usage. libhwbinder will no longer be
required in the future (however removing references to it will come
separately).

Bug: 134961554
Test: boot
Change-Id: I2b9a4fb9d87913b6c0e4291d3debadbf27511111
2019-06-18 15:38:10 -07:00
John Zhao
5cac100e3d healthd: charger: shutdown timer configurable
config the shutdown timer via the property system
for vendor customize.

Bug: 129599884
Test: setprop ro.product.charger.unplugged_shutdown_time 5000
      getprop ro.product.charger.unplugged_shutdown_time
      5000
      dmesg:
          charger: [371812] device unplugged:
                   shutting down in [5000] (@ 421812)

Change-Id: Ifa377cdb8e100c453346522a3eb93379fd7e2567
Signed-off-by: John Zhao <yuankuiz@qualcomm.corp-partner.google.com>
2019-04-08 12:46:47 -07:00
Ken Tsou
6c7ece743c charger: fix show 0% symptom when start to draw UI
Bug: 123060995
Test: m -j succeeded and confirm offmode charge UI behavior
Change-Id: I7412157cfe829a86e72b3f43d9c43032f3567ed3
2019-03-29 18:33:00 +08:00
Yifan Hong
dc9c08b900 charger: android_get_control_file on last_kmsg
Call android_get_control_file on last_kmsg files if the file
descriptor is provided by init.

Also, uses base::Read(File|Fd)ToString functions to read the
files (because load_file doesn't support fd arguments).

Test: charger mode
Test: manual kernel panic, then start charger; seen last kmsg.

Bug: 129138950
Change-Id: Idd3376e349f29586a1e66faab2c0f1bf73e0eda5
2019-03-26 15:51:55 -07:00
Tao Bao
5747e228f7 healthd: Add charger.recovery module.
This CL splits out healthd_mode_charger_nops for building
charger.recovery. It doesn't change the functionality of the charger
module under recovery, i.e. a) it still doesn't do much work other than
reporting the battery status periodically; b) it keeps calling
device-specific healthd functions (healthd_board_init and
healthd_board_battery_update) via the statically linked HAL.

Previously `charger -r` was used to indicate starting charger under
recovery mode. This CL makes it a noop since we've changed the caller in
recovery.

Bug: 73660730
Bug: 114042635
Test: Boot into charger mode on walleye. Check that charger UI works.
Test: Boot into recovery mode on walleye. Check that /system/bin/charger
      keeps working.
Test: Run charger_test on walleye.
Change-Id: Id91acfcc77ec315c2382392dc54e36c3e85de2eb
2019-03-06 14:41:47 -08:00
Tao Bao
f2455d8068 healthd: charger uses shared libraries.
With the change in [1], /sbin/charger always gets included into
system.img (as opposed to ramdisk) and started by second-stage-init. It
no longer needs to be statically linked. This CL switches it to use
shared libraries, and moves it to /system/bin/charger.

With this change, charger no longer gets installed into recovery image,
which will be handled by a follow-up CL.

[1] https://android-review.googlesource.com/c/platform/build/+/728287

Bug: 73660730
Test: Boot into charger mode on taimen. Check that charger UI works.
Test: Run charger_test on taimen.
Change-Id: Idff70cfad09c825cdba4d35a471ff7ecd5f8a8f7
2019-03-06 14:36:59 -08:00
Suren Baghdasaryan
82b72a5667 libprocessgroup: Add support for task profiles
Abstract usage of cgroups into task profiles that allows for changes
in cgroup hierarchy and version without affecting framework codebase.
Rework current processgroup and sched_policy API function implementations
to use task profiles instead of hardcoded paths and attributes.
Mount cgroups using information from cgroups.json rather than from init.rc

Exempt-From-Owner-Approval: already approved in internal master

Bug: 111307099
Test: builds, boots

Change-Id: If5532d6dc570add825cebd5b5148e00c7d688e32
Merged-In: If5532d6dc570add825cebd5b5148e00c7d688e32
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-02-03 16:48:35 +00:00
Treehugger Robot
accdf0e9c7 Merge "healthd: update owners" 2019-01-29 22:24:34 +00:00
Yifan Hong
505b5513b4 healthd: update owners
Test: pass
Change-Id: I2efea4086ef9f8d9865da387bfc91345a31fc123
2019-01-28 14:55:39 -08:00
Yifan Hong
082d295fb3 healthd: charger loads resources from /product
Load resources from /product/etc/res/{values,images}/charger. If a
resource fails, falls back to /res/{values,images}/charger.

If the device has GSI flashed, resources may exist in both paths.
Resources in /product is used with a higher priority.

Test: turn off device, charge, observe animation
Bug: 119549685
Change-Id: I5a5143d132a0cc6ce9135469fb523feeeafd1b1b
2019-01-28 14:46:53 -08:00
Suren Baghdasaryan
02843339f9 Add dependencies on libprocessgroup for sched_policy users
After moving sched_policy functions into libprocessgroup its users require
additional dependency and inclusion of sched_policy_ctrl.h header.

Exempt-From-Owner-Approval: janitorial

Bug: 111307099
Test: builds, boots

Merged-In: Icc052080e1bce46ce06f7264446950cab0490a95
Change-Id: Icc052080e1bce46ce06f7264446950cab0490a95
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-22 18:19:45 +00:00
Thierry Strudel
f73de6f037 healthd.h: add ignorePowerSupplyNames to healthd_config
In case some power supply paths should not be considered, add a black list
to the healthd_config to instruct BatteryMonitor of the power supply paths
to ignore on init.

Bug: 117903348
Change-Id: I6f9ddeff9351ad01772b43728ddc2627da81df2a
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2019-01-11 18:08:23 -08:00
Felix
fb55955462 health: Add CAP_WAKE_ALARM to service via init
platform/interfaces/health/2.0/default/healthd_common.cpp wants to use
timerfd_create() to register a wakealarm.

To use the timerfd_create() syscall with CLOCK_BOOTTIME_ALARM,
CAP_WAKE_ALARM is needed.

Since the .rc file for android.hardware.health@2.0 is shipped here in
system/core, update it here.

Signed-off-by: Felix <google@ix5.org>
Change-Id: I6cd5701b6e5cac37eb021d894251a3a9dc590b95
2019-01-04 02:24:41 +01:00
ShevT
9d98a6ac93 healthd: BatteryMonitor: Fix compiler warning
system/core/healthd/BatteryMonitor.cpp:248:19: note: initialize the variable 'i' to silence this warning
    unsigned int i;
                  ^
                   = 0
1 warning generated.

Change-Id: Ib2fa0061d657fd93871ca8a9056d173d5b7ab58d
2018-11-02 17:59:09 +00:00
Tao Bao
777af95c4e healthd: GRSurface now is a class.
Test: mmma -j system/core/healthd
Change-Id: I696542535cf4707c707c4f024de504ce343b1e69
2018-10-22 13:20:33 -07:00
Elliott Hughes
643268f325 Move system/core/ off NO_ERROR.
It causes trouble for Windows, and OK already exists.

Bug: N/A
Test: builds
Change-Id: Ida22fd658b0ebb259c710ba39049b07c9e495d9c
2018-10-08 11:15:52 -07:00
Jayant Chowdhary
c2d3949693 Reland "Add static libbinderthreadstate explicitly to charger module.""
This reverts commit 17a65497bb.

Reason for revert: Dependencies which broke tests due to exclusion from LOCAL_JNI_SHARED_LIBS have been added. 

Change-Id: I51e8ea7072026f233cd4a6c7e2142d92603af1f9
2018-10-01 22:50:07 +00:00
Remi NGUYEN VAN
17a65497bb Revert "Add static libbinderthreadstate explicitly to charger module."
This reverts commit f23fa3b12f.

Reason for revert: This breaks framework tests and blocks presubmit

Change-Id: Iccf29d7499c378c611ea5a783074865febf8514e
2018-09-28 07:50:18 +00:00
Jayant Chowdhary
f23fa3b12f Add static libbinderthreadstate explicitly to charger module.
Bug: 110364143

Bug: 114311116

Test: Builds

Change-Id: I367cab4f6113d72bbaf1c9a41099110124916f57
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
2018-09-27 10:36:13 -07:00
Tao Bao
b6ccc78e0c healthd: Drop the unneeded include path.
libminui has been exporting headers since Oreo.

Test: mmma -j system/core/healthd
Change-Id: Iaadfa526619dcd4837a97b78cfa03dc69ffa4000
2018-09-06 15:14:31 -07:00
kentsou
ba61ea462f charger: screen blank on disconnect and 0% not displayed
Bug: 74771887
Test: m -j succeeded and confirm offmode charge UI behavior
Change-Id: I8c97230f6c1e32ac9949601a86added79a3ead82
Signed-off-by: kentsou <kentsou@google.com>
2018-08-17 03:58:19 +00:00
Tao Bao
d6b7711e3d Merge "charger: minui error handling fixups"
am: bc31fc62ce

Change-Id: I48633f51f5259d783e7f72f98576ffbd8c26abbf
2018-07-30 10:39:55 -07:00
Todd Poynor
e5d1b62300 charger: minui error handling fixups
Log an error if minui init fails, and avoid subsequent calls to minui
in this case (which are likely to crash).

Warn if no system text font available.  This is now expected on most
devices, and the fallback text is not expected to be needed, but just
in case.

Avoid the attempt to print text if no system font available, log
warnings instead.

Bug: 80249440
Test: manual: charger mode with no system font
Change-Id: Ib0c761d37e41a893b2a192438eebcf48c4827049
Merged-In: Ib0c761d37e41a893b2a192438eebcf48c4827049
(cherry picked from commit 8211515fbe)
2018-07-30 08:45:52 -07:00
Thierry Strudel
2cbe2c7b29 healthd_mode_charger: unblank the screen only on first frame
Original code is unblank screen for all frames of the first
cycle, unblank is needed only before the first frame of the
first cycle.

Bug: 74771887
Change-Id: I51d8390e359335a0b1cb127b096db1a8b889b169
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2018-07-30 00:18:06 -07:00
Yifan Hong
ef26fe4c16 healthd: uses android.hardware.health@2.0-service_defaults
Test: builds
Test: boots
Change-Id: Ia47ba805aa0e8f7cd6c0a7f5877b3120b0265c78
2018-07-18 13:51:01 -07:00
Yifan Hong
d5c59f729e Merge "healthd: libbatterymonitor: recovery_available" into stage-aosp-master 2018-07-18 19:54:58 +00:00
Yifan Hong
90fdc72409 healthd: libbatterymonitor: recovery_available
Bug: 80132328
Test: builds
Change-Id: I4d5ac73431fb002cc839fed2d97b1acff3fde263
Merged-In: I4d5ac73431fb002cc839fed2d97b1acff3fde263
(cherry picked from commit 0e317d7873)
2018-07-18 11:28:29 -07:00
Yifan Hong
9a81d54ce3 healthd: add missing libbatteryservice_headers dep
It used to use global header include dirs, which is bad.
Test: builds
Bug: 68724651

Change-Id: Ib5354c66633499ad57fe5997e2c35283ba5e408f
Merged-In: Ib5354c66633499ad57fe5997e2c35283ba5e408f
(cherry picked from commit 530ac5bad1)
2018-07-17 15:36:14 -07:00
Yifan Hong
31150c1121 healthd: overridden by health@2.0-service
Test: boots
Bug: 79107699
Bug: 77541952
Bug: 79107699
Change-Id: Ida4cf80d3553365b673e30cdd19590c156cb52e0
Merged-In: Ida4cf80d3553365b673e30cdd19590c156cb52e0
(cherry picked from commit 28d2fb80b2)
2018-07-17 11:57:44 -07:00