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

Commit e01b1177 authored by xiaowang's avatar xiaowang Committed by Jack He
Browse files

Revert "BassClient: Fix issue that source could not be found"

This reverts commit d94ee6a6.

Reason for revert: incorrect email id

Test: compile
Bug: 236995005
Merged-In: I74b91daf8944da1547049817ae2e9c353bbcc3f2
Change-Id: I74b91daf8944da1547049817ae2e9c353bbcc3f2
(cherry picked from commit f122d1a0)
parent b256fc5c
Loading
Loading
Loading
Loading
+6 −29
Original line number Original line Diff line number Diff line
@@ -69,7 +69,6 @@ public class BassClientService extends ProfileService {


    private final Map<BluetoothDevice, BassClientStateMachine> mStateMachines = new HashMap<>();
    private final Map<BluetoothDevice, BassClientStateMachine> mStateMachines = new HashMap<>();
    private final Object mSearchScanCallbackLock = new Object();
    private final Object mSearchScanCallbackLock = new Object();
    private final Map<Integer, ScanResult> mScanBroadcasts = new HashMap<>();


    private HandlerThread mStateMachinesThread;
    private HandlerThread mStateMachinesThread;
    private HandlerThread mCallbackHandlerThread;
    private HandlerThread mCallbackHandlerThread;
@@ -327,16 +326,8 @@ public class BassClientService extends ProfileService {
    }
    }


    private boolean hasRoomForBroadcastSourceAddition(BluetoothDevice device) {
    private boolean hasRoomForBroadcastSourceAddition(BluetoothDevice device) {
        boolean isRoomAvailable = false;
        List<BluetoothLeBroadcastReceiveState> currentAllSources = getAllSources(device);
        String emptyBluetoothDevice = "00:00:00:00:00:00";
        return currentAllSources.size() < getMaximumSourceCapacity(device);
        for (BluetoothLeBroadcastReceiveState recvState: getAllSources(device)) {
            if (recvState.getSourceDevice().getAddress().equals(emptyBluetoothDevice)) {
                isRoomAvailable = true;
                break;
            }
        }
        log("isRoomAvailable: " + isRoomAvailable);
        return isRoomAvailable;
    }
    }


    private BassClientStateMachine getOrCreateStateMachine(BluetoothDevice device) {
    private BassClientStateMachine getOrCreateStateMachine(BluetoothDevice device) {
@@ -642,29 +633,16 @@ public class BassClientService extends ProfileService {
                            BassConstants.BAAS_UUID)) {
                            BassConstants.BAAS_UUID)) {
                        return;
                        return;
                    }
                    }
                    log( "Broadcast Source Found:" + result.getDevice());
                    Message msg = mBassUtils.getAutoAssistScanHandler()
                    byte[] broadcastIdArray = listOfUuids.get(BassConstants.BAAS_UUID);
                            .obtainMessage(BassConstants.AA_SCAN_SUCCESS);
                    int broadcastId = (int)(((broadcastIdArray[2] & 0xff) << 16)
                    msg.obj = result;
                            | ((broadcastIdArray[1] & 0xff) << 8)
                    mBassUtils.getAutoAssistScanHandler().sendMessage(msg);
                            | (broadcastIdArray[0] & 0xff));
                    if (mScanBroadcasts.get(broadcastId) == null) {
                        log("selectBroadcastSource: broadcastId " + broadcastId);
                        mScanBroadcasts.put(broadcastId, result);
                        synchronized (mStateMachines) {
                            for (BassClientStateMachine sm : mStateMachines.values()) {
                                if (sm.isConnected()) {
                                    selectSource(sm.getDevice(), result, false);
                                }
                            }
                        }
                    }
                }
                }


                public void onScanFailed(int errorCode) {
                public void onScanFailed(int errorCode) {
                    Log.e(TAG, "Scan Failure:" + errorCode);
                    Log.e(TAG, "Scan Failure:" + errorCode);
                }
                }
            };
            };
            mScanBroadcasts.clear();
            ScanSettings settings = new ScanSettings.Builder().setCallbackType(
            ScanSettings settings = new ScanSettings.Builder().setCallbackType(
                    ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
                    ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
                    .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
                    .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
@@ -710,7 +688,6 @@ public class BassClientService extends ProfileService {
            scanner.stopScan(mSearchScanCallback);
            scanner.stopScan(mSearchScanCallback);
            mSearchScanCallback = null;
            mSearchScanCallback = null;
            mCallbacks.notifySearchStopped(BluetoothStatusCodes.REASON_LOCAL_APP_REQUEST);
            mCallbacks.notifySearchStopped(BluetoothStatusCodes.REASON_LOCAL_APP_REQUEST);
            mScanBroadcasts.clear();
        }
        }
    }
    }


