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

Commit 718ab81e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12007880 from 98fd384c to 24Q4-release

Change-Id: Ie0a87065bc84b2d748b4720b0d20c38ec968627b
parents c1f306b2 98fd384c
Loading
Loading
Loading
Loading
+55 −3
Original line number Diff line number Diff line
@@ -1821,21 +1821,60 @@ public class LeAudioService extends ProfileService {
                return;
            }
            if (Flags.scanManagerRefactor()) {
                mAdapterService
                        .getBluetoothScanController()
                        .getTransitionalScanHelper()
                        .stopScanInternal(mScannerId);

                mAdapterService
                        .getBluetoothScanController()
                        .getTransitionalScanHelper()
                        .unregisterScannerInternal(mScannerId);
            } else {
                mAdapterService
                        .getBluetoothGattService()
                        .getTransitionalScanHelper()
                        .stopScanInternal(mScannerId);

                mAdapterService
                        .getBluetoothGattService()
                        .getTransitionalScanHelper()
                        .unregisterScannerInternal(mScannerId);
            }
            mScannerId = 0;
        }

        @Override
        public synchronized void onScannerRegistered(int status, int scannerId) {
            mScannerId = scannerId;

            /* Filter we are building here will not match to anything.
             * Eventually we should be able to start scan from native when
             * b/276350722 is done
             */
            ScanFilter filter =
                    new ScanFilter.Builder()
                            .setServiceData(BluetoothUuid.LE_AUDIO, new byte[] {0x11})
                            .build();

            ScanSettings settings =
                    new ScanSettings.Builder()
                            .setLegacy(false)
                            .setScanMode(ScanSettings.SCAN_MODE_BALANCED)
                            .setPhy(BluetoothDevice.PHY_LE_1M)
                            .build();

            if (Flags.scanManagerRefactor()) {
                mAdapterService
                        .getBluetoothScanController()
                        .getTransitionalScanHelper()
                        .startScanInternal(scannerId, settings, List.of(filter));
            } else {
                mAdapterService
                        .getBluetoothGattService()
                        .getTransitionalScanHelper()
                        .startScanInternal(scannerId, settings, List.of(filter));
            }
        }

        // Eventually we should be able to start scan from native when b/276350722 is done
