Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit d5a6dabc authored by William Escande's avatar William Escande
Browse files

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
parent 6fa6d9cb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment