Merge "Check in_use to prevent accessing deallocated cb" into main
diff --git a/Cargo.toml b/Cargo.toml
index 5ed873e..d3cee87 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,7 +16,6 @@
[workspace]
default-members = [
- "system/gd/rust/shim",
"system/gd/rust/topshim",
"system/gd/rust/linux/mgmt",
"system/gd/rust/linux/service",
@@ -26,7 +25,6 @@
]
members = [
- "system/gd/rust/shim",
"system/gd/rust/topshim",
"system/gd/rust/linux/mgmt",
"system/gd/rust/linux/service",
diff --git a/OWNERS b/OWNERS
index a69eb5a..4df6c99 100644
--- a/OWNERS
+++ b/OWNERS
@@ -4,11 +4,12 @@
girardier@google.com #{LAST_RESORT_SUGGESTION}
muhammadfalam@google.com #{LAST_RESORT_SUGGESTION}
siyuanh@google.com #{LAST_RESORT_SUGGESTION}
+okamil@google.com #{LAST_RESORT_SUGGESTION}
# Per-file ownership
-# Build files / test_config / presubmit / preupload
-per-file PREUPLOAD.cfg,TEST_MAPPING,*.bp,*.xml=file:/OWNERS_build
+# Build files / test_config / presubmit / preupload / linter file
+per-file PREUPLOAD.cfg,TEST_MAPPING,*.bp,*.xml,pyrightconfig.json=file:/OWNERS_build
# ChromeOS team owns Linux build files
# - build.py is used for Linux build
diff --git a/android/app/Android.bp b/android/app/Android.bp
index 616dc1b..af6a2af 100644
--- a/android/app/Android.bp
+++ b/android/app/Android.bp
@@ -125,7 +125,6 @@
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbtcore",
"libbtdevice",
"libbte",
diff --git a/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp b/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp
index 8036b43..b4cf5eb 100644
--- a/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -1020,8 +1020,7 @@
}
static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest, jboolean isCommonCriteriaMode,
- int configCompareResult, jobjectArray initFlags, jboolean isAtvDevice,
- jstring userDataDirectory) {
+ int configCompareResult, jboolean isAtvDevice, jstring userDataDirectory) {
std::unique_lock<std::shared_timed_mutex> lock(jniObjMutex);
log::verbose("");
@@ -1036,34 +1035,15 @@
return JNI_FALSE;
}
- int flagCount = env->GetArrayLength(initFlags);
- jstring* flagObjs = new jstring[flagCount];
- const char** flags = nullptr;
- if (flagCount > 0) {
- flags = new const char*[flagCount + 1];
- flags[flagCount] = nullptr;
- }
-
- for (int i = 0; i < flagCount; i++) {
- flagObjs[i] = (jstring)env->GetObjectArrayElement(initFlags, i);
- flags[i] = env->GetStringUTFChars(flagObjs[i], NULL);
- }
-
const char* user_data_directory = env->GetStringUTFChars(userDataDirectory, NULL);
- int ret = sBluetoothInterface->init(&sBluetoothCallbacks, isGuest == JNI_TRUE ? 1 : 0,
- isCommonCriteriaMode == JNI_TRUE ? 1 : 0, configCompareResult,
- flags, isAtvDevice == JNI_TRUE ? 1 : 0, user_data_directory);
+ int ret =
+ sBluetoothInterface->init(&sBluetoothCallbacks, isGuest == JNI_TRUE ? 1 : 0,
+ isCommonCriteriaMode == JNI_TRUE ? 1 : 0, configCompareResult,
+ nullptr, isAtvDevice == JNI_TRUE ? 1 : 0, user_data_directory);
env->ReleaseStringUTFChars(userDataDirectory, user_data_directory);
- for (int i = 0; i < flagCount; i++) {
- env->ReleaseStringUTFChars(flagObjs[i], flags[i]);
- }
-
- delete[] flags;
- delete[] flagObjs;
-
if (ret != BT_STATUS_SUCCESS) {
log::error("Error while setting the callbacks: {}", ret);
sBluetoothInterface = NULL;
@@ -2245,8 +2225,7 @@
int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) {
const JNINativeMethod methods[] = {
- {"initNative", "(ZZI[Ljava/lang/String;ZLjava/lang/String;)Z",
- reinterpret_cast<void*>(initNative)},
+ {"initNative", "(ZZIZLjava/lang/String;)Z", reinterpret_cast<void*>(initNative)},
{"cleanupNative", "()V", reinterpret_cast<void*>(cleanupNative)},
{"enableNative", "()Z", reinterpret_cast<void*>(enableNative)},
{"disableNative", "()Z", reinterpret_cast<void*>(disableNative)},
diff --git a/android/app/jni/com_android_bluetooth_hfp.cpp b/android/app/jni/com_android_bluetooth_hfp.cpp
index 40b587e..c1d982d 100644
--- a/android/app/jni/com_android_bluetooth_hfp.cpp
+++ b/android/app/jni/com_android_bluetooth_hfp.cpp
@@ -16,6 +16,8 @@
#define LOG_TAG "BluetoothHeadsetServiceJni"
+#include <bluetooth/log.h>
+
#include <mutex>
#include <shared_mutex>
@@ -24,7 +26,6 @@
#include "hardware/bluetooth_headset_callbacks.h"
#include "hardware/bluetooth_headset_interface.h"
#include "hardware/bt_hf.h"
-#include "os/log.h"
namespace android {
@@ -948,22 +949,22 @@
jbyteArray address) {
std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, NULL);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
bt_status_t ret = sBluetoothHfpInterface->EnableSwb(
(bluetooth::headset::bthf_swb_codec_t)swbCodec, (bool)enable, (RawAddress*)addr);
if (ret != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed to %s", __func__, (enable ? "enable" : "disable"));
+ log::error("Failed to {}", (enable ? "enable" : "disable"));
return JNI_FALSE;
}
- ALOGV("%s: Successfully %s", __func__, (enable ? "enabled" : "disabled"));
+ log::verbose("Successfully {}", (enable ? "enabled" : "disabled"));
return JNI_TRUE;
}
diff --git a/android/app/src/com/android/bluetooth/bass_client/BassClientService.java b/android/app/src/com/android/bluetooth/bass_client/BassClientService.java
index 0f2a1da..63d6bb2 100644
--- a/android/app/src/com/android/bluetooth/bass_client/BassClientService.java
+++ b/android/app/src/com/android/bluetooth/bass_client/BassClientService.java
@@ -3378,6 +3378,34 @@
}
}
+ /** Handle device newly connected and its peer device still has active source */
+ private void checkAndResumeBroadcast(BluetoothDevice sink) {
+ BluetoothLeBroadcastMetadata metadata = mBroadcastMetadataMap.get(sink);
+ if (metadata == null) {
+ Log.d(TAG, "checkAndResumeBroadcast: no metadata available");
+ return;
+ }
+ for (BluetoothDevice groupDevice : getTargetDeviceList(sink, true)) {
+ if (groupDevice.equals(sink)) {
+ continue;
+ }
+ // Check peer device
+ Optional<BluetoothLeBroadcastReceiveState> receiver =
+ getOrCreateStateMachine(groupDevice).getAllSources().stream()
+ .filter(e -> e.getBroadcastId() == metadata.getBroadcastId())
+ .findAny();
+ if (receiver.isPresent()
+ && !getAllSources(sink).stream()
+ .anyMatch(
+ rs ->
+ (rs.getBroadcastId()
+ == receiver.get().getBroadcastId()))) {
+ Log.d(TAG, "checkAndResumeBroadcast: restore the source for device: " + sink);
+ addSource(sink, metadata, false);
+ }
+ }
+ }
+
private void logPausedBroadcastsAndSinks() {
log(
"mPausedBroadcastIds: "
@@ -3788,6 +3816,7 @@
private static final int MSG_SOURCE_REMOVED_FAILED = 11;
private static final int MSG_RECEIVESTATE_CHANGED = 12;
private static final int MSG_SOURCE_LOST = 13;
+ private static final int MSG_BASS_STATE_READY = 14;
@GuardedBy("mCallbacksList")
private final RemoteCallbackList<IBluetoothLeBroadcastAssistantCallback> mCallbacksList =
@@ -3840,8 +3869,33 @@
}
}
+ private boolean handleServiceInternalMessage(Message msg) {
+ boolean isMsgHandled = false;
+ if (sService == null) {
+ Log.e(TAG, "Service is null");
+ return isMsgHandled;
+ }
+ BluetoothDevice sink;
+
+ switch (msg.what) {
+ case MSG_BASS_STATE_READY:
+ sink = (BluetoothDevice) msg.obj;
+ sService.checkAndResumeBroadcast(sink);
+ isMsgHandled = true;
+ break;
+ default:
+ break;
+ }
+ return isMsgHandled;
+ }
+
@Override
public void handleMessage(Message msg) {
+ if (handleServiceInternalMessage(msg)) {
+ log("Handled internal message: " + msg.what);
+ return;
+ }
+
checkForPendingGroupOpRequest(msg);
synchronized (mCallbacksList) {
@@ -4100,6 +4154,11 @@
sEventLogger.logd(TAG, "notifySourceLost: broadcastId: " + broadcastId);
obtainMessage(MSG_SOURCE_LOST, 0, broadcastId).sendToTarget();
}
+
+ void notifyBassStateReady(BluetoothDevice sink) {
+ sEventLogger.logd(TAG, "notifyBassStateReady: sink: " + sink);
+ obtainMessage(MSG_BASS_STATE_READY, sink).sendToTarget();
+ }
}
@Override
diff --git a/android/app/src/com/android/bluetooth/bass_client/BassClientStateMachine.java b/android/app/src/com/android/bluetooth/bass_client/BassClientStateMachine.java
index 6ac75f7..333d853 100644
--- a/android/app/src/com/android/bluetooth/bass_client/BassClientStateMachine.java
+++ b/android/app/src/com/android/bluetooth/bass_client/BassClientStateMachine.java
@@ -20,6 +20,7 @@
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;
import static com.android.bluetooth.flags.Flags.leaudioBigDependsOnAudioState;
+import static com.android.bluetooth.flags.Flags.leaudioBroadcastResyncHelper;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
@@ -968,6 +969,11 @@
mBroadcastSyncStats.clear();
}
+ private boolean isSourceAbsent(BluetoothLeBroadcastReceiveState recvState) {
+ return recvState.getSourceDevice() == null
+ || recvState.getSourceDevice().getAddress().equals("00:00:00:00:00:00");
+ }
+
private void checkAndUpdateBroadcastCode(BluetoothLeBroadcastReceiveState recvState) {
log("checkAndUpdateBroadcastCode");
// Whenever receive state indicated code requested, assistant should set the broadcast code
@@ -1149,14 +1155,18 @@
return;
}
mBluetoothLeBroadcastReceiveStates.put(characteristic.getInstanceId(), recvState);
- checkAndUpdateBroadcastCode(recvState);
- processPASyncState(recvState);
+ if (!isSourceAbsent(recvState)) {
+ checkAndUpdateBroadcastCode(recvState);
+ processPASyncState(recvState);
+ }
+ if (leaudioBroadcastResyncHelper()) {
+ // Notify service BASS state ready for operations
+ mService.getCallbacks().notifyBassStateReady(mDevice);
+ }
} else {
log("Updated receiver state: " + recvState);
mBluetoothLeBroadcastReceiveStates.replace(characteristic.getInstanceId(), recvState);
- String emptyBluetoothDevice = "00:00:00:00:00:00";
- if (oldRecvState.getSourceDevice() == null
- || oldRecvState.getSourceDevice().getAddress().equals(emptyBluetoothDevice)) {
+ if (isSourceAbsent(oldRecvState)) {
log("New Source Addition");
removeMessages(CANCEL_PENDING_SOURCE_OPERATION);
mService.getCallbacks()
@@ -1170,8 +1180,7 @@
processPASyncState(recvState);
processSyncStateChangeStats(recvState);
} else {
- if (recvState.getSourceDevice() == null
- || recvState.getSourceDevice().getAddress().equals(emptyBluetoothDevice)) {
+ if (isSourceAbsent(recvState)) {
BluetoothDevice removedDevice = oldRecvState.getSourceDevice();
log("sourceInfo removal " + removedDevice);
int prevSourceId = oldRecvState.getSourceId();
@@ -2210,7 +2219,7 @@
BassConstants.GATT_TXN_TIMEOUT_MS);
sendMessageDelayed(
CANCEL_PENDING_SOURCE_OPERATION,
- metaData.getBroadcastCode(),
+ metaData.getBroadcastId(),
BassConstants.SOURCE_OPERATION_TIMEOUT_MS);
} else {
Log.e(TAG, "ADD_BCAST_SOURCE: no Bluetooth Gatt handle, Fatal");
@@ -2255,7 +2264,7 @@
BassConstants.GATT_TXN_TIMEOUT_MS);
sendMessageDelayed(
CANCEL_PENDING_SOURCE_OPERATION,
- metaData.getBroadcastCode(),
+ metaData.getBroadcastId(),
BassConstants.SOURCE_OPERATION_TIMEOUT_MS);
} else {
Log.e(TAG, "UPDATE_BCAST_SOURCE: no Bluetooth Gatt handle, Fatal");
diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterNativeInterface.java b/android/app/src/com/android/bluetooth/btservice/AdapterNativeInterface.java
index 28bff10..87cd353 100644
--- a/android/app/src/com/android/bluetooth/btservice/AdapterNativeInterface.java
+++ b/android/app/src/com/android/bluetooth/btservice/AdapterNativeInterface.java
@@ -64,7 +64,6 @@
boolean startRestricted,
boolean isCommonCriteriaMode,
int configCompareResult,
- String[] initFlags,
boolean isAtvDevice,
String userDataDirectory) {
mJniCallbacks = new JniCallbacks(service, adapterProperties);
@@ -72,7 +71,6 @@
startRestricted,
isCommonCriteriaMode,
configCompareResult,
- initFlags,
isAtvDevice,
userDataDirectory);
}
@@ -297,7 +295,6 @@
boolean startRestricted,
boolean isCommonCriteriaMode,
int configCompareResult,
- String[] initFlags,
boolean isAtvDevice,
String userDataDirectory);
diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterService.java b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
index 5acdcd0..19c8aee 100644
--- a/android/app/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
@@ -700,7 +700,6 @@
mUserManager.isGuestUser(),
isCommonCriteriaMode,
configCompareResult,
- getInitFlags(),
isAtvDevice,
getApplicationInfo().dataDir);
mNativeAvailable = true;
@@ -6441,18 +6440,6 @@
}
}
- private String[] getInitFlags() {
- final DeviceConfig.Properties properties =
- DeviceConfig.getProperties(DeviceConfig.NAMESPACE_BLUETOOTH);
- ArrayList<String> initFlags = new ArrayList<>();
- for (String property : properties.getKeyset()) {
- if (property.startsWith("INIT_")) {
- initFlags.add(property + "=" + properties.getString(property, null));
- }
- }
- return initFlags.toArray(new String[0]);
- }
-
private final Object mDeviceConfigLock = new Object();
/**
diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterSuspend.java b/android/app/src/com/android/bluetooth/btservice/AdapterSuspend.java
index ab5187b..751bb3d 100644
--- a/android/app/src/com/android/bluetooth/btservice/AdapterSuspend.java
+++ b/android/app/src/com/android/bluetooth/btservice/AdapterSuspend.java
@@ -27,6 +27,8 @@
import android.util.Log;
import android.view.Display;
+import com.android.internal.annotations.VisibleForTesting;
+
import java.util.Arrays;
public class AdapterSuspend {
@@ -75,12 +77,18 @@
mDisplayManager.unregisterDisplayListener(mDisplayListener);
}
+ @VisibleForTesting
+ boolean isSuspended() {
+ return mSuspended;
+ }
+
private boolean isScreenOn() {
return Arrays.stream(mDisplayManager.getDisplays())
.anyMatch(display -> display.getState() == Display.STATE_ON);
}
- private void handleSuspend() {
+ @VisibleForTesting
+ void handleSuspend() {
if (mSuspended) {
return;
}
@@ -102,7 +110,8 @@
Log.i(TAG, "ready to suspend");
}
- private void handleResume() {
+ @VisibleForTesting
+ void handleResume() {
if (!mSuspended) {
return;
}
diff --git a/android/app/src/com/android/bluetooth/hfp/HeadsetService.java b/android/app/src/com/android/bluetooth/hfp/HeadsetService.java
index 15f16e3..26b83a1 100644
--- a/android/app/src/com/android/bluetooth/hfp/HeadsetService.java
+++ b/android/app/src/com/android/bluetooth/hfp/HeadsetService.java
@@ -1395,6 +1395,17 @@
+ disconnectStatus);
}
}
+
+ // Make sure the Audio Manager knows the previous active device is no longer active.
+ if (Utils.isScoManagedByAudioEnabled()) {
+ mSystemInterface
+ .getAudioManager()
+ .handleBluetoothActiveDeviceChanged(
+ null,
+ mActiveDevice,
+ BluetoothProfileConnectionInfo.createHfpInfo());
+ }
+
mActiveDevice = null;
mNativeInterface.setActiveDevice(null);
broadcastActiveDevice(null);
diff --git a/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java
index 295b41f..b48c278 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientServiceTest.java
@@ -6659,4 +6659,58 @@
.periodicAdvertisingManagerRegisterSync(
any(), any(), anyInt(), anyInt(), any(), any());
}
+
+ /**
+ * Test add source will be triggered if new device connected and its peer is synced to broadcast
+ * source
+ */
+ @Test
+ @EnableFlags({
+ Flags.FLAG_LEAUDIO_BROADCAST_RESYNC_HELPER,
+ Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE
+ })
+ public void sinkBassStateReady_addSourceIfPeerDeviceSynced() {
+ // Imitate broadcast being active
+ doReturn(true).when(mLeAudioService).isPlaying(TEST_BROADCAST_ID);
+ prepareTwoSynchronizedDevicesForLocalBroadcast();
+
+ mBassClientService.getCallbacks().notifyBassStateReady(mCurrentDevice);
+ TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper());
+
+ assertThat(mStateMachines.size()).isEqualTo(2);
+ for (BassClientStateMachine sm : mStateMachines.values()) {
+ // No adding source if device remain synced
+ verify(sm, never()).sendMessage(any());
+ }
+
+ // Remove source on the mCurrentDevice
+ for (BassClientStateMachine sm : mStateMachines.values()) {
+ if (sm.getDevice().equals(mCurrentDevice)) {
+ injectRemoteSourceStateRemoval(sm, TEST_SOURCE_ID);
+ }
+ }
+
+ mBassClientService.getCallbacks().notifyBassStateReady(mCurrentDevice);
+ TestUtils.waitForLooperToFinishScheduledTask(mBassClientService.getCallbacks().getLooper());
+
+ for (BassClientStateMachine sm : mStateMachines.values()) {
+ // Verify mCurrentDevice is resuming the broadcast
+ if (sm.getDevice().equals(mCurrentDevice1)) {
+ verify(sm, never()).sendMessage(any());
+ } else if (sm.getDevice().equals(mCurrentDevice)) {
+ ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
+ verify(sm, atLeast(1)).sendMessage(messageCaptor.capture());
+
+ Message msg =
+ messageCaptor.getAllValues().stream()
+ .filter(m -> (m.what == BassClientStateMachine.ADD_BCAST_SOURCE))
+ .findFirst()
+ .orElse(null);
+ assertThat(msg).isNotNull();
+ clearInvocations(sm);
+ } else {
+ throw new AssertionError("Unexpected device");
+ }
+ }
+ }
}
diff --git a/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientStateMachineTest.java b/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientStateMachineTest.java
index ebfba1e..70b5006 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientStateMachineTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/bass_client/BassClientStateMachineTest.java
@@ -2372,6 +2372,106 @@
assertThat(mBassClientStateMachine.hasPendingSourceOperation(metadata.getBroadcastId()))
.isTrue();
+ assertThat(mBassClientStateMachine.mMsgWhats).contains(CANCEL_PENDING_SOURCE_OPERATION);
+ assertThat(mBassClientStateMachine.mMsgAgr1).isEqualTo(TEST_BROADCAST_ID);
+
+ /* Inject a cancel pending source operation event */
+ Message msg = mBassClientStateMachine.obtainMessage(CANCEL_PENDING_SOURCE_OPERATION);
+ msg.arg1 = metadata.getBroadcastId();
+ mBassClientStateMachine.sendMessage(msg);
+
+ TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper());
+
+ /* Verify if pending add source operation is canceled */
+ assertThat(mBassClientStateMachine.hasPendingSourceOperation(metadata.getBroadcastId()))
+ .isFalse();
+ }
+
+ @Test
+ public void cancelPendingUpdateBcastSourceMessage_inConnectedState() {
+ initToConnectedState();
+ mBassClientStateMachine.connectGatt(true);
+ mBassClientStateMachine.mNumOfBroadcastReceiverStates = 2;
+
+ // Prepare mBluetoothLeBroadcastReceiveStates for test
+ BassClientService.Callbacks callbacks = Mockito.mock(BassClientService.Callbacks.class);
+ when(mBassClientService.getCallbacks()).thenReturn(callbacks);
+ int sourceId = 1;
+ int paSync = BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_IDLE;
+ byte[] value =
+ new byte[] {
+ (byte) sourceId, // sourceId
+ (byte) (mSourceTestDevice.getAddressType() & 0xFF), // sourceAddressType
+ Utils.getByteAddress(mSourceTestDevice)[5],
+ Utils.getByteAddress(mSourceTestDevice)[4],
+ Utils.getByteAddress(mSourceTestDevice)[3],
+ Utils.getByteAddress(mSourceTestDevice)[2],
+ Utils.getByteAddress(mSourceTestDevice)[1],
+ Utils.getByteAddress(mSourceTestDevice)[0], // sourceAddress
+ 0x00, // sourceAdvSid
+ 0x00,
+ 0x00,
+ 0x00, // broadcastIdBytes
+ (byte) paSync,
+ (byte) BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_BAD_CODE,
+ // 16 bytes badBroadcastCode
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x01, // numSubGroups
+ // SubGroup #1
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00, // audioSyncIndex
+ 0x02, // metaDataLength
+ 0x00,
+ 0x00, // metadata
+ };
+ BluetoothGattCharacteristic characteristic =
+ Mockito.mock(BluetoothGattCharacteristic.class);
+ when(characteristic.getValue()).thenReturn(value);
+ when(characteristic.getInstanceId()).thenReturn(sourceId);
+ when(characteristic.getUuid()).thenReturn(BassConstants.BASS_BCAST_RECEIVER_STATE);
+ mBassClientStateMachine.mGattCallback.onCharacteristicRead(
+ null, characteristic, GATT_SUCCESS);
+ TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper());
+
+ BluetoothLeBroadcastMetadata metadata = createBroadcastMetadata();
+ BassClientStateMachine.BluetoothGattTestableWrapper btGatt =
+ Mockito.mock(BassClientStateMachine.BluetoothGattTestableWrapper.class);
+ mBassClientStateMachine.mBluetoothGatt = btGatt;
+ BluetoothGattCharacteristic scanControlPoint =
+ Mockito.mock(BluetoothGattCharacteristic.class);
+ mBassClientStateMachine.mBroadcastScanControlPoint = scanControlPoint;
+
+ sendMessageAndVerifyTransition(
+ mBassClientStateMachine.obtainMessage(
+ UPDATE_BCAST_SOURCE, sourceId, paSync, metadata),
+ BassClientStateMachine.ConnectedProcessing.class);
+ verify(scanControlPoint).setValue(any(byte[].class));
+ verify(btGatt).writeCharacteristic(any());
+
+ /* Verify if there is pending add source operation */
+ assertThat(mBassClientStateMachine.hasPendingSourceOperation(metadata.getBroadcastId()))
+ .isTrue();
+
+ assertThat(mBassClientStateMachine.mMsgWhats).contains(CANCEL_PENDING_SOURCE_OPERATION);
+ assertThat(mBassClientStateMachine.mMsgAgr1).isEqualTo(TEST_BROADCAST_ID);
+
/* Inject a cancel pending source operation event */
Message msg = mBassClientStateMachine.obtainMessage(CANCEL_PENDING_SOURCE_OPERATION);
msg.arg1 = metadata.getBroadcastId();
@@ -2519,6 +2619,39 @@
eq(0x3)); // STATS_SYNC_AUDIO_SYNC_SUCCESS
}
+ @Test
+ @EnableFlags({
+ Flags.FLAG_LEAUDIO_BROADCAST_RESYNC_HELPER,
+ Flags.FLAG_LEAUDIO_BROADCAST_EXTRACT_PERIODIC_SCANNER_FROM_STATE_MACHINE
+ })
+ public void sinkConnected_queueAddingSourceForReceiveStateReady() {
+ mBassClientStateMachine.connectGatt(true);
+ BluetoothGattCallback cb = mBassClientStateMachine.mGattCallback;
+ cb.onMtuChanged(null, 23, GATT_SUCCESS);
+ initToConnectedState();
+
+ mBassClientStateMachine.mNumOfBroadcastReceiverStates = 1;
+ BassClientService.Callbacks callbacks = Mockito.mock(BassClientService.Callbacks.class);
+ when(mBassClientService.getCallbacks()).thenReturn(callbacks);
+
+ BassClientStateMachine.BluetoothGattTestableWrapper btGatt =
+ Mockito.mock(BassClientStateMachine.BluetoothGattTestableWrapper.class);
+ mBassClientStateMachine.mBluetoothGatt = btGatt;
+ BluetoothGattCharacteristic scanControlPoint =
+ Mockito.mock(BluetoothGattCharacteristic.class);
+ mBassClientStateMachine.mBroadcastScanControlPoint = scanControlPoint;
+
+ // Initial receive state with empty source device
+ generateBroadcastReceiveStatesAndVerify(
+ mEmptyTestDevice,
+ TEST_SOURCE_ID,
+ BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_IDLE,
+ BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_NOT_ENCRYPTED,
+ 0x0L);
+ // Verify notifyBassStateReady is called
+ verify(callbacks).notifyBassStateReady(eq(mTestDevice));
+ }
+
private void initToConnectingState() {
allowConnection(true);
allowConnectGatt(true);
@@ -2627,6 +2760,7 @@
private void prepareInitialReceiveStateForGatt() {
initToConnectedState();
mBassClientStateMachine.connectGatt(true);
+
mBassClientStateMachine.mNumOfBroadcastReceiverStates = 2;
BassClientService.Callbacks callbacks = Mockito.mock(BassClientService.Callbacks.class);
when(mBassClientService.getCallbacks()).thenReturn(callbacks);
@@ -2798,6 +2932,7 @@
int mMsgAgr1;
int mMsgArg2;
Object mMsgObj;
+ long mMsgDelay;
StubBassClientStateMachine(
BluetoothDevice device,
@@ -2826,6 +2961,28 @@
}
}
+ @Override
+ public void sendMessageDelayed(int what, Object obj, long delayMillis) {
+ mMsgWhats.add(what);
+ mMsgWhat = what;
+ mMsgObj = obj;
+ mMsgDelay = delayMillis;
+ if (mShouldHandleMessage) {
+ super.sendMessageDelayed(what, obj, delayMillis);
+ }
+ }
+
+ @Override
+ public void sendMessageDelayed(int what, int arg1, long delayMillis) {
+ mMsgWhats.add(what);
+ mMsgWhat = what;
+ mMsgAgr1 = arg1;
+ mMsgDelay = delayMillis;
+ if (mShouldHandleMessage) {
+ super.sendMessageDelayed(what, arg1, delayMillis);
+ }
+ }
+
public void notifyConnectionStateChanged(int status, int newState) {
if (mGattCallback != null) {
BluetoothGatt gatt = null;
diff --git a/android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterSuspendTest.java b/android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterSuspendTest.java
new file mode 100644
index 0000000..65bf756
--- /dev/null
+++ b/android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterSuspendTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.bluetooth.btservice;
+
+import static android.bluetooth.BluetoothAdapter.SCAN_MODE_CONNECTABLE;
+import static android.bluetooth.BluetoothAdapter.SCAN_MODE_NONE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.hardware.display.DisplayManager;
+import android.os.test.TestLooper;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class AdapterSuspendTest {
+ private TestLooper mTestLooper;
+ private DisplayManager mDisplayManager;
+ private AdapterSuspend mAdapterSuspend;
+
+ @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
+ @Mock private AdapterNativeInterface mAdapterNativeInterface;
+
+ @Before
+ public void setUp() throws Exception {
+ Context context = InstrumentationRegistry.getTargetContext();
+ mTestLooper = new TestLooper();
+ mDisplayManager = context.getSystemService(DisplayManager.class);
+
+ mAdapterSuspend =
+ new AdapterSuspend(
+ mAdapterNativeInterface, mTestLooper.getLooper(), mDisplayManager);
+ }
+
+ private void triggerSuspend() throws Exception {
+ mAdapterSuspend.handleSuspend();
+ }
+
+ private void triggerResume() throws Exception {
+ mAdapterSuspend.handleResume();
+ }
+
+ private boolean isSuspended() throws Exception {
+ return mAdapterSuspend.isSuspended();
+ }
+
+ @Test
+ public void testSuspend() throws Exception {
+ assertThat(isSuspended()).isFalse();
+
+ triggerSuspend();
+
+ verify(mAdapterNativeInterface).setDefaultEventMaskExcept(anyLong(), anyLong());
+ verify(mAdapterNativeInterface)
+ .setScanMode(AdapterService.convertScanModeToHal(SCAN_MODE_NONE));
+ verify(mAdapterNativeInterface).clearEventFilter();
+ verify(mAdapterNativeInterface).clearFilterAcceptList();
+ verify(mAdapterNativeInterface).disconnectAllAcls();
+ assertThat(isSuspended()).isTrue();
+ }
+
+ @Test
+ public void testResume() throws Exception {
+ triggerSuspend();
+ assertThat(isSuspended()).isTrue();
+
+ clearInvocations(mAdapterNativeInterface);
+ triggerResume();
+
+ verify(mAdapterNativeInterface).setDefaultEventMaskExcept(0, 0);
+ verify(mAdapterNativeInterface).clearEventFilter();
+ verify(mAdapterNativeInterface).restoreFilterAcceptList();
+ verify(mAdapterNativeInterface)
+ .setScanMode(AdapterService.convertScanModeToHal(SCAN_MODE_CONNECTABLE));
+ assertThat(isSuspended()).isFalse();
+ }
+}
diff --git a/android/pandora/mmi2grpc/mmi2grpc/l2cap.py b/android/pandora/mmi2grpc/mmi2grpc/l2cap.py
index 09ef10d..09136be 100644
--- a/android/pandora/mmi2grpc/mmi2grpc/l2cap.py
+++ b/android/pandora/mmi2grpc/mmi2grpc/l2cap.py
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import time
import sys
from mmi2grpc._helpers import assert_description
@@ -22,15 +21,16 @@
from pandora.host_grpc import Host
from pandora.host_pb2 import PUBLIC, RANDOM, Connection
+from pandora.l2cap_grpc import L2CAP
+from pandora.l2cap_pb2 import CreditBasedChannelRequest
from pandora.security_pb2 import PairingEventAnswer
from pandora.security_grpc import Security
-from pandora_experimental.l2cap_grpc import L2CAP
-from typing import Optional
+from typing import Optional, Dict
class L2CAPProxy(ProfileProxy):
- test_status_map = {} # record test status and pass them between MMI
+ test_status_map: Dict[str, str] = {} # record test status and pass them between MMI
LE_DATA_PACKET_LARGE = "data: LE_DATA_PACKET_LARGE"
LE_DATA_PACKET1 = "data: LE_PACKET1"
connection: Optional[Connection] = None
@@ -44,6 +44,7 @@
self.connection = None
self.pairing_events = None
+ self.channel = None
def test_started(self, test: str, **kwargs):
self.rootcanal.select_pts_dongle(Dongle.CSR_RCK_PTS_DONGLE)
@@ -63,16 +64,12 @@
tests_target_to_fail = [
'L2CAP/LE/CFC/BV-01-C',
'L2CAP/LE/CFC/BV-04-C',
- 'L2CAP/LE/CFC/BV-10-C',
- 'L2CAP/LE/CFC/BV-11-C',
- 'L2CAP/LE/CFC/BV-12-C',
'L2CAP/LE/CFC/BV-14-C',
'L2CAP/LE/CFC/BV-16-C',
'L2CAP/LE/CFC/BV-18-C',
'L2CAP/LE/CFC/BV-19-C',
"L2CAP/LE/CFC/BV-21-C",
]
- tests_require_secure_connection = []
# This MMI is called twice in 'L2CAP/LE/CFC/BV-04-C'
# We are not sure whether the lower tester’s BluetoothServerSocket
@@ -97,10 +94,13 @@
if test == 'L2CAP/LE/CFC/BV-12-C':
psm = 0xF3 # default TSPX_psm_authorization_required value
- secure_connection = test in tests_require_secure_connection
-
try:
- self.l2cap.CreateLECreditBasedChannel(connection=self.connection, psm=psm, secure=secure_connection)
+ connect_response = self.l2cap.Connect(connection=self.connection,
+ le_credit_based=CreditBasedChannelRequest(spsm=psm))
+ if connect_response.HasField('channel'):
+ self.channel = connect_response.channel
+ else:
+ raise Exception(connect_response.error)
except Exception as e:
if test in tests_target_to_fail:
self.test_status_map[test] = 'OK'
@@ -117,11 +117,13 @@
"""
Place the IUT into LE connectable mode.
"""
+
self.advertise = self.host.Advertise(
legacy=True,
connectable=True,
own_address_type=PUBLIC,
)
+
# not strictly necessary, but can save time on waiting connection
tests_to_open_bluetooth_server_socket = [
"L2CAP/COS/CFC/BV-01-C",
@@ -129,31 +131,19 @@
"L2CAP/COS/CFC/BV-03-C",
"L2CAP/COS/CFC/BV-04-C",
"L2CAP/LE/CFC/BV-03-C",
- "L2CAP/LE/CFC/BV-05-C",
"L2CAP/LE/CFC/BV-06-C",
"L2CAP/LE/CFC/BV-09-C",
- "L2CAP/LE/CFC/BV-13-C",
"L2CAP/LE/CFC/BV-20-C",
"L2CAP/LE/CFC/BI-01-C",
]
- tests_require_secure_connection = [
- "L2CAP/LE/CFC/BV-13-C",
- ]
- tests_connection_target_to_failed = [
- "L2CAP/LE/CFC/BV-05-C",
- ]
if test in tests_to_open_bluetooth_server_socket:
- secure_connection = test in tests_require_secure_connection
- self.l2cap.ListenL2CAPChannel(connection=self.connection, secure=secure_connection)
- try:
- self.l2cap.AcceptL2CAPChannel(connection=self.connection)
- except Exception as e:
- if test in tests_connection_target_to_failed:
- self.test_status_map[test] = 'OK'
- print(test, 'connection targets to fail', file=sys.stderr)
- else:
- raise e
+ wait_connection_response = self.l2cap.WaitConnection(le_credit_based=CreditBasedChannelRequest(spsm=0))
+ if wait_connection_response.HasField('channel'):
+ self.channel = wait_connection_response.channel
+ else:
+ raise Exception(wait_connection_response.error)
+
return "OK"
@assert_description
@@ -171,7 +161,8 @@
# all data frames arrived
# it seemed like when the time gap between the 1st frame and 2nd frame
# larger than 100ms this problem will occur
- self.l2cap.SendData(connection=self.connection, data=bytes(self.LE_DATA_PACKET_LARGE, "utf-8"))
+ assert self.channel
+ self.l2cap.Send(channel=self.channel, data=bytes(self.LE_DATA_PACKET_LARGE, "utf-8"))
return "OK"
@match_description
@@ -198,8 +189,9 @@
Upper Tester command IUT to send at least 4 frames of LE data packets to
the PTS.
"""
- self.l2cap.SendData(
- connection=self.connection,
+ assert self.channel
+ self.l2cap.Send(
+ channel=self.channel,
data=b"this is a large data package with at least 4 frames: MMI_UPPER_TESTER_SEND_LE_DATA_PACKET_LARGE")
return "OK"
@@ -208,8 +200,9 @@
"""
IUT continue to send LE data packet(s) to the PTS.
"""
- self.l2cap.SendData(
- connection=self.connection,
+ assert self.channel
+ self.l2cap.Send(
+ channel=self.channel,
data=b"this is a large data package with at least 4 frames: MMI_UPPER_TESTER_SEND_LE_DATA_PACKET_LARGE")
return "OK"
@@ -232,7 +225,8 @@
"""
Please confirm the Upper Tester receive data
"""
- data = self.l2cap.ReceiveData(connection=self.connection)
+ assert self.channel
+ data = next(self.l2cap.Receive(channel=self.channel)).data
assert data, "data received should not be empty"
return "OK"
@@ -504,7 +498,8 @@
Description : The Implementation Under Test(IUT)
should send none segmantation LE frame of LE data to the PTS.
"""
- self.l2cap.SendData(connection=self.connection, data=bytes(self.LE_DATA_PACKET1, "utf-8"))
+ assert self.channel
+ self.l2cap.Send(channel=self.channel, data=bytes(self.LE_DATA_PACKET1, "utf-8"))
return "OK"
@assert_description
diff --git a/android/pandora/mmi2grpc/pyrightconfig.json b/android/pandora/mmi2grpc/pyrightconfig.json
deleted file mode 100644
index fab9f61..0000000
--- a/android/pandora/mmi2grpc/pyrightconfig.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "typeCheckingMode": "strict",
- "useLibraryCodeForTypes": true,
- "verboseOutput": false,
- "reportMissingTypeStubs": false,
- "reportUnknownLambdaType": false,
- "reportImportCycles": false,
- "reportPrivateUsage": false,
- "extraPaths": [
- "../../../pandora/server",
- "../../../../../../out/soong/.intermediates/external/pandora/bt-test-interfaces/python/pandora-python-gen-src/gen/",
- "../../../../../../out/soong/.intermediates/packages/modules/Bluetooth/pandora/interfaces/python/pandora_experimental-python-gen-src/gen/"
- ]
-}
diff --git a/android/pandora/server/configs/pts_bot_tests_config.json b/android/pandora/server/configs/pts_bot_tests_config.json
index 9310292..3cfbe0d2 100644
--- a/android/pandora/server/configs/pts_bot_tests_config.json
+++ b/android/pandora/server/configs/pts_bot_tests_config.json
@@ -1048,6 +1048,7 @@
"L2CAP/CMC/BV-13-C",
"L2CAP/CMC/BV-14-C",
"L2CAP/CMC/BV-15-C",
+ "L2CAP/COS/CED/BI-02-C",
"L2CAP/COS/CED/BV-10-C",
"L2CAP/COS/CED/BV-12-C",
"L2CAP/COS/CED/BV-13-C",
diff --git a/android/pandora/server/src/L2cap.kt b/android/pandora/server/src/L2cap.kt
index 77b9603..1d1e9c8 100644
--- a/android/pandora/server/src/L2cap.kt
+++ b/android/pandora/server/src/L2cap.kt
@@ -16,46 +16,35 @@
package com.android.pandora
+import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothManager
-import android.bluetooth.BluetoothServerSocket
+import android.bluetooth.BluetoothSocket
import android.content.Context
import android.util.Log
+import com.google.protobuf.Any
import com.google.protobuf.ByteString
import io.grpc.stub.StreamObserver
import java.io.Closeable
-import java.io.IOException
-import java.io.InputStream
-import java.io.OutputStream
+import java.util.concurrent.atomic.AtomicLong
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
-import kotlinx.coroutines.withContext
-import pandora.HostProto.Connection
-import pandora.L2CAPGrpc.L2CAPImplBase
-import pandora.L2capProto.AcceptL2CAPChannelRequest
-import pandora.L2capProto.AcceptL2CAPChannelResponse
-import pandora.L2capProto.CreateLECreditBasedChannelRequest
-import pandora.L2capProto.CreateLECreditBasedChannelResponse
-import pandora.L2capProto.ListenL2CAPChannelRequest
-import pandora.L2capProto.ListenL2CAPChannelResponse
-import pandora.L2capProto.ReceiveDataRequest
-import pandora.L2capProto.ReceiveDataResponse
-import pandora.L2capProto.SendDataRequest
-import pandora.L2capProto.SendDataResponse
+import kotlinx.coroutines.flow.flow
+import pandora.l2cap.L2CAPGrpc.L2CAPImplBase
+import pandora.l2cap.L2CAPProto.*
@kotlinx.coroutines.ExperimentalCoroutinesApi
class L2cap(val context: Context) : L2CAPImplBase(), Closeable {
private val TAG = "PandoraL2cap"
private val scope: CoroutineScope
private val BLUETOOTH_SERVER_SOCKET_TIMEOUT: Int = 10000
+ private val channelIdCounter = AtomicLong(1)
private val BUFFER_SIZE = 512
private val bluetoothManager =
context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
private val bluetoothAdapter = bluetoothManager.adapter
- private var connectionInStreamMap: HashMap<Connection, InputStream> = hashMapOf()
- private var connectionOutStreamMap: HashMap<Connection, OutputStream> = hashMapOf()
- private var connectionServerSocketMap: HashMap<Connection, BluetoothServerSocket> = hashMapOf()
+ private val channels: HashMap<Long, BluetoothSocket> = hashMapOf()
init {
// Init the CoroutineScope
@@ -67,127 +56,117 @@
scope.cancel()
}
- suspend fun receive(inStream: InputStream): ByteArray {
- return withContext(Dispatchers.IO) {
- val buf = ByteArray(BUFFER_SIZE)
- inStream.read(buf, 0, BUFFER_SIZE) // blocking
- Log.i(TAG, "receive: $buf")
- buf
- }
- }
-
- /** Open a BluetoothServerSocket to accept connections */
- override fun listenL2CAPChannel(
- request: ListenL2CAPChannelRequest,
- responseObserver: StreamObserver<ListenL2CAPChannelResponse>,
+ override fun connect(
+ request: ConnectRequest,
+ responseObserver: StreamObserver<ConnectResponse>,
) {
grpcUnary(scope, responseObserver) {
- Log.i(TAG, "listenL2CAPChannel: secure=${request.secure}")
- val connection = request.connection
- val bluetoothServerSocket =
- if (request.secure) {
- bluetoothAdapter.listenUsingL2capChannel()
- } else {
- bluetoothAdapter.listenUsingInsecureL2capChannel()
- }
- connectionServerSocketMap[connection] = bluetoothServerSocket
- ListenL2CAPChannelResponse.newBuilder().build()
- }
- }
-
- override fun acceptL2CAPChannel(
- request: AcceptL2CAPChannelRequest,
- responseObserver: StreamObserver<AcceptL2CAPChannelResponse>,
- ) {
- grpcUnary(scope, responseObserver) {
- Log.i(TAG, "acceptL2CAPChannel")
-
- val connection = request.connection
- val bluetoothServerSocket = connectionServerSocketMap[connection]
- try {
- val bluetoothSocket =
- bluetoothServerSocket!!.accept(BLUETOOTH_SERVER_SOCKET_TIMEOUT)
- connectionInStreamMap[connection] = bluetoothSocket.getInputStream()!!
- connectionOutStreamMap[connection] = bluetoothSocket.getOutputStream()!!
- } catch (e: IOException) {
- Log.e(TAG, "bluetoothServerSocket not accepted", e)
- throw e
- }
-
- AcceptL2CAPChannelResponse.newBuilder().build()
- }
- }
-
- /** Set device to send LE based connection request */
- override fun createLECreditBasedChannel(
- request: CreateLECreditBasedChannelRequest,
- responseObserver: StreamObserver<CreateLECreditBasedChannelResponse>,
- ) {
- // Creates a gRPC coroutine in a given coroutine scope which executes a given suspended
- // function
- // returning a gRPC response and sends it on a given gRPC stream observer.
- grpcUnary(scope, responseObserver) {
- Log.i(TAG, "createLECreditBasedChannel: secure=${request.secure}, psm=${request.psm}")
- val connection = request.connection
val device = request.connection.toBluetoothDevice(bluetoothAdapter)
- val psm = request.psm
- try {
- val bluetoothSocket =
- if (request.secure) {
- device.createL2capChannel(psm)
- } else {
- device.createInsecureL2capChannel(psm)
- }
- bluetoothSocket.connect()
- connectionInStreamMap[connection] = bluetoothSocket.getInputStream()!!
- connectionOutStreamMap[connection] = bluetoothSocket.getOutputStream()!!
- } catch (e: IOException) {
- Log.d(TAG, "bluetoothSocket not connected: $e")
- throw e
- }
-
- // Response sent to client
- CreateLECreditBasedChannelResponse.newBuilder().build()
- }
- }
-
- /** send data packet */
- override fun sendData(
- request: SendDataRequest,
- responseObserver: StreamObserver<SendDataResponse>,
- ) {
- grpcUnary(scope, responseObserver) {
- Log.i(TAG, "sendDataPacket: data=${request.data}")
- val buffer = request.data!!.toByteArray()
- val connection = request.connection
- val outputStream = connectionOutStreamMap[connection]!!
-
- withContext(Dispatchers.IO) {
- try {
- outputStream.write(buffer)
- outputStream.flush()
- } catch (e: IOException) {
- Log.e(TAG, "Exception during writing to sendDataPacket output stream", e)
+ val psm =
+ when {
+ request.hasBasic() -> request.basic.psm
+ request.hasLeCreditBased() -> request.leCreditBased.spsm
+ request.hasEnhancedCreditBased() -> request.enhancedCreditBased.spsm
+ else -> throw RuntimeException("unreachable")
}
- }
+ Log.i(TAG, "connect: $device psm: $psm")
- // Response sent to client
- SendDataResponse.newBuilder().build()
+ val bluetoothSocket = device.createInsecureL2capChannel(psm)
+ bluetoothSocket.connect()
+ val channelId = getNewChannelId()
+ channels.put(channelId, bluetoothSocket)
+
+ Log.d(TAG, "connect: channelId=$channelId")
+ ConnectResponse.newBuilder().setChannel(craftChannel(channelId)).build()
}
}
- override fun receiveData(
- request: ReceiveDataRequest,
- responseObserver: StreamObserver<ReceiveDataResponse>,
+ override fun waitConnection(
+ request: WaitConnectionRequest,
+ responseObserver: StreamObserver<WaitConnectionResponse>,
) {
grpcUnary(scope, responseObserver) {
- Log.i(TAG, "receiveData")
- val connection = request.connection
- val inputStream = connectionInStreamMap[connection]!!
- val buf = receive(inputStream)
+ val device: BluetoothDevice? =
+ try {
+ request.connection.toBluetoothDevice(bluetoothAdapter)
+ } catch (e: Exception) {
+ Log.w(TAG, e)
+ null
+ }
- ReceiveDataResponse.newBuilder().setData(ByteString.copyFrom(buf)).build()
+ Log.i(TAG, "waitConnection: $device")
+
+ val psm =
+ when {
+ request.hasBasic() -> request.basic.psm
+ request.hasLeCreditBased() -> request.leCreditBased.spsm
+ request.hasEnhancedCreditBased() -> request.enhancedCreditBased.spsm
+ else -> throw RuntimeException("unreachable")
+ }
+
+ var bluetoothSocket: BluetoothSocket?
+
+ while (true) {
+ val bluetoothServerSocket =
+ if (psm == 0) {
+ bluetoothAdapter.listenUsingInsecureL2capChannel()
+ } else {
+ bluetoothAdapter.listenUsingInsecureL2capOn(psm)
+ }
+ bluetoothSocket = bluetoothServerSocket.accept()
+ bluetoothServerSocket.close()
+ if (device != null && !bluetoothSocket.getRemoteDevice().equals(device)) continue
+ break
+ }
+
+ val channelId = getNewChannelId()
+ channels.put(channelId, bluetoothSocket!!)
+
+ Log.d(TAG, "waitConnection: channelId=$channelId")
+ WaitConnectionResponse.newBuilder().setChannel(craftChannel(channelId)).build()
}
}
+
+ override fun send(request: SendRequest, responseObserver: StreamObserver<SendResponse>) {
+ grpcUnary(scope, responseObserver) {
+ Log.i(TAG, "send")
+ val bluetoothSocket = request.channel.toBluetoothSocket(channels)
+ val outputStream = bluetoothSocket.outputStream
+
+ outputStream.write(request.data.toByteArray())
+ outputStream.flush()
+
+ SendResponse.newBuilder().build()
+ }
+ }
+
+ override fun receive(
+ request: ReceiveRequest,
+ responseObserver: StreamObserver<ReceiveResponse>,
+ ) {
+ Log.i(TAG, "receive")
+ val bluetoothSocket = request.channel.toBluetoothSocket(channels)
+ val inputStream = bluetoothSocket.inputStream
+ grpcServerStream(scope, responseObserver) {
+ flow {
+ val buffer = ByteArray(BUFFER_SIZE)
+ inputStream.read(buffer, 0, BUFFER_SIZE)
+ val data = ByteString.copyFrom(buffer)
+ val response = ReceiveResponse.newBuilder().setData(data).build()
+ emit(response)
+ }
+ }
+ }
+
+ fun getNewChannelId(): Long = channelIdCounter.getAndIncrement()
+
+ fun craftChannel(id: Long): Channel {
+ val cookie = Any.newBuilder().setValue(ByteString.copyFromUtf8(id.toString())).build()
+ val channel = Channel.newBuilder().setCookie(cookie).build()
+ return channel
+ }
+
+ fun Channel.toBluetoothSocket(channels: HashMap<Long, BluetoothSocket>): BluetoothSocket =
+ channels.get(this.cookie.value.toStringUtf8().toLong())!!
}
diff --git a/android/pandora/test/pyrightconfig.json b/android/pandora/test/pyrightconfig.json
deleted file mode 100644
index ea458b5c6..0000000
--- a/android/pandora/test/pyrightconfig.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "typeCheckingMode": "strict",
- "useLibraryCodeForTypes": true,
- "verboseOutput": false,
- "reportMissingTypeStubs": false,
- "reportUnknownLambdaType": false,
- "reportImportCycles": false,
- "reportPrivateUsage": false,
- "extraPaths": [
- "../../../pandora/server",
- "../../../../../../external/pandora/avatar",
- "../../../../../../external/python/bumble",
- "../../../../../../external/python/mobly",
- "../../../../../../external/python/pyee",
- "../../../../../../external/python/portpicker/src",
- "../../../../../../out/soong/.intermediates/external/pandora/bt-test-interfaces/python/pandora-python-gen-src/gen/",
- "../../../../../../out/soong/.intermediates/packages/modules/Bluetooth/pandora/interfaces/python/pandora_experimental-python-gen-src/gen/"
- ]
-}
\ No newline at end of file
diff --git a/pandora/interfaces/pandora_experimental/l2cap.proto b/pandora/interfaces/pandora_experimental/l2cap.proto
deleted file mode 100644
index 443010a..0000000
--- a/pandora/interfaces/pandora_experimental/l2cap.proto
+++ /dev/null
@@ -1,62 +0,0 @@
-syntax = "proto3";
-
-package pandora;
-
-option java_outer_classname = "L2capProto";
-
-import "google/protobuf/empty.proto";
-import "pandora/host.proto";
-
-service L2CAP {
- // Create a L2CAP connection to a peer.
- rpc CreateLECreditBasedChannel(CreateLECreditBasedChannelRequest) returns (CreateLECreditBasedChannelResponse);
- // Send some data
- rpc SendData(SendDataRequest) returns (SendDataResponse);
- // Receive data
- rpc ReceiveData(ReceiveDataRequest) returns (ReceiveDataResponse);
- // Listen L2CAP channel for connection
- rpc ListenL2CAPChannel(ListenL2CAPChannelRequest) returns (ListenL2CAPChannelResponse);
- // Accept L2CAP connection
- rpc AcceptL2CAPChannel(AcceptL2CAPChannelRequest) returns (AcceptL2CAPChannelResponse);
-}
-
-// Request for the `OpenSource` method.
-message CreateLECreditBasedChannelRequest {
- // The connection that will open the stream.
- Connection connection = 1;
- int32 psm = 2;
- bool secure = 3;
-}
-
-// Request for the `OpenSource` method.
-message CreateLECreditBasedChannelResponse {}
-
-message SendDataRequest {
- // The connection that will open the stream.
- Connection connection = 1;
- bytes data = 2;
-}
-
-message SendDataResponse {}
-
-message ReceiveDataRequest {
- // The connection that will open the stream.
- Connection connection = 1;
-}
-
-message ReceiveDataResponse {
- bytes data = 1;
-}
-
-message ListenL2CAPChannelRequest{
- Connection connection = 1;
- bool secure = 2;
-}
-
-message ListenL2CAPChannelResponse {}
-
-message AcceptL2CAPChannelRequest{
- Connection connection = 1;
-}
-
-message AcceptL2CAPChannelResponse {}
\ No newline at end of file
diff --git a/pandora/interfaces/python/Android.bp b/pandora/interfaces/python/Android.bp
index 4532716..2abac30 100644
--- a/pandora/interfaces/python/Android.bp
+++ b/pandora/interfaces/python/Android.bp
@@ -54,10 +54,6 @@
"pandora_experimental/hid_grpc_aio.py",
"pandora_experimental/hid_pb2.py",
"pandora_experimental/hid_pb2.pyi",
- "pandora_experimental/l2cap_grpc.py",
- "pandora_experimental/l2cap_grpc_aio.py",
- "pandora_experimental/l2cap_pb2.py",
- "pandora_experimental/l2cap_pb2.pyi",
"pandora_experimental/le_audio_grpc.py",
"pandora_experimental/le_audio_grpc_aio.py",
"pandora_experimental/le_audio_pb2.py",
@@ -118,7 +114,6 @@
":pandora_experimental-python-gen-src{pandora_experimental/hap_pb2.pyi}",
":pandora_experimental-python-gen-src{pandora_experimental/hfp_pb2.pyi}",
":pandora_experimental-python-gen-src{pandora_experimental/hid_pb2.pyi}",
- ":pandora_experimental-python-gen-src{pandora_experimental/l2cap_pb2.pyi}",
":pandora_experimental-python-gen-src{pandora_experimental/le_audio_pb2.pyi}",
":pandora_experimental-python-gen-src{pandora_experimental/map_pb2.pyi}",
":pandora_experimental-python-gen-src{pandora_experimental/mediaplayer_pb2.pyi}",
diff --git a/pyrightconfig.json b/pyrightconfig.json
new file mode 100644
index 0000000..e2b62af
--- /dev/null
+++ b/pyrightconfig.json
@@ -0,0 +1,34 @@
+{
+ "typeCheckingMode": "strict",
+ "useLibraryCodeForTypes": true,
+ "verboseOutput": false,
+ "reportMissingTypeStubs": false,
+ "reportUnknownLambdaType": false,
+ "reportImportCycles": false,
+ "reportPrivateUsage": false,
+ "executionEnvironments": [
+ {
+ "root": "android/pandora/test",
+ "extraPaths": ["pandora/server"]
+ },
+ {
+ "root": "android/pandora/mmi2grpc"
+ },
+ {
+ "root": "pandora/server/bumble_experimental"
+ },
+ {
+ "root": "framework/tests/bumble/src/bumble_server.py",
+ "extraPaths": ["pandora/server"]
+ }
+ ],
+ "extraPaths": [
+ "../../../external/pandora/avatar",
+ "../../../external/python/bumble",
+ "../../../external/python/mobly",
+ "../../../external/python/pyee",
+ "../../../external/python/portpicker/src",
+ "../../../out/soong/.intermediates/external/pandora/bt-test-interfaces/python/pandora-python-gen-src/gen/",
+ "../../../out/soong/.intermediates/packages/modules/Bluetooth/pandora/interfaces/python/pandora_experimental-python-gen-src/gen/"
+ ]
+}
diff --git a/service/src/com/android/server/bluetooth/BluetoothServerProxy.java b/service/src/com/android/server/bluetooth/BluetoothServerProxy.java
index 7c6eb98..5b05d5d 100644
--- a/service/src/com/android/server/bluetooth/BluetoothServerProxy.java
+++ b/service/src/com/android/server/bluetooth/BluetoothServerProxy.java
@@ -63,10 +63,6 @@
return Settings.Secure.getString(contentResolver, name);
}
- int settingsGlobalGetInt(ContentResolver contentResolver, String name, int def) {
- return Settings.Global.getInt(contentResolver, name, def);
- }
-
int getBluetoothPersistedState(ContentResolver resolver, int defaultValue) {
return Settings.Global.getInt(resolver, Settings.Global.BLUETOOTH_ON, defaultValue);
}
diff --git a/system/audio/Android.bp b/system/audio/Android.bp
index 9165555..d5dde59 100644
--- a/system/audio/Android.bp
+++ b/system/audio/Android.bp
@@ -37,7 +37,6 @@
"libbase",
"libbluetooth_hci_pdl",
"libbluetooth_log",
- "libbt_shim_bridge",
"libflatbuffers-cpp",
],
host_supported: true,
@@ -77,7 +76,6 @@
"libbluetooth_hci_pdl",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
"libchrome",
"libevent",
"libflatbuffers-cpp",
diff --git a/system/audio_hal_interface/Android.bp b/system/audio_hal_interface/Android.bp
index 9ccd5c4..af82b64 100644
--- a/system/audio_hal_interface/Android.bp
+++ b/system/audio_hal_interface/Android.bp
@@ -31,7 +31,6 @@
"bluetooth_flags_c_lib",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
"libosi",
],
target: {
@@ -123,7 +122,6 @@
"libbluetooth_log",
"libbt-audio-hal-interface",
"libbt-common",
- "libbt_shim_bridge",
"libchrome",
],
header_libs: ["libbluetooth_headers"],
@@ -190,7 +188,6 @@
"libbluetooth-types",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
"libchrome",
"libflagtest",
"libfmq",
@@ -240,14 +237,12 @@
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
- "libbluetooth_rust_interop",
"libbt-common", // needed for MessageLoopThread
"libbt-jni-thread",
"libbt-sbc-decoder",
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbtcore",
"libbtdevice",
"libbte",
@@ -317,7 +312,6 @@
"libbt-bta",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libchrome",
"libevent",
"libgmock",
diff --git a/system/audio_hal_interface/BUILD.gn b/system/audio_hal_interface/BUILD.gn
index 5e26e14..a637d5a 100644
--- a/system/audio_hal_interface/BUILD.gn
+++ b/system/audio_hal_interface/BUILD.gn
@@ -27,7 +27,6 @@
"//bt/system/bta/include",
"//bt/system/btif/include",
"//bt/system/stack/include",
- "//bt/system/gd/rust/shim",
]
configs += [
diff --git a/system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc b/system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc
index a3e0ec2..e711711 100644
--- a/system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc
+++ b/system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc
@@ -23,11 +23,23 @@
#include <vector>
#include "a2dp_provider_info.h"
-#include "a2dp_transport.h"
#include "audio_aidl_interfaces.h"
+#include "client_interface_aidl.h"
#include "codec_status_aidl.h"
#include "transport_instance.h"
+typedef enum {
+ A2DP_CTRL_CMD_NONE,
+ A2DP_CTRL_CMD_CHECK_READY,
+ A2DP_CTRL_CMD_START,
+ A2DP_CTRL_CMD_STOP,
+ A2DP_CTRL_CMD_SUSPEND,
+ A2DP_CTRL_GET_INPUT_AUDIO_CONFIG,
+ A2DP_CTRL_GET_OUTPUT_AUDIO_CONFIG,
+ A2DP_CTRL_SET_OUTPUT_AUDIO_CONFIG,
+ A2DP_CTRL_GET_PRESENTATION_POSITION,
+} tA2DP_CTRL_CMD;
+
namespace fmt {
template <>
struct formatter<tA2DP_CTRL_CMD> : enum_formatter<tA2DP_CTRL_CMD> {};
@@ -42,6 +54,47 @@
namespace aidl {
namespace a2dp {
+namespace {
+
+using ::bluetooth::audio::a2dp::BluetoothAudioStatus;
+using ::bluetooth::audio::aidl::a2dp::LatencyMode;
+
+// Provide call-in APIs for the Bluetooth Audio HAL
+class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothTransportInstance {
+public:
+ A2dpTransport(SessionType sessionType);
+
+ BluetoothAudioStatus StartRequest(bool is_low_latency) override;
+
+ BluetoothAudioStatus SuspendRequest() override;
+
+ void StopRequest() override;
+
+ void SetLatencyMode(LatencyMode latency_mode) override;
+
+ bool GetPresentationPosition(uint64_t* remote_delay_report_ns, uint64_t* total_bytes_read,
+ timespec* data_position) override;
+
+ tA2DP_CTRL_CMD GetPendingCmd() const;
+
+ void ResetPendingCmd();
+
+ void ResetPresentationPosition();
+
+ void LogBytesRead(size_t bytes_read) override;
+
+ // delay reports from AVDTP is based on 1/10 ms (100us)
+ void SetRemoteDelay(uint16_t delay_report);
+
+private:
+ static tA2DP_CTRL_CMD a2dp_pending_cmd_;
+ static uint16_t remote_delay_report_;
+ uint64_t total_bytes_read_;
+ timespec data_position_;
+};
+
+} // namespace
+
using ::bluetooth::audio::a2dp::BluetoothAudioPort;
using ::bluetooth::audio::a2dp::BluetoothAudioStatus;
@@ -57,8 +110,7 @@
using ::aidl::android::hardware::bluetooth::audio::PcmConfiguration;
using ::aidl::android::hardware::bluetooth::audio::SessionType;
-using ::bluetooth::audio::aidl::a2dp::BluetoothAudioCtrlAck;
-using ::bluetooth::audio::aidl::a2dp::BluetoothAudioSinkClientInterface;
+using ::bluetooth::audio::aidl::a2dp::BluetoothAudioClientInterface;
using ::bluetooth::audio::aidl::a2dp::codec::A2dpAacToHalConfig;
using ::bluetooth::audio::aidl::a2dp::codec::A2dpAptxToHalConfig;
using ::bluetooth::audio::aidl::a2dp::codec::A2dpCodecToHalBitsPerSample;
@@ -68,21 +120,6 @@
using ::bluetooth::audio::aidl::a2dp::codec::A2dpOpusToHalConfig;
using ::bluetooth::audio::aidl::a2dp::codec::A2dpSbcToHalConfig;
-static BluetoothAudioCtrlAck a2dp_ack_to_bt_audio_ctrl_ack(BluetoothAudioStatus ack) {
- switch (ack) {
- case BluetoothAudioStatus::SUCCESS:
- return BluetoothAudioCtrlAck::SUCCESS_FINISHED;
- case BluetoothAudioStatus::PENDING:
- return BluetoothAudioCtrlAck::PENDING;
- case BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION:
- return BluetoothAudioCtrlAck::FAILURE_UNSUPPORTED;
- case BluetoothAudioStatus::UNKNOWN:
- case BluetoothAudioStatus::FAILURE:
- default:
- return BluetoothAudioCtrlAck::FAILURE;
- }
-}
-
/***
*
* A2dpTransport functions and variables
@@ -94,24 +131,24 @@
uint16_t A2dpTransport::remote_delay_report_ = 0;
A2dpTransport::A2dpTransport(SessionType sessionType)
- : IBluetoothSinkTransportInstance(sessionType, (AudioConfiguration){}),
+ : IBluetoothTransportInstance(sessionType, (AudioConfiguration){}),
total_bytes_read_(0),
data_position_({}) {
a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE;
remote_delay_report_ = 0;
}
-BluetoothAudioCtrlAck A2dpTransport::StartRequest(bool is_low_latency) {
+BluetoothAudioStatus A2dpTransport::StartRequest(bool is_low_latency) {
// Check if a previous Start request is ongoing.
if (a2dp_pending_cmd_ == A2DP_CTRL_CMD_START) {
log::warn("unable to start stream: already pending");
- return BluetoothAudioCtrlAck::PENDING;
+ return BluetoothAudioStatus::PENDING;
}
// Check if a different request is ongoing.
if (a2dp_pending_cmd_ != A2DP_CTRL_CMD_NONE) {
log::warn("unable to start stream: busy with pending command {}", a2dp_pending_cmd_);
- return BluetoothAudioCtrlAck::FAILURE;
+ return BluetoothAudioStatus::FAILURE;
}
log::info("");
@@ -120,20 +157,20 @@
a2dp_pending_cmd_ =
status == BluetoothAudioStatus::PENDING ? A2DP_CTRL_CMD_START : A2DP_CTRL_CMD_NONE;
- return a2dp_ack_to_bt_audio_ctrl_ack(status);
+ return status;
}
-BluetoothAudioCtrlAck A2dpTransport::SuspendRequest() {
+BluetoothAudioStatus A2dpTransport::SuspendRequest() {
// Check if a previous Suspend request is ongoing.
if (a2dp_pending_cmd_ == A2DP_CTRL_CMD_SUSPEND) {
log::warn("unable to suspend stream: already pending");
- return BluetoothAudioCtrlAck::PENDING;
+ return BluetoothAudioStatus::PENDING;
}
// Check if a different request is ongoing.
if (a2dp_pending_cmd_ != A2DP_CTRL_CMD_NONE) {
log::warn("unable to suspend stream: busy with pending command {}", a2dp_pending_cmd_);
- return BluetoothAudioCtrlAck::FAILURE;
+ return BluetoothAudioStatus::FAILURE;
}
log::info("");
@@ -142,7 +179,7 @@
a2dp_pending_cmd_ =
status == BluetoothAudioStatus::PENDING ? A2DP_CTRL_CMD_SUSPEND : A2DP_CTRL_CMD_NONE;
- return a2dp_ack_to_bt_audio_ctrl_ack(status);
+ return status;
}
void A2dpTransport::StopRequest() {
@@ -167,20 +204,6 @@
return true;
}
-void A2dpTransport::SourceMetadataChanged(const source_metadata_v7_t& source_metadata) {
- auto track_count = source_metadata.track_count;
- auto tracks = source_metadata.tracks;
- log::verbose("{} track(s) received", track_count);
- while (track_count) {
- log::verbose("usage={}, content_type={}, gain={}", tracks->base.usage,
- tracks->base.content_type, tracks->base.gain);
- --track_count;
- ++tracks;
- }
-}
-
-void A2dpTransport::SinkMetadataChanged(const sink_metadata_v7_t&) {}
-
tA2DP_CTRL_CMD A2dpTransport::GetPendingCmd() const { return a2dp_pending_cmd_; }
void A2dpTransport::ResetPendingCmd() { a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; }
@@ -208,9 +231,9 @@
void A2dpTransport::SetRemoteDelay(uint16_t delay_report) { remote_delay_report_ = delay_report; }
// Common interface to call-out into Bluetooth Audio HAL
-BluetoothAudioSinkClientInterface* software_hal_interface = nullptr;
-BluetoothAudioSinkClientInterface* offloading_hal_interface = nullptr;
-BluetoothAudioSinkClientInterface* active_hal_interface = nullptr;
+BluetoothAudioClientInterface* software_hal_interface = nullptr;
+BluetoothAudioClientInterface* offloading_hal_interface = nullptr;
+BluetoothAudioClientInterface* active_hal_interface = nullptr;
// ProviderInfo for A2DP hardware offload encoding and decoding data paths,
// if supported by the HAL and enabled. nullptr if not supported
@@ -321,9 +344,9 @@
// Opens the HAL client interface of the specified session type and check
// that is is valid. Returns nullptr if the client interface did not open
// properly.
-static BluetoothAudioSinkClientInterface* new_hal_interface(SessionType session_type) {
+static BluetoothAudioClientInterface* new_hal_interface(SessionType session_type) {
auto a2dp_transport = new A2dpTransport(session_type);
- auto hal_interface = new BluetoothAudioSinkClientInterface(a2dp_transport);
+ auto hal_interface = new BluetoothAudioClientInterface(a2dp_transport);
if (hal_interface->IsValid()) {
return hal_interface;
} else {
@@ -335,7 +358,7 @@
}
/// Delete the selected HAL client interface.
-static void delete_hal_interface(BluetoothAudioSinkClientInterface* hal_interface) {
+static void delete_hal_interface(BluetoothAudioClientInterface* hal_interface) {
if (hal_interface == nullptr) {
return;
}
@@ -534,7 +557,7 @@
auto a2dp_sink = static_cast<A2dpTransport*>(active_hal_interface->GetTransportInstance());
auto pending_cmd = a2dp_sink->GetPendingCmd();
if (pending_cmd == A2DP_CTRL_CMD_START) {
- active_hal_interface->StreamStarted(a2dp_ack_to_bt_audio_ctrl_ack(ack));
+ active_hal_interface->StreamStarted(ack);
} else {
log::warn("pending={} ignore result={}", pending_cmd, ack);
return;
@@ -553,7 +576,7 @@
auto a2dp_sink = static_cast<A2dpTransport*>(active_hal_interface->GetTransportInstance());
auto pending_cmd = a2dp_sink->GetPendingCmd();
if (pending_cmd == A2DP_CTRL_CMD_SUSPEND) {
- active_hal_interface->StreamSuspended(a2dp_ack_to_bt_audio_ctrl_ack(ack));
+ active_hal_interface->StreamSuspended(ack);
} else if (pending_cmd == A2DP_CTRL_CMD_STOP) {
log::info("A2DP_CTRL_CMD_STOP result={}", ack);
} else {
diff --git a/system/audio_hal_interface/aidl/a2dp/a2dp_transport.h b/system/audio_hal_interface/aidl/a2dp/a2dp_transport.h
deleted file mode 100644
index ae244cc..0000000
--- a/system/audio_hal_interface/aidl/a2dp/a2dp_transport.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include "client_interface_aidl.h"
-
-typedef enum {
- A2DP_CTRL_CMD_NONE,
- A2DP_CTRL_CMD_CHECK_READY,
- A2DP_CTRL_CMD_START,
- A2DP_CTRL_CMD_STOP,
- A2DP_CTRL_CMD_SUSPEND,
- A2DP_CTRL_GET_INPUT_AUDIO_CONFIG,
- A2DP_CTRL_GET_OUTPUT_AUDIO_CONFIG,
- A2DP_CTRL_SET_OUTPUT_AUDIO_CONFIG,
- A2DP_CTRL_GET_PRESENTATION_POSITION,
-} tA2DP_CTRL_CMD;
-
-namespace bluetooth {
-namespace audio {
-namespace aidl {
-namespace a2dp {
-
-namespace {
-
-using ::bluetooth::audio::aidl::a2dp::LatencyMode;
-
-// Provide call-in APIs for the Bluetooth Audio HAL
-class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothSinkTransportInstance {
-public:
- A2dpTransport(SessionType sessionType);
-
- BluetoothAudioCtrlAck StartRequest(bool is_low_latency) override;
-
- BluetoothAudioCtrlAck SuspendRequest() override;
-
- void StopRequest() override;
-
- void SetLatencyMode(LatencyMode latency_mode) override;
-
- bool GetPresentationPosition(uint64_t* remote_delay_report_ns, uint64_t* total_bytes_read,
- timespec* data_position) override;
-
- void SourceMetadataChanged(const source_metadata_v7_t& source_metadata);
-
- void SinkMetadataChanged(const sink_metadata_v7_t&) override;
-
- tA2DP_CTRL_CMD GetPendingCmd() const;
-
- void ResetPendingCmd();
-
- void ResetPresentationPosition();
-
- void LogBytesRead(size_t bytes_read) override;
-
- // delay reports from AVDTP is based on 1/10 ms (100us)
- void SetRemoteDelay(uint16_t delay_report);
-
-private:
- static tA2DP_CTRL_CMD a2dp_pending_cmd_;
- static uint16_t remote_delay_report_;
- uint64_t total_bytes_read_;
- timespec data_position_;
-};
-} // namespace
-
-} // namespace a2dp
-} // namespace aidl
-} // namespace audio
-} // namespace bluetooth
diff --git a/system/audio_hal_interface/aidl/a2dp/audio_aidl_interfaces.h b/system/audio_hal_interface/aidl/a2dp/audio_aidl_interfaces.h
index e8fb9ba..af0daa1 100644
--- a/system/audio_hal_interface/aidl/a2dp/audio_aidl_interfaces.h
+++ b/system/audio_hal_interface/aidl/a2dp/audio_aidl_interfaces.h
@@ -45,16 +45,10 @@
#include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h>
#include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.h>
#include <aidl/android/hardware/bluetooth/audio/LatencyMode.h>
-#include <aidl/android/hardware/bluetooth/audio/Lc3Capabilities.h>
-#include <aidl/android/hardware/bluetooth/audio/Lc3Configuration.h>
#include <aidl/android/hardware/bluetooth/audio/LdacCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/LdacChannelMode.h>
#include <aidl/android/hardware/bluetooth/audio/LdacConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/LdacQualityIndex.h>
-#include <aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.h>
-#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h>
-#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.h>
-#include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/PcmCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/PcmConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/PresentationPosition.h>
@@ -75,4 +69,4 @@
#undef LOG_DEBUG
#endif
-// clang-format on
\ No newline at end of file
+// clang-format on
diff --git a/system/audio_hal_interface/aidl/a2dp/audio_ctrl_ack.h b/system/audio_hal_interface/aidl/a2dp/audio_ctrl_ack.h
deleted file mode 100644
index 0bb70c1..0000000
--- a/system/audio_hal_interface/aidl/a2dp/audio_ctrl_ack.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <bluetooth/log.h>
-
-#include "audio_aidl_interfaces.h"
-
-namespace bluetooth {
-namespace audio {
-namespace aidl {
-namespace a2dp {
-
-enum class BluetoothAudioCtrlAck : uint8_t {
- SUCCESS_FINISHED = 0,
- SUCCESS_RECONFIGURATION,
- PENDING,
- FAILURE_UNSUPPORTED,
- FAILURE_BUSY,
- FAILURE_DISCONNECTING,
- FAILURE
-};
-
-std::ostream& operator<<(std::ostream& os, const BluetoothAudioCtrlAck& ack);
-
-inline ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus
-BluetoothAudioCtrlAckToHalStatus(const BluetoothAudioCtrlAck& ack) {
- using ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus;
- switch (ack) {
- case BluetoothAudioCtrlAck::SUCCESS_FINISHED:
- return BluetoothAudioStatus::SUCCESS;
- case BluetoothAudioCtrlAck::FAILURE_UNSUPPORTED:
- return BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION;
- case BluetoothAudioCtrlAck::PENDING:
- return BluetoothAudioStatus::FAILURE;
- case BluetoothAudioCtrlAck::FAILURE_BUSY:
- return BluetoothAudioStatus::FAILURE;
- case BluetoothAudioCtrlAck::FAILURE_DISCONNECTING:
- return BluetoothAudioStatus::FAILURE;
- case BluetoothAudioCtrlAck::SUCCESS_RECONFIGURATION:
- return BluetoothAudioStatus::RECONFIGURATION;
- default:
- return BluetoothAudioStatus::FAILURE;
- }
-}
-
-} // namespace a2dp
-} // namespace aidl
-} // namespace audio
-} // namespace bluetooth
-
-namespace fmt {
-template <>
-struct formatter<bluetooth::audio::aidl::a2dp::BluetoothAudioCtrlAck> : ostream_formatter {};
-} // namespace fmt
diff --git a/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.cc b/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.cc
index 30d83a2..6172b33 100644
--- a/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.cc
+++ b/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.cc
@@ -23,6 +23,7 @@
#include "android/binder_ibinder_platform.h"
#include "btif/include/btif_common.h"
+#include "client_interface_aidl.h"
#include "common/stop_watch_legacy.h"
namespace bluetooth {
@@ -41,9 +42,9 @@
ndk::ScopedAStatus BluetoothAudioPortImpl::startStream(bool is_low_latency) {
StopWatchLegacy stop_watch(__func__);
- BluetoothAudioCtrlAck ack = transport_instance_->StartRequest(is_low_latency);
- if (ack != BluetoothAudioCtrlAck::PENDING) {
- auto aidl_retval = provider_->streamStarted(BluetoothAudioCtrlAckToHalStatus(ack));
+ BluetoothAudioStatus ack = transport_instance_->StartRequest(is_low_latency);
+ if (ack != BluetoothAudioStatus::PENDING) {
+ auto aidl_retval = provider_->streamStarted(BluetoothAudioStatusToHalStatus(ack));
if (!aidl_retval.isOk()) {
log::error("BluetoothAudioHal failure: {}", aidl_retval.getDescription());
}
@@ -53,9 +54,9 @@
ndk::ScopedAStatus BluetoothAudioPortImpl::suspendStream() {
StopWatchLegacy stop_watch(__func__);
- BluetoothAudioCtrlAck ack = transport_instance_->SuspendRequest();
- if (ack != BluetoothAudioCtrlAck::PENDING) {
- auto aidl_retval = provider_->streamSuspended(BluetoothAudioCtrlAckToHalStatus(ack));
+ BluetoothAudioStatus ack = transport_instance_->SuspendRequest();
+ if (ack != BluetoothAudioStatus::PENDING) {
+ auto aidl_retval = provider_->streamSuspended(BluetoothAudioStatusToHalStatus(ack));
if (!aidl_retval.isOk()) {
log::error("BluetoothAudioHal failure: {}", aidl_retval.getDescription());
}
@@ -95,111 +96,12 @@
}
ndk::ScopedAStatus BluetoothAudioPortImpl::updateSourceMetadata(
- const SourceMetadata& source_metadata) {
- StopWatchLegacy stop_watch(__func__);
- log::info("{} track(s)", source_metadata.tracks.size());
-
- std::vector<playback_track_metadata_v7> tracks_vec;
- tracks_vec.reserve(source_metadata.tracks.size());
- for (const auto& track : source_metadata.tracks) {
- auto num_of_tags = track.tags.size();
- log::info("metadata tags size: {}", num_of_tags);
-
- playback_track_metadata_v7 desc_track = {
- .base = {.usage = static_cast<audio_usage_t>(track.usage),
- .content_type = static_cast<audio_content_type_t>(track.contentType),
- .gain = track.gain},
- };
-
- if (num_of_tags != 0) {
- int copied_size = 0;
- int max_tags_size = sizeof(desc_track.tags);
- std::string separator(1, AUDIO_ATTRIBUTES_TAGS_SEPARATOR);
- for (size_t i = 0; i < num_of_tags - 1; i++) {
- int string_len = track.tags[i].length();
-
- if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) {
- log::error("Too many tags, copied size: {}", copied_size);
- break;
- }
-
- track.tags[i].copy(desc_track.tags + copied_size, string_len, 0);
- copied_size += string_len;
- separator.copy(desc_track.tags + copied_size, 1, 0);
- copied_size += 1;
- }
-
- int string_len = track.tags[num_of_tags - 1].length();
- if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) {
- log::error("Too many tags, copied size: {}", copied_size);
- } else {
- track.tags[num_of_tags - 1].copy(desc_track.tags + copied_size, string_len, 0);
- }
- } else {
- memset(desc_track.tags, 0, sizeof(desc_track.tags));
- }
-
- tracks_vec.push_back(desc_track);
- }
-
- const source_metadata_v7_t legacy_source_metadata = {.track_count = tracks_vec.size(),
- .tracks = tracks_vec.data()};
- transport_instance_->SourceMetadataChanged(legacy_source_metadata);
+ const SourceMetadata& /*source_metadata*/) {
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus BluetoothAudioPortImpl::updateSinkMetadata(const SinkMetadata& sink_metadata) {
- StopWatchLegacy stop_watch(__func__);
- log::info("{} track(s)", sink_metadata.tracks.size());
-
- std::vector<record_track_metadata_v7> tracks_vec;
- tracks_vec.reserve(sink_metadata.tracks.size());
- for (const auto& track : sink_metadata.tracks) {
- auto num_of_tags = track.tags.size();
- log::info("metadata tags size: {}", num_of_tags);
-
- record_track_metadata_v7 desc_track = {
- .base =
- {
- .source = static_cast<audio_source_t>(track.source),
- .gain = track.gain,
- },
- };
-
- if (num_of_tags != 0) {
- int copied_size = 0;
- int max_tags_size = sizeof(desc_track.tags);
- std::string separator(1, AUDIO_ATTRIBUTES_TAGS_SEPARATOR);
- for (size_t i = 0; i < num_of_tags - 1; i++) {
- int string_len = track.tags[i].length();
-
- if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) {
- log::error("Too many tags, copied size: {}", copied_size);
- break;
- }
-
- track.tags[i].copy(desc_track.tags + copied_size, string_len, 0);
- copied_size += string_len;
- separator.copy(desc_track.tags + copied_size, 1, 0);
- copied_size += 1;
- }
-
- int string_len = track.tags[num_of_tags - 1].length();
- if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) {
- log::error("Too many tags, copied size: {}", copied_size);
- } else {
- track.tags[num_of_tags - 1].copy(desc_track.tags + copied_size, string_len, 0);
- }
- } else {
- memset(desc_track.tags, 0, sizeof(desc_track.tags));
- }
-
- tracks_vec.push_back(desc_track);
- }
-
- const sink_metadata_v7_t legacy_sink_metadata = {.track_count = tracks_vec.size(),
- .tracks = tracks_vec.data()};
- transport_instance_->SinkMetadataChanged(legacy_sink_metadata);
+ndk::ScopedAStatus BluetoothAudioPortImpl::updateSinkMetadata(
+ const SinkMetadata& /*sink_metadata*/) {
return ndk::ScopedAStatus::ok();
}
diff --git a/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.h b/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.h
index de4432b..154702b 100644
--- a/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.h
+++ b/system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.h
@@ -38,17 +38,11 @@
const std::shared_ptr<IBluetoothAudioProvider>& provider);
ndk::ScopedAStatus startStream(bool is_low_latency) override;
-
ndk::ScopedAStatus suspendStream() override;
-
ndk::ScopedAStatus stopStream() override;
-
ndk::ScopedAStatus getPresentationPosition(PresentationPosition* _aidl_return) override;
-
ndk::ScopedAStatus updateSourceMetadata(const SourceMetadata& source_metadata) override;
-
ndk::ScopedAStatus updateSinkMetadata(const SinkMetadata& sink_metadata) override;
-
ndk::ScopedAStatus setLatencyMode(LatencyMode latency_mode) override;
protected:
@@ -60,7 +54,6 @@
private:
ndk::ScopedAStatus switchCodec(bool isLowLatency);
-
ndk::SpAIBinder createBinder() override;
};
diff --git a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc
index 59d7f67..fdfdcec 100644
--- a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc
+++ b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc
@@ -37,25 +37,6 @@
namespace aidl {
namespace a2dp {
-std::ostream& operator<<(std::ostream& os, const BluetoothAudioCtrlAck& ack) {
- switch (ack) {
- case BluetoothAudioCtrlAck::SUCCESS_FINISHED:
- return os << "SUCCESS_FINISHED";
- case BluetoothAudioCtrlAck::PENDING:
- return os << "PENDING";
- case BluetoothAudioCtrlAck::FAILURE_UNSUPPORTED:
- return os << "FAILURE_UNSUPPORTED";
- case BluetoothAudioCtrlAck::FAILURE_BUSY:
- return os << "FAILURE_BUSY";
- case BluetoothAudioCtrlAck::FAILURE_DISCONNECTING:
- return os << "FAILURE_DISCONNECTING";
- case BluetoothAudioCtrlAck::FAILURE:
- return os << "FAILURE";
- default:
- return os << "UNDEFINED " << static_cast<int8_t>(ack);
- }
-}
-
BluetoothAudioClientInterface::BluetoothAudioClientInterface(IBluetoothTransportInstance* instance)
: provider_(nullptr),
provider_factory_(nullptr),
@@ -65,6 +46,13 @@
latency_modes_({LatencyMode::FREE}) {
death_recipient_ =
::ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(binderDiedCallbackAidl));
+ FetchAudioProvider();
+}
+
+BluetoothAudioClientInterface::~BluetoothAudioClientInterface() {
+ if (provider_factory_ != nullptr) {
+ AIBinder_unlinkToDeath(provider_factory_->asBinder().get(), death_recipient_.get(), nullptr);
+ }
}
bool BluetoothAudioClientInterface::IsValid() const { return provider_ != nullptr; }
@@ -230,30 +218,6 @@
fmt::ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)"));
}
-BluetoothAudioSinkClientInterface::BluetoothAudioSinkClientInterface(
- IBluetoothSinkTransportInstance* sink)
- : BluetoothAudioClientInterface{sink}, sink_(sink) {
- FetchAudioProvider();
-}
-
-BluetoothAudioSinkClientInterface::~BluetoothAudioSinkClientInterface() {
- if (provider_factory_ != nullptr) {
- AIBinder_unlinkToDeath(provider_factory_->asBinder().get(), death_recipient_.get(), nullptr);
- }
-}
-
-BluetoothAudioSourceClientInterface::BluetoothAudioSourceClientInterface(
- IBluetoothSourceTransportInstance* source)
- : BluetoothAudioClientInterface{source}, source_(source) {
- FetchAudioProvider();
-}
-
-BluetoothAudioSourceClientInterface::~BluetoothAudioSourceClientInterface() {
- if (provider_factory_ != nullptr) {
- AIBinder_unlinkToDeath(provider_factory_->asBinder().get(), death_recipient_.get(), nullptr);
- }
-}
-
void BluetoothAudioClientInterface::binderDiedCallbackAidl(void* ptr) {
log::warn("restarting connection with new Audio Hal");
auto client = static_cast<BluetoothAudioClientInterface*>(ptr);
@@ -431,17 +395,17 @@
}
}
-void BluetoothAudioClientInterface::StreamStarted(const BluetoothAudioCtrlAck& ack) {
+void BluetoothAudioClientInterface::StreamStarted(const BluetoothAudioStatus& ack) {
if (provider_ == nullptr) {
log::error("BluetoothAudioHal nullptr");
return;
}
- if (ack == BluetoothAudioCtrlAck::PENDING) {
+ if (ack == BluetoothAudioStatus::PENDING) {
log::info("{} ignored", ack);
return;
}
- auto status = BluetoothAudioCtrlAckToHalStatus(ack);
+ auto status = BluetoothAudioStatusToHalStatus(ack);
auto aidl_retval = provider_->streamStarted(status);
if (!aidl_retval.isOk()) {
@@ -449,17 +413,17 @@
}
}
-void BluetoothAudioClientInterface::StreamSuspended(const BluetoothAudioCtrlAck& ack) {
+void BluetoothAudioClientInterface::StreamSuspended(const BluetoothAudioStatus& ack) {
if (provider_ == nullptr) {
log::error("BluetoothAudioHal nullptr");
return;
}
- if (ack == BluetoothAudioCtrlAck::PENDING) {
+ if (ack == BluetoothAudioStatus::PENDING) {
log::info("{} ignored", ack);
return;
}
- auto status = BluetoothAudioCtrlAckToHalStatus(ack);
+ auto status = BluetoothAudioStatusToHalStatus(ack);
auto aidl_retval = provider_->streamSuspended(status);
if (!aidl_retval.isOk()) {
@@ -490,33 +454,7 @@
return 0;
}
-void BluetoothAudioClientInterface::FlushAudioData() {
- if (transport_->GetSessionType() == SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
- transport_->GetSessionType() == SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH ||
- transport_->GetSessionType() ==
- SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
- (bta_ag_is_sco_managed_by_audio() &&
- transport_->GetSessionType() == SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH)) {
- return;
- }
-
- if (data_mq_ == nullptr || !data_mq_->isValid()) {
- log::warn("data_mq_ invalid");
- return;
- }
- size_t size = data_mq_->availableToRead();
- if (size == 0) {
- return;
- }
-
- std::vector<MqDataType> buffer(size);
-
- if (data_mq_->read(buffer.data(), size) != size) {
- log::warn("failed to flush data queue!");
- }
-}
-
-size_t BluetoothAudioSinkClientInterface::ReadAudioData(uint8_t* p_buf, uint32_t len) {
+size_t BluetoothAudioClientInterface::ReadAudioData(uint8_t* p_buf, uint32_t len) {
if (!IsValid()) {
log::error("BluetoothAudioHal is not valid");
return 0;
@@ -563,7 +501,7 @@
log::verbose("{} -> {} read", len, total_read);
}
- sink_->LogBytesRead(total_read);
+ transport_->LogBytesRead(total_read);
return total_read;
}
@@ -580,155 +518,6 @@
}
}
-size_t BluetoothAudioSourceClientInterface::WriteAudioData(const uint8_t* p_buf, uint32_t len) {
- if (!IsValid()) {
- log::error("BluetoothAudioHal is not valid");
- return 0;
- }
- if (p_buf == nullptr || len == 0) {
- return 0;
- }
-
- std::lock_guard<std::mutex> guard(internal_mutex_);
-
- size_t total_written = 0;
- int timeout_ms = kDefaultDataWriteTimeoutMs;
- do {
- if (data_mq_ == nullptr || !data_mq_->isValid()) {
- break;
- }
-
- size_t avail_to_write = data_mq_->availableToWrite();
- if (avail_to_write) {
- if (avail_to_write > len - total_written) {
- avail_to_write = len - total_written;
- }
- if (data_mq_->write((const MqDataType*)p_buf + total_written, avail_to_write) == 0) {
- log::warn("len={} total_written={} failed", len, total_written);
- break;
- }
- total_written += avail_to_write;
- } else if (timeout_ms >= kDefaultDataWritePollIntervalMs) {
- std::this_thread::sleep_for(std::chrono::milliseconds(kDefaultDataWritePollIntervalMs));
- timeout_ms -= kDefaultDataWritePollIntervalMs;
- continue;
- } else {
- log::warn("{}/{} no data {} ms", len - total_written, len,
- kDefaultDataWriteTimeoutMs - timeout_ms);
- break;
- }
- } while (total_written < len);
-
- if (timeout_ms < (kDefaultDataWriteTimeoutMs - kDefaultDataWritePollIntervalMs) &&
- timeout_ms >= kDefaultDataWritePollIntervalMs) {
- log::verbose("underflow {} -> {} read {} ms", len, total_written,
- kDefaultDataWriteTimeoutMs - timeout_ms);
- } else {
- log::verbose("{} -> {} written", len, total_written);
- }
-
- source_->LogBytesWritten(total_written);
- return total_written;
-}
-
-void BluetoothAudioClientInterface::SetCodecPriority(CodecId codec_id, int32_t priority) {
- log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr");
- auto aidl_retval = provider_->setCodecPriority(codec_id, priority);
- if (!aidl_retval.isOk()) {
- log::error("BluetoothAudioHal::setCodecPriority failure: {}", aidl_retval.getDescription());
- }
-}
-
-std::vector<IBluetoothAudioProvider::LeAudioAseConfigurationSetting>
-BluetoothAudioClientInterface::GetLeAudioAseConfiguration(
- std::optional<
- std::vector<std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
- remoteSinkAudioCapabilities,
- std::optional<
- std::vector<std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
- remoteSourceAudioCapabilities,
- std::vector<IBluetoothAudioProvider::LeAudioConfigurationRequirement>& requirements) {
- log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr");
-
- std::vector<IBluetoothAudioProvider::LeAudioAseConfigurationSetting> configurations;
- auto aidl_retval = provider_->getLeAudioAseConfiguration(remoteSinkAudioCapabilities,
- remoteSourceAudioCapabilities,
- requirements, &configurations);
-
- if (!aidl_retval.isOk()) {
- log::error("BluetoothAudioHal::getLeAudioAseConfiguration failure: {}",
- aidl_retval.getDescription());
- } else {
- log::info(
- "BluetoothAudioHal::getLeAudioAseConfiguration returned {} "
- "configurations.",
- configurations.size());
- }
-
- return configurations;
-}
-
-IBluetoothAudioProvider::LeAudioAseQosConfigurationPair
-BluetoothAudioClientInterface::getLeAudioAseQosConfiguration(
- IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement& qosRequirement) {
- log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr");
-
- IBluetoothAudioProvider::LeAudioAseQosConfigurationPair qos_configuration;
- auto aidl_retval = provider_->getLeAudioAseQosConfiguration(qosRequirement, &qos_configuration);
-
- if (!aidl_retval.isOk()) {
- log::error("BluetoothAudioHal::getLeAudioAseQosConfiguration failure: {}",
- aidl_retval.getDescription());
- }
- return qos_configuration;
-}
-
-void BluetoothAudioClientInterface::onSinkAseMetadataChanged(
- IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId,
- std::optional<std::vector<std::optional<MetadataLtv>>>& metadata) {
- log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr");
-
- auto aidl_retval = provider_->onSinkAseMetadataChanged(state, cigId, cisId, metadata);
-
- if (!aidl_retval.isOk()) {
- log::error("BluetoothAudioHal::onSinkAseMetadataChanged failure: {}",
- aidl_retval.getDescription());
- }
-}
-
-void BluetoothAudioClientInterface::onSourceAseMetadataChanged(
- IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId,
- std::optional<std::vector<std::optional<MetadataLtv>>>& metadata) {
- log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr");
-
- auto aidl_retval = provider_->onSourceAseMetadataChanged(state, cigId, cisId, metadata);
-
- if (!aidl_retval.isOk()) {
- log::error("BluetoothAudioHal::onSourceAseMetadataChanged failure: {}",
- aidl_retval.getDescription());
- }
-}
-
-IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting
-BluetoothAudioClientInterface::getLeAudioBroadcastConfiguration(
- const std::optional<
- std::vector<std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
- remoteSinkAudioCapabilities,
- const IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement& requirement) {
- log::assert_that(provider_ != nullptr, "assert failed: provider_ != nullptr");
-
- IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting setting;
- auto aidl_retval = provider_->getLeAudioBroadcastConfiguration(remoteSinkAudioCapabilities,
- requirement, &setting);
-
- if (!aidl_retval.isOk()) {
- log::error("BluetoothAudioHal::getLeAudioBroadcastConfiguration failure: {}",
- aidl_retval.getDescription());
- }
-
- return setting;
-}
-
} // namespace a2dp
} // namespace aidl
} // namespace audio
diff --git a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h
index 89aa10f..fd8f160 100644
--- a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h
+++ b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h
@@ -24,12 +24,15 @@
#include <vector>
#include "audio_aidl_interfaces.h"
-#include "audio_ctrl_ack.h"
#include "bluetooth_audio_port_impl.h"
#include "bta/le_audio/broadcaster/broadcaster_types.h"
#include "bta/le_audio/le_audio_types.h"
#include "transport_instance.h"
+// Keep after audio_aidl_interfaces.h because of <base/logging.h>
+// conflicting definitions.
+#include "a2dp_encoding.h"
+
namespace bluetooth {
namespace audio {
namespace aidl {
@@ -62,6 +65,21 @@
using DataMQ = AidlMessageQueue<MqDataType, MqDataMode>;
using DataMQDesc = MQDescriptor<MqDataType, MqDataMode>;
+inline ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus
+BluetoothAudioStatusToHalStatus(BluetoothAudioStatus ack) {
+ switch (ack) {
+ case BluetoothAudioStatus::SUCCESS:
+ return ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus::SUCCESS;
+ case BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION:
+ return ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus::
+ UNSUPPORTED_CODEC_CONFIGURATION;
+ case BluetoothAudioStatus::PENDING:
+ case BluetoothAudioStatus::FAILURE:
+ default:
+ return ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus::FAILURE;
+ }
+}
+
/***
* The client interface connects an IBluetoothTransportInstance to
* IBluetoothAudioProvider and helps to route callbacks to
@@ -70,9 +88,10 @@
class BluetoothAudioClientInterface {
public:
BluetoothAudioClientInterface(IBluetoothTransportInstance* instance);
- virtual ~BluetoothAudioClientInterface() = default;
+ virtual ~BluetoothAudioClientInterface();
bool IsValid() const;
+ IBluetoothTransportInstance* GetTransportInstance() const { return transport_; }
std::vector<AudioCapabilities> GetAudioCapabilities() const;
@@ -89,9 +108,9 @@
std::vector<A2dpRemoteCapabilities> const& remote_capabilities,
A2dpConfigurationHint const& hint) const;
- void StreamStarted(const BluetoothAudioCtrlAck& ack);
+ void StreamStarted(const BluetoothAudioStatus& ack);
- void StreamSuspended(const BluetoothAudioCtrlAck& ack);
+ void StreamSuspended(const BluetoothAudioStatus& ack);
int StartSession();
@@ -106,35 +125,10 @@
bool SetAllowedLatencyModes(std::vector<LatencyMode> latency_modes);
- void FlushAudioData();
-
- void SetCodecPriority(CodecId codec_id, int32_t priority);
-
- std::vector<IBluetoothAudioProvider::LeAudioAseConfigurationSetting> GetLeAudioAseConfiguration(
- std::optional<
- std::vector<std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
- remoteSinkAudioCapabilities,
- std::optional<
- std::vector<std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
- remoteSourceAudioCapabilities,
- std::vector<IBluetoothAudioProvider::LeAudioConfigurationRequirement>& requirements);
-
- IBluetoothAudioProvider::LeAudioAseQosConfigurationPair getLeAudioAseQosConfiguration(
- IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement& qosRequirement);
-
- void onSinkAseMetadataChanged(IBluetoothAudioProvider::AseState state, int32_t cigId,
- int32_t cisId,
- std::optional<std::vector<std::optional<MetadataLtv>>>& metadata);
-
- void onSourceAseMetadataChanged(IBluetoothAudioProvider::AseState state, int32_t cigId,
- int32_t cisId,
- std::optional<std::vector<std::optional<MetadataLtv>>>& metadata);
-
- IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting getLeAudioBroadcastConfiguration(
- const std::optional<
- std::vector<std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
- remoteSinkAudioCapabilities,
- const IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement& requirement);
+ /***
+ * Read data from audio HAL through fmq
+ ***/
+ size_t ReadAudioData(uint8_t* p_buf, uint32_t len);
static constexpr PcmConfiguration kInvalidPcmConfiguration = {};
@@ -153,7 +147,6 @@
static void binderDiedCallbackAidl(void* cookie_ptr);
std::shared_ptr<IBluetoothAudioProvider> provider_;
-
std::shared_ptr<IBluetoothAudioProviderFactory> provider_factory_;
bool session_started_;
@@ -169,59 +162,11 @@
IBluetoothTransportInstance* transport_;
std::vector<AudioCapabilities> capabilities_;
std::vector<LatencyMode> latency_modes_;
-};
-
-/***
- * The client interface connects an IBluetoothTransportInstance to
- * IBluetoothAudioProvider and helps to route callbacks to
- * IBluetoothTransportInstance
- ***/
-class BluetoothAudioSinkClientInterface : public BluetoothAudioClientInterface {
-public:
- /***
- * Constructs an BluetoothAudioSinkClientInterface to communicate to
- * BluetoothAudio HAL. |sink| is the implementation for the transport.
- ***/
- BluetoothAudioSinkClientInterface(IBluetoothSinkTransportInstance* sink);
- virtual ~BluetoothAudioSinkClientInterface();
-
- IBluetoothSinkTransportInstance* GetTransportInstance() const { return sink_; }
-
- /***
- * Read data from audio HAL through fmq
- ***/
- size_t ReadAudioData(uint8_t* p_buf, uint32_t len);
-
-private:
- IBluetoothSinkTransportInstance* sink_;
static constexpr int kDefaultDataReadTimeoutMs = 10;
static constexpr int kDefaultDataReadPollIntervalMs = 1;
};
-class BluetoothAudioSourceClientInterface : public BluetoothAudioClientInterface {
-public:
- /***
- * Constructs an BluetoothAudioSourceClientInterface to communicate to
- * BluetoothAudio HAL. |source| is the implementation for the transport.
- ***/
- BluetoothAudioSourceClientInterface(IBluetoothSourceTransportInstance* source);
- virtual ~BluetoothAudioSourceClientInterface();
-
- IBluetoothSourceTransportInstance* GetTransportInstance() const { return source_; }
-
- /***
- * Write data to audio HAL through fmq
- ***/
- size_t WriteAudioData(const uint8_t* p_buf, uint32_t len);
-
-private:
- IBluetoothSourceTransportInstance* source_;
-
- static constexpr int kDefaultDataWriteTimeoutMs = 10;
- static constexpr int kDefaultDataWritePollIntervalMs = 1;
-};
-
} // namespace a2dp
} // namespace aidl
} // namespace audio
diff --git a/system/audio_hal_interface/aidl/a2dp/codec_status_aidl.cc b/system/audio_hal_interface/aidl/a2dp/codec_status_aidl.cc
index d9c85c5..cb4a601 100644
--- a/system/audio_hal_interface/aidl/a2dp/codec_status_aidl.cc
+++ b/system/audio_hal_interface/aidl/a2dp/codec_status_aidl.cc
@@ -59,7 +59,7 @@
namespace {
-// capabilities from BluetoothAudioSinkClientInterface::GetAudioCapabilities()
+// capabilities from BluetoothAudioClientInterface::GetAudioCapabilities()
std::vector<AudioCapabilities> audio_hal_capabilities(0);
// capabilities that audio HAL supports and frameworks / Bluetooth SoC / runtime
// preference would like to use.
@@ -475,7 +475,7 @@
bool UpdateOffloadingCapabilities(
const std::vector<btav_a2dp_codec_config_t>& framework_preference) {
- audio_hal_capabilities = BluetoothAudioSinkClientInterface::GetAudioCapabilities(
+ audio_hal_capabilities = BluetoothAudioClientInterface::GetAudioCapabilities(
SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH);
std::unordered_set<CodecType> codec_type_set;
for (auto preference : framework_preference) {
diff --git a/system/audio_hal_interface/aidl/a2dp/transport_instance.h b/system/audio_hal_interface/aidl/a2dp/transport_instance.h
index 3d45896..274f236 100644
--- a/system/audio_hal_interface/aidl/a2dp/transport_instance.h
+++ b/system/audio_hal_interface/aidl/a2dp/transport_instance.h
@@ -18,8 +18,8 @@
#include <hardware/audio.h>
+#include "a2dp_encoding.h"
#include "audio_aidl_interfaces.h"
-#include "audio_ctrl_ack.h"
namespace bluetooth {
namespace audio {
@@ -29,6 +29,7 @@
using ::aidl::android::hardware::bluetooth::audio::AudioConfiguration;
using ::aidl::android::hardware::bluetooth::audio::LatencyMode;
using ::aidl::android::hardware::bluetooth::audio::SessionType;
+using ::bluetooth::audio::a2dp::BluetoothAudioStatus;
/***
* An IBluetoothTransportInstance needs to be implemented by a Bluetooth
@@ -42,7 +43,6 @@
virtual ~IBluetoothTransportInstance() = default;
SessionType GetSessionType() const { return session_type_; }
-
AudioConfiguration GetAudioConfiguration() const { return audio_config_; }
void UpdateAudioConfiguration(const AudioConfiguration& audio_config) {
@@ -55,75 +55,38 @@
audio_config_.set<AudioConfiguration::a2dpConfig>(
audio_config.get<AudioConfiguration::a2dpConfig>());
break;
- case AudioConfiguration::hfpConfig:
- audio_config_.set<AudioConfiguration::hfpConfig>(
- audio_config.get<AudioConfiguration::hfpConfig>());
- break;
- case AudioConfiguration::leAudioConfig:
- audio_config_.set<AudioConfiguration::leAudioConfig>(
- audio_config.get<AudioConfiguration::leAudioConfig>());
- break;
- case AudioConfiguration::leAudioBroadcastConfig:
- audio_config_.set<AudioConfiguration::leAudioBroadcastConfig>(
- audio_config.get<AudioConfiguration::leAudioBroadcastConfig>());
- break;
case AudioConfiguration::a2dp:
audio_config_.set<AudioConfiguration::a2dp>(audio_config.get<AudioConfiguration::a2dp>());
break;
+ case AudioConfiguration::leAudioConfig:
+ case AudioConfiguration::leAudioBroadcastConfig:
+ case AudioConfiguration::hfpConfig:
+ // Unused by the A2DP client interface.
+ break;
}
}
- virtual BluetoothAudioCtrlAck StartRequest(bool is_low_latency) = 0;
-
- virtual BluetoothAudioCtrlAck SuspendRequest() = 0;
-
+ virtual BluetoothAudioStatus StartRequest(bool is_low_latency) = 0;
+ virtual BluetoothAudioStatus SuspendRequest() = 0;
virtual void StopRequest() = 0;
virtual void SetLatencyMode(LatencyMode latency_mode) = 0;
-
virtual bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
uint64_t* total_bytes_readed, timespec* data_position) = 0;
- virtual void SourceMetadataChanged(const source_metadata_v7_t& source_metadata) = 0;
- virtual void SinkMetadataChanged(const sink_metadata_v7_t& sink_metadata) = 0;
-
/***
* Invoked when the transport is requested to reset presentation position
***/
virtual void ResetPresentationPosition() = 0;
-private:
- const SessionType session_type_;
- AudioConfiguration audio_config_;
-};
-
-/***
- * An IBluetoothSinkTransportInstance needs to be implemented by a Bluetooth
- * audio transport, such as A2DP, Hearing Aid or LeAudio, to handle callbacks
- * from Audio HAL.
- ***/
-class IBluetoothSinkTransportInstance : public IBluetoothTransportInstance {
-public:
- IBluetoothSinkTransportInstance(SessionType sessionType, AudioConfiguration audioConfig)
- : IBluetoothTransportInstance{sessionType, audioConfig} {}
- virtual ~IBluetoothSinkTransportInstance() = default;
-
/***
* Invoked when the transport is requested to log bytes read
***/
virtual void LogBytesRead(size_t bytes_readed) = 0;
-};
-class IBluetoothSourceTransportInstance : public IBluetoothTransportInstance {
-public:
- IBluetoothSourceTransportInstance(SessionType sessionType, AudioConfiguration audioConfig)
- : IBluetoothTransportInstance{sessionType, audioConfig} {}
- virtual ~IBluetoothSourceTransportInstance() = default;
-
- /***
- * Invoked when the transport is requested to log bytes written
- ***/
- virtual void LogBytesWritten(size_t bytes_written) = 0;
+private:
+ const SessionType session_type_;
+ AudioConfiguration audio_config_;
};
} // namespace a2dp
diff --git a/system/audio_hal_interface/aidl/audio_aidl_interfaces.h b/system/audio_hal_interface/aidl/audio_aidl_interfaces.h
index e8fb9ba..fbc302a 100644
--- a/system/audio_hal_interface/aidl/audio_aidl_interfaces.h
+++ b/system/audio_hal_interface/aidl/audio_aidl_interfaces.h
@@ -28,11 +28,6 @@
#include <aidl/android/hardware/bluetooth/audio/BnBluetoothAudioPort.h>
#include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h>
-#include <aidl/android/hardware/bluetooth/audio/AacCapabilities.h>
-#include <aidl/android/hardware/bluetooth/audio/AacConfiguration.h>
-#include <aidl/android/hardware/bluetooth/audio/AacObjectType.h>
-#include <aidl/android/hardware/bluetooth/audio/AptxCapabilities.h>
-#include <aidl/android/hardware/bluetooth/audio/AptxConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/AudioCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/AudioConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/AudioLocation.h>
@@ -47,10 +42,6 @@
#include <aidl/android/hardware/bluetooth/audio/LatencyMode.h>
#include <aidl/android/hardware/bluetooth/audio/Lc3Capabilities.h>
#include <aidl/android/hardware/bluetooth/audio/Lc3Configuration.h>
-#include <aidl/android/hardware/bluetooth/audio/LdacCapabilities.h>
-#include <aidl/android/hardware/bluetooth/audio/LdacChannelMode.h>
-#include <aidl/android/hardware/bluetooth/audio/LdacConfiguration.h>
-#include <aidl/android/hardware/bluetooth/audio/LdacQualityIndex.h>
#include <aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h>
#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.h>
@@ -58,10 +49,6 @@
#include <aidl/android/hardware/bluetooth/audio/PcmCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/PcmConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/PresentationPosition.h>
-#include <aidl/android/hardware/bluetooth/audio/SbcAllocMethod.h>
-#include <aidl/android/hardware/bluetooth/audio/SbcCapabilities.h>
-#include <aidl/android/hardware/bluetooth/audio/SbcChannelMode.h>
-#include <aidl/android/hardware/bluetooth/audio/SbcConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/SessionType.h>
@@ -75,4 +62,4 @@
#undef LOG_DEBUG
#endif
-// clang-format on
\ No newline at end of file
+// clang-format on
diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.cc b/system/audio_hal_interface/aidl/client_interface_aidl.cc
index 15a20be..fc65552 100644
--- a/system/audio_hal_interface/aidl/client_interface_aidl.cc
+++ b/system/audio_hal_interface/aidl/client_interface_aidl.cc
@@ -127,50 +127,6 @@
return provider_info;
}
-std::optional<A2dpConfiguration> BluetoothAudioClientInterface::GetA2dpConfiguration(
- std::vector<A2dpRemoteCapabilities> const& remote_capabilities,
- A2dpConfigurationHint const& hint) const {
- if (!is_aidl_available()) {
- return std::nullopt;
- }
-
- if (provider_ == nullptr) {
- log::error("can't get a2dp configuration from unknown provider");
- return std::nullopt;
- }
-
- std::optional<A2dpConfiguration> configuration = std::nullopt;
- auto aidl_retval = provider_->getA2dpConfiguration(remote_capabilities, hint, &configuration);
-
- if (!aidl_retval.isOk()) {
- log::error("getA2dpConfiguration failure: {}", aidl_retval.getDescription());
- return std::nullopt;
- }
-
- return configuration;
-}
-
-std::optional<A2dpStatus> BluetoothAudioClientInterface::ParseA2dpConfiguration(
- const CodecId& codec_id, const std::vector<uint8_t>& configuration,
- CodecParameters* codec_parameters) const {
- A2dpStatus a2dp_status;
-
- if (provider_ == nullptr) {
- log::error("can not parse A2DP configuration because of unknown provider");
- return std::nullopt;
- }
-
- auto aidl_retval = provider_->parseA2dpConfiguration(codec_id, configuration, codec_parameters,
- &a2dp_status);
-
- if (!aidl_retval.isOk()) {
- log::error("parseA2dpConfiguration failure: {}", aidl_retval.getDescription());
- return std::nullopt;
- }
-
- return std::make_optional(a2dp_status);
-}
-
void BluetoothAudioClientInterface::FetchAudioProvider() {
if (!is_aidl_available()) {
log::error("aidl is not supported on this platform.");
diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.h b/system/audio_hal_interface/aidl/client_interface_aidl.h
index b5bb309..a3c6038 100644
--- a/system/audio_hal_interface/aidl/client_interface_aidl.h
+++ b/system/audio_hal_interface/aidl/client_interface_aidl.h
@@ -34,10 +34,6 @@
namespace audio {
namespace aidl {
-using ::aidl::android::hardware::bluetooth::audio::A2dpConfiguration;
-using ::aidl::android::hardware::bluetooth::audio::A2dpConfigurationHint;
-using ::aidl::android::hardware::bluetooth::audio::A2dpRemoteCapabilities;
-using ::aidl::android::hardware::bluetooth::audio::A2dpStatus;
using ::aidl::android::hardware::bluetooth::audio::AudioCapabilities;
using ::aidl::android::hardware::bluetooth::audio::AudioConfiguration;
using ::aidl::android::hardware::bluetooth::audio::CodecId;
@@ -80,16 +76,7 @@
SessionType session_type,
std::shared_ptr<IBluetoothAudioProviderFactory> provider_factory = nullptr);
- std::optional<A2dpStatus> ParseA2dpConfiguration(const CodecId& codec_id,
- const std::vector<uint8_t>& configuration,
- CodecParameters* codec_parameters) const;
-
- std::optional<A2dpConfiguration> GetA2dpConfiguration(
- std::vector<A2dpRemoteCapabilities> const& remote_capabilities,
- A2dpConfigurationHint const& hint) const;
-
void StreamStarted(const BluetoothAudioCtrlAck& ack);
-
void StreamSuspended(const BluetoothAudioCtrlAck& ack);
int StartSession();
diff --git a/system/audio_hal_interface/fuzzer/Android.bp b/system/audio_hal_interface/fuzzer/Android.bp
index 5b03d9f..e55a9d6 100644
--- a/system/audio_hal_interface/fuzzer/Android.bp
+++ b/system/audio_hal_interface/fuzzer/Android.bp
@@ -67,7 +67,6 @@
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
- "libbluetooth_rust_interop",
"libbt-audio-hal-interface",
"libbt-bta",
"libbt-bta-core",
@@ -79,7 +78,6 @@
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbtcore",
"libbtdevice",
"libbte",
diff --git a/system/bta/Android.bp b/system/bta/Android.bp
index db142a9..319b5db 100644
--- a/system/bta/Android.bp
+++ b/system/bta/Android.bp
@@ -150,7 +150,6 @@
"libbt-audio-asrc",
"libbt-bta-core",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libcom.android.sysprop.bluetooth.wrapped",
"liblc3",
],
@@ -218,7 +217,6 @@
"libbluetooth_log",
"libbt-audio-hal-interface",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libcom.android.sysprop.bluetooth.wrapped",
"libflatbuffers-cpp",
"server_configurable_flags",
@@ -317,8 +315,6 @@
"libbt-btu-main-thread",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libbtdevice",
"libchrome",
@@ -398,8 +394,6 @@
"libbt-bta-core",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
@@ -438,6 +432,7 @@
static_libs: [
"bluetooth_flags_c_lib",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
@@ -447,8 +442,6 @@
"libbt-btu-main-thread",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libchrome",
"libgmock",
@@ -501,8 +494,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libbtdevice",
"libchrome",
@@ -570,8 +561,6 @@
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcutils",
"libgmock",
@@ -620,8 +609,6 @@
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libgmock",
"libosi",
@@ -682,8 +669,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libgmock",
"server_configurable_flags",
@@ -839,8 +824,6 @@
"libbt-audio-hal-interface",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libflatbuffers-cpp",
@@ -951,8 +934,6 @@
"libbt-audio-asrc",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libflatbuffers-cpp",
@@ -1039,8 +1020,6 @@
"libbt-audio-hal-interface",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libflagtest",
@@ -1134,8 +1113,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libflagtest",
"libflatbuffers-cpp",
@@ -1212,8 +1189,6 @@
"libbt-audio-hal-interface",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libflagtest",
@@ -1282,8 +1257,6 @@
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libgmock",
],
@@ -1350,14 +1323,13 @@
static_libs: [
"bluetooth_flags_c_lib",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_hci_pdl",
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
"libevent",
@@ -1423,14 +1395,13 @@
static_libs: [
"bluetooth_flags_c_lib",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_hci_pdl",
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
"libevent",
diff --git a/system/bta/BUILD.gn b/system/bta/BUILD.gn
index 306aaae..ba89c1c 100644
--- a/system/bta/BUILD.gn
+++ b/system/bta/BUILD.gn
@@ -172,7 +172,6 @@
"//bt/system/bta:install_audio_set_scenarios_bfbs",
"//bt/system/bta:install_audio_set_configurations_bfbs",
"//bt/system:libbt-platform-protos-lite",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
]
libs = [
diff --git a/system/bta/dm/bta_dm_act.cc b/system/bta/dm/bta_dm_act.cc
index f908268..1d1d5c5 100644
--- a/system/bta/dm/bta_dm_act.cc
+++ b/system/bta/dm/bta_dm_act.cc
@@ -73,8 +73,6 @@
using namespace bluetooth;
bool ble_vnd_is_included();
-void BTIF_dm_disable();
-void BTIF_dm_enable();
void btm_ble_scanner_init(void);
static void bta_dm_check_av();
diff --git a/system/bta/le_audio/devices.h b/system/bta/le_audio/devices.h
index d874e8d..d4c7d4b 100644
--- a/system/bta/le_audio/devices.h
+++ b/system/bta/le_audio/devices.h
@@ -113,9 +113,9 @@
alarm_t* link_quality_timer;
uint16_t link_quality_timer_data;
- LeAudioDevice(const RawAddress& address_, DeviceConnectState state,
+ LeAudioDevice(const RawAddress& address, DeviceConnectState state,
int group_id = bluetooth::groups::kGroupUnknown)
- : address_(address_),
+ : address_(address),
connection_state_(state),
known_service_handles_(false),
notify_connected_after_read_(false),
diff --git a/system/bta/le_audio/le_audio_types.h b/system/bta/le_audio/le_audio_types.h
index c42c301..54e3898 100644
--- a/system/bta/le_audio/le_audio_types.h
+++ b/system/bta/le_audio/le_audio_types.h
@@ -103,6 +103,8 @@
/* Gaming Audio Service Characteristics */
static const bluetooth::Uuid kRoleCharacteristicUuid = bluetooth::Uuid::From16Bit(0x2C00);
+static const bluetooth::Uuid kUnicastGameGatewayCharacteristicUuid =
+ bluetooth::Uuid::From16Bit(0x2C01);
static const bluetooth::Uuid kUnicastGameTerminalCharacteristicUuid =
bluetooth::Uuid::From16Bit(0x2C02);
} // namespace uuid
diff --git a/system/btcore/Android.bp b/system/btcore/Android.bp
index 6410de7..96da5ab 100644
--- a/system/btcore/Android.bp
+++ b/system/btcore/Android.bp
@@ -57,7 +57,6 @@
},
static_libs: [
"libbluetooth_log",
- "libbt_shim_bridge",
],
}
@@ -71,7 +70,6 @@
min_sdk_version: "Tiramisu",
static_libs: [
"libbluetooth_log",
- "libbt_shim_bridge",
],
}
diff --git a/system/btcore/BUILD.gn b/system/btcore/BUILD.gn
index f7b86f2..7685355 100644
--- a/system/btcore/BUILD.gn
+++ b/system/btcore/BUILD.gn
@@ -32,11 +32,6 @@
"//bt/system:target_defaults",
"//bt/system/log:log_defaults",
]
-
- deps = [
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
- "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
- ]
}
if (use.test) {
diff --git a/system/btcore/fuzzer/Android.bp b/system/btcore/fuzzer/Android.bp
index 746fdb9..746a3b3 100644
--- a/system/btcore/fuzzer/Android.bp
+++ b/system/btcore/fuzzer/Android.bp
@@ -35,10 +35,7 @@
"libbluetooth-types",
"libbluetooth_crypto_toolbox",
"libbluetooth_log",
- "libbluetooth_rust_interop",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libchrome",
"libevent",
diff --git a/system/btif/Android.bp b/system/btif/Android.bp
index 1876062..eb4ee99 100644
--- a/system/btif/Android.bp
+++ b/system/btif/Android.bp
@@ -60,7 +60,6 @@
srcs: ["src/btif_jni_task.cc"],
static_libs: [
"libbluetooth_log",
- "libbt_shim_bridge",
"libosi",
],
shared_libs: [
@@ -163,7 +162,6 @@
"libbt-platform-protos-lite",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbtif-core",
"libflatbuffers-cpp",
],
@@ -244,7 +242,6 @@
"libbt-jni-thread",
"libbt-platform-protos-lite",
"libbt-stack-core",
- "libbt_shim_bridge",
"libcom.android.sysprop.bluetooth.wrapped",
"libflatbuffers-cpp",
"libstatslog_bt",
@@ -320,7 +317,6 @@
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbtcore",
"libbtdevice",
"libbtif",
@@ -392,8 +388,6 @@
"libbluetooth-types",
"libbluetooth_gd",
"libbluetooth_log",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libosi",
],
@@ -431,8 +425,6 @@
static_libs: [
"libbluetooth-types",
"libbluetooth_log",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libosi",
],
@@ -480,8 +472,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
],
@@ -523,10 +513,9 @@
],
static_libs: [
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_log",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
"libgmock",
@@ -612,6 +601,7 @@
"lib-bt-packets-avrcp",
"lib-bt-packets-base",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
@@ -623,8 +613,6 @@
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libbtif",
"libbtif-core",
@@ -736,6 +724,7 @@
"lib-bt-packets-avrcp",
"lib-bt-packets-base",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_hci_pdl",
@@ -747,8 +736,6 @@
"libbt-platform-protos-lite",
"libbt-sbc-decoder",
"libbt-sbc-encoder",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libbtif",
"libbtif-core",
diff --git a/system/btif/BUILD.gn b/system/btif/BUILD.gn
index 7e4897f..5129a1e 100644
--- a/system/btif/BUILD.gn
+++ b/system/btif/BUILD.gn
@@ -113,7 +113,6 @@
"//bt/sysprop:libcom.android.sysprop.bluetooth",
"//bt/system:libbt-platform-protos-lite",
"//bt/system/common",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
"//bt/system/profile/avrcp:profile_avrcp",
"//bt/system/gd:libbluetooth-gdx",
]
diff --git a/system/btif/include/btif_acl.h b/system/btif/include/btif_acl.h
deleted file mode 100644
index cab40b4..0000000
--- a/system/btif/include/btif_acl.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include "stack/include/acl_api_types.h"
-
-void BTIF_dm_report_inquiry_status_change(tBTM_INQUIRY_STATE inquiry_state);
diff --git a/system/btif/include/btif_dm.h b/system/btif/include/btif_dm.h
index 5db8b50..15a5bfa 100644
--- a/system/btif/include/btif_dm.h
+++ b/system/btif/include/btif_dm.h
@@ -16,8 +16,7 @@
*
******************************************************************************/
-#ifndef BTIF_DM_H
-#define BTIF_DM_H
+#pragma once
#include "bta/include/bta_api.h"
#include "bta/include/bta_sec_api.h"
@@ -25,6 +24,7 @@
#include "hci/le_rand_callback.h"
#include "internal_include/bt_target.h"
#include "internal_include/bte_appl.h"
+#include "stack/include/acl_api_types.h"
#include "types/raw_address.h"
/*******************************************************************************
@@ -97,13 +97,12 @@
void btif_dm_generate_local_oob_data(tBT_TRANSPORT transport);
void btif_check_device_in_inquiry_db(const RawAddress& address);
+bool btif_get_address_type(const RawAddress& bda, tBLE_ADDR_TYPE* p_addr_type);
+bool btif_get_device_type(const RawAddress& bda, int* p_device_type);
void btif_dm_clear_event_filter();
-
void btif_dm_clear_event_mask();
-
void btif_dm_clear_filter_accept_list();
-
void btif_dm_disconnect_all_acls();
void btif_dm_le_rand(bluetooth::hci::LeRandCallback callback);
@@ -121,6 +120,12 @@
/*callout for reading SMP properties from Text file*/
bool btif_dm_get_smp_config(tBTE_APPL_CFG* p_cfg);
+void btif_dm_enable_service(tBTA_SERVICE_ID service_id, bool enable);
+
+void BTIF_dm_disable();
+void BTIF_dm_enable();
+void BTIF_dm_report_inquiry_status_change(tBTM_INQUIRY_STATE inquiry_state);
+
typedef struct {
bool is_penc_key_rcvd;
tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
@@ -150,4 +155,11 @@
bool check_cod_hid_major(const RawAddress& bd_addr, uint32_t cod);
bool is_device_le_audio_capable(const RawAddress bd_addr);
bool is_le_audio_capable_during_service_discovery(const RawAddress& bd_addr);
-#endif
+
+namespace bluetooth::legacy::testing {
+void bta_energy_info_cb(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time,
+ tBTM_BLE_IDLE_TIME_MS idle_time, tBTM_BLE_ENERGY_USED energy_used,
+ tBTM_CONTRL_STATE ctrl_state, tBTA_STATUS status);
+void btif_on_name_read(RawAddress bd_addr, tHCI_ERROR_CODE hci_status, const BD_NAME bd_name,
+ bool during_device_search);
+} // namespace bluetooth::legacy::testing
diff --git a/system/gd/common/init_flags_test.cc b/system/btif/include/btif_hf_client.h
similarity index 74%
rename from system/gd/common/init_flags_test.cc
rename to system/btif/include/btif_hf_client.h
index 98a1779..72090e3 100644
--- a/system/gd/common/init_flags_test.cc
+++ b/system/btif/include/btif_hf_client.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright 2019 The Android Open Source Project
+ * Copyright 2024 Google, LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,4 +16,10 @@
*
******************************************************************************/
-#include <gtest/gtest.h>
\ No newline at end of file
+#pragma once
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hf_client.h>
+
+const bthf_client_interface_t* btif_hf_client_get_interface();
+bt_status_t btif_hf_client_execute_service(bool b_enable);
diff --git a/system/btif/include/btif_sdp.h b/system/btif/include/btif_sdp.h
index 9f0daed..c1d719a 100644
--- a/system/btif/include/btif_sdp.h
+++ b/system/btif/include/btif_sdp.h
@@ -29,6 +29,10 @@
#include <hardware/bt_sdp.h>
-btsdp_interface_t* btif_sdp_get_interface();
+const btsdp_interface_t* btif_sdp_get_interface();
+bt_status_t btif_sdp_execute_service(bool b_enable);
+
+bt_status_t sdp_server_init();
+void sdp_server_cleanup();
#endif
diff --git a/system/btif/include/btif_sock_l2cap.h b/system/btif/include/btif_sock_l2cap.h
index d527ed8..c08ef53 100644
--- a/system/btif/include/btif_sock_l2cap.h
+++ b/system/btif/include/btif_sock_l2cap.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
/*******************************************************************************
* L2CAP Socket Interface
******************************************************************************/
diff --git a/system/btif/src/bluetooth.cc b/system/btif/src/bluetooth.cc
index 46c04cc..aeeb450 100644
--- a/system/btif/src/bluetooth.cc
+++ b/system/btif/src/bluetooth.cc
@@ -70,6 +70,7 @@
#include "btif/include/btif_dm.h"
#include "btif/include/btif_hd.h"
#include "btif/include/btif_hf.h"
+#include "btif/include/btif_hf_client.h"
#include "btif/include/btif_hh.h"
#include "btif/include/btif_keystore.h"
#include "btif/include/btif_metrics_logging.h"
@@ -161,8 +162,6 @@
/* list all extended interfaces here */
-/* handsfree profile - client */
-extern const bthf_client_interface_t* btif_hf_client_get_interface();
/*rfc l2cap*/
extern const btsock_interface_t* btif_sock_get_interface();
/* hid host profile */
@@ -194,8 +193,6 @@
bt_status_t btif_av_sink_execute_service(bool b_enable);
bt_status_t btif_hh_execute_service(bool b_enable);
-bt_status_t btif_hf_client_execute_service(bool b_enable);
-bt_status_t btif_sdp_execute_service(bool b_enable);
bt_status_t btif_hd_execute_service(bool b_enable);
extern void gatt_tcb_dump(int fd);
diff --git a/system/btif/src/btif_core.cc b/system/btif/src/btif_core.cc
index c73a5ce..c6e277c 100644
--- a/system/btif/src/btif_core.cc
+++ b/system/btif/src/btif_core.cc
@@ -110,12 +110,6 @@
static uid_set_t* uid_set;
/*******************************************************************************
- * Externs
- ******************************************************************************/
-void btif_dm_enable_service(tBTA_SERVICE_ID service_id, bool enable);
-void btif_dm_load_local_oob(void);
-
-/*******************************************************************************
*
* Function btif_is_dut_mode
*
diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc
index f08036d..082dded 100644
--- a/system/btif/src/btif_dm.cc
+++ b/system/btif/src/btif_dm.cc
@@ -61,6 +61,7 @@
#include "btif_config.h"
#include "btif_dm.h"
#include "btif_metrics_logging.h"
+#include "btif_sdp.h"
#include "btif_storage.h"
#include "btif_util.h"
#include "common/lru_cache.h"
@@ -105,12 +106,6 @@
#include <android/sysprop/BluetoothProperties.sysprop.h>
#endif
-// TODO(b/369381361) Enfore -Wmissing-prototypes
-#pragma GCC diagnostic ignored "-Wmissing-prototypes"
-
-bool btif_get_address_type(const RawAddress& bda, tBLE_ADDR_TYPE* p_addr_type);
-bool btif_get_device_type(const RawAddress& bda, int* p_device_type);
-
using bluetooth::Uuid;
using namespace bluetooth;
@@ -297,7 +292,6 @@
/******************************************************************************
* Externs
*****************************************************************************/
-bt_status_t btif_sdp_execute_service(bool b_enable);
void btif_iot_update_remote_info(tBTA_DM_AUTH_CMPL* p_auth_cmpl, bool is_ble, bool is_ssp);
/******************************************************************************
@@ -323,7 +317,7 @@
}
}
-bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id, bool b_enable) {
+static bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id, bool b_enable) {
log::verbose("service_id:{}", service_id);
if (service_id == BTA_SDP_SERVICE_ID) {
@@ -496,14 +490,10 @@
return remote_cod;
}
-bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) {
+static bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) {
return (get_cod(remote_bdaddr) & COD_DEVICE_MASK) == cod;
}
-bool check_cod_hid(const RawAddress* remote_bdaddr) {
- return (get_cod(remote_bdaddr) & COD_HID_MASK) == COD_HID_MAJOR;
-}
-
bool check_cod_hid(const RawAddress& bd_addr) {
return (get_cod(&bd_addr) & COD_HID_MASK) == COD_HID_MAJOR;
}
@@ -514,9 +504,10 @@
(remote_cod & COD_HID_SUB_MAJOR) == (cod & COD_HID_SUB_MAJOR);
}
-bool check_cod_le_audio(const RawAddress& bd_addr) {
+static bool check_cod_le_audio(const RawAddress& bd_addr) {
return (get_cod(&bd_addr) & COD_CLASS_LE_AUDIO) == COD_CLASS_LE_AUDIO;
}
+
/*****************************************************************************
*
* Function check_sdp_bl
@@ -1183,7 +1174,7 @@
state = BT_BOND_STATE_BONDED;
bd_addr = p_auth_cmpl->bd_addr;
- if (check_sdp_bl(&bd_addr) && check_cod_hid(&bd_addr)) {
+ if (check_sdp_bl(&bd_addr) && check_cod_hid(bd_addr)) {
log::warn("skip SDP");
skip_sdp = true;
}
@@ -1717,8 +1708,8 @@
}
}
-void btif_on_gatt_results(RawAddress bd_addr, std::vector<bluetooth::Uuid>& services,
- bool is_transport_le) {
+static void btif_on_gatt_results(RawAddress bd_addr, std::vector<bluetooth::Uuid>& services,
+ bool is_transport_le) {
std::vector<bt_property_t> prop;
std::vector<uint8_t> property_value;
std::set<Uuid> uuids;
@@ -1892,13 +1883,14 @@
}
}
-void btif_on_name_read_from_btm(const RawAddress& bd_addr, DEV_CLASS /* dc */, BD_NAME bd_name) {
+static void btif_on_name_read_from_btm(const RawAddress& bd_addr, DEV_CLASS /* dc */,
+ BD_NAME bd_name) {
log::info("{} {}", bd_addr, reinterpret_cast<char const*>(bd_name));
btif_on_name_read(bd_addr, HCI_SUCCESS, bd_name, false /* during_device_search */);
}
-void btif_on_did_received(RawAddress bd_addr, uint8_t vendor_id_src, uint16_t vendor_id,
- uint16_t product_id, uint16_t version) {
+static void btif_on_did_received(RawAddress bd_addr, uint8_t vendor_id_src, uint16_t vendor_id,
+ uint16_t product_id, uint16_t version) {
bt_vendor_product_info_t vp_info{
.vendor_id_src = vendor_id_src,
.vendor_id = vendor_id,
diff --git a/system/btif/src/btif_gatt_client.cc b/system/btif/src/btif_gatt_client.cc
index e7276bb..a873664 100644
--- a/system/btif/src/btif_gatt_client.cc
+++ b/system/btif/src/btif_gatt_client.cc
@@ -43,6 +43,7 @@
#include "bta/include/bta_sec_api.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_config.h"
+#include "btif/include/btif_dm.h"
#include "btif/include/btif_gatt.h"
#include "btif/include/btif_gatt_util.h"
#include "hci/controller_interface.h"
@@ -68,9 +69,6 @@
using namespace bluetooth;
using std::vector;
-bool btif_get_address_type(const RawAddress& bda, tBLE_ADDR_TYPE* p_addr_type);
-bool btif_get_device_type(const RawAddress& bda, int* p_device_type);
-
static bt_status_t btif_gattc_test_command_impl(int command, const btgatt_test_params_t* params);
extern const btgatt_callbacks_t* bt_gatt_callbacks;
diff --git a/system/btif/src/btif_gatt_server.cc b/system/btif/src/btif_gatt_server.cc
index fab86d7..558148e 100644
--- a/system/btif/src/btif_gatt_server.cc
+++ b/system/btif/src/btif_gatt_server.cc
@@ -38,6 +38,7 @@
#include "bta/include/bta_gatt_api.h"
#include "bta/include/bta_sec_api.h"
#include "btif/include/btif_common.h"
+#include "btif/include/btif_dm.h"
#include "btif/include/btif_gatt.h"
#include "btif/include/btif_gatt_util.h"
#include "osi/include/allocator.h"
@@ -49,9 +50,6 @@
#include "types/bt_transport.h"
#include "types/raw_address.h"
-bool btif_get_address_type(const RawAddress& bda, tBLE_ADDR_TYPE* p_addr_type);
-bool btif_get_device_type(const RawAddress& bda, int* p_device_type);
-
using base::Bind;
using bluetooth::Uuid;
using std::vector;
diff --git a/system/btif/src/btif_hd.cc b/system/btif/src/btif_hd.cc
index 742e9fd..1ddc10f 100644
--- a/system/btif/src/btif_hd.cc
+++ b/system/btif/src/btif_hd.cc
@@ -37,6 +37,7 @@
#include "bta/sys/bta_sys.h"
#include "bta_sec_api.h"
#include "btif/include/btif_common.h"
+#include "btif/include/btif_dm.h"
#include "btif/include/btif_profile_storage.h"
#include "btif/include/btif_util.h"
#include "include/hardware/bt_hd.h"
@@ -61,8 +62,6 @@
using namespace bluetooth;
bool bta_dm_check_if_only_hd_connected(const RawAddress& peer_addr);
-bool check_cod_hid(const RawAddress* remote_bdaddr);
-bool check_cod_hid(const RawAddress& bd_addr);
void btif_hh_service_registration(bool enable);
/* HD request events */
@@ -222,8 +221,8 @@
break;
case BTA_HD_OPEN_EVT: {
- RawAddress* addr = (RawAddress*)&p_data->conn.bda;
- log::warn("BTA_HD_OPEN_EVT, address={}", *addr);
+ RawAddress& addr = p_data->conn.bda;
+ log::warn("BTA_HD_OPEN_EVT, address={}", addr);
/* Check if the connection is from hid host and not hid device */
if (check_cod_hid(addr)) {
/* Incoming connection from hid device, reject it */
diff --git a/system/btif/src/btif_hf.cc b/system/btif/src/btif_hf.cc
index fb93ac1..317c00e 100644
--- a/system/btif/src/btif_hf.cc
+++ b/system/btif/src/btif_hf.cc
@@ -27,6 +27,8 @@
#define LOG_TAG "bt_btif_hf"
+#include "btif/include/btif_hf.h"
+
#include <android_bluetooth_sysprop.h>
#include <base/functional/callback.h>
#include <bluetooth/log.h>
@@ -55,15 +57,11 @@
#include "stack/include/btm_log_history.h"
#include "types/raw_address.h"
-// TODO(b/369381361) Enfore -Wmissing-prototypes
-#pragma GCC diagnostic ignored "-Wmissing-prototypes"
-
namespace {
constexpr char kBtmLogTag[] = "HFP";
}
-namespace bluetooth {
-namespace headset {
+namespace bluetooth::headset {
/*******************************************************************************
* Constants & Macros
@@ -271,7 +269,7 @@
return (value & (static_cast<uint32_t>(1) << n)) != 0;
}
-void clear_phone_state_multihf(btif_hf_cb_t* hf_cb) {
+static void clear_phone_state_multihf(btif_hf_cb_t* hf_cb) {
hf_cb->call_setup_state = BTHF_CALL_STATE_IDLE;
hf_cb->num_active = 0;
hf_cb->num_held = 0;
@@ -1622,5 +1620,4 @@
return HeadsetInterface::GetInstance();
}
-} // namespace headset
-} // namespace bluetooth
+} // namespace bluetooth::headset
diff --git a/system/btif/src/btif_hf_client.cc b/system/btif/src/btif_hf_client.cc
index 9a6eb12..79b9b54 100644
--- a/system/btif/src/btif_hf_client.cc
+++ b/system/btif/src/btif_hf_client.cc
@@ -42,9 +42,9 @@
*
******************************************************************************/
-#ifndef LOG_TAG
#define LOG_TAG "bt_btif_hfc"
-#endif
+
+#include "btif_hf_client.h"
#include <bluetooth/log.h>
#include <hardware/bluetooth.h>
@@ -68,9 +68,6 @@
#define BTIF_HF_CLIENT_SERVICE_NAME ("Handsfree")
#endif
-// TODO(b/369381361) Enfore -Wmissing-prototypes
-#pragma GCC diagnostic ignored "-Wmissing-prototypes"
-
using namespace bluetooth;
/*******************************************************************************
@@ -94,9 +91,8 @@
/******************************************************************************
* Local function declarations
******************************************************************************/
-btif_hf_client_cb_t* btif_hf_client_get_cb_by_handle(uint16_t handle);
-btif_hf_client_cb_t* btif_hf_client_get_cb_by_bda(const RawAddress& addr);
-bool is_connected(const btif_hf_client_cb_t* cb);
+static btif_hf_client_cb_t* btif_hf_client_get_cb_by_bda(const RawAddress& addr);
+static bool is_connected(const btif_hf_client_cb_t* cb);
/*******************************************************************************
* Static variables
@@ -183,7 +179,7 @@
/*******************************************************************************
* Functions
******************************************************************************/
-bool is_connected(const btif_hf_client_cb_t* cb) {
+static bool is_connected(const btif_hf_client_cb_t* cb) {
if ((cb->state == BTHF_CLIENT_CONNECTION_STATE_CONNECTED) ||
(cb->state == BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED)) {
return true;
@@ -195,28 +191,6 @@
/*******************************************************************************
*
- * Function btif_hf_client_get_cb_by_handle
- *
- * Description Get control block by handle
- *
- * Returns btif_hf_client_cb_t pointer if available NULL otherwise
- *
- ******************************************************************************/
-btif_hf_client_cb_t* btif_hf_client_get_cb_by_handle(uint16_t handle) {
- log::verbose("cb by handle {}", handle);
- for (int i = 0; i < HF_CLIENT_MAX_DEVICES; i++) {
- // Block is valid only if it is allocated i.e. state is not DISCONNECTED
- if (btif_hf_client_cb_arr.cb[i].state != BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED &&
- btif_hf_client_cb_arr.cb[i].handle == handle) {
- return &btif_hf_client_cb_arr.cb[i];
- }
- }
- log::error("could not find block for handle {}", handle);
- return NULL;
-}
-
-/*******************************************************************************
- *
* Function btif_hf_client_get_cb_by_bda
*
* Description Get control block by bda
@@ -224,7 +198,7 @@
* Returns btif_hf_client_cb_t pointer if available NULL otherwise
*
******************************************************************************/
-btif_hf_client_cb_t* btif_hf_client_get_cb_by_bda(const RawAddress& bd_addr) {
+static btif_hf_client_cb_t* btif_hf_client_get_cb_by_bda(const RawAddress& bd_addr) {
log::verbose("incoming addr {}", bd_addr);
for (int i = 0; i < HF_CLIENT_MAX_DEVICES; i++) {
@@ -247,7 +221,7 @@
* Returns btif_hf_client_cb_t pointer if available NULL otherwise
*
******************************************************************************/
-btif_hf_client_cb_t* btif_hf_client_allocate_cb() {
+static btif_hf_client_cb_t* btif_hf_client_allocate_cb() {
for (int i = 0; i < HF_CLIENT_MAX_DEVICES; i++) {
btif_hf_client_cb_t* cb = &btif_hf_client_cb_arr.cb[i];
if (cb->state == BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED) {
diff --git a/system/btif/src/btif_hh.cc b/system/btif/src/btif_hh.cc
index 93720f5..4a4bddd 100644
--- a/system/btif/src/btif_hh.cc
+++ b/system/btif/src/btif_hh.cc
@@ -143,17 +143,8 @@
******************************************************************************/
static void btif_hh_transport_select(tAclLinkSpec& link_spec);
-
-/*******************************************************************************
- * Externs
- ******************************************************************************/
-
-bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod);
-bool check_cod_hid(const RawAddress* remote_bdaddr);
-bool check_cod_hid_major(const RawAddress& bd_addr, uint32_t cod);
-
-static void bte_hh_evt(tBTA_HH_EVT event, tBTA_HH* p_data);
static void btif_hh_timer_timeout(void* data);
+static void bte_hh_evt(tBTA_HH_EVT event, tBTA_HH* p_data);
/*******************************************************************************
* Functions
@@ -870,7 +861,7 @@
BTHH_STATE_UPDATE(p_dev->link_spec, p_dev->dev_status);
if (!com::android::bluetooth::flags::remove_input_device_on_vup()) {
- if (p_dev->local_vup || check_cod_hid(&(p_dev->link_spec.addrt.bda))) {
+ if (p_dev->local_vup || check_cod_hid(p_dev->link_spec.addrt.bda)) {
p_dev->local_vup = false;
BTA_DmRemoveDevice(p_dev->link_spec.addrt.bda);
} else {
@@ -890,7 +881,7 @@
// Remove the HID device
btif_hh_remove_device(p_dev->link_spec);
- if (p_dev->local_vup || check_cod_hid(&(p_dev->link_spec.addrt.bda))) {
+ if (p_dev->local_vup || check_cod_hid(p_dev->link_spec.addrt.bda)) {
// Remove the bond if locally initiated or remote device has major class HID
p_dev->local_vup = false;
BTA_DmRemoveDevice(p_dev->link_spec.addrt.bda);
diff --git a/system/btif/src/btif_profile_storage.cc b/system/btif/src/btif_profile_storage.cc
index 4c5fad6..d0949d6 100644
--- a/system/btif/src/btif_profile_storage.cc
+++ b/system/btif/src/btif_profile_storage.cc
@@ -385,8 +385,6 @@
*
******************************************************************************/
-bool btif_get_address_type(const RawAddress& bda, tBLE_ADDR_TYPE* p_addr_type);
-
std::vector<std::pair<RawAddress, uint8_t>> btif_storage_get_le_hid_devices(void) {
std::vector<std::pair<RawAddress, uint8_t>> hid_addresses;
for (const auto& bd_addr : btif_config_get_paired_devices()) {
diff --git a/system/btif/src/btif_rc.cc b/system/btif/src/btif_rc.cc
index 4eaf0e6..5c82b54 100644
--- a/system/btif/src/btif_rc.cc
+++ b/system/btif/src/btif_rc.cc
@@ -375,7 +375,6 @@
/*****************************************************************************
* Externs
*****************************************************************************/
-bool check_cod(const RawAddress& remote_bdaddr, uint32_t cod);
void btif_rc_get_addr_by_handle(uint8_t handle, RawAddress& rc_addr) {
log::verbose("handle: 0x{:x}", handle);
diff --git a/system/btif/src/btif_sdp.cc b/system/btif/src/btif_sdp.cc
index db75f5e..a7e61c3 100644
--- a/system/btif/src/btif_sdp.cc
+++ b/system/btif/src/btif_sdp.cc
@@ -28,6 +28,8 @@
#define LOG_TAG "bt_btif_sdp"
+#include "btif/include/btif_sdp.h"
+
#include <bluetooth/log.h>
#include <hardware/bluetooth.h>
#include <hardware/bt_sdp.h>
@@ -40,9 +42,6 @@
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"
-// TODO(b/369381361) Enfore -Wmissing-prototypes
-#pragma GCC diagnostic ignored "-Wmissing-prototypes"
-
using bluetooth::Uuid;
using namespace bluetooth;
diff --git a/system/btif/src/btif_sock.cc b/system/btif/src/btif_sock.cc
index 95f2789..04b43dd 100644
--- a/system/btif/src/btif_sock.cc
+++ b/system/btif/src/btif_sock.cc
@@ -114,7 +114,7 @@
return BT_STATUS_SUCCESS;
-error:;
+error:
thread_free(thread);
thread = NULL;
if (thread_handle != -1) {
diff --git a/system/btif/test/btif_dm_test.cc b/system/btif/test/btif_dm_test.cc
index 9d1a3d5..5d7595b 100644
--- a/system/btif/test/btif_dm_test.cc
+++ b/system/btif/test/btif_dm_test.cc
@@ -41,22 +41,9 @@
constexpr char kBdName[] = {'k', 'B', 'd', 'N', 'a', 'm', 'e', '\0'};
} // namespace
-namespace bluetooth {
-namespace legacy {
-namespace testing {
-
+namespace bluetooth::legacy::testing {
void set_interface_to_profiles(bluetooth::core::CoreInterface* interfaceToProfiles);
-
-void bta_energy_info_cb(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time,
- tBTM_BLE_IDLE_TIME_MS idle_time, tBTM_BLE_ENERGY_USED energy_used,
- tBTM_CONTRL_STATE ctrl_state, tBTA_STATUS status);
-
-void btif_on_name_read(RawAddress bd_addr, tHCI_ERROR_CODE hci_status, const BD_NAME bd_name,
- bool during_device_search);
-
-} // namespace testing
-} // namespace legacy
-} // namespace bluetooth
+} // namespace bluetooth::legacy::testing
namespace {
constexpr tBTM_BLE_TX_TIME_MS tx_time = 0x12345678;
diff --git a/system/common/Android.bp b/system/common/Android.bp
index f50de9f..3009c77 100644
--- a/system/common/Android.bp
+++ b/system/common/Android.bp
@@ -57,7 +57,6 @@
"libbluetooth_crypto_toolbox",
"libbluetooth_log",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
],
}
@@ -107,7 +106,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libchrome",
"libevent",
"libgmock",
diff --git a/system/common/BUILD.gn b/system/common/BUILD.gn
index 52c14aa..8352d2b 100644
--- a/system/common/BUILD.gn
+++ b/system/common/BUILD.gn
@@ -34,7 +34,6 @@
deps = [
"//bt/system:libbt-platform-protos-lite",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
]
configs += [
diff --git a/system/device/Android.bp b/system/device/Android.bp
index 21d2344..f4b0679 100644
--- a/system/device/Android.bp
+++ b/system/device/Android.bp
@@ -39,7 +39,6 @@
"libaconfig_storage_read_api_cc",
"libbluetooth_hci_pdl",
"libbluetooth_log",
- "libbt_shim_bridge",
"libflatbuffers-cpp",
"server_configurable_flags",
],
@@ -66,8 +65,6 @@
"libbluetooth-types",
"libbluetooth_gd",
"libbluetooth_log",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libbtdevice",
"libchrome",
@@ -106,8 +103,6 @@
"libbluetooth-types",
"libbluetooth_log",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libbtdevice",
"libchrome",
diff --git a/system/device/BUILD.gn b/system/device/BUILD.gn
index 08cf229..12d38b3 100644
--- a/system/device/BUILD.gn
+++ b/system/device/BUILD.gn
@@ -34,8 +34,6 @@
deps = [
"//bt/flags:bluetooth_flags_c_lib",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
- "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
"//bt/system/pdl:BluetoothGeneratedPackets_h",
]
}
diff --git a/system/device/fuzzer/Android.bp b/system/device/fuzzer/Android.bp
index 64271ae..0b5e6c1 100644
--- a/system/device/fuzzer/Android.bp
+++ b/system/device/fuzzer/Android.bp
@@ -49,8 +49,6 @@
"libbluetooth_gd",
"libbluetooth_hci_pdl",
"libbluetooth_log",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtcore",
"libbtdevice",
"libchrome",
diff --git a/system/gd/Android.bp b/system/gd/Android.bp
index 1e4950d..d09e184 100644
--- a/system/gd/Android.bp
+++ b/system/gd/Android.bp
@@ -178,11 +178,8 @@
"libbluetooth-types",
"libbluetooth_crypto_toolbox",
"libbluetooth_log",
- "libbluetooth_rust_interop",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libcom.android.sysprop.bluetooth.wrapped",
"libosi",
"server_configurable_flags",
@@ -192,7 +189,6 @@
"packages/modules/Bluetooth/system/stack/include",
"packages/modules/Bluetooth/system/types",
],
- export_static_lib_headers: ["libbluetooth_rust_interop"],
}
cc_library {
@@ -329,11 +325,8 @@
"libbluetooth_l2cap_pdl",
"libbluetooth_log",
"libbluetooth_ras_pdl",
- "libbluetooth_rust_interop",
"libbluetooth_smp_pdl",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
"libflatbuffers-cpp",
@@ -501,12 +494,9 @@
"libbluetooth_l2cap_pdl",
"libbluetooth_log",
"libbluetooth_ras_pdl",
- "libbluetooth_rust_interop",
"libbluetooth_smp_pdl",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
"libflagtest",
@@ -569,8 +559,6 @@
"libbt-btu-main-thread",
"libbt-common",
"libbt-jni-thread",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libflatbuffers-cpp",
@@ -611,9 +599,6 @@
static_libs: [
"libbase",
"libbluetooth_log",
- "libbluetooth_rust_interop",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"liblog",
],
target: {
@@ -649,10 +634,7 @@
"libbluetooth_crypto_toolbox",
"libbluetooth_gd_fuzzing",
"libbluetooth_log",
- "libbluetooth_rust_interop",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
"libgmock",
@@ -746,7 +728,6 @@
"libbase",
"libbluetooth_gd",
"libbluetooth_log",
- "libbt_shim_bridge",
"libchrome",
"liblog",
"server_configurable_flags",
diff --git a/system/gd/BUILD.gn b/system/gd/BUILD.gn
index 914ec30..4e14df9 100644
--- a/system/gd/BUILD.gn
+++ b/system/gd/BUILD.gn
@@ -50,7 +50,6 @@
"//bt/system:libbt-platform-protos-lite",
"//bt/system/gd:BluetoothGeneratedDumpsysDataSchema_h",
"//bt/system/gd/dumpsys:libbluetooth-dumpsys",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
"//bt/system/pdl:BluetoothGeneratedPackets_h",
]
}
@@ -77,7 +76,6 @@
configs += [ ":gd_defaults" ]
deps = [
"//bt/system/gd/rust/topshim:libbluetooth_topshim",
- "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
"//bt/system/gd/common:BluetoothCommonSources",
"//bt/system/gd/dumpsys:BluetoothDumpsysSources",
"//bt/system/gd/hal:BluetoothHalSources",
diff --git a/system/gd/common/Android.bp b/system/gd/common/Android.bp
index 36da276..5e8b927 100644
--- a/system/gd/common/Android.bp
+++ b/system/gd/common/Android.bp
@@ -24,7 +24,6 @@
"blocking_queue_unittest.cc",
"byte_array_test.cc",
"circular_buffer_test.cc",
- "init_flags_test.cc",
"list_map_test.cc",
"lru_cache_test.cc",
"metric_id_manager_unittest.cc",
diff --git a/system/gd/common/init_flags.h b/system/gd/common/init_flags.h
deleted file mode 100644
index de3d561..0000000
--- a/system/gd/common/init_flags.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include "src/init_flags.rs.h"
-
-namespace bluetooth {
-namespace common {
-
-class InitFlags final {
-public:
- inline static void Load(const char** flags) {
- rust::Vec<rust::String> rusted_flags = rust::Vec<rust::String>();
- while (flags != nullptr && *flags != nullptr) {
- rusted_flags.push_back(rust::String(*flags));
- flags++;
- }
- init_flags::load(std::move(rusted_flags));
- }
-};
-
-} // namespace common
-} // namespace bluetooth
diff --git a/system/gd/hal/BUILD.gn b/system/gd/hal/BUILD.gn
index ecdc60e..f0a2f9d 100644
--- a/system/gd/hal/BUILD.gn
+++ b/system/gd/hal/BUILD.gn
@@ -24,7 +24,10 @@
]
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_hci_host") {
diff --git a/system/gd/hal/snoop_logger.cc b/system/gd/hal/snoop_logger.cc
index 44cd8ba..6b9fc8a 100644
--- a/system/gd/hal/snoop_logger.cc
+++ b/system/gd/hal/snoop_logger.cc
@@ -14,10 +14,16 @@
* limitations under the License.
*/
+#define ATRACE_TAG ATRACE_TAG_APP
+
#include "hal/snoop_logger.h"
#include <arpa/inet.h>
#include <bluetooth/log.h>
+#include <com_android_bluetooth_flags.h>
+#ifdef __ANDROID__
+#include <cutils/trace.h>
+#endif // __ANDROID__
#include <sys/stat.h>
#include <algorithm>
@@ -28,6 +34,7 @@
#include "common/circular_buffer.h"
#include "common/strings.h"
#include "hal/snoop_logger_common.h"
+#include "hci/hci_packets.h"
#include "module_dumper_flatbuffer.h"
#include "os/files.h"
#include "os/parameter_provider.h"
@@ -1123,6 +1130,13 @@
HciPacket mutable_packet(immutable_packet);
HciPacket& packet = mutable_packet;
//////////////////////////////////////////////////////////////////////////
+
+ #ifdef __ANDROID__
+ if (com::android::bluetooth::flags::snoop_logger_tracing()) {
+ LogTracePoint(packet, direction, type);
+ }
+ #endif // __ANDROID__
+
uint64_t timestamp_us = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
@@ -1401,5 +1415,55 @@
IsBtSnoopLogPersisted());
});
+#ifdef __ANDROID__
+void SnoopLogger::LogTracePoint(const HciPacket& packet, Direction direction, PacketType type) {
+ switch (type) {
+ case PacketType::EVT: {
+ uint8_t evt_code = packet[0];
+
+ if (evt_code == static_cast<uint8_t>(hci::EventCode::LE_META_EVENT) ||
+ evt_code == static_cast<uint8_t>(hci::EventCode::VENDOR_SPECIFIC)) {
+ uint8_t subevt_code = packet[2];
+ std::string message =
+ fmt::format("BTSL:{}/{}/{}/{:02x}/{:02x}", static_cast<uint8_t>(type),
+ static_cast<uint8_t>(direction), packet.size(), evt_code, subevt_code);
+
+ ATRACE_INSTANT_FOR_TRACK(LOG_TAG, message.c_str());
+ } else {
+ std::string message = fmt::format("BTSL:{}/{}/{}/{:02x}", static_cast<uint8_t>(type),
+ static_cast<uint8_t>(direction), packet.size(), evt_code);
+
+ ATRACE_INSTANT_FOR_TRACK(LOG_TAG, message.c_str());
+ }
+ } break;
+ case PacketType::CMD: {
+ uint16_t op_code = packet[0] | (packet[1] << 8);
+
+ std::string message = fmt::format("BTSL:{}/{}/{}/{:04x}", static_cast<uint8_t>(type),
+ static_cast<uint8_t>(direction), packet.size(), op_code);
+
+ ATRACE_INSTANT_FOR_TRACK(LOG_TAG, message.c_str());
+ } break;
+ case PacketType::ACL: {
+ uint16_t handle = (packet[0] | (packet[1] << 8)) & 0x0fff;
+ uint8_t pb_flag = (packet[1] & 0x30) >> 4;
+
+ std::string message = fmt::format("BTSL:{}/{}/{}/{:03x}/{}", static_cast<uint8_t>(type),
+ static_cast<uint8_t>(direction), packet.size(), handle,
+ pb_flag);
+
+ ATRACE_INSTANT_FOR_TRACK(LOG_TAG, message.c_str());
+ } break;
+ case PacketType::ISO:
+ case PacketType::SCO: {
+ std::string message = fmt::format("BTSL:{}/{}/{}", static_cast<uint8_t>(type),
+ static_cast<uint8_t>(direction), packet.size());
+
+ ATRACE_INSTANT_FOR_TRACK(LOG_TAG, message.c_str());
+ } break;
+ }
+}
+#endif // __ANDROID__
+
} // namespace hal
} // namespace bluetooth
diff --git a/system/gd/hal/snoop_logger.h b/system/gd/hal/snoop_logger.h
index 656b3b1..3566630 100644
--- a/system/gd/hal/snoop_logger.h
+++ b/system/gd/hal/snoop_logger.h
@@ -319,6 +319,10 @@
std::unique_ptr<SnoopLoggerSocketThread> snoop_logger_socket_thread_;
+ #ifdef __ANDROID__
+ void LogTracePoint(const HciPacket& packet, Direction direction, PacketType type);
+ #endif // __ANDROID__
+
private:
static std::string btsnoop_mode_;
std::string snoop_log_path_;
diff --git a/system/gd/os/BUILD.gn b/system/gd/os/BUILD.gn
index e56c688..6824184 100644
--- a/system/gd/os/BUILD.gn
+++ b/system/gd/os/BUILD.gn
@@ -27,7 +27,6 @@
]
deps = [
"//bt/system:libbt-platform-protos-lite",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
]
}
@@ -46,7 +45,6 @@
]
deps = [
"//bt/system:libbt-platform-protos-lite",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
]
}
diff --git a/system/gd/packet/BUILD.gn b/system/gd/packet/BUILD.gn
index 871209a..2dbe5b1 100644
--- a/system/gd/packet/BUILD.gn
+++ b/system/gd/packet/BUILD.gn
@@ -28,7 +28,6 @@
include_dirs = [ "//bt/system/gd" ]
- deps = [ "//bt/system/gd/rust/shim:init_flags_bridge_header" ]
configs += [
"//bt/system:target_defaults",
"//bt/system/log:log_defaults",
diff --git a/system/gd/rust/common/Android.bp b/system/gd/rust/common/Android.bp
index 188225e..a1e8c4a 100644
--- a/system/gd/rust/common/Android.bp
+++ b/system/gd/rust/common/Android.bp
@@ -7,6 +7,16 @@
default_applicable_licenses: ["system_bt_license"],
}
+rust_defaults {
+ name: "gd_rust_defaults",
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+ host_supported: true,
+}
+
rust_library {
name: "libbt_common",
defaults: ["libbt_common_defaults"],
diff --git a/system/gd/rust/common/src/init_flags.rs b/system/gd/rust/common/src/init_flags.rs
deleted file mode 100644
index feb0ed9..0000000
--- a/system/gd/rust/common/src/init_flags.rs
+++ /dev/null
@@ -1,241 +0,0 @@
-use log::{error, info};
-use paste::paste;
-use std::collections::{BTreeMap, HashMap};
-use std::fmt;
-use std::sync::LazyLock;
-use std::sync::Mutex;
-
-// Fallback to bool when type is not specified
-macro_rules! type_expand {
- () => {
- bool
- };
- ($type:ty) => {
- $type
- };
-}
-
-macro_rules! default_value {
- () => {
- false
- };
- ($type:ty) => {
- <$type>::default()
- };
- ($($type:ty)? = $default:tt) => {
- $default
- };
-}
-
-#[cfg(test)]
-macro_rules! call_getter_fn {
- ($flag:ident) => {
- paste! {
- [<$flag _is_enabled>]()
- }
- };
-}
-
-macro_rules! create_getter_fn {
- ($flag:ident) => {
- paste! {
- #[doc = concat!(" Return true if ", stringify!($flag), " is enabled")]
- pub fn [<$flag _is_enabled>]() -> bool {
- FLAGS.lock().unwrap().$flag
- }
- }
- };
-}
-
-macro_rules! init_flags {
- (
- name: $name:ident
- $($args:tt)*
- ) => {
- init_flags_struct! {
- name: $name
- $($args)*
- }
-
- init_flags_getters! {
- $($args)*
- }
- }
-}
-
-trait FlagHolder: Default {
- fn get_defaults_for_test() -> Self;
- fn parse(flags: Vec<String>) -> Self;
- fn dump(&self) -> BTreeMap<&'static str, String>;
-}
-
-macro_rules! init_flags_struct {
- (
- name: $name:ident
- flags: { $($flag:ident $(: $type:ty)? $(= $default:tt)?,)* }) => {
-
- struct $name {
- $($flag : type_expand!($($type)?),)*
- }
-
- impl $name {
- pub const fn new() -> Self {
- Self {
- $($flag : default_value!($($type)? $(= $default)?),)*
- }
- }
- }
-
- impl Default for $name {
- fn default() -> Self {
- Self::new()
- }
- }
-
- impl FlagHolder for $name {
- fn get_defaults_for_test() -> Self {
- Self {
- $($flag: true,)*
- }
- }
-
- fn dump(&self) -> BTreeMap<&'static str, String> {
- [
- $((stringify!($flag), format!("{}", self.$flag)),)*
- ].into()
- }
-
- fn parse(flags: Vec<String>) -> Self {
- let mut init_flags = Self::default();
-
- for flag in flags {
- let values: Vec<&str> = flag.split("=").collect();
- if values.len() != 2 {
- error!("Bad flag {}, must be in <FLAG>=<VALUE> format", flag);
- continue;
- }
-
- match values[0] {
- $(concat!("INIT_", stringify!($flag)) =>
- init_flags.$flag = values[1].parse().unwrap_or_else(|e| {
- error!("Parse failure on '{}': {}", flag, e);
- default_value!($($type)? $(= $default)?)}),)*
- _ => error!("Unsaved flag: {} = {}", values[0], values[1])
- }
- }
-
- init_flags
- }
- }
-
- impl fmt::Display for $name {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f,
- concat!($(concat!(stringify!($flag), "={}")),*),
- $(self.$flag),*)
- }
- }
-
- }
-}
-
-macro_rules! init_flags_getters {
- (flags: { $($flag:ident $(: $type:ty)? $(= $default:tt)?,)* }) => {
-
- $(create_getter_fn!($flag $($type)?);)*
-
- #[cfg(test)]
- mod tests_autogenerated {
- use super::*;
- $(paste! {
- #[test]
- pub fn [<test_get_ $flag>]() {
- let _guard = tests::ASYNC_LOCK.lock().unwrap();
- tests::test_load(vec![
- &*format!(concat!(concat!("INIT_", stringify!($flag)), "={}"), true)
- ]);
- let get_value = call_getter_fn!($flag);
- drop(_guard); // Prevent poisonning other tests if a panic occurs
- assert_eq!(get_value, true);
- }
- })*
- }
- }
-}
-
-#[allow(dead_code)]
-#[derive(Default)]
-struct ExplicitTagSettings {
- map: HashMap<String, i32>,
-}
-
-impl fmt::Display for ExplicitTagSettings {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{:?}", self.map)
- }
-}
-
-/// Sets all bool flags to true
-/// Set all other flags and extra fields to their default type value
-pub fn set_all_for_testing() {
- *FLAGS.lock().unwrap() = InitFlags::get_defaults_for_test();
-}
-
-init_flags!(
- name: InitFlags
- flags: {
- use_unified_connection_manager,
- }
-);
-
-/// Store some flag values
-static FLAGS: Mutex<InitFlags> = Mutex::new(InitFlags::new());
-/// Store the uid of bluetooth
-pub static AID_BLUETOOTH: Mutex<u32> = Mutex::new(1002);
-/// Store the prefix for file system
-pub static MISC: LazyLock<Mutex<String>> = LazyLock::new(|| Mutex::new("/data/misc/".to_string()));
-
-/// Loads the flag values from the passed-in vector of string values
-pub fn load(raw_flags: Vec<String>) {
- crate::init_logging();
-
- let flags = InitFlags::parse(raw_flags);
- info!("Flags loaded: {}", flags);
- *FLAGS.lock().unwrap() = flags;
-}
-
-/// Dumps all flag K-V pairs, storing values as strings
-pub fn dump() -> BTreeMap<&'static str, String> {
- FLAGS.lock().unwrap().dump()
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- /// do not run concurrent tests as they all use the same global init_flag struct and
- /// accessor
- pub(super) static ASYNC_LOCK: Mutex<bool> = Mutex::new(false);
-
- pub(super) fn test_load(raw_flags: Vec<&str>) {
- let raw_flags = raw_flags.into_iter().map(|x| x.to_string()).collect();
- load(raw_flags);
- }
-
- init_flags_struct!(
- name: InitFlagsForTest
- flags: {
- cat,
- }
- );
-
- #[test]
- fn test_dumpsys() {
- let flags = InitFlagsForTest { ..Default::default() };
-
- let out = flags.dump();
-
- assert_eq!(out.len(), 1);
- assert_eq!(out["cat"], "false");
- }
-}
diff --git a/system/gd/rust/common/src/lib.rs b/system/gd/rust/common/src/lib.rs
index c4001f5..165aaa5 100644
--- a/system/gd/rust/common/src/lib.rs
+++ b/system/gd/rust/common/src/lib.rs
@@ -1,7 +1,4 @@
//! Bluetooth common library
-/// Provides runtime configured-at-startup flags
-pub mod init_flags;
-
mod logging;
pub use logging::*;
diff --git a/system/gd/rust/linux/service/Cargo.toml b/system/gd/rust/linux/service/Cargo.toml
index 6904910..2ff5c1d 100644
--- a/system/gd/rust/linux/service/Cargo.toml
+++ b/system/gd/rust/linux/service/Cargo.toml
@@ -6,7 +6,6 @@
[dependencies]
bt_topshim = { path = "../../topshim" }
-bt_shim = { path = "../../shim" }
btstack = { path = "../stack" }
clap = "2.33.3"
dbus_projection = { path = "../dbus_projection" }
diff --git a/system/gd/rust/linux/service/src/main.rs b/system/gd/rust/linux/service/src/main.rs
index df78179..f326bb6 100644
--- a/system/gd/rust/linux/service/src/main.rs
+++ b/system/gd/rust/linux/service/src/main.rs
@@ -9,10 +9,6 @@
use tokio::runtime::Builder;
use tokio::sync::mpsc::Sender;
-// Necessary to link right entries.
-#[allow(clippy::single_component_path_imports, unused_imports)]
-use bt_shim;
-
use bt_topshim::{btif::get_btinterface, topstack};
use btstack::{
battery_manager::BatteryManager,
diff --git a/system/gd/rust/linux/stack/Cargo.toml b/system/gd/rust/linux/stack/Cargo.toml
index 2562617..da42d9f 100644
--- a/system/gd/rust/linux/stack/Cargo.toml
+++ b/system/gd/rust/linux/stack/Cargo.toml
@@ -6,7 +6,6 @@
[dependencies]
bt_common = { path = "../../common" }
bt_topshim = { path = "../../topshim" }
-bt_shim = { path = "../../shim" }
bt_utils = { path = "../utils" }
btif_macros = { path = "btif_macros" }
diff --git a/system/gd/rust/linux/stack/src/bluetooth_admin.rs b/system/gd/rust/linux/stack/src/bluetooth_admin.rs
index 5a8e238..ce34bc4 100644
--- a/system/gd/rust/linux/stack/src/bluetooth_admin.rs
+++ b/system/gd/rust/linux/stack/src/bluetooth_admin.rs
@@ -423,10 +423,7 @@
use crate::bluetooth_admin::{BluetoothAdmin, BluetoothAdminPolicyHelper};
use bt_topshim::btif::Uuid;
- // A workaround needed for linking. For more details, check the comment in
- // system/gd/rust/topshim/facade/src/main.rs
#[allow(unused)]
- use bt_shim::*;
use serde_json::{json, Value};
#[test]
diff --git a/system/gd/rust/shim/Android.bp b/system/gd/rust/shim/Android.bp
deleted file mode 100644
index 295f766..0000000
--- a/system/gd/rust/shim/Android.bp
+++ /dev/null
@@ -1,116 +0,0 @@
-package {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "system_bt_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: ["system_bt_license"],
-}
-
-rust_defaults {
- name: "gd_rust_defaults",
- target: {
- darwin: {
- enabled: false,
- },
- },
- host_supported: true,
-}
-
-cc_defaults {
- name: "gd_ffi_defaults",
- target: {
- darwin: {
- enabled: false,
- },
- },
-}
-
-rust_defaults {
- name: "libbt_shim_defaults",
- defaults: ["gd_rust_defaults"],
- crate_name: "bt_shim",
- srcs: ["src/lib.rs"],
- rustlibs: [
- "libbt_common",
- "libcxx",
- ],
- proc_macros: [
- "libpaste",
- ],
- apex_available: [
- "com.android.btservices",
- ],
- min_sdk_version: "30",
-}
-
-rust_library_rlib {
- name: "libbt_shim",
- defaults: ["libbt_shim_defaults"],
-}
-
-rust_ffi_static {
- name: "libbt_shim_ffi",
- defaults: ["libbt_shim_defaults"],
-}
-
-cc_library_static {
- name: "libbt_shim_bridge",
- defaults: [
- "gd_ffi_defaults",
- ],
- generated_headers: [
- "cxx-bridge-header",
- "libbt_init_flags_bridge_header",
- ],
- generated_sources: [
- "libbt_init_flags_bridge_code",
- ],
- export_generated_headers: [
- "cxx-bridge-header",
- "libbt_init_flags_bridge_header",
- ],
- include_dirs: [
- "packages/modules/Bluetooth/system/gd",
- ],
- cflags: [
- "-Wno-unused-const-variable",
- ],
- host_supported: true,
- apex_available: [
- "com.android.btservices",
- ],
- min_sdk_version: "30",
-}
-
-cc_library_static {
- name: "libbluetooth_rust_interop",
- defaults: [
- "gd_ffi_defaults",
- ],
- static_libs: [
- "libbt_shim_bridge",
- "libbt_shim_ffi",
- ],
- host_supported: true,
- apex_available: [
- "com.android.btservices",
- ],
- min_sdk_version: "30",
-}
-
-genrule {
- name: "libbt_init_flags_bridge_header",
- tools: ["cxxbridge"],
- cmd: "$(location cxxbridge) $(in) --header > $(out)",
- srcs: ["src/init_flags.rs"],
- out: ["src/init_flags.rs.h"],
-}
-
-genrule {
- name: "libbt_init_flags_bridge_code",
- tools: ["cxxbridge"],
- cmd: "$(location cxxbridge) $(in) >> $(out)",
- srcs: ["src/init_flags.rs"],
- out: ["init_flags.cc"],
-}
diff --git a/system/gd/rust/shim/BUILD.gn b/system/gd/rust/shim/BUILD.gn
deleted file mode 100644
index 363c639..0000000
--- a/system/gd/rust/shim/BUILD.gn
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright 2020 Google
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import("//common-mk/cxxbridge.gni")
-
-config("rust_shim_config") {
- include_dirs = [ "//bt/system/gd/rust/shim" ]
-}
-
-cxxbridge_header("init_flags_bridge_header") {
- sources = [ "src/init_flags.rs" ]
- all_dependent_configs = [ ":rust_shim_config" ]
- deps = [ ":cxxlibheader" ]
-}
-
-cxxbridge_cc("init_flags_bridge_code") {
- sources = [ "src/init_flags.rs" ]
- deps = [ ":init_flags_bridge_header" ]
- configs = [ "//bt/system/gd:gd_defaults" ]
-}
-
-cxxbridge_libheader("cxxlibheader") {
- deps = []
-}
-
-static_library("libbluetooth_rust_interop") {
- deps = [
- ":cxxlibheader",
- ":init_flags_bridge_code",
- ]
-}
diff --git a/system/gd/rust/shim/Cargo.toml b/system/gd/rust/shim/Cargo.toml
deleted file mode 100644
index 4731d79..0000000
--- a/system/gd/rust/shim/Cargo.toml
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright 2021 Google, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-[package]
-name = "bt_shim"
-version = "0.0.1"
-edition = "2018"
-
-[dependencies]
-# BT dependencies
-bt_common = { path = "../common" }
-
-# All external dependencies. Keep all versions at build/rust/Cargo.toml
-cxx = { version = "1.0.42", features = ["c++17"] }
-env_logger = "0.8"
-
-[lib]
-path = "src/lib.rs"
diff --git a/system/gd/rust/shim/src/init_flags.rs b/system/gd/rust/shim/src/init_flags.rs
deleted file mode 100644
index a4819bd..0000000
--- a/system/gd/rust/shim/src/init_flags.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-#[cxx::bridge(namespace = bluetooth::common::init_flags)]
-#[allow(unsafe_op_in_unsafe_fn)]
-mod ffi {
- struct InitFlagWithValue {
- flag: &'static str,
- value: String,
- }
-
- extern "Rust" {
- fn load(flags: Vec<String>);
- fn set_all_for_testing();
-
- fn dump() -> Vec<InitFlagWithValue>;
-
- fn use_unified_connection_manager_is_enabled() -> bool;
- }
-}
-
-use crate::init_flags::ffi::InitFlagWithValue;
-
-fn dump() -> Vec<InitFlagWithValue> {
- bt_common::init_flags::dump()
- .into_iter()
- .map(|(flag, value)| InitFlagWithValue { flag, value })
- .collect()
-}
-
-use bt_common::init_flags::*;
diff --git a/system/gd/rust/shim/src/lib.rs b/system/gd/rust/shim/src/lib.rs
deleted file mode 100644
index 4a3910a..0000000
--- a/system/gd/rust/shim/src/lib.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-//! The main entry point for the legacy C++ code
-
-mod init_flags;
diff --git a/system/gd/rust/topshim/Android.bp b/system/gd/rust/topshim/Android.bp
index 1ce5215..af5ed8c 100644
--- a/system/gd/rust/topshim/Android.bp
+++ b/system/gd/rust/topshim/Android.bp
@@ -39,9 +39,6 @@
cc_library_static {
name: "libbt_topshim_cxx",
- defaults: [
- "gd_ffi_defaults",
- ],
srcs: [
"btav/btav_shim.cc",
"btav_sink/btav_sink_shim.cc",
@@ -57,7 +54,6 @@
generated_headers: [
"BluetoothGeneratedDumpsysDataSchema_h",
"cxx-bridge-header",
- "libbt_init_flags_bridge_header",
"libbt_topshim_bridge_header",
],
generated_sources: ["libbt_topshim_bridge_code"],
@@ -75,6 +71,11 @@
"libchrome",
"libflatbuffers-cpp",
],
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
}
gensrcs {
diff --git a/system/gd/rust/topshim/facade/Android.bp b/system/gd/rust/topshim/facade/Android.bp
index 8e31ae7..cfecd44 100644
--- a/system/gd/rust/topshim/facade/Android.bp
+++ b/system/gd/rust/topshim/facade/Android.bp
@@ -21,7 +21,6 @@
rustlibs: [
"libbluetooth_core_rs_for_facade",
"libbt_common",
- "libbt_shim",
"libbt_topshim",
"libbt_topshim_facade_protobuf",
"libclap",
@@ -56,7 +55,6 @@
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbt_topshim_cxx",
"libbtcore",
"libbtdevice",
diff --git a/system/gd/rust/topshim/facade/src/main.rs b/system/gd/rust/topshim/facade/src/main.rs
index 65ac4c7..a8a97457 100644
--- a/system/gd/rust/topshim/facade/src/main.rs
+++ b/system/gd/rust/topshim/facade/src/main.rs
@@ -31,8 +31,6 @@
// This is fine for now since bt_shim doesn't export anything
#[allow(unused)]
use bluetooth_core_rs_for_facade::*;
-#[allow(unused)]
-use bt_shim::*;
fn main() {
// SAFETY: There is no signal handler installed before this.
diff --git a/system/gd/rust/topshim/src/btif.rs b/system/gd/rust/topshim/src/btif.rs
index b5df64f..5a6d76b 100644
--- a/system/gd/rust/topshim/src/btif.rs
+++ b/system/gd/rust/topshim/src/btif.rs
@@ -1215,7 +1215,6 @@
/// # Arguments
///
/// * `callbacks` - Dispatcher struct that accepts [`BaseCallbacks`]
- /// * `init_flags` - List of flags sent to libbluetooth for init.
/// * `hci_index` - Index of the hci adapter in use
pub fn initialize(&mut self, callbacks: BaseCallbacksDispatcher, hci_index: i32) -> bool {
if get_dispatchers().lock().unwrap().set::<BaseCb>(Arc::new(Mutex::new(callbacks))) {
diff --git a/system/gd/shim/BUILD.gn b/system/gd/shim/BUILD.gn
index addc752..2747594 100644
--- a/system/gd/shim/BUILD.gn
+++ b/system/gd/shim/BUILD.gn
@@ -22,7 +22,6 @@
"//bt/flags:bluetooth_flags_c_lib",
"//bt/system/gd/dumpsys:libbluetooth-dumpsys",
"//bt/system/gd/dumpsys/bundler:BluetoothGeneratedBundlerSchema_h_bfbs",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
]
configs += [
diff --git a/system/hci/Android.bp b/system/hci/Android.bp
index b0773d3..5e49328 100644
--- a/system/hci/Android.bp
+++ b/system/hci/Android.bp
@@ -34,7 +34,6 @@
header_libs: ["libbluetooth_headers"],
static_libs: [
"libbluetooth_log",
- "libbt_shim_bridge",
],
}
diff --git a/system/include/hardware/bluetooth.h b/system/include/hardware/bluetooth.h
index bf53607..7e89157 100644
--- a/system/include/hardware/bluetooth.h
+++ b/system/include/hardware/bluetooth.h
@@ -687,9 +687,8 @@
* config file. These devices are deleted upon leaving restricted mode.
* The |is_common_criteria_mode| flag inits the adapter in common criteria
* mode. The |config_compare_result| flag show the config checksum check
- * result if is in common criteria mode. The |init_flags| are config flags
- * that cannot change during run. The |is_atv| flag indicates whether the
- * local device is an Android TV
+ * result if is in common criteria mode. The |is_atv| flag indicates whether
+ * the local device is an Android TV
*/
int (*init)(bt_callbacks_t* callbacks, bool guest_mode, bool is_common_criteria_mode,
int config_compare_result, const char** init_flags, bool is_atv,
diff --git a/system/main/Android.bp b/system/main/Android.bp
index f1b07c0..62445e5 100644
--- a/system/main/Android.bp
+++ b/system/main/Android.bp
@@ -55,7 +55,6 @@
"libbluetooth_gd",
"libbluetooth_log",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libcom.android.sysprop.bluetooth.wrapped",
],
header_libs: ["libbluetooth_headers"],
@@ -149,7 +148,6 @@
"bluetooth_flags_c_lib",
"libbluetooth_log",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libcom.android.sysprop.bluetooth.wrapped",
],
}
@@ -209,14 +207,13 @@
"libbluetooth-dumpsys",
"libbluetooth-gdx",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_hci_pdl",
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
@@ -295,14 +292,13 @@
"libbluetooth-dumpsys",
"libbluetooth-gdx",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_hci_pdl",
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
diff --git a/system/main/shim/BUILD.gn b/system/main/shim/BUILD.gn
index 93ac01f..88bbba0 100644
--- a/system/main/shim/BUILD.gn
+++ b/system/main/shim/BUILD.gn
@@ -24,7 +24,6 @@
"//bt/system",
"//bt/system/btif/include",
"//bt/system/gd",
- "//bt/system/gd/rust/shim",
"//bt/system/stack/include",
"//bt/system/types",
]
@@ -36,7 +35,6 @@
"//bt/system/gd/hci:BluetoothHciSources",
"//bt/system/gd/os:BluetoothOsSources_linux_generic",
"//bt/system/gd/packet:BluetoothPacketSources",
- "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
"//bt/system/gd/rust/topshim:libbluetooth_topshim",
"//bt/system/osi",
"//bt/system/pdl:BluetoothGeneratedPackets_h",
@@ -71,7 +69,6 @@
"//bt/system",
"//bt/system/btif/include",
"//bt/system/gd",
- "//bt/system/gd/rust/shim",
"//bt/system/stack/include",
"//bt/system/types",
]
@@ -84,7 +81,6 @@
"//bt/system/gd/hci:BluetoothHciSources",
"//bt/system/gd/os:BluetoothOsSources_linux_generic",
"//bt/system/gd/packet:BluetoothPacketSources",
- "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
"//bt/system/gd/rust/topshim:libbluetooth_topshim",
"//bt/system/osi",
"//bt/system/pdl:BluetoothGeneratedPackets_h",
diff --git a/system/osi/Android.bp b/system/osi/Android.bp
index 9a9358b..04e9a1f 100644
--- a/system/osi/Android.bp
+++ b/system/osi/Android.bp
@@ -92,7 +92,6 @@
"libaconfig_storage_read_api_cc",
"libbluetooth_log",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"server_configurable_flags",
],
}
@@ -142,8 +141,6 @@
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
diff --git a/system/osi/BUILD.gn b/system/osi/BUILD.gn
index af410b5..fdd2736 100644
--- a/system/osi/BUILD.gn
+++ b/system/osi/BUILD.gn
@@ -56,7 +56,6 @@
deps = [
"//bt/flags:bluetooth_flags_c_lib",
"//bt/system/common",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
]
configs += [
diff --git a/system/profile/avrcp/Android.bp b/system/profile/avrcp/Android.bp
index 8840ae2..7420ac5 100644
--- a/system/profile/avrcp/Android.bp
+++ b/system/profile/avrcp/Android.bp
@@ -30,7 +30,6 @@
"lib-bt-packets",
"libbluetooth-types",
"libbluetooth_log",
- "libbt_shim_bridge",
"libosi",
],
whole_static_libs: [
@@ -81,8 +80,6 @@
"libbluetooth-types",
"libbluetooth_gd",
"libbluetooth_log",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libcutils",
@@ -130,8 +127,6 @@
"libbluetooth-types",
"libbluetooth_gd",
"libbluetooth_log",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libcutils",
"libevent",
diff --git a/system/profile/avrcp/BUILD.gn b/system/profile/avrcp/BUILD.gn
index 84bff49..3305fc0 100644
--- a/system/profile/avrcp/BUILD.gn
+++ b/system/profile/avrcp/BUILD.gn
@@ -40,7 +40,6 @@
deps = [
"//bt/flags:bluetooth_flags_c_lib",
- "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
]
configs += [
diff --git a/system/rust/Android.bp b/system/rust/Android.bp
index 4281cae..f3fddcd 100644
--- a/system/rust/Android.bp
+++ b/system/rust/Android.bp
@@ -22,7 +22,6 @@
"libbase",
],
static_libs: [
- "libbt_shim_bridge",
"libchrome",
"libevent",
"libmodpb64",
@@ -35,7 +34,6 @@
"libanyhow",
"libbitflags",
"libbt_common",
- "libbt_shim",
"libbytes",
"libcxx",
"liblog_rust",
@@ -45,11 +43,6 @@
whole_static_libs: [
"libbluetooth_core_rs_bridge",
],
- features: [
- // used to hide libbt_shim in Cargo builds, but
- // expose it to Soong to work around linker bug
- "via_android_bp",
- ],
target: {
android: {
shared_libs: [
@@ -130,8 +123,6 @@
static_libs: [
"libbluetooth_hci_pdl",
"libbluetooth_log",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libflatbuffers-cpp",
],
@@ -143,6 +134,7 @@
"BluetoothGeneratedDumpsysDataSchema_h",
],
export_generated_headers: [
+ "cxx-bridge-header",
"libbluetooth_core_rs_bridge_codegen_header",
],
host_supported: true,
diff --git a/system/rust/BUILD.gn b/system/rust/BUILD.gn
index 202e9df..5c386e5 100644
--- a/system/rust/BUILD.gn
+++ b/system/rust/BUILD.gn
@@ -43,7 +43,6 @@
deps = [
":cxxlibheader",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
"//bt/system/pdl:BluetoothGeneratedPackets_h",
]
diff --git a/system/rust/src/lib.rs b/system/rust/src/lib.rs
index b3361ba..b8154a1 100644
--- a/system/rust/src/lib.rs
+++ b/system/rust/src/lib.rs
@@ -26,13 +26,6 @@
use tokio::sync::mpsc;
-#[cfg(feature = "via_android_bp")]
-mod do_not_use {
- // DO NOT USE
- #[allow(unused)]
- use bt_shim::*;
-}
-
pub mod connection;
pub mod core;
pub mod gatt;
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index 152b866..20f12e4 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -21,7 +21,6 @@
],
static_libs: [
"libbluetooth_log",
- "libbt_shim_bridge",
],
shared_libs: [
"libchrome",
@@ -147,7 +146,6 @@
"libbt-hci",
"libbt-platform-protos-lite",
"libbt-stack-core",
- "libbt_shim_bridge",
"liblc3",
],
whole_static_libs: [
@@ -329,6 +327,7 @@
],
generated_headers: [
"BluetoothGeneratedDumpsysDataSchema_h",
+ "cxx-bridge-header",
],
cflags: [
/* we export all classes, so change default visibility, instead of having EXPORT_SYMBOL on each class*/
@@ -344,7 +343,6 @@
"libbluetooth_log",
"libbt-hci",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libcom.android.sysprop.bluetooth.wrapped",
"server_configurable_flags",
],
@@ -454,8 +452,6 @@
"libbluetooth-types",
"libbluetooth_log",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
],
shared_libs: [
"libaconfig_storage_read_api_cc",
@@ -510,14 +506,13 @@
"bluetooth_flags_c_lib",
"libaconfig_storage_read_api_cc",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_hci_pdl",
"libbluetooth_l2cap_pdl",
"libbluetooth_log",
"libbluetooth_smp_pdl",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
],
}
@@ -565,14 +560,13 @@
static_libs: [
"bluetooth_flags_c_lib",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_hci_pdl",
"libbluetooth_l2cap_pdl",
"libbluetooth_log",
"libbluetooth_smp_pdl",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
],
}
@@ -621,8 +615,6 @@
"libbluetooth_smp_pdl",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libevent",
],
}
@@ -665,8 +657,6 @@
"libbluetooth_log",
"libbluetooth_smp_pdl",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
],
}
@@ -716,8 +706,6 @@
"libbluetooth_log",
"libbluetooth_smp_pdl",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libcom.android.sysprop.bluetooth.wrapped",
],
}
@@ -760,8 +748,6 @@
"libbluetooth_log",
"libbluetooth_smp_pdl",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
],
shared_libs: [
"libaconfig_storage_read_api_cc",
@@ -846,7 +832,6 @@
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbtcore",
"libbtdevice",
"libbtif",
@@ -952,8 +937,6 @@
"libbt-btu-main-thread",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
@@ -1044,8 +1027,6 @@
"libbt-btu-main-thread",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
@@ -1125,8 +1106,6 @@
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
@@ -1179,12 +1158,11 @@
"bluetooth_flags_c_lib_for_test",
"libbase",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
@@ -1257,8 +1235,6 @@
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
@@ -1370,8 +1346,6 @@
"libbt-common",
"libbt-sbc-decoder",
"libbt-sbc-encoder",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libgmock",
"liblog",
@@ -1423,7 +1397,6 @@
"libbluetooth_crypto_toolbox",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
"libchrome",
"liblog",
"libosi",
@@ -1482,13 +1455,12 @@
"bluetooth_flags_c_lib_for_test",
"libbase",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
@@ -1548,7 +1520,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libchrome",
"libgmock",
"liblog",
@@ -1625,8 +1596,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libevent",
"libgmock",
@@ -1750,6 +1719,7 @@
"bluetooth_flags_c_lib_for_test",
"libbase",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
@@ -1757,8 +1727,6 @@
"libbt-platform-protos-lite",
"libbt-sbc-decoder",
"libbt-sbc-encoder",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
@@ -1773,6 +1741,7 @@
shared_libs: [
"libaconfig_storage_read_api_cc",
"libcrypto",
+ "libcutils",
"server_configurable_flags",
],
sanitize: {
@@ -1814,7 +1783,6 @@
"libbluetooth_crypto_toolbox",
"libbluetooth_log",
"libbt-common",
- "libbt_shim_bridge",
"libbtdevice",
"libbte",
"libchrome",
@@ -1874,8 +1842,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libbte",
"libchrome",
@@ -1954,8 +1920,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libevent",
@@ -2040,13 +2004,12 @@
"bluetooth_flags_c_lib_for_test",
"libbase",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libevent",
@@ -2140,8 +2103,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libevent",
@@ -2231,12 +2192,11 @@
static_libs: [
"bluetooth_flags_c_lib",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_gd",
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libcutils",
@@ -2332,6 +2292,7 @@
"bluetooth_flags_c_lib_for_test",
"libbase",
"libbluetooth-types",
+ "libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
@@ -2339,8 +2300,6 @@
"libbt-platform-protos-lite",
"libbt-sbc-decoder",
"libbt-sbc-encoder",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libbtdevice",
"libchrome",
"libcom.android.sysprop.bluetooth.wrapped",
@@ -2355,6 +2314,7 @@
shared_libs: [
"libaconfig_storage_read_api_cc",
"libcrypto",
+ "libcutils",
"server_configurable_flags",
],
sanitize: {
@@ -2411,8 +2371,6 @@
"libbluetooth_log",
"libbt-common",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
- "libbt_shim_ffi",
"libchrome",
"libflagtest",
"libgmock",
diff --git a/system/stack/BUILD.gn b/system/stack/BUILD.gn
index ebb070c..cc96633 100644
--- a/system/stack/BUILD.gn
+++ b/system/stack/BUILD.gn
@@ -40,7 +40,6 @@
]
deps = [
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
"//bt/system/stack/mmc",
]
@@ -223,9 +222,9 @@
deps = [
"//bt/sysprop:libcom.android.sysprop.bluetooth",
"//bt/system/gd/crypto_toolbox:crypto_toolbox",
+ "//bt/system/gd/rust/topshim:cxxlibheader",
":nonstandard_codecs",
"//bt/system:libbt-platform-protos-lite",
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
"//bt/system/stack/mmc",
"//bt/system/types",
]
diff --git a/system/stack/btm/btm_inq.cc b/system/stack/btm/btm_inq.cc
index 255b9cb..b545696 100644
--- a/system/stack/btm/btm_inq.cc
+++ b/system/stack/btm/btm_inq.cc
@@ -35,7 +35,7 @@
#include <mutex>
-#include "btif/include/btif_acl.h"
+#include "btif/include/btif_dm.h"
#include "common/time_util.h"
#include "hci/controller_interface.h"
#include "hci/event_checkers.h"
diff --git a/system/stack/mmc/codec_server/BUILD.gn b/system/stack/mmc/codec_server/BUILD.gn
index a8f6b14..0d7a3a7 100644
--- a/system/stack/mmc/codec_server/BUILD.gn
+++ b/system/stack/mmc/codec_server/BUILD.gn
@@ -27,7 +27,6 @@
"//bt/system/stack/include",
]
deps = [
- "//bt/system/gd/rust/shim:init_flags_bridge_header",
"//bt/system/stack/mmc/proto:mmc_config_proto",
]
sources = [ "a2dp_aac_mmc_encoder.cc" ]
diff --git a/system/stack/test/fuzzers/Android.bp b/system/stack/test/fuzzers/Android.bp
index 92de791..8d14683 100644
--- a/system/stack/test/fuzzers/Android.bp
+++ b/system/stack/test/fuzzers/Android.bp
@@ -57,7 +57,6 @@
"libbt-sbc-encoder",
"libbt-stack",
"libbt-stack-core",
- "libbt_shim_bridge",
"libbtcore",
"libbtdevice",
"libbte",
diff --git a/system/test/Android.bp b/system/test/Android.bp
index 2970d10..a78ed4e 100644
--- a/system/test/Android.bp
+++ b/system/test/Android.bp
@@ -553,13 +553,6 @@
}
filegroup {
- name: "TestCommonInitFlags",
- srcs: [
- "common/init_flags.cc",
- ],
-}
-
-filegroup {
name: "TestCommonStackConfig",
srcs: [
"common/stack_config.cc",
diff --git a/system/test/common/init_flags.cc b/system/test/common/init_flags.cc
deleted file mode 100644
index 97be602..0000000
--- a/system/test/common/init_flags.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-#include "common/init_flags.h"
-
-#include <map>
-#include <string>
-
-namespace bluetooth {
-namespace common {
-
-bool InitFlags::logging_debug_enabled_for_all = false;
-std::unordered_map<std::string, bool> InitFlags::logging_debug_explicit_tag_settings = {};
-void InitFlags::Load(const char** flags) {}
-void InitFlags::SetAll(bool value) { InitFlags::logging_debug_enabled_for_all = value; }
-
-} // namespace common
-} // namespace bluetooth
diff --git a/system/test/headless/Android.bp b/system/test/headless/Android.bp
index 3349dc6..9e0a234 100644
--- a/system/test/headless/Android.bp
+++ b/system/test/headless/Android.bp
@@ -88,7 +88,6 @@
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
"libbluetooth_log",
- "libbluetooth_rust_interop",
"libbt-audio-asrc",
"libbt-audio-hal-interface",
"libbt-bta",
diff --git a/system/test/headless/headless.cc b/system/test/headless/headless.cc
index 0ff3155..dd15c2a 100644
--- a/system/test/headless/headless.cc
+++ b/system/test/headless/headless.cc
@@ -258,7 +258,7 @@
const bool is_atv = false;
int status = bluetoothInterface.init(&bt_callbacks, start_restricted, is_common_criteria_mode,
- config_compare_result, {}, is_atv, nullptr);
+ config_compare_result, nullptr, is_atv, nullptr);
if (status == BT_STATUS_SUCCESS) {
log::info("Initialized bluetooth callbacks");
diff --git a/system/test/mock/mock_btif_dm.cc b/system/test/mock/mock_btif_dm.cc
index f4baf57..cc3bf79 100644
--- a/system/test/mock/mock_btif_dm.cc
+++ b/system/test/mock/mock_btif_dm.cc
@@ -40,14 +40,6 @@
inc_func_call_count(__func__);
return false;
}
-bool check_cod(const RawAddress* /* remote_bdaddr */, uint32_t /* cod */) {
- inc_func_call_count(__func__);
- return false;
-}
-bool check_cod_hid(const RawAddress* /* remote_bdaddr */) {
- inc_func_call_count(__func__);
- return false;
-}
bool check_cod_hid(const RawAddress& /* remote_bdaddr */) {
inc_func_call_count(__func__);
return false;
diff --git a/system/test/suite/Android.bp b/system/test/suite/Android.bp
index 6ad7fdb..6729fa6 100644
--- a/system/test/suite/Android.bp
+++ b/system/test/suite/Android.bp
@@ -129,7 +129,6 @@
"libbt-btu-main-thread",
"libbt-jni-thread",
"libbt-platform-protos-lite",
- "libbt_shim_bridge",
"libchrome",
"libevent",
"libflags_rust_cpp_bridge",
diff --git a/system/test/suite/adapter/bluetooth_test.cc b/system/test/suite/adapter/bluetooth_test.cc
index cea06fa..ce7f0c4 100644
--- a/system/test/suite/adapter/bluetooth_test.cc
+++ b/system/test/suite/adapter/bluetooth_test.cc
@@ -96,8 +96,8 @@
}
void BluetoothTest::ClearSemaphore(btsemaphore& sem) {
- while (sem.try_wait())
- ;
+ while (sem.try_wait()) {
+ }
}
const bt_interface_t* BluetoothTest::bt_interface() { return &bluetoothInterface; }
diff --git a/system/test/tool/mockcify.pl b/system/test/tool/mockcify.pl
index 1f99784..dadd768 100755
--- a/system/test/tool/mockcify.pl
+++ b/system/test/tool/mockcify.pl
@@ -210,7 +210,6 @@
sub reject_include_list {
my @incs = ();
foreach (@_) {
- next if (/init_flags/);
push(@incs, $_);
}
return @incs;
@@ -239,7 +238,6 @@
## Verious external or generated header not needed for mocks
foreach((
"test/mock/mock.h",
- "src/init_flags.rs.h",
"src/message_loop_thread.rs.h",
"android/hardware/bluetooth/audio/2.2/IBluetoothAudioProvidersFactory.h",
"android/hardware/bluetooth/audio/2.2/types.h",
diff --git a/system/udrv/Android.bp b/system/udrv/Android.bp
index 0e8be07..5a69d8e 100644
--- a/system/udrv/Android.bp
+++ b/system/udrv/Android.bp
@@ -30,6 +30,5 @@
header_libs: ["libbluetooth_headers"],
static_libs: [
"libbluetooth_log",
- "libbt_shim_bridge",
],
}