Skip to content
Commit cf9a8b2e authored by Yifan Hong's avatar Yifan Hong
Browse files

BatteryService: Clean up init logic.

* Use getService instead of getTransport, because
  getService checks VINTF already. Init has fewer #
  of hwbinder calls and simpler logic.

* init() calls registerCallback() to HAL synchronously. Now that
  there is a way to check for equality of interfaces in Java,
  registerCallback can be called in HealthServiceWrapper.init()
  earlier, and registerCallback in service notification can
  be avoided when the service pre-exists.

* Instead of making hwbinder calls in a lock in hwbinder threads
  (service notification callback), post to a background HandlerThread.
  As a consequence, no lock is needed because ordering is ensured.
  (Making hwbinder calls in a lock can lead to deadlocks if an
  implementation calls back to system server and tries to acquire the
  same lock.)

Test: boot 20 times
Test: BatteryServiceTest

Change-Id: Id27b789da78f0df9f867cba75d15203a4fb74e04
parent 4c10ba49
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment