Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java +70 −10 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; /** * LocalBluetoothLeBroadcastAssistant provides an interface between the Settings app and the Loading @@ -63,6 +64,7 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile private BluetoothLeBroadcastMetadata mBluetoothLeBroadcastMetadata; private BluetoothLeBroadcastMetadata.Builder mBuilder; private boolean mIsProfileReady; private Executor mExecutor; // Cached assistant callbacks being register before service is connected. private final Map<BluetoothLeBroadcastAssistant.Callback, Executor> mCachedCallbackExecutorMap = new ConcurrentHashMap<>(); Loading Loading @@ -98,7 +100,9 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile } mProfileManager.callServiceConnectedListeners(); if (!mIsProfileReady) { mIsProfileReady = true; registerServiceCallBack(mExecutor, mAssistantCallback); if (DEBUG) { Log.d( TAG, Loading @@ -106,7 +110,9 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile + mCachedCallbackExecutorMap); } mCachedCallbackExecutorMap.forEach( (callback, executor) -> registerServiceCallBack(executor, callback)); (callback, executor) -> registerServiceCallBack(executor, callback)); } } @Override Loading @@ -119,9 +125,62 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile Log.d(TAG, "Bluetooth service disconnected"); } mProfileManager.callServiceDisconnectedListeners(); if (mIsProfileReady) { mIsProfileReady = false; unregisterServiceCallBack(mAssistantCallback); mCachedCallbackExecutorMap.clear(); } } }; private final BluetoothLeBroadcastAssistant.Callback mAssistantCallback = new BluetoothLeBroadcastAssistant.Callback() { @Override public void onSourceAdded(@NonNull BluetoothDevice sink, int sourceId, int reason) { } @Override public void onSearchStarted(int reason) {} @Override public void onSearchStartFailed(int reason) {} @Override public void onSearchStopped(int reason) {} @Override public void onSearchStopFailed(int reason) {} @Override public void onSourceFound(@NonNull BluetoothLeBroadcastMetadata source) {} @Override public void onSourceAddFailed( @NonNull BluetoothDevice sink, @NonNull BluetoothLeBroadcastMetadata source, int reason) {} @Override public void onSourceModified( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onSourceModifyFailed( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onSourceRemoved( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onSourceRemoveFailed( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onReceiveStateChanged( @NonNull BluetoothDevice sink, int sourceId, @NonNull BluetoothLeBroadcastReceiveState state) {} }; public LocalBluetoothLeBroadcastAssistant( Loading @@ -130,6 +189,7 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile LocalBluetoothProfileManager profileManager) { mProfileManager = profileManager; mDeviceManager = deviceManager; mExecutor = Executors.newSingleThreadExecutor(); BluetoothAdapter.getDefaultAdapter() .getProfileProxy( context, mServiceListener, BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java +70 −10 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; /** * LocalBluetoothLeBroadcastAssistant provides an interface between the Settings app and the Loading @@ -63,6 +64,7 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile private BluetoothLeBroadcastMetadata mBluetoothLeBroadcastMetadata; private BluetoothLeBroadcastMetadata.Builder mBuilder; private boolean mIsProfileReady; private Executor mExecutor; // Cached assistant callbacks being register before service is connected. private final Map<BluetoothLeBroadcastAssistant.Callback, Executor> mCachedCallbackExecutorMap = new ConcurrentHashMap<>(); Loading Loading @@ -98,7 +100,9 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile } mProfileManager.callServiceConnectedListeners(); if (!mIsProfileReady) { mIsProfileReady = true; registerServiceCallBack(mExecutor, mAssistantCallback); if (DEBUG) { Log.d( TAG, Loading @@ -106,7 +110,9 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile + mCachedCallbackExecutorMap); } mCachedCallbackExecutorMap.forEach( (callback, executor) -> registerServiceCallBack(executor, callback)); (callback, executor) -> registerServiceCallBack(executor, callback)); } } @Override Loading @@ -119,9 +125,62 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile Log.d(TAG, "Bluetooth service disconnected"); } mProfileManager.callServiceDisconnectedListeners(); if (mIsProfileReady) { mIsProfileReady = false; unregisterServiceCallBack(mAssistantCallback); mCachedCallbackExecutorMap.clear(); } } }; private final BluetoothLeBroadcastAssistant.Callback mAssistantCallback = new BluetoothLeBroadcastAssistant.Callback() { @Override public void onSourceAdded(@NonNull BluetoothDevice sink, int sourceId, int reason) { } @Override public void onSearchStarted(int reason) {} @Override public void onSearchStartFailed(int reason) {} @Override public void onSearchStopped(int reason) {} @Override public void onSearchStopFailed(int reason) {} @Override public void onSourceFound(@NonNull BluetoothLeBroadcastMetadata source) {} @Override public void onSourceAddFailed( @NonNull BluetoothDevice sink, @NonNull BluetoothLeBroadcastMetadata source, int reason) {} @Override public void onSourceModified( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onSourceModifyFailed( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onSourceRemoved( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onSourceRemoveFailed( @NonNull BluetoothDevice sink, int sourceId, int reason) {} @Override public void onReceiveStateChanged( @NonNull BluetoothDevice sink, int sourceId, @NonNull BluetoothLeBroadcastReceiveState state) {} }; public LocalBluetoothLeBroadcastAssistant( Loading @@ -130,6 +189,7 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile LocalBluetoothProfileManager profileManager) { mProfileManager = profileManager; mDeviceManager = deviceManager; mExecutor = Executors.newSingleThreadExecutor(); BluetoothAdapter.getDefaultAdapter() .getProfileProxy( context, mServiceListener, BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT); Loading