Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java +41 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,14 @@ import java.util.concurrent.Executors; * BluetoothLeBroadcastAssistant.Callback} to get the result callback. */ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile { /** A derived source state based on {@link BluetoothLeBroadcastReceiveState}. */ public enum LocalBluetoothLeBroadcastSourceState { UNKNOWN, STREAMING, DECRYPTION_FAILED, PAUSED, } private static final String TAG = "LocalBluetoothLeBroadcastAssistant"; private static final int UNKNOWN_VALUE_PLACEHOLDER = -1; private static final boolean DEBUG = BluetoothUtils.D; Loading @@ -59,6 +67,13 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile static final String NAME = "LE_AUDIO_BROADCAST_ASSISTANT"; // Order of this profile in device profiles list private static final int ORDINAL = 1; // Referring to Broadcast Audio Scan Service 1.0 // Table 3.9: Broadcast Receive State characteristic format // 0x00000000: 0b0 = Not synchronized to BIS_index[x] // 0xFFFFFFFF: Failed to sync to BIG private static final long BIS_SYNC_NOT_SYNC_TO_BIS = 0x00000000L; private static final long BIS_SYNC_FAILED_SYNC_TO_BIG = 0xFFFFFFFFL; private static final String EMPTY_DEVICE_ADDRESS = "00:00:00:00:00:00"; private LocalBluetoothProfileManager mProfileManager; private BluetoothLeBroadcastAssistant mService; Loading Loading @@ -558,4 +573,30 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile } } } /** Checks the source connection status based on the provided broadcast receive state. */ public static LocalBluetoothLeBroadcastSourceState getLocalSourceState( BluetoothLeBroadcastReceiveState state) { // Source is actively streaming if (state.getBisSyncState().stream() .anyMatch( bitmap -> (bitmap != BIS_SYNC_NOT_SYNC_TO_BIS && bitmap != BIS_SYNC_FAILED_SYNC_TO_BIG))) { return LocalBluetoothLeBroadcastSourceState.STREAMING; } // Wrong password is used for the source if (state.getPaSyncState() == BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCHRONIZED && state.getBigEncryptionState() == BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_BAD_CODE) { return LocalBluetoothLeBroadcastSourceState.DECRYPTION_FAILED; } // Source in hysteresis mode if (!state.getSourceDevice().getAddress().equals(EMPTY_DEVICE_ADDRESS)) { // Referring to Broadcast Audio Scan Service 1.0 // All zero address means no source on the sink device return LocalBluetoothLeBroadcastSourceState.PAUSED; } return LocalBluetoothLeBroadcastSourceState.UNKNOWN; } } Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java +41 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,14 @@ import java.util.concurrent.Executors; * BluetoothLeBroadcastAssistant.Callback} to get the result callback. */ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile { /** A derived source state based on {@link BluetoothLeBroadcastReceiveState}. */ public enum LocalBluetoothLeBroadcastSourceState { UNKNOWN, STREAMING, DECRYPTION_FAILED, PAUSED, } private static final String TAG = "LocalBluetoothLeBroadcastAssistant"; private static final int UNKNOWN_VALUE_PLACEHOLDER = -1; private static final boolean DEBUG = BluetoothUtils.D; Loading @@ -59,6 +67,13 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile static final String NAME = "LE_AUDIO_BROADCAST_ASSISTANT"; // Order of this profile in device profiles list private static final int ORDINAL = 1; // Referring to Broadcast Audio Scan Service 1.0 // Table 3.9: Broadcast Receive State characteristic format // 0x00000000: 0b0 = Not synchronized to BIS_index[x] // 0xFFFFFFFF: Failed to sync to BIG private static final long BIS_SYNC_NOT_SYNC_TO_BIS = 0x00000000L; private static final long BIS_SYNC_FAILED_SYNC_TO_BIG = 0xFFFFFFFFL; private static final String EMPTY_DEVICE_ADDRESS = "00:00:00:00:00:00"; private LocalBluetoothProfileManager mProfileManager; private BluetoothLeBroadcastAssistant mService; Loading Loading @@ -558,4 +573,30 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile } } } /** Checks the source connection status based on the provided broadcast receive state. */ public static LocalBluetoothLeBroadcastSourceState getLocalSourceState( BluetoothLeBroadcastReceiveState state) { // Source is actively streaming if (state.getBisSyncState().stream() .anyMatch( bitmap -> (bitmap != BIS_SYNC_NOT_SYNC_TO_BIS && bitmap != BIS_SYNC_FAILED_SYNC_TO_BIG))) { return LocalBluetoothLeBroadcastSourceState.STREAMING; } // Wrong password is used for the source if (state.getPaSyncState() == BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCHRONIZED && state.getBigEncryptionState() == BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_BAD_CODE) { return LocalBluetoothLeBroadcastSourceState.DECRYPTION_FAILED; } // Source in hysteresis mode if (!state.getSourceDevice().getAddress().equals(EMPTY_DEVICE_ADDRESS)) { // Referring to Broadcast Audio Scan Service 1.0 // All zero address means no source on the sink device return LocalBluetoothLeBroadcastSourceState.PAUSED; } return LocalBluetoothLeBroadcastSourceState.UNKNOWN; } }