Adapter: Reduce MainLooper load when connect profiles
Historically, getProfileProxy has been running it's callback on the main
thread. To respect API contract, we cannot change this anymore, plus, As
per API guideline, this is expected:
go/android-api-guidelines#provide-executor
> if the Executor is not provided, the callback should be invoked on the
main thread using Looper.getMainLooper()
If we want to change the callback to another thread/executor, we need to
provide a new API that take an executor in parameter.
But before doing that, we can analyze that the current implementation is
doing other operation on the main looper, and Bluetooth could reduce the
burden on the main looper without the need for a new API.
For example, `proxy.onServiceConnected` doesn't involve a callback call
and has no reason to be run on the mainLooper (except for simplicity of
lock). We can extract all of this and only call the user callback on the
mainLooper.
Bug: 377808044
Bug: 367914132
Bug: 370815283
Test: m .
Test: pair some HA devices and reboot the phone. The settings should
have it's cached properly updated
Flag: com.android.bluetooth.flags.get_profile_use_lock
Change-Id: Ibaf52b538a35e037f0307106ea1fbe05dd0461c8
Loading
Please register or sign in to comment