2

In the Android Open Source Project, where would I add/override the code which tells Android about the battery level and AC power?

I need to poll a component on an i2c bus to get this information, on my board, and pass it to Android.

fadedbee
  • 42,671
  • 44
  • 178
  • 308

1 Answers1

3

It depends on your Android version:

Oreo and Newer

You have to replace the existing Health HAL service with a custom one that provides the information you want. You don't have to write the service from scratch but change the provided dummy implementation.

Nougat and Older

These version do not yet have a Health HAL. You have to update the healthd directly in system/core/healthd.

Simpl
  • 1,938
  • 1
  • 10
  • 21
  • 1
    Thanks for your answer, I should have specified Android 6 in the question. I've found aosp/system/core/healthd/BatteryMonitor.cpp which looks like a good place to start. – fadedbee Jul 16 '19 at 08:15