sonyxperiadev / device-sony-common

70 stars 139 forks source link

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

Closed MarijnS95 closed 3 weeks ago

MarijnS95 commented 1 month ago

Fixes https://github.com/sonyxperiadev/device-sony-common/issues/916 Fixes https://github.com/sonyxperiadev/bug_tracker/issues/835 Closes https://github.com/sonyxperiadev/device-sony-common/pull/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 android.hardware.health@2.1.

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

jerpelea commented 4 weeks ago

@MarijnS95 11-20 04:33:19.108 784 784 F android.hardware.health@2.1-service: 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 android.hardware.health@2.1::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 'android.hardware.health@2.1::IHealth/default' for ctl.interface_start from pid: 530 (/system/bin/hwservicemanager) 11-20 04:33:19.181 530 530 I hwservicemanager: Since android.hardware.health@2.1::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 "android.hardware.health@2.1::IHealth/default": error code: 0x20 11-20 04:33:19.181 530 848 I hwservicemanager: Tried to start android.hardware.health@2.1::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 android.hardware.health@2.1::IHealth/default...

MarijnS95 commented 4 weeks ago
11-20 04:33:19.108 784 784 F android.hardware.health@2.1-service: 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 commented 4 weeks ago

@MarijnS95 11-20 05:03:58.229 788 788 F android.hardware.health@2.1-service: 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/android.hardware.health@2.1-service 11-20 05:03:58.328 822 822 F DEBUG : pid: 788, tid: 788, name: android.hardwar >>> /vendor/bin/hw/android.hardware.health@2.1-service <<< 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 : #01 pc 0000000000006324 /system/lib64/liblog.so (__android_log_default_aborter+12) (BuildId: 74a6eaa1fbab6ad0e1e3eea25b06791a) 11-20 05:03:58.331 822 822 F DEBUG : #02 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 : #03 pc 0000000000006254 /vendor/bin/hw/android.hardware.health@2.1-service (main+512) (BuildId: ca5a48b609b38ba8427b0827e5d7ea96) 11-20 05:03:58.332 822 822 F DEBUG : #04 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 commented 4 weeks ago

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 commented 4 weeks ago

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 commented 3 weeks ago

@MarijnS95 11-20 23:32:07.441 848 848 F DEBUG : Cmdline: /vendor/bin/hw/android.hardware.health@2.1-service 11-20 23:32:07.441 848 848 F DEBUG : pid: 788, tid: 788, name: android.hardwar >>> /vendor/bin/hw/android.hardware.health@2.1-service <<< 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 : #01 pc 0000000000006324 /system/lib64/liblog.so (__android_log_default_aborter+12) (BuildId: 74a6eaa1fbab6ad0e1e3eea25b06791a) 11-20 23:32:07.444 848 848 F DEBUG : #02 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 : #03 pc 0000000000006254 /vendor/bin/hw/android.hardware.health@2.1-service (main+512) (BuildId: ca5a48b609b38ba8427b0827e5d7ea96) 11-20 23:32:07.444 848 848 F DEBUG : #04 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 :