@@ -2216,17 +2255,30 @@ public class LeAudioService extends ProfileService {
                        + ", mExposedActiveDevice: "
                        + mExposedActiveDevice);

        LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(currentlyActiveGroupId);
        if (isBroadcastActive()
                && currentlyActiveGroupId == LE_AUDIO_GROUP_ID_INVALID
                && mUnicastGroupIdDeactivatedForBroadcastTransition != LE_AUDIO_GROUP_ID_INVALID
                && groupId != LE_AUDIO_GROUP_ID_INVALID) {
                && mUnicastGroupIdDeactivatedForBroadcastTransition != LE_AUDIO_GROUP_ID_INVALID) {
            // If broadcast is ongoing and need to update unicast fallback active group
            // we need to update the cached group id and skip changing the active device
            updateFallbackUnicastGroupIdForBroadcast(groupId);

            /* In case of removing fallback unicast group, monitoring input device should be
             * removed from active devices.
             */
            if (groupDescriptor != null && groupId == LE_AUDIO_GROUP_ID_INVALID) {
                updateActiveDevices(
                        groupId,
                        groupDescriptor.mDirection,
                        AUDIO_DIRECTION_NONE,
                        false,
                        groupDescriptor.mHasFallbackDeviceWhenGettingInactive,
                        false);
            }

            return true;
        }

        LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(currentlyActiveGroupId);
        if (groupDescriptor != null && groupId == currentlyActiveGroupId) {
            /* Make sure active group is already exposed to audio framework.
             * If not, lets wait for it and don't sent additional intent.
+30 −1
Original line number Diff line number Diff line
@@ -1182,12 +1182,36 @@ public class TransitionalScanHelper {
                Utils.checkCallerHasScanWithoutLocationPermission(mContext);
        scanClient.associatedDevices = getAssociatedDevices(callingPackage);

        startScan(scannerId, settings, filters, scanClient);
    }

    /** Intended for internal use within the Bluetooth app. Bypass permission check */
    public void startScanInternal(int scannerId, ScanSettings settings, List<ScanFilter> filters) {
        final ScanClient scanClient = new ScanClient(scannerId, settings, filters);
        scanClient.userHandle = Binder.getCallingUserHandle();
        scanClient.eligibleForSanitizedExposureNotification = false;
        scanClient.hasDisavowedLocation = false;
        scanClient.isQApp = true;
        scanClient.hasNetworkSettingsPermission =
                Utils.checkCallerHasNetworkSettingsPermission(mContext);
        scanClient.hasNetworkSetupWizardPermission =
                Utils.checkCallerHasNetworkSetupWizardPermission(mContext);
        scanClient.hasScanWithoutLocationPermission =
                Utils.checkCallerHasScanWithoutLocationPermission(mContext);
        scanClient.associatedDevices = Collections.emptyList();

        startScan(scannerId, settings, filters, scanClient);
    }

    private void startScan(
            int scannerId, ScanSettings settings, List<ScanFilter> filters, ScanClient scanClient) {
        AppScanStats app = mScannerMap.getAppScanStatsById(scannerId);
        ContextMap.App cbApp = mScannerMap.getById(scannerId);
        if (app != null) {
            scanClient.stats = app;
            boolean isFilteredScan = (filters != null) && !filters.isEmpty();
            boolean isCallbackScan = false;

            ContextMap.App cbApp = mScannerMap.getById(scannerId);
            if (cbApp != null) {
                isCallbackScan = cbApp.callback != null;
            }
@@ -1319,6 +1343,11 @@ public class TransitionalScanHelper {
                mContext, attributionSource, "ScanHelper stopScan")) {
            return;
        }
        stopScanInternal(scannerId);
    }

    /** Intended for internal use within the Bluetooth app. Bypass permission check */
    public void stopScanInternal(int scannerId) {
        int scanQueueSize =
                mScanManager.getBatchScanQueue().size() + mScanManager.getRegularScanQueue().size();
        Log.d(TAG, "stopScan() - queue size =" + scanQueueSize);
+6 −0
Original line number Diff line number Diff line
@@ -1683,6 +1683,12 @@ public class LeAudioServiceTest {
        // Verify only update the fallback group and not proceed to change active
        assertThat(mService.setActiveDevice(mSingleDevice)).isTrue();
        assertThat(mService.mUnicastGroupIdDeactivatedForBroadcastTransition).isEqualTo(groupId);

        // Verify only update the fallback group to INVALID and not proceed to change active
        assertThat(mService.setActiveDevice(null)).isTrue();
        assertThat(mService.mUnicastGroupIdDeactivatedForBroadcastTransition)
                .isEqualTo(BluetoothLeAudio.GROUP_ID_INVALID);

        verify(mNativeInterface, times(0)).groupSetActive(anyInt());
    }

+484 −0

File changed.

Preview size limit exceeded, changes collapsed.

+5 −0
Original line number Diff line number Diff line
@@ -386,6 +386,11 @@ bool a2dp_get_selected_hal_pcm_config(PcmConfiguration* pcm_config) {
  pcm_config->sampleRateHz = A2dpCodecToHalSampleRate(current_codec);
  pcm_config->bitsPerSample = A2dpCodecToHalBitsPerSample(current_codec);
  pcm_config->channelMode = A2dpCodecToHalChannelMode(current_codec);

  if (com::android::bluetooth::flags::a2dp_aidl_encoding_interval()) {
    pcm_config->dataIntervalUs = bta_av_co_get_encoder_preferred_interval_us();
  }

  return (pcm_config->sampleRateHz > 0 && pcm_config->bitsPerSample > 0 &&
          pcm_config->channelMode != ChannelMode::UNKNOWN);
}
Loading