Construct profiles instead of remotely starting them
Each profile was exposed as a service that was interacted with in two ways asynchronously: - startService: by the Bluetooth app, calling into ActivityManager to start a service inside the Bluetooth app itself. - bindService: by the bluetooth_manager to retrieve the binder of this service. Bluetooth was making an asynchronous call to ActivityManager from the main thread of its process to start a Service on the main thread of its process. This forces a lot of things to be passed as a global variable, as the creation of the service was externaly managed, which comes with all the issues associated with global variables. The flow for the framework to retrieve the binder of a service was 3rd party app -> system_server (bluetooth manager then activity manager) -> Bluetooth app. This is unnecessarily complex and is replaced by this CL to just 3rd party app -> Bluetooth app. Also all is synchronous now, simplifying some tests and making the lifecycle easier and removing some races like: - https://r.android.com/1626228 - https://r.android.com/2810743 A lot of things can be simplified as follow-up thanks to this: - Removing most global variables of the Bluetooth app. - Easier and static startup of profiles. Co-authored-by:David Duarte <licorne@google.com> Bug: 291815510 Bug: 305741984 Test: atest BluetoothInstrumentationTest Flag: EXEMPT, Manifest flagging is not available and this change is unsafe to do if we don't remove the service entries from the manifest Change-Id: I83a38e1d67de95d8717b5f866868b740e364335d
Loading
Please register or sign in to comment