Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[T/U] hardware/health: Upgrade to 2.1 via libhealth2impl #918

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

MarijnS95
Copy link
Contributor

@MarijnS95 MarijnS95 commented Jul 5, 2024

Fixes #916
Fixes sonyxperiadev/bug_tracker#835
Closes #917, CC @ShujathMohd

Caution

This pull request has only been build-tested on Android T, and has never been tried on an actual device yet!

Please help me do so if you have the opportunity.

The libhealthservice and libhealthstoragedefault helper libraries to implement Health HALs have been removed in Android 14 QPR 3. At the same time a newer 2.1 HIDL HAL has been made available (which is already deprecated too, in favour of an AIDL HAL). Upgrade our custom implementation - which backs up the battery cycles and learned capacity - to leverage libhealth2impl and automatically implement [email protected].

Its implementation and header even describe how to upgrade away from the old healthd_board_*() callback symbols.

Furthermore, the default implementation already provides a passthrough service, which allows us to convert this service to an impl library and use the builtin service (plus all the files it needs) instead.

TODO

  • Update README that @ix5 provided back when adding this HAL.

MarijnS95 added a commit to MarijnS95/device-sony-sepolicy that referenced this pull request Jul 5, 2024
Since the migration to `[email protected]` in [#918] we're using the builtin
passthrough service that loads our custom implementation from an `impl`
library.  Android's builtin vendor sepolicy already labels this binary
with `hal_health_default_exec`, and the `2.0-service.sony` file is no
longer provided and should be removed.

[#918]: sonyxperiadev/device-sony-common#918
MarijnS95 added a commit to MarijnS95/device-sony-sepolicy that referenced this pull request Jul 8, 2024
Since the migration to `[email protected]` in [#918] we're using the builtin
passthrough service that loads our custom implementation from an `impl`
library.  Android's builtin vendor sepolicy already labels this binary
with `hal_health_default_exec`, and the `2.0-service.sony` file is no
longer provided and should be removed.

[#918]: sonyxperiadev/device-sony-common#918
jerpelea pushed a commit to sonyxperiadev/device-sony-sepolicy that referenced this pull request Jul 9, 2024
Since the migration to `[email protected]` in [#918] we're using the builtin
passthrough service that loads our custom implementation from an `impl`
library.  Android's builtin vendor sepolicy already labels this binary
with `hal_health_default_exec`, and the `2.0-service.sony` file is no
longer provided and should be removed.

[#918]: sonyxperiadev/device-sony-common#918
@jerpelea
Copy link
Collaborator

jerpelea commented Jul 30, 2024

@MarijnS95
11-20 04:33:19.108 784 784 F [email protected]: Check failed: passthrough != nullptr Cannot find passthrough implementation of health 2.1 HAL for instance default
11-20 04:33:19.173 530 530 I hwservicemanager: Since [email protected]::IHealth/default is not registered, trying to start it as a lazy HAL
11-20 04:33:19.181 0 0 E init : Control message: Could not find '[email protected]::IHealth/default' for ctl.interface_start from pid: 530 (/system/bin/hwservicemanager)
11-20 04:33:19.181 530 530 I hwservicemanager: Since [email protected]::IHealth/default is not registered, trying to start it as a lazy HAL.
11-20 04:33:19.181 530 848 W libc : Unable to set property "ctl.interface_start" to "[email protected]::IHealth/default": error code: 0x20
11-20 04:33:19.181 530 848 I hwservicemanager: Tried to start [email protected]::IHealth/default as a lazy service, but was unable to. Usually this happens when a service is not installed, but if >
11-20 04:33:19.182 783 847 I HidlServiceManagement: getService: Trying again for [email protected]::IHealth/default...

@MarijnS95
Copy link
Contributor Author

11-20 04:33:19.108 784 784 F [email protected]: Check failed: passthrough != nullptr Cannot find passthrough implementation of health 2.1 HAL for instance default

Looking at the code, perhaps it should have been named -impl-sony.so instead of -impl.sony.so.

@jerpelea
Copy link
Collaborator

@MarijnS95
11-20 05:03:58.229 788 788 F [email protected]: Check failed: passthrough != nullptr Cannot find passthrough implementation of health 2.1 HAL for instance default
11-20 05:03:58.326 822 822 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-20 05:03:58.327 822 822 F DEBUG : Build fingerprint: 'Sony/aosp_xqdc54/pdx235:13/TQ3A.230805.001.A2/001:userdebug/test-keys'
11-20 05:03:58.327 822 822 F DEBUG : Revision: '0'
11-20 05:03:58.327 822 822 F DEBUG : ABI: 'arm64'
11-20 05:03:58.327 822 822 F DEBUG : Timestamp: 1970-11-20 05:03:58.293117548+0000
11-20 05:03:58.327 822 822 F DEBUG : Process uptime: 0s
11-20 05:03:58.327 822 822 F DEBUG : Cmdline: /vendor/bin/hw/[email protected]
11-20 05:03:58.328 822 822 F DEBUG : pid: 788, tid: 788, name: android.hardwar >>> /vendor/bin/hw/[email protected] <<<
11-20 05:03:58.328 822 822 F DEBUG : uid: 1000
11-20 05:03:58.328 822 822 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
11-20 05:03:58.328 822 822 F DEBUG : Abort message: 'Check failed: passthrough != nullptr Cannot find passthrough implementation of health 2.1 HAL for instance default'
11-20 05:03:58.328 822 822 F DEBUG : x0 0000000000000000 x1 0000000000000314 x2 0000000000000006 x3 0000007fe3e8a8a0
11-20 05:03:58.328 822 822 F DEBUG : x4 6b746d1f3c201f67 x5 6b746d1f3c201f67 x6 6b746d1f3c201f67 x7 7f7f7f7f7f7f7f7f
11-20 05:03:58.328 822 822 F DEBUG : x8 00000000000000f0 x9 00000071086229e0 x10 0000000000000001 x11 0000007108660b14
11-20 05:03:58.329 822 822 F DEBUG : x12 0000007fe3e8a820 x13 0000000000000073 x14 b400006f683fd520 x15 0000000034155555
11-20 05:03:58.329 822 822 F DEBUG : x16 00000071086c4d50 x17 00000071086a29a0 x18 0000007109c42000 x19 0000000000000314
11-20 05:03:58.329 822 822 F DEBUG : x20 0000000000000314 x21 00000000ffffffff x22 000000710964d000 x23 0000000000000000
11-20 05:03:58.329 822 822 F DEBUG : x24 0000000000000000 x25 0000000000000000 x26 0000000000000000 x27 0000000000000000
11-20 05:03:58.329 822 822 F DEBUG : x28 0000000000000000 x29 0000007fe3e8a920
11-20 05:03:58.330 822 822 F DEBUG : lr 0000007108652718 sp 0000007fe3e8a880 pc 0000007108652744 pst 0000000000001000
11-20 05:03:58.330 822 822 F DEBUG : backtrace:
11-20 05:03:58.331 822 822 F DEBUG : #00 pc 0000000000051744 /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: a233a8c1a23ee63f36f4b138880288f3)
11-20 05:03:58.331 822 822 F DEBUG : #1 pc 0000000000006324 /system/lib64/liblog.so (__android_log_default_aborter+12) (BuildId: 74a6eaa1fbab6ad0e1e3eea25b06791a)
11-20 05:03:58.331 822 822 F DEBUG : #2 pc 0000000000016450 /apex/com.android.vndk.v33/lib64/libbase.so (android::base::LogMessage::~LogMessage()+352) (BuildId: b9c09796471ac89d86346dfd09d6dbdc)
11-20 05:03:58.331 822 822 F DEBUG : #3 pc 0000000000006254 /vendor/bin/hw/[email protected] (main+512) (BuildId: ca5a48b609b38ba8427b0827e5d7ea96)
11-20 05:03:58.332 822 822 F DEBUG : #4 pc 000000000004a064 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+96) (BuildId: a233a8c1a23ee63f36f4b138880288f3)
11-20 05:03:58.337 822 822 E crash_dump64: unable to connect to activity manager: No such file or directory
11-20 05:03:58.337 654 654 E tombstoned: Tombstone written to: tombstone_00
11-20 05:03:58.339 0 0 I init : Service 'health-hal-2-1' (pid 788) received signal 6
11-20 05:03:58.339 0 0 I init : Sending signal 9 to service 'health-hal-2-1' (pid 788) process group...

@MarijnS95
Copy link
Contributor Author

It's been too long. I'm thinking the following to test:

  1. Add a vintf file that describes the passthrough file, pushed that change now; if that doesn,t work, we'll try:
  2. To use stem to strip off -sony from the name;
  3. If all else fails (and I believe passthrough HALs are anyway deprecated for anything that doesn't need to be loaded within a process like GPU drivers and their gralloc memory interfaces), we'll remove the passthrough setup and make this the service binary directly.

@MarijnS95
Copy link
Contributor Author

Note that the thing I've done here looks to be very similar to what AOSP recommends: https://android.googlesource.com/platform/hardware/interfaces/+/main/health/2.1/README.md#impl

@jerpelea
Copy link
Collaborator

@MarijnS95
11-20 23:32:07.441 848 848 F DEBUG : Cmdline: /vendor/bin/hw/[email protected]
11-20 23:32:07.441 848 848 F DEBUG : pid: 788, tid: 788, name: android.hardwar >>> /vendor/bin/hw/[email protected] <<<
11-20 23:32:07.442 848 848 F DEBUG : uid: 1000
11-20 23:32:07.442 848 848 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
11-20 23:32:07.442 848 848 F DEBUG : Abort message: 'Check failed: passthrough != nullptr Cannot find passthrough implementation of health 2.1 HAL for instance default'
11-20 23:32:07.442 848 848 F DEBUG : x0 0000000000000000 x1 0000000000000314 x2 0000000000000006 x3 0000007fde63c080
11-20 23:32:07.442 848 848 F DEBUG : x4 6b746d1f3c201f67 x5 6b746d1f3c201f67 x6 6b746d1f3c201f67 x7 7f7f7f7f7f7f7f7f
11-20 23:32:07.442 848 848 F DEBUG : x8 00000000000000f0 x9 000000738d6c39e0 x10 0000000000000001 x11 000000738d701b14
11-20 23:32:07.443 848 848 F DEBUG : x12 0000007fde63c000 x13 0000000000000073 x14 b4000071ed648840 x15 0000000034155555
11-20 23:32:07.443 848 848 F DEBUG : x16 000000738d765d50 x17 000000738d7439a0 x18 000000738f7f8000 x19 0000000000000314
11-20 23:32:07.443 848 848 F DEBUG : x20 0000000000000314 x21 00000000ffffffff x22 000000738e767000 x23 0000000000000000
11-20 23:32:07.443 848 848 F DEBUG : x24 0000000000000000 x25 0000000000000000 x26 0000000000000000 x27 0000000000000000
11-20 23:32:07.443 848 848 F DEBUG : x28 0000000000000000 x29 0000007fde63c100
11-20 23:32:07.443 848 848 F DEBUG : lr 000000738d6f3718 sp 0000007fde63c060 pc 000000738d6f3744 pst 0000000000001000
11-20 23:32:07.444 848 848 F DEBUG : backtrace:
11-20 23:32:07.444 848 848 F DEBUG : #00 pc 0000000000051744 /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: a233a8c1a23ee63f36f4b138880288f3)
11-20 23:32:07.444 848 848 F DEBUG : #1 pc 0000000000006324 /system/lib64/liblog.so (__android_log_default_aborter+12) (BuildId: 74a6eaa1fbab6ad0e1e3eea25b06791a)
11-20 23:32:07.444 848 848 F DEBUG : #2 pc 0000000000016450 /apex/com.android.vndk.v33/lib64/libbase.so (android::base::LogMessage::~LogMessage()+352) (BuildId: b9c09796471ac89d86346dfd09d6dbdc)
11-20 23:32:07.444 848 848 F DEBUG : #3 pc 0000000000006254 /vendor/bin/hw/[email protected] (main+512) (BuildId: ca5a48b609b38ba8427b0827e5d7ea96)
11-20 23:32:07.444 848 848 F DEBUG : #4 pc 000000000004a064 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+96) (BuildId: a233a8c1a23ee63f36f4b138880288f3)
11-20 23:32:10.202 1194 1194 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

The `libhealthservice` and `libhealthstoragedefault` helper libraries
to implement Health HALs have been removed in Android 14 QPR 3.  At
the same time a newer 2.1 HIDL HAL has been made available (which
is already deprecated too, in favour of an AIDL HAL).  Upgrade our
custom implementation - which backs up the battery cycles and learned
capacity - to leverage `libhealth2impl` and automatically implement
`[email protected]`.

Its implementation and header even describe how to upgrade away from
the old `healthd_board_*()` callback symbols.

Furthermore, the default implementation already provides a passthrough
service, which allows us to convert this service to an `impl` library
and use the builtin service (plus all the files it needs) instead.

In the end this all turns out to already be documented explicitly
upstream:
https://android.googlesource.com/platform/hardware/interfaces/+/main/health/2.1/README.md#impl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants