diff options
34 files changed, 241 insertions, 264 deletions
diff --git a/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java b/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java index 61429c8d90..46fda180fa 100644 --- a/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +++ b/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java @@ -417,7 +417,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac final LeAudioService leAudioService = mFactory.getLeAudioService(); setA2dpActiveDevice(null, true); setHfpActiveDevice(null); - if (Flags.admVerifyActiveFallbackDevice() && leAudioService != null) { + if (leAudioService != null) { setLeAudioActiveDevice( null, !leAudioService.getActiveDevices().contains(device)); } else { @@ -1162,13 +1162,11 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac * recently removed device, it means it just switched profile it is using and is * not new one. */ - boolean hasFallbackDevice = true; - if (Flags.admVerifyActiveFallbackDevice()) { - hasFallbackDevice = - !(recentlyRemovedDevice != null - && device.equals(recentlyRemovedDevice) - && connectedHearingAidDevices.size() == 1); - } + boolean hasFallbackDevice = + !(recentlyRemovedDevice != null + && device.equals(recentlyRemovedDevice) + && connectedHearingAidDevices.size() == 1); + if (mHearingAidConnectedDevices.contains(device)) { Log.d(TAG, "Found a hearing aid fallback device: " + device); setHearingAidActiveDevice(device); diff --git a/android/app/src/com/android/bluetooth/hfp/HeadsetService.java b/android/app/src/com/android/bluetooth/hfp/HeadsetService.java index c5ab1f8dde..ce7c623aaf 100644 --- a/android/app/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/android/app/src/com/android/bluetooth/hfp/HeadsetService.java @@ -1105,10 +1105,7 @@ public class HeadsetService extends ProfileService { } else { broadcastActiveDevice(null); } - - if (Flags.updateActiveDeviceInBandRingtone()) { - updateInbandRinging(null, true); - } + updateInbandRinging(null, true); } } @@ -1222,9 +1219,7 @@ public class HeadsetService extends ProfileService { broadcastActiveDevice(mActiveDevice); } } - if (Flags.updateActiveDeviceInBandRingtone()) { - updateInbandRinging(device, true); - } + updateInbandRinging(device, true); } return true; } @@ -1941,7 +1936,7 @@ public class HeadsetService extends ProfileService { if (getConnectedDevices().size() > 1 || isHeadsetClientConnected() - || (Flags.updateActiveDeviceInBandRingtone() && mActiveDevice == null)) { + || mActiveDevice == null) { mInbandRingingRuntimeDisable = true; } else { mInbandRingingRuntimeDisable = false; diff --git a/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index 6ea741af32..3c2fe0f8bf 100644 --- a/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -58,6 +58,7 @@ import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.flags.Flags; +import com.android.bluetooth.util.SystemProperties; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.State; import com.android.internal.util.StateMachine; @@ -187,6 +188,9 @@ class HeadsetStateMachine extends StateMachine { BluetoothAssignedNumbers.GOOGLE); } + @VisibleForTesting + static final String HFP_VOLUME_CONTROL_ENABLED = "bluetooth.hfp_volume_control.enabled"; + private HeadsetStateMachine( BluetoothDevice device, Looper looper, @@ -2026,7 +2030,10 @@ class HeadsetStateMachine extends StateMachine { } if (volumeType == HeadsetHalConstants.VOLUME_TYPE_SPK) { mSpeakerVolume = volume; - int flag = (mCurrentState == mAudioOn) ? AudioManager.FLAG_SHOW_UI : 0; + boolean showVolume = + !Flags.hfpVolumeControlProperty() + || SystemProperties.getBoolean(HFP_VOLUME_CONTROL_ENABLED, true); + int flag = showVolume && (mCurrentState == mAudioOn) ? AudioManager.FLAG_SHOW_UI : 0; int volStream = deprecateStreamBtSco() ? AudioManager.STREAM_VOICE_CALL diff --git a/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java b/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java index 3576d07c3c..54ced65311 100644 --- a/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java +++ b/android/app/src/com/android/bluetooth/le_audio/LeAudioService.java @@ -348,7 +348,7 @@ public class LeAudioService extends ProfileService { mLostLeadDeviceWhileStreaming = null; mCurrentLeadDevice = null; mInbandRingtoneEnabled = isInbandRingtoneEnabled; - mAvailableContexts = Flags.leaudioUnicastNoAvailableContexts() ? null : 0; + mAvailableContexts = null; mInputSelectableConfig = new ArrayList<>(); mOutputSelectableConfig = new ArrayList<>(); mInactivatedDueToContextType = false; @@ -4342,8 +4342,7 @@ public class LeAudioService extends ProfileService { if (getConnectedPeerDevices(groupId).isEmpty()) { descriptor.mIsConnected = false; descriptor.mAutoActiveModeEnabled = true; - descriptor.mAvailableContexts = - Flags.leaudioUnicastNoAvailableContexts() ? null : 0; + descriptor.mAvailableContexts = null; if (descriptor.isActive()) { /* Notify Native layer */ removeActiveDevice(hasFallbackDevice); diff --git a/android/app/src/com/android/bluetooth/mcp/MediaControlProfile.java b/android/app/src/com/android/bluetooth/mcp/MediaControlProfile.java index b96923ca7d..aff115c59e 100644 --- a/android/app/src/com/android/bluetooth/mcp/MediaControlProfile.java +++ b/android/app/src/com/android/bluetooth/mcp/MediaControlProfile.java @@ -39,7 +39,6 @@ import com.android.bluetooth.audio_util.MediaData; import com.android.bluetooth.audio_util.MediaPlayerList; import com.android.bluetooth.audio_util.MediaPlayerWrapper; import com.android.bluetooth.btservice.AdapterService; -import com.android.bluetooth.flags.Flags; import com.android.bluetooth.le_audio.ContentControlIdKeeper; import com.android.internal.annotations.VisibleForTesting; @@ -409,8 +408,7 @@ public class MediaControlProfile implements MediaControlServiceCallbacks { + Request.Opcodes.toString(request.opcode())); Request.Results status = Request.Results.COMMAND_CANNOT_BE_COMPLETED; - if (Flags.mcpAllowPlayWithoutActivePlayer() - && !Utils.isPtsTestMode() + if (!Utils.isPtsTestMode() && mMediaPlayerList.getActivePlayer() == null && request.opcode() == Request.Opcodes.PLAY) { Log.d(TAG, "Player is not active. GMCS send media key for PLAY"); diff --git a/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java b/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java index 746e4985e9..9a2579d59c 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java @@ -1388,7 +1388,6 @@ public class ActiveDeviceManagerTest { * and selected as active. First LE Audio device disconnects with fallback to new one. */ @Test - @EnableFlags(Flags.FLAG_ADM_VERIFY_ACTIVE_FALLBACK_DEVICE) public void sameDeviceAsAshaAndLeAudio_noFallbackOnSwitch() { /* Dual mode ASHA/LeAudio device from group 1 */ when(mLeAudioService.getGroupId(mHearingAidDevice)).thenReturn(1); @@ -1426,7 +1425,6 @@ public class ActiveDeviceManagerTest { * and selected as active. First ASHA device disconnects with fallback to new one. */ @Test - @EnableFlags(Flags.FLAG_ADM_VERIFY_ACTIVE_FALLBACK_DEVICE) public void sameDeviceAsLeAudioAndAsha_noFallbackOnSwitch() { // Turn on the dual mode audio flag so the A2DP won't disconnect LE Audio when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_NORMAL); diff --git a/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java b/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java index 6595d55deb..4040b31d53 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java @@ -491,7 +491,6 @@ public class HeadsetServiceAndStateMachineTest { /** Test the value of isInbandRingingEnabled will be changed with the change of active device */ @Test public void testIsInbandRingingEnabled_SwitchActiveDevice() { - mSetFlagsRule.enableFlags(Flags.FLAG_UPDATE_ACTIVE_DEVICE_IN_BAND_RINGTONE); BluetoothDevice device = getTestDevice(0); connectTestDevice(device); @@ -937,14 +936,8 @@ public class HeadsetServiceAndStateMachineTest { BluetoothDevice deviceB = getTestDevice(1); connectTestDevice(deviceB); InOrder inOrder = inOrder(mNativeInterface); - if (!Flags.updateActiveDeviceInBandRingtone()) { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(true)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - } else { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - } + inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); + inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); // Set active device to device B assertThat(mHeadsetService.setActiveDevice(deviceB)).isTrue(); mTestLooper.dispatchAll(); @@ -1004,14 +997,8 @@ public class HeadsetServiceAndStateMachineTest { connectTestDevice(deviceA); BluetoothDevice deviceB = getTestDevice(1); connectTestDevice(deviceB); - if (!Flags.updateActiveDeviceInBandRingtone()) { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(true)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - } else { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - } + inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); + inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); // Set active device to device B assertThat(mHeadsetService.setActiveDevice(deviceB)).isTrue(); mTestLooper.dispatchAll(); @@ -1071,14 +1058,8 @@ public class HeadsetServiceAndStateMachineTest { BluetoothDevice deviceB = getTestDevice(1); connectTestDevice(deviceB); InOrder inOrder = inOrder(mNativeInterface); - if (!Flags.updateActiveDeviceInBandRingtone()) { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(true)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - } else { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - } + inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); + inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); // Set active device to device B assertThat(mHeadsetService.setActiveDevice(deviceB)).isTrue(); mTestLooper.dispatchAll(); @@ -1123,14 +1104,8 @@ public class HeadsetServiceAndStateMachineTest { BluetoothDevice deviceB = getTestDevice(1); connectTestDevice(deviceB); InOrder inOrder = inOrder(mNativeInterface); - if (!Flags.updateActiveDeviceInBandRingtone()) { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(true)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - } else { - inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); - inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); - } + inOrder.verify(mNativeInterface).sendBsir(eq(deviceA), eq(false)); + inOrder.verify(mNativeInterface).sendBsir(eq(deviceB), eq(false)); // Set active device to device B assertThat(mHeadsetService.setActiveDevice(deviceB)).isTrue(); mTestLooper.dispatchAll(); diff --git a/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceTest.java index 2e03a61c22..8526408a6d 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceTest.java @@ -1247,7 +1247,6 @@ public class HeadsetServiceTest { } @Test - @EnableFlags({Flags.FLAG_UPDATE_ACTIVE_DEVICE_IN_BAND_RINGTONE}) public void testIncomingCallDeviceConnect_InbandRingStatus() { when(mDatabaseManager.getProfileConnectionPolicy( any(BluetoothDevice.class), eq(BluetoothProfile.HEADSET))) @@ -1269,7 +1268,6 @@ public class HeadsetServiceTest { } @Test - @EnableFlags({Flags.FLAG_UPDATE_ACTIVE_DEVICE_IN_BAND_RINGTONE}) public void testIncomingCallWithDeviceAudioConnected() { ArrayList<BluetoothDevice> connectedDevices = new ArrayList<>(); when(mDatabaseManager.getProfileConnectionPolicy( diff --git a/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetStateMachineTest.java b/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetStateMachineTest.java index 9f4a2c1382..529110f7d2 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetStateMachineTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetStateMachineTest.java @@ -69,10 +69,12 @@ import com.android.bluetooth.TestUtils; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.ActiveDeviceManager; import com.android.bluetooth.btservice.AdapterService; +import com.android.bluetooth.btservice.PhonePolicy; import com.android.bluetooth.btservice.RemoteDevices; import com.android.bluetooth.btservice.SilenceDeviceManager; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.flags.Flags; +import com.android.bluetooth.util.SystemProperties; import org.junit.After; import org.junit.Before; @@ -121,6 +123,7 @@ public class HeadsetStateMachineTest { private MockContentResolver mMockContentResolver; @Mock private HeadsetNativeInterface mNativeInterface; @Mock private RemoteDevices mRemoteDevices; + @Mock private SystemProperties.MockableSystemProperties mProperties; @Before public void setUp() throws Exception { @@ -175,6 +178,8 @@ public class HeadsetStateMachineTest { mAdapterService, mNativeInterface, mSystemInterface); + + SystemProperties.mProperties = mProperties; } @After @@ -1765,6 +1770,49 @@ public class HeadsetStateMachineTest { verify(mockAudioManager).setStreamVolume(AudioManager.STREAM_VOICE_CALL, 2, 0); } + @RequiresFlagsEnabled(Flags.FLAG_HFP_VOLUME_CONTROL_PROPERTY) + @Test + public void testProcessVolumeEventAudioConnected_withVolumeControlEnabled_ShowUiFlagEnabled() { + doReturn(true) + .when(mProperties) + .getBoolean(eq(HeadsetStateMachine.HFP_VOLUME_CONTROL_ENABLED), anyBoolean()); + + setUpAudioOnState(); + + when(mHeadsetService.getActiveDevice()).thenReturn(mDevice); + AudioManager mockAudioManager = mock(AudioManager.class); + when(mockAudioManager.getStreamVolume(anyInt())).thenReturn(1); + when(mSystemInterface.getAudioManager()).thenReturn(mockAudioManager); + + mHeadsetStateMachine.processVolumeEvent(HeadsetHalConstants.VOLUME_TYPE_SPK, 2); + + var flagsCaptor = ArgumentCaptor.forClass(Integer.class); + verify(mockAudioManager).setStreamVolume(anyInt(), anyInt(), flagsCaptor.capture()); + assertThat(flagsCaptor.getValue() & AudioManager.FLAG_SHOW_UI) + .isEqualTo(AudioManager.FLAG_SHOW_UI); + } + + @RequiresFlagsEnabled(Flags.FLAG_HFP_VOLUME_CONTROL_PROPERTY) + @Test + public void testProcessVolumeEventAudioConnected_withVolumeControlEnabled_ShowUiFlagDisabled() { + doReturn(false) + .when(mProperties) + .getBoolean(eq(HeadsetStateMachine.HFP_VOLUME_CONTROL_ENABLED), anyBoolean()); + + setUpAudioOnState(); + + when(mHeadsetService.getActiveDevice()).thenReturn(mDevice); + AudioManager mockAudioManager = mock(AudioManager.class); + when(mockAudioManager.getStreamVolume(anyInt())).thenReturn(1); + when(mSystemInterface.getAudioManager()).thenReturn(mockAudioManager); + + mHeadsetStateMachine.processVolumeEvent(HeadsetHalConstants.VOLUME_TYPE_SPK, 2); + + var flagsCaptor = ArgumentCaptor.forClass(Integer.class); + verify(mockAudioManager).setStreamVolume(anyInt(), anyInt(), flagsCaptor.capture()); + assertThat(flagsCaptor.getValue() & AudioManager.FLAG_SHOW_UI).isEqualTo(0); + } + @Test public void testVolumeChangeEvent_fromIntentWhenAudioOn() { setUpAudioOnState(); diff --git a/android/app/tests/unit/src/com/android/bluetooth/le_audio/LeAudioServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/le_audio/LeAudioServiceTest.java index 5d3634d952..b69b864bb4 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/le_audio/LeAudioServiceTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/le_audio/LeAudioServiceTest.java @@ -211,7 +211,6 @@ public class LeAudioServiceTest { public static List<FlagsParameterization> getParams() { return FlagsParameterization.progressionOf( Flags.FLAG_LEAUDIO_BROADCAST_PRIMARY_GROUP_SELECTION, - Flags.FLAG_LEAUDIO_UNICAST_NO_AVAILABLE_CONTEXTS, Flags.FLAG_LEAUDIO_BROADCAST_API_MANAGE_PRIMARY_GROUP, Flags.FLAG_DO_NOT_HARDCODE_TMAP_ROLE_MASK); } @@ -2836,7 +2835,6 @@ public class LeAudioServiceTest { * </pre> */ @Test - @EnableFlags(Flags.FLAG_LEAUDIO_UNICAST_NO_AVAILABLE_CONTEXTS) public void testActivateGroupWhenAvailableContextAreBack_Scenario1() { int groupId = 1; /* AUDIO_DIRECTION_OUTPUT_BIT = 0x01 */ @@ -2920,7 +2918,6 @@ public class LeAudioServiceTest { * </pre> */ @Test - @EnableFlags(Flags.FLAG_LEAUDIO_UNICAST_NO_AVAILABLE_CONTEXTS) public void testActivateDeviceWhenAvailableContextAreBack_Scenario2() { int groupId = 1; /* AUDIO_DIRECTION_OUTPUT_BIT = 0x01 */ @@ -3018,7 +3015,6 @@ public class LeAudioServiceTest { * 4. The available contexts are updated with non-zero value. Group becomes active. */ @Test - @EnableFlags(Flags.FLAG_LEAUDIO_UNICAST_NO_AVAILABLE_CONTEXTS) public void testActivateDeviceWhenAvailableContextAreBack_Scenario3() { int groupId = 1; /* AUDIO_DIRECTION_OUTPUT_BIT = 0x01 */ diff --git a/android/pandora/mmi2grpc/mmi2grpc/_audio.py b/android/pandora/mmi2grpc/mmi2grpc/_audio.py index 7bc97167a8..6ab5b148ff 100644 --- a/android/pandora/mmi2grpc/mmi2grpc/_audio.py +++ b/android/pandora/mmi2grpc/mmi2grpc/_audio.py @@ -18,7 +18,7 @@ import math import os from threading import Thread -# import numpy as np +import numpy as np # from scipy.io import wavfile SINE_FREQUENCY = 440 diff --git a/android/pandora/mmi2grpc/mmi2grpc/hap.py b/android/pandora/mmi2grpc/mmi2grpc/hap.py index bd2fd83643..99202e9f7f 100644 --- a/android/pandora/mmi2grpc/mmi2grpc/hap.py +++ b/android/pandora/mmi2grpc/mmi2grpc/hap.py @@ -28,7 +28,8 @@ from pandora.security_grpc import Security from pandora.security_pb2 import LE_LEVEL3, PairingEventAnswer from pandora_experimental.gatt_grpc import GATT from pandora_experimental.hap_grpc import HAP -from pandora_experimental.hap_pb2 import HaPlaybackAudioRequest +from pandora_experimental.le_audio_pb2 import LeAudioPlaybackAudioRequest +from pandora_experimental.le_audio_grpc import LeAudio BASE_UUID = uuid.UUID("00000000-0000-1000-8000-00805F9B34FB") SINK_ASE_UUID = 0x2BC4 @@ -60,9 +61,9 @@ class HAPProxy(ProfileProxy): self.connection = None def convert_frame(data): - return HaPlaybackAudioRequest(data=data, source=self.source) + return LeAudioPlaybackAudioRequest(data=data) - self.audio = AudioSignal(lambda frames: self.hap.HaPlaybackAudio(map(convert_frame, frames)), + self.audio = AudioSignal(lambda frames: self.le_audio.LeAudioPlaybackAudio(map(convert_frame, frames)), AUDIO_SIGNAL_AMPLITUDE, AUDIO_SIGNAL_SAMPLING_RATE) def test_started(self, test: str, **kwargs): diff --git a/android/pandora/server/configs/PtsBotTest.xml b/android/pandora/server/configs/PtsBotTest.xml index 2acbd64521..60a609cc56 100644 --- a/android/pandora/server/configs/PtsBotTest.xml +++ b/android/pandora/server/configs/PtsBotTest.xml @@ -35,6 +35,7 @@ <target_preparer class="com.android.tradefed.targetprep.PythonVirtualenvPreparer"> <option name="dep-module" value="grpcio" /> <option name="dep-module" value="protobuf==3.20.1" /> + <option name="dep-module" value="numpy" /> <!-- Re-enable when A2DP audio streaming tests are active, disabling to speed up atest runtime (installation takes roughly 30s each time, never cached) --> diff --git a/android/pandora/server/src/Hap.kt b/android/pandora/server/src/Hap.kt index ddecaeb773..a242f4bcf2 100644 --- a/android/pandora/server/src/Hap.kt +++ b/android/pandora/server/src/Hap.kt @@ -29,8 +29,6 @@ import android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED import android.bluetooth.BluetoothProfile.STATE_CONNECTED import android.content.Context import android.content.IntentFilter -import android.media.AudioManager -import android.media.AudioTrack import android.util.Log import com.google.protobuf.Empty import io.grpc.Status @@ -61,7 +59,6 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { private val bluetoothManager = context.getSystemService(BluetoothManager::class.java)!! private val bluetoothAdapter = bluetoothManager.adapter - private val audioManager = context.getSystemService(AudioManager::class.java)!! private val bluetoothHapClient = getProfileProxy<BluetoothHapClient>(context, BluetoothProfile.HAP_CLIENT) @@ -79,8 +76,6 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { ) .shareIn(scope, SharingStarted.Eagerly) - private var audioTrack: AudioTrack? = null - private class PresetInfoChanged( var connection: Connection, var presetInfoList: List<BluetoothHapPresetInfo>, @@ -287,67 +282,6 @@ class Hap(val context: Context) : HAPImplBase(), Closeable { } } - override fun haPlaybackAudio( - responseObserver: StreamObserver<Empty> - ): StreamObserver<HaPlaybackAudioRequest> { - Log.i(TAG, "haPlaybackAudio") - - if (audioTrack == null) { - audioTrack = buildAudioTrack() - } - - // Play an audio track. - audioTrack!!.play() - - if (audioTrack!!.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) { - responseObserver.onError( - Status.UNKNOWN.withDescription("AudioTrack is not started").asException() - ) - } - - // Volume is maxed out to avoid any amplitude modification of the provided audio data, - // enabling the test runner to do comparisons between input and output audio signal. - // Any volume modification should be done before providing the audio data. - if (audioManager.isVolumeFixed) { - Log.w(TAG, "Volume is fixed, cannot max out the volume") - } else { - val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) - if (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < maxVolume) { - audioManager.setStreamVolume( - AudioManager.STREAM_MUSIC, - maxVolume, - AudioManager.FLAG_SHOW_UI, - ) - } - } - - return object : StreamObserver<HaPlaybackAudioRequest> { - override fun onNext(request: HaPlaybackAudioRequest) { - val data = request.data.toByteArray() - val written = synchronized(audioTrack!!) { audioTrack!!.write(data, 0, data.size) } - if (written != data.size) { - responseObserver.onError( - Status.UNKNOWN.withDescription("AudioTrack write failed").asException() - ) - } - } - - override fun onError(t: Throwable) { - t.printStackTrace() - val sw = StringWriter() - t.printStackTrace(PrintWriter(sw)) - responseObserver.onError( - Status.UNKNOWN.withCause(t).withDescription(sw.toString()).asException() - ) - } - - override fun onCompleted() { - responseObserver.onNext(Empty.getDefaultInstance()) - responseObserver.onCompleted() - } - } - } - override fun waitPresetChanged( request: Empty, responseObserver: StreamObserver<WaitPresetChangedResponse>, diff --git a/android/pandora/server/src/LeAudio.kt b/android/pandora/server/src/LeAudio.kt index 7e7e7e6147..7677f9ea71 100644 --- a/android/pandora/server/src/LeAudio.kt +++ b/android/pandora/server/src/LeAudio.kt @@ -25,9 +25,11 @@ import android.bluetooth.BluetoothProfile.STATE_DISCONNECTED import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.media.* +import android.media.AudioTrack +import android.media.AudioManager import android.util.Log import com.google.protobuf.Empty +import io.grpc.Status import io.grpc.stub.StreamObserver import java.io.Closeable import kotlinx.coroutines.CoroutineScope @@ -41,6 +43,8 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.shareIn import pandora.LeAudioGrpc.LeAudioImplBase import pandora.LeAudioProto.* +import java.io.PrintWriter +import java.io.StringWriter @kotlinx.coroutines.ExperimentalCoroutinesApi class LeAudio(val context: Context) : LeAudioImplBase(), Closeable { @@ -57,6 +61,8 @@ class LeAudio(val context: Context) : LeAudioImplBase(), Closeable { private val bluetoothLeAudio = getProfileProxy<BluetoothLeAudio>(context, BluetoothProfile.LE_AUDIO) + private var audioTrack: AudioTrack? = null + init { scope = CoroutineScope(Dispatchers.Default) val intentFilter = IntentFilter() @@ -98,4 +104,92 @@ class LeAudio(val context: Context) : LeAudioImplBase(), Closeable { Empty.getDefaultInstance() } } + + override fun leAudioStart(request: LeAudioStartRequest, responseObserver: StreamObserver<Empty>) { + grpcUnary<Empty>(scope, responseObserver) { + if (audioTrack == null) { + audioTrack = buildAudioTrack() + } + val device = request.connection.toBluetoothDevice(bluetoothAdapter) + Log.i(TAG, "start: device=$device") + + if (bluetoothLeAudio.getConnectionState(device) != BluetoothLeAudio.STATE_CONNECTED) { + throw RuntimeException("Device is not connected, cannot start") + } + + // Configure the selected device as active device if it is not + // already. + bluetoothLeAudio.setActiveDevice(device) + + // Play an audio track. + audioTrack!!.play() + + Empty.getDefaultInstance() + } + } + + override fun leAudioStop(request: LeAudioStopRequest, responseObserver: StreamObserver<Empty>) { + grpcUnary<Empty>(scope, responseObserver) { + checkNotNull(audioTrack) { "No track to pause!" } + + // Play an audio track. + audioTrack!!.pause() + + Empty.getDefaultInstance() + } + } + + override fun leAudioPlaybackAudio( + responseObserver: StreamObserver<LeAudioPlaybackAudioResponse> + ): StreamObserver<LeAudioPlaybackAudioRequest> { + Log.i(TAG, "leAudioPlaybackAudio") + + if (audioTrack!!.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) { + responseObserver.onError( + Status.UNKNOWN.withDescription("AudioTrack is not started").asException() + ) + } + + // Volume is maxed out to avoid any amplitude modification of the provided audio data, + // enabling the test runner to do comparisons between input and output audio signal. + // Any volume modification should be done before providing the audio data. + if (audioManager.isVolumeFixed) { + Log.w(TAG, "Volume is fixed, cannot max out the volume") + } else { + val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) + if (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < maxVolume) { + audioManager.setStreamVolume( + AudioManager.STREAM_MUSIC, + maxVolume, + AudioManager.FLAG_SHOW_UI, + ) + } + } + + return object : StreamObserver<LeAudioPlaybackAudioRequest> { + override fun onNext(request: LeAudioPlaybackAudioRequest) { + val data = request.data.toByteArray() + val written = synchronized(audioTrack!!) { audioTrack!!.write(data, 0, data.size) } + if (written != data.size) { + responseObserver.onError( + Status.UNKNOWN.withDescription("AudioTrack write failed").asException() + ) + } + } + + override fun onError(t: Throwable) { + t.printStackTrace() + val sw = StringWriter() + t.printStackTrace(PrintWriter(sw)) + responseObserver.onError( + Status.UNKNOWN.withCause(t).withDescription(sw.toString()).asException() + ) + } + + override fun onCompleted() { + responseObserver.onNext(LeAudioPlaybackAudioResponse.getDefaultInstance()) + responseObserver.onCompleted() + } + } + } } diff --git a/android/pandora/server/src/Pan.kt b/android/pandora/server/src/Pan.kt index 62334af83b..6961eea7dd 100644 --- a/android/pandora/server/src/Pan.kt +++ b/android/pandora/server/src/Pan.kt @@ -67,6 +67,7 @@ class Pan(private val context: Context) : PANImplBase(), Closeable { } override fun close() { + mTetheringManager.stopTethering(TETHERING_BLUETOOTH) bluetoothAdapter.closeProfileProxy(BluetoothProfile.PAN, bluetoothPan) mScope.cancel() } diff --git a/flags/Android.bp b/flags/Android.bp index 80a57891a5..6f1e67e262 100644 --- a/flags/Android.bp +++ b/flags/Android.bp @@ -34,7 +34,6 @@ aconfig_declarations { "le_scanning.aconfig", "leaudio.aconfig", "mapclient.aconfig", - "mcp.aconfig", "metric.aconfig", "opp.aconfig", "pairing.aconfig", diff --git a/flags/BUILD.gn b/flags/BUILD.gn index da5aa8621b..a53cb379fe 100644 --- a/flags/BUILD.gn +++ b/flags/BUILD.gn @@ -27,7 +27,6 @@ aconfig("bluetooth_flags_c_lib") { "le_scanning.aconfig", "leaudio.aconfig", "mapclient.aconfig", - "mcp.aconfig", "metric.aconfig", "opp.aconfig", "pairing.aconfig", diff --git a/flags/active_device_manager.aconfig b/flags/active_device_manager.aconfig index b2438be452..ebaf40fdb9 100644 --- a/flags/active_device_manager.aconfig +++ b/flags/active_device_manager.aconfig @@ -2,16 +2,6 @@ package: "com.android.bluetooth.flags" container: "com.android.bt" flag { - name: "adm_verify_active_fallback_device" - namespace: "bluetooth" - description: "Verify if device selected for fallback is different then last one" - bug: "369799111" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "adm_fix_disconnect_of_set_member" namespace: "bluetooth" description: "Fix disconnecting of the set member device. Make sure the other set member is not considered as fallback device." diff --git a/flags/adapter.aconfig b/flags/adapter.aconfig index 0195723932..39e681be16 100644 --- a/flags/adapter.aconfig +++ b/flags/adapter.aconfig @@ -9,6 +9,16 @@ flag { } flag { + name: "call_bluetooth_ready_before_profiles_start" + namespace: "bluetooth" + description: "Initiates the adapter properties before starting profiles" + bug: "405437771" + metadata { + purpose: PURPOSE_BUGFIX + } +} + +flag { name: "empty_names_are_invalid" namespace: "bluetooth" description: "Make sure the names used in the stack are valid" diff --git a/flags/hfp.aconfig b/flags/hfp.aconfig index 9e3bd50b5d..14a91bdc6e 100644 --- a/flags/hfp.aconfig +++ b/flags/hfp.aconfig @@ -74,16 +74,6 @@ flag { } flag { - name: "update_active_device_in_band_ringtone" - namespace: "bluetooth" - description: "Active device update the in band ringtone, but how ringtone is played is still decided by the headset" - bug: "349318724" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "choose_wrong_hfp_codec_in_specific_config" namespace: "bluetooth" description: "Flag to fix codec selection in nego when the peer device only support NB and SWB." diff --git a/flags/leaudio.aconfig b/flags/leaudio.aconfig index bc9210e9b4..7a917fbaca 100644 --- a/flags/leaudio.aconfig +++ b/flags/leaudio.aconfig @@ -51,16 +51,6 @@ flag { } flag { - name: "leaudio_mono_location_errata" - namespace: "bluetooth" - description: "Add mono location as per Bluetooth Assigned Numbers" - bug: "331139722" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "leaudio_mono_location_errata_api" is_exported: true namespace: "bluetooth" @@ -69,13 +59,6 @@ flag { } flag { - name: "le_audio_support_unidirectional_voice_assistant" - namespace: "bluetooth" - description: "Allow to create unidirectional stream for VOICEASSISTANT" - bug: "332510824" -} - -flag { name: "run_clock_recovery_in_worker_thread" namespace: "bluetooth" description: "Fix thread ownership issue in clock_recovery" @@ -137,26 +120,6 @@ flag { } flag { - name: "leaudio_unicast_no_available_contexts" - namespace: "bluetooth" - description: "Fix handling initial zero available contexts" - bug: "367325041" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { - name: "leaudio_improve_switch_during_phone_call" - namespace: "bluetooth" - description: "Fix audio slip to speaker while switching bt audio device during phonecall" - bug: "369322905" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "leaudio_sort_scans_to_sync_by_fails" namespace: "bluetooth" description: "Sort scan results for source sync by fails counter" diff --git a/flags/mcp.aconfig b/flags/mcp.aconfig deleted file mode 100644 index 80567acae7..0000000000 --- a/flags/mcp.aconfig +++ /dev/null @@ -1,13 +0,0 @@ -package: "com.android.bluetooth.flags" -container: "com.android.bt" - -flag { - name: "mcp_allow_play_without_active_player" - namespace: "bluetooth" - description: "Handle LeAudio play same as in AVRCP in case player is not active" - bug: "337169240" - metadata { - purpose: PURPOSE_BUGFIX - } - -} diff --git a/pandora/interfaces/pandora_experimental/hap.proto b/pandora/interfaces/pandora_experimental/hap.proto index 5847887529..d56fdb515d 100644 --- a/pandora/interfaces/pandora_experimental/hap.proto +++ b/pandora/interfaces/pandora_experimental/hap.proto @@ -28,8 +28,6 @@ service HAP { rpc SetNextPreset(SetNextPresetRequest) returns (google.protobuf.Empty); // Set next preset rpc SetPreviousPreset(SetPreviousPresetRequest) returns (google.protobuf.Empty); - // Playback audio - rpc HaPlaybackAudio(stream HaPlaybackAudioRequest) returns (google.protobuf.Empty); // Set preset name rpc WritePresetName(WritePresetNameRequest) returns (google.protobuf.Empty); // Get preset record @@ -50,16 +48,6 @@ message GetFeaturesResponse{ int32 features = 1; } -// Request of the `PlaybackAudio` method. -message HaPlaybackAudioRequest { - // Low Energy connection. - Connection connection = 1; - // Audio data to playback. - // `data` should be interleaved stereo frames with 16-bit signed little-endian - // linear PCM samples at 44100Hz sample rate - bytes data = 2; -} - // Request of the `SetActivePreset` method. message SetActivePresetRequest { // Connection crafted by grpc server diff --git a/pandora/interfaces/pandora_experimental/le_audio.proto b/pandora/interfaces/pandora_experimental/le_audio.proto index 4500564991..4628ac9a2e 100644 --- a/pandora/interfaces/pandora_experimental/le_audio.proto +++ b/pandora/interfaces/pandora_experimental/le_audio.proto @@ -10,8 +10,33 @@ package pandora; // Service to trigger LE Audio procedures. service LeAudio { rpc Open(OpenRequest) returns (google.protobuf.Empty); + // Playback audio + rpc LeAudioPlaybackAudio(stream LeAudioPlaybackAudioRequest) returns (LeAudioPlaybackAudioResponse); + // Start an opened stream. + rpc LeAudioStart(LeAudioStartRequest) returns (google.protobuf.Empty); + // Stop an opened stream. + rpc LeAudioStop(LeAudioStopRequest) returns (google.protobuf.Empty); } message OpenRequest { Connection connection = 1; } + +// Request for the `LeAudioStart` method. +message LeAudioStartRequest { + Connection connection = 1; +} + +// Request of the `PlaybackAudio` method. +message LeAudioPlaybackAudioRequest { + // Audio data to playback. + bytes data = 1; +} + +// Response of the `LeAudioPlaybackAudio` method. +message LeAudioPlaybackAudioResponse {} + +// Request of the `LeAudioStop` method. +message LeAudioStopRequest { + Connection connection = 1; +} diff --git a/system/bta/le_audio/client.cc b/system/bta/le_audio/client.cc index 388070ef8a..ff1b7e2c77 100644 --- a/system/bta/le_audio/client.cc +++ b/system/bta/le_audio/client.cc @@ -1636,11 +1636,6 @@ public: } void PrepareStreamForAConversational(LeAudioDeviceGroup* group) { - if (!com::android::bluetooth::flags::leaudio_improve_switch_during_phone_call()) { - log::info("Flag leaudio_improve_switch_during_phone_call is not enabled"); - return; - } - log::debug("group_id: {}", group->group_id_); auto remote_direction = bluetooth::le_audio::types::kLeAudioDirectionSink; diff --git a/system/bta/le_audio/codec_manager.cc b/system/bta/le_audio/codec_manager.cc index 104d397833..03ea6eede7 100644 --- a/system/bta/le_audio/codec_manager.cc +++ b/system/bta/le_audio/codec_manager.cc @@ -787,11 +787,8 @@ public: bool UpdateCisMonoConfiguration(const std::vector<struct types::cis>& cises, const stream_parameters& stream_params, uint8_t direction) { - if (!LeAudioHalVerifier::SupportsStreamActiveApi() || - !com::android::bluetooth::flags::leaudio_mono_location_errata()) { - log::error( - "SupportsStreamActiveApi() not supported or leaudio_mono_location_errata flag is not " - "enabled. Mono stream cannot be enabled"); + if (!LeAudioHalVerifier::SupportsStreamActiveApi()) { + log::error("SupportsStreamActiveApi() not supported. Mono stream cannot be enabled"); return false; } diff --git a/system/bta/le_audio/codec_manager_test.cc b/system/bta/le_audio/codec_manager_test.cc index c69464b72e..f238b959f8 100644 --- a/system/bta/le_audio/codec_manager_test.cc +++ b/system/bta/le_audio/codec_manager_test.cc @@ -369,8 +369,6 @@ public: // Disable codec extensibility by default osi_property_set_bool(kPropLeAudioCodecExtensibility, false); - com::android::bluetooth::flags::provider_->leaudio_mono_location_errata(false); - CodecManagerTestBase::SetUp(); } }; @@ -542,7 +540,6 @@ TEST_F(CodecManagerTestAdsp, testStreamConfigurationAdspDownMix) { } TEST_F(CodecManagerTestAdsp, testStreamConfigurationMono) { - com::android::bluetooth::flags::provider_->leaudio_mono_location_errata(true); const std::vector<bluetooth::le_audio::btle_audio_codec_config_t> offloading_preference(0); codec_manager->Start(offloading_preference); @@ -1343,7 +1340,6 @@ TEST_F(CodecManagerTestHost, test_dont_call_hal_for_config) { } TEST_F(CodecManagerTestAdsp, testStreamConfigurationVendor) { - com::android::bluetooth::flags::provider_->leaudio_mono_location_errata(true); osi_property_set_bool(kPropLeAudioCodecExtensibility, true); const std::vector<bluetooth::le_audio::btle_audio_codec_config_t> offloading_preference(0); diff --git a/system/bta/le_audio/device_groups.cc b/system/bta/le_audio/device_groups.cc index 43f27c0a31..6b1f98a6f8 100644 --- a/system/bta/le_audio/device_groups.cc +++ b/system/bta/le_audio/device_groups.cc @@ -862,8 +862,7 @@ LeAudioDeviceGroup::GetAudioSetConfigurationRequirements(types::LeAudioContextTy continue; } - if ((com::android::bluetooth::flags::le_audio_support_unidirectional_voice_assistant() && - ctx_type == types::LeAudioContextType::VOICEASSISTANTS) || + if (ctx_type == types::LeAudioContextType::VOICEASSISTANTS || ctx_type == types::LeAudioContextType::GAME) { // For GAME and VOICE ASSISTANT, ignore direction if it is not supported only on a single // direction. @@ -1689,19 +1688,16 @@ bool LeAudioDeviceGroup::IsAudioSetConfigurationSupported( continue; } - if (com::android::bluetooth::flags::le_audio_support_unidirectional_voice_assistant()) { - // Verify the direction requirements. - if (direction == types::kLeAudioDirectionSink && - requirements.sink_requirements->size() == 0) { - log::debug("There is no requirement for Sink direction."); - return false; - } + // Verify the direction requirements. + if (direction == types::kLeAudioDirectionSink && requirements.sink_requirements->size() == 0) { + log::debug("There is no requirement for Sink direction."); + return false; + } - if (direction == types::kLeAudioDirectionSource && - requirements.source_requirements->size() == 0) { - log::debug("There is no requirement for source direction."); - return false; - } + if (direction == types::kLeAudioDirectionSource && + requirements.source_requirements->size() == 0) { + log::debug("There is no requirement for source direction."); + return false; } // Match with requirement first if we have diff --git a/system/bta/le_audio/le_audio_client_test.cc b/system/bta/le_audio/le_audio_client_test.cc index a27c272872..69cd0fe768 100644 --- a/system/bta/le_audio/le_audio_client_test.cc +++ b/system/bta/le_audio/le_audio_client_test.cc @@ -5022,7 +5022,6 @@ TEST_F(UnicastTest, GroupSetActive_and_InactiveDuringStreamConfiguration) { } TEST_F(UnicastTest, AnotherGroupSetActive_DuringMediaStream) { - com::android::bluetooth::flags::provider_->leaudio_improve_switch_during_phone_call(true); const RawAddress test_address0 = GetTestAddress(0); const RawAddress test_address1 = GetTestAddress(1); int group_id_1 = 1; @@ -5101,7 +5100,6 @@ TEST_F(UnicastTest, AnotherGroupSetActive_DuringMediaStream) { } TEST_F(UnicastTest, AnotherGroupSetActive_DuringVoip) { - com::android::bluetooth::flags::provider_->leaudio_improve_switch_during_phone_call(true); const RawAddress test_address0 = GetTestAddress(0); const RawAddress test_address1 = GetTestAddress(1); int group_id_1 = 1; @@ -5174,7 +5172,6 @@ TEST_F(UnicastTest, AnotherGroupSetActive_DuringVoip) { } TEST_F(UnicastTest, GroupSetActive_and_GroupSetInactive_DuringPhoneCall) { - com::android::bluetooth::flags::provider_->leaudio_improve_switch_during_phone_call(true); const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; @@ -5221,7 +5218,6 @@ TEST_F(UnicastTest, GroupSetActive_and_GroupSetInactive_DuringPhoneCall) { } TEST_F(UnicastTest, GroupSetActive_DuringPhoneCall_ThenResume) { - com::android::bluetooth::flags::provider_->leaudio_improve_switch_during_phone_call(true); const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; @@ -6577,7 +6573,6 @@ TEST_F(UnicastTest, SpeakerStreamingNonDefault) { } TEST_F(UnicastTest, TestUnidirectionalGameAndLiveRecording) { - com::android::bluetooth::flags::provider_->le_audio_support_unidirectional_voice_assistant(true); const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; @@ -6768,7 +6763,6 @@ TEST_F(UnicastTest, TestUnidirectionalGameAndLiveRecordingMicOnlyDev) { } TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Sink) { - com::android::bluetooth::flags::provider_->le_audio_support_unidirectional_voice_assistant(true); const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; @@ -6842,7 +6836,6 @@ TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Sink) { } TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Source) { - com::android::bluetooth::flags::provider_->le_audio_support_unidirectional_voice_assistant(true); const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; diff --git a/system/gd/hal/BUILD.gn b/system/gd/hal/BUILD.gn index ebf15255af..57007d2571 100644 --- a/system/gd/hal/BUILD.gn +++ b/system/gd/hal/BUILD.gn @@ -42,7 +42,10 @@ source_set("BluetoothHalSources_hci_host") { } configs += [ "//bt/system/gd:gd_defaults" ] - deps = [ "//bt/system/gd:gd_default_deps" ] + deps = [ + "//bt/flags:bluetooth_flags_c_lib", + "//bt/system/gd:gd_default_deps", + ] } source_set("BluetoothHalSources_ranging_host") { diff --git a/system/gd/hal/snoop_logger.cc b/system/gd/hal/snoop_logger.cc index 538d13ec3e..2462834b53 100644 --- a/system/gd/hal/snoop_logger.cc +++ b/system/gd/hal/snoop_logger.cc @@ -55,7 +55,7 @@ static std::string GetBtSnoopMode() { // Default mode is FILTERED on userdebug/eng build, DISABLED on user build. // In userdebug/eng build, it can also be overwritten by modifying the global setting std::string btsnoop_mode = SnoopLogger::kBtSnoopLogModeDisabled; - if (os::GetSystemPropertyBool(SnoopLogger::kIsDebuggableProperty, false)) { + if (os::GetSystemProperty(SnoopLogger::kRoBuildType) != "user") { btsnoop_mode = os::GetSystemProperty(SnoopLogger::kBtSnoopDefaultLogModeProperty) .value_or(SnoopLogger::kBtSnoopLogModeFiltered); } @@ -471,7 +471,7 @@ size_t get_btsnooz_packet_length_to_write(const HciPacket& packet, SnoopLogger:: // system properties const std::string SnoopLogger::kBtSnoopMaxPacketsPerFileProperty = "persist.bluetooth.btsnoopsize"; -const std::string SnoopLogger::kIsDebuggableProperty = "ro.debuggable"; +const std::string SnoopLogger::kRoBuildType = "ro.build.type"; const std::string SnoopLogger::kBtSnoopLogModeProperty = "persist.bluetooth.btsnooplogmode"; const std::string SnoopLogger::kBtSnoopDefaultLogModeProperty = "persist.bluetooth.btsnoopdefaultmode"; @@ -1333,7 +1333,7 @@ void SnoopLogger::Start() { EnableFilters(); } - if (os::GetSystemPropertyBool(kIsDebuggableProperty, false)) { + if (os::GetSystemProperty(kRoBuildType) != "user") { // Cf b/375056207: The implementation must pass a security review // in order to enable the snoop logger socket in user builds. auto snoop_logger_socket = std::make_unique<SnoopLoggerSocket>(&syscall_if); @@ -1404,9 +1404,9 @@ size_t SnoopLogger::GetMaxPacketsPerFile() { size_t SnoopLogger::GetMaxPacketsPerBuffer() { // We want to use at most 256 KB memory for btsnooz log for release builds // and 512 KB memory for userdebug/eng builds - auto is_debuggable = os::GetSystemPropertyBool(kIsDebuggableProperty, false); + auto is_debug_build = (os::GetSystemProperty(kRoBuildType) != "user"); - size_t btsnooz_max_memory_usage_bytes = (is_debuggable ? 1024 : 256) * 1024; + size_t btsnooz_max_memory_usage_bytes = (is_debug_build ? 1024 : 256) * 1024; // Calculate max number of packets based on max memory usage and max packet size return btsnooz_max_memory_usage_bytes / kDefaultBtSnoozMaxBytesPerPacket; } @@ -1419,8 +1419,8 @@ void SnoopLogger::RegisterSocket(SnoopLoggerSocketInterface* socket) { } bool SnoopLogger::IsBtSnoopLogPersisted() { - auto is_debuggable = os::GetSystemPropertyBool(kIsDebuggableProperty, false); - return is_debuggable && os::GetSystemPropertyBool(kBtSnoopLogPersists, false); + auto is_debug_build = (os::GetSystemProperty(kRoBuildType) != "user"); + return is_debug_build && os::GetSystemPropertyBool(kBtSnoopLogPersists, false); } bool SnoopLogger::IsQualcommDebugLogEnabled() { diff --git a/system/gd/hal/snoop_logger.h b/system/gd/hal/snoop_logger.h index b0783442b3..5f45e8a0b2 100644 --- a/system/gd/hal/snoop_logger.h +++ b/system/gd/hal/snoop_logger.h @@ -146,7 +146,7 @@ public: static const ModuleFactory Factory; static const std::string kBtSnoopMaxPacketsPerFileProperty; - static const std::string kIsDebuggableProperty; + static const std::string kRoBuildType; static const std::string kBtSnoopLogModeProperty; static const std::string kBtSnoopLogPersists; static const std::string kBtSnoopDefaultLogModeProperty; diff --git a/system/gd/metrics/BUILD.gn b/system/gd/metrics/BUILD.gn index ff0d72e81e..6d235376c6 100644 --- a/system/gd/metrics/BUILD.gn +++ b/system/gd/metrics/BUILD.gn @@ -50,7 +50,10 @@ source_set("BluetoothMetricsSources") { "//bt/system/gd:gd_defaults", "//bt/system/log:log_defaults", ] - deps = [ "//bt/system/gd:gd_default_deps" ] + deps = [ + "//bt/flags:bluetooth_flags_c_lib", + "//bt/system/gd:gd_default_deps", + ] if (target_os == "chromeos") { deps += [ ":BluetoothMetricsSources_chromeos" ] |