Fix deadlock between AMS and EphemeralResolverConnection
The ActivityManagerService lock may be taken when calling into ERC
through ActivityStarter.startActivityMayWait().
At the same time, a PackageManagerService.getLastChosenActivity() call
could take the ERC lock and call unbindService(), requesting the AMS
lock.
Deadlock.
Solved by making sure to drop the ERC lock before calling into AMS.
This necessitated an extra state to prevent multiple callers from
clobbering the binding, so mIsBinding became mBindState.
The IDLE state means that nothing is currently binding.
The BINDING state means someone is initiating a bind, including the
wait() call thereafter.
The PENDING state means that bindService() has been called, but the
caller's timeout expired (i.e. the new caller may want to rebind).
Fixes:
63150916
Test: for x in $(seq 100); do adb shell am start http://127.0.0.1/does-not-exist.html; adb shell input keyevent 3; done
Change-Id: I2cb5610a2277ef641f8e2d7f5ad1c4a72bb4f026