+3 −25
Original line number Original line Diff line number Diff line
@@ -436,13 +436,7 @@ public class BassClientStateMachine extends StateMachine {
                channel.setSelected(false);
                channel.setSelected(false);
                subGroup.addChannel(channel.build());
                subGroup.addChannel(channel.build());
            }
            }
            byte[] arrayCodecId = baseLevel2.codecId;
            subGroup.setCodecId(ByteBuffer.wrap(baseLevel2.codecId).getLong());
            long codeId = (long) ((arrayCodecId[4] & 0xff) << 32
                    | (arrayCodecId[3] & 0xff) << 24
                    | (arrayCodecId[2] & 0xff) << 16
                    | (arrayCodecId[1] & 0xff) << 8
                    | (arrayCodecId[0] & 0xff));
            subGroup.setCodecId(codeId);
            subGroup.setCodecSpecificConfig(BluetoothLeAudioCodecConfigMetadata.
            subGroup.setCodecSpecificConfig(BluetoothLeAudioCodecConfigMetadata.
                    fromRawBytes(baseLevel2.codecConfigInfo));
                    fromRawBytes(baseLevel2.codecConfigInfo));
            subGroup.setContentMetadata(BluetoothLeAudioContentMetadata.
            subGroup.setContentMetadata(BluetoothLeAudioContentMetadata.
@@ -450,18 +444,6 @@ public class BassClientStateMachine extends StateMachine {
            metaData.addSubgroup(subGroup.build());
            metaData.addSubgroup(subGroup.build());
        }
        }
        metaData.setSourceDevice(device, device.getAddressType());
        metaData.setSourceDevice(device, device.getAddressType());
        byte[] arrayPresentationDelay = baseData.getLevelOne().presentationDelay;
        int presentationDelay = (int) ((arrayPresentationDelay[2] & 0xff) << 16
                | (arrayPresentationDelay[1] & 0xff)
                | (arrayPresentationDelay[0] & 0xff));
        metaData.setPresentationDelayMicros(presentationDelay);
        PeriodicAdvertisementResult result =
                mService.getPeriodicAdvertisementResult(device);
        if (result != null) {
            int broadcastId = result.getBroadcastId();
            log("broadcast ID: " + broadcastId);
            metaData.setBroadcastId(broadcastId);
        }
        return metaData.build();
        return metaData.build();
    }
    }


@@ -652,7 +634,6 @@ public class BassClientStateMachine extends StateMachine {
            byte metaDataSyncState = receiverState[BassConstants.BCAST_RCVR_STATE_PA_SYNC_IDX];
            byte metaDataSyncState = receiverState[BassConstants.BCAST_RCVR_STATE_PA_SYNC_IDX];
            byte encryptionStatus = receiverState[BassConstants.BCAST_RCVR_STATE_ENC_STATUS_IDX];
            byte encryptionStatus = receiverState[BassConstants.BCAST_RCVR_STATE_ENC_STATUS_IDX];
            byte[] badBroadcastCode = null;
            byte[] badBroadcastCode = null;
            int badBroadcastCodeLen = 0;
            if (encryptionStatus
            if (encryptionStatus
                    == BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_BAD_CODE) {
                    == BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_BAD_CODE) {
                badBroadcastCode = new byte[BassConstants.BCAST_RCVR_STATE_BADCODE_SIZE];
                badBroadcastCode = new byte[BassConstants.BCAST_RCVR_STATE_BADCODE_SIZE];
@@ -663,12 +644,11 @@ public class BassClientStateMachine extends StateMachine {
                        0,
                        0,
                        BassConstants.BCAST_RCVR_STATE_BADCODE_SIZE);
                        BassConstants.BCAST_RCVR_STATE_BADCODE_SIZE);
                badBroadcastCode = reverseBytes(badBroadcastCode);
                badBroadcastCode = reverseBytes(badBroadcastCode);
                badBroadcastCodeLen = BassConstants.BCAST_RCVR_STATE_BADCODE_SIZE;
            }
            }
            byte numSubGroups = receiverState[BassConstants.BCAST_RCVR_STATE_BADCODE_START_IDX
            byte numSubGroups = receiverState[BassConstants.BCAST_RCVR_STATE_BADCODE_START_IDX
                    + badBroadcastCodeLen];
                    + BassConstants.BCAST_RCVR_STATE_BADCODE_SIZE];
            int offset = BassConstants.BCAST_RCVR_STATE_BADCODE_START_IDX
            int offset = BassConstants.BCAST_RCVR_STATE_BADCODE_START_IDX
                    + badBroadcastCodeLen + 1;
                    + BassConstants.BCAST_RCVR_STATE_BADCODE_SIZE + 1;
            ArrayList<BluetoothLeAudioContentMetadata> metadataList =
            ArrayList<BluetoothLeAudioContentMetadata> metadataList =
                    new ArrayList<BluetoothLeAudioContentMetadata>();
                    new ArrayList<BluetoothLeAudioContentMetadata>();
            ArrayList<Long> audioSyncState = new ArrayList<Long>();
            ArrayList<Long> audioSyncState = new ArrayList<Long>();
@@ -679,8 +659,6 @@ public class BassClientStateMachine extends StateMachine {
                offset += BassConstants.BCAST_RCVR_STATE_BIS_SYNC_SIZE;
                offset += BassConstants.BCAST_RCVR_STATE_BIS_SYNC_SIZE;
                log("BIS index byte array: ");
                log("BIS index byte array: ");
                BassUtils.printByteArray(audioSyncIndex);
                BassUtils.printByteArray(audioSyncIndex);
                ByteBuffer wrapped = ByteBuffer.wrap(reverseBytes(audioSyncIndex));
                audioSyncState.add((long) wrapped.getInt());


                byte metaDataLength = receiverState[offset++];
                byte metaDataLength = receiverState[offset++];
                if (metaDataLength > 0) {
                if (metaDataLength > 0) {