diff options
| author | Etienne Ruffieux <eruffieux@google.com> | 2022-11-07 14:40:27 -0800 |
|---|---|---|
| committer | Etienne Ruffieux <eruffieux@google.com> | 2022-11-29 13:50:09 -0800 |
| commit | 312688bba41f74b9e3362a5bbbf419a00bda8d16 (patch) | |
| tree | 1177d82e7a646ef1aec7f86ee9d55f3e1891f8cc /service/java/com/android/server/bluetooth/BluetoothManagerService.java | |
| parent | 16f28028d5c66685d3a8cbd395dfd1a1737bb8f0 (diff) | |
Move all profile services bind to BluetoothManagerService
We are currently binding the profile services in framework/
BluetoothProfileConnector, except for BluetoothHeadset
and BluetoothLeCallControl that are bound in BMS.
The issue with binding the profiles in framework/ is that
calling apps don't always have the required permission
(BLUETOOTH_PRIVILEGED) to check if the service is enabled
or not (BluetoothAdapter#getSupportedProfiles), so we are
trying to bind the service even if the profile is disabled.
This change will unify the profiles service binding by
moving the bind process in BluetoothProfileConnector in
BluetoothManagerService and making BluetoothHeadset and
BluetoothLeCallControl use BluetoothProfileConnector.
Bug: 241827236
Bug: 236399693
Test: atest CtsBluetoothTestCases
Test: atest BluetoothInstrumentationTests
Tag: #feature
Ignore-AOSP-First: Cherry-pick
Change-Id: I925b4415c023ff9e43a8ff947ae7ca5456babe64
Merged-In: I925b4415c023ff9e43a8ff947ae7ca5456babe64
Diffstat (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java')
| -rw-r--r-- | service/java/com/android/server/bluetooth/BluetoothManagerService.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java index f7bcc69cc6..60d61b8e12 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -46,8 +46,6 @@ import android.bluetooth.BluetoothProtoEnums; import android.bluetooth.IBluetooth; import android.bluetooth.IBluetoothCallback; import android.bluetooth.IBluetoothGatt; -import android.bluetooth.IBluetoothHeadset; -import android.bluetooth.IBluetoothLeCallControl; import android.bluetooth.IBluetoothManager; import android.bluetooth.IBluetoothManagerCallback; import android.bluetooth.IBluetoothProfileServiceConnection; @@ -1541,7 +1539,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { } @Override - public boolean bindBluetoothProfileService(int bluetoothProfile, + public boolean bindBluetoothProfileService(int bluetoothProfile, String serviceName, IBluetoothProfileServiceConnection proxy) { if (mState != BluetoothAdapter.STATE_ON) { if (DBG) { @@ -1551,23 +1549,19 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { return false; } synchronized (mProfileServices) { - ProfileServiceConnections psc = mProfileServices.get(new Integer(bluetoothProfile)); - Intent intent; - if (bluetoothProfile == BluetoothProfile.HEADSET - && mSupportedProfileList.contains(BluetoothProfile.HEADSET)) { - intent = new Intent(IBluetoothHeadset.class.getName()); - } else if (bluetoothProfile == BluetoothProfile.LE_CALL_CONTROL - && mSupportedProfileList.contains(BluetoothProfile.LE_CALL_CONTROL)) { - intent = new Intent(IBluetoothLeCallControl.class.getName()); - } else { + if (!mSupportedProfileList.contains(bluetoothProfile)) { + Log.w(TAG, "Cannot bind profile: " + bluetoothProfile + + ", not in supported profiles list"); return false; } + ProfileServiceConnections psc = + mProfileServices.get(Integer.valueOf(bluetoothProfile)); if (psc == null) { if (DBG) { Log.d(TAG, "Creating new ProfileServiceConnections object for" + " profile: " + bluetoothProfile); } - psc = new ProfileServiceConnections(intent); + psc = new ProfileServiceConnections(new Intent(serviceName)); if (!psc.bindService(DEFAULT_REBIND_COUNT)) { return false; } |
