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
Loading
Please register or sign in to comment