diff options
author | 2024-11-13 01:18:45 +0000 | |
---|---|---|
committer | 2024-11-20 23:23:22 +0000 | |
commit | b052e5857c3c1baf69205ae8e8291f5b566faf28 (patch) | |
tree | 4a3ffaa83ecabe17aafed4d3c624b50eb83e4dbb | |
parent | 5b2d839b311024806acbfa57f09bc5e10308e4b5 (diff) |
system: Migrate from {fmt} to std::format
Bug: 305066880
Test: m com.android.btservices
Flag: EXEMPT, log change
Change-Id: If1dbab99250a4f62626206fc9f73d27e71ebab56
191 files changed, 659 insertions, 590 deletions
diff --git a/android/app/jni/com_android_bluetooth_avrcp_controller.cpp b/android/app/jni/com_android_bluetooth_avrcp_controller.cpp index a0b80f7902..5150a01c6e 100644 --- a/android/app/jni/com_android_bluetooth_avrcp_controller.cpp +++ b/android/app/jni/com_android_bluetooth_avrcp_controller.cpp @@ -779,7 +779,7 @@ static jboolean sendPassThroughCommandNative(JNIEnv* env, jobject /* object */, return JNI_FALSE; } - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); log::info("key_code: {}, key_state: {}", key_code, key_state); @@ -808,7 +808,7 @@ static jboolean sendGroupNavigationCommandNative(JNIEnv* env, jobject /* object return JNI_FALSE; } - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); log::info("key_code: {}, key_state: {}", key_code, key_state); @@ -833,7 +833,7 @@ static jboolean sendGroupNavigationCommandNative(JNIEnv* env, jobject /* object static void setPlayerApplicationSettingValuesNative(JNIEnv* env, jobject /* object */, jbyteArray address, jbyte num_attrib, jbyteArray attrib_ids, jbyteArray attrib_val) { - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); if (!sBluetoothAvrcpInterface) { return; } @@ -893,7 +893,7 @@ static void sendAbsVolRspNative(JNIEnv* env, jobject /* object */, jbyteArray ad return; } - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -916,7 +916,7 @@ static void sendRegisterAbsVolRspNative(JNIEnv* env, jobject /* object */, jbyte jniThrowIOException(env, EINVAL); return; } - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -939,7 +939,7 @@ static void getCurrentMetadataNative(JNIEnv* env, jobject /* object */, jbyteArr jniThrowIOException(env, EINVAL); return; } - log::verbose("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::verbose("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -961,7 +961,7 @@ static void getPlaybackStateNative(JNIEnv* env, jobject /* object */, jbyteArray jniThrowIOException(env, EINVAL); return; } - log::verbose("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::verbose("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -982,7 +982,7 @@ static void getNowPlayingListNative(JNIEnv* env, jobject /* object */, jbyteArra jniThrowIOException(env, EINVAL); return; } - log::verbose("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::verbose("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -1004,7 +1004,7 @@ static void getFolderListNative(JNIEnv* env, jobject /* object */, jbyteArray ad jniThrowIOException(env, EINVAL); return; } - log::verbose("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::verbose("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -1025,7 +1025,7 @@ static void getPlayerListNative(JNIEnv* env, jobject /* object */, jbyteArray ad jniThrowIOException(env, EINVAL); return; } - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -1053,7 +1053,7 @@ static void changeFolderPathNative(JNIEnv* env, jobject /* object */, jbyteArray // return; //} - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); @@ -1077,7 +1077,7 @@ static void setBrowsedPlayerNative(JNIEnv* env, jobject /* object */, jbyteArray RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); bt_status_t status = sBluetoothAvrcpInterface->set_browsed_player_cmd(rawAddress, (uint16_t)id); if (status != BT_STATUS_SUCCESS) { log::error("Failed sending setBrowsedPlayerNative command, status: {}", bt_status_text(status)); @@ -1098,7 +1098,7 @@ static void setAddressedPlayerNative(JNIEnv* env, jobject /* object */, jbyteArr RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); bt_status_t status = sBluetoothAvrcpInterface->set_addressed_player_cmd(rawAddress, (uint16_t)id); if (status != BT_STATUS_SUCCESS) { log::error("Failed sending setAddressedPlayerNative command, status: {}", @@ -1126,7 +1126,7 @@ static void playItemNative(JNIEnv* env, jobject /* object */, jbyteArray address RawAddress rawAddress; rawAddress.FromOctets((uint8_t*)addr); - log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface)); + log::info("sBluetoothAvrcpInterface: {}", std::format_ptr(sBluetoothAvrcpInterface)); bt_status_t status = sBluetoothAvrcpInterface->play_item_cmd( rawAddress, (uint8_t)scope, (uint8_t*)&uid, (uint16_t)uidCounter); if (status != BT_STATUS_SUCCESS) { diff --git a/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp b/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp index da4b61e146..0d31f17a43 100644 --- a/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +++ b/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp @@ -49,12 +49,12 @@ using bluetooth::Uuid; extern bt_interface_t bluetoothInterface; -namespace fmt { +namespace std { template <> struct formatter<bt_state_t> : enum_formatter<bt_state_t> {}; template <> struct formatter<bt_discovery_state_t> : enum_formatter<bt_discovery_state_t> {}; -} // namespace fmt +} // namespace std static Uuid from_java_uuid(jlong uuid_msb, jlong uuid_lsb) { std::array<uint8_t, Uuid::kNumBytes128> uu; @@ -825,7 +825,7 @@ static void callback_thread_event(bt_cb_thread_evt event) { vm->AttachCurrentThread(&callbackEnv, &args); sHaveCallbackThread = true; sCallbackThread = pthread_self(); - log::verbose("Callback thread attached: {}", fmt::ptr(callbackEnv)); + log::verbose("Callback thread attached: {}", std::format_ptr(callbackEnv)); } else if (event == DISASSOCIATE_JVM) { if (!isCallbackThread()) { log::error("Callback: '' is not called on the correct thread"); diff --git a/system/audio_hal_interface/a2dp_encoding.h b/system/audio_hal_interface/a2dp_encoding.h index 5c8e68cc2f..d7812bbb9e 100644 --- a/system/audio_hal_interface/a2dp_encoding.h +++ b/system/audio_hal_interface/a2dp_encoding.h @@ -198,8 +198,8 @@ tA2DP_STATUS parse_a2dp_configuration(btav_a2dp_codec_index_t codec_index, } // namespace audio } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<::bluetooth::audio::a2dp::BluetoothAudioStatus> : enum_formatter<::bluetooth::audio::a2dp::BluetoothAudioStatus> {}; -} // namespace fmt +} // namespace std diff --git a/system/audio_hal_interface/a2dp_encoding_host.cc b/system/audio_hal_interface/a2dp_encoding_host.cc index 65c5eba23f..2436aa0af8 100644 --- a/system/audio_hal_interface/a2dp_encoding_host.cc +++ b/system/audio_hal_interface/a2dp_encoding_host.cc @@ -48,12 +48,12 @@ typedef enum { A2DP_CTRL_GET_PRESENTATION_POSITION, } tA2DP_CTRL_CMD; -namespace fmt { +namespace std { template <> struct formatter<tUIPC_EVENT> : enum_formatter<tUIPC_EVENT> {}; template <> struct formatter<tA2DP_CTRL_CMD> : enum_formatter<tA2DP_CTRL_CMD> {}; -} // namespace fmt +} // namespace std namespace { 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 cde3eedd39..8f4d075a1e 100644 --- a/system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc +++ b/system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc @@ -40,14 +40,14 @@ typedef enum { A2DP_CTRL_GET_PRESENTATION_POSITION, } tA2DP_CTRL_CMD; -namespace fmt { +namespace std { template <> struct formatter<tA2DP_CTRL_CMD> : enum_formatter<tA2DP_CTRL_CMD> {}; template <> struct formatter<audio_usage_t> : enum_formatter<audio_usage_t> {}; template <> struct formatter<audio_content_type_t> : enum_formatter<audio_content_type_t> {}; -} // namespace fmt +} // namespace std namespace bluetooth { namespace audio { 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 42af94d9a7..6303bbda09 100644 --- a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc +++ b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc @@ -215,7 +215,7 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { } log::info("IBluetoothAudioProvidersFactory::openProvider() returned {}{}", - fmt::ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); + std::format_ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); } void BluetoothAudioClientInterface::binderDiedCallbackAidl(void* ptr) { diff --git a/system/audio_hal_interface/aidl/audio_ctrl_ack.h b/system/audio_hal_interface/aidl/audio_ctrl_ack.h index 5cd051ca83..336bb1ffdd 100644 --- a/system/audio_hal_interface/aidl/audio_ctrl_ack.h +++ b/system/audio_hal_interface/aidl/audio_ctrl_ack.h @@ -61,7 +61,7 @@ BluetoothAudioCtrlAckToHalStatus(const BluetoothAudioCtrlAck& ack) { } // namespace audio } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::audio::aidl::BluetoothAudioCtrlAck> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.cc b/system/audio_hal_interface/aidl/client_interface_aidl.cc index e8b143fb5d..176b355eeb 100644 --- a/system/audio_hal_interface/aidl/client_interface_aidl.cc +++ b/system/audio_hal_interface/aidl/client_interface_aidl.cc @@ -182,7 +182,7 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { } log::info("IBluetoothAudioProvidersFactory::openProvider() returned {}{}", - fmt::ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); + std::format_ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); } BluetoothAudioSinkClientInterface::BluetoothAudioSinkClientInterface( diff --git a/system/audio_hal_interface/aidl/hearing_aid_software_encoding_aidl.cc b/system/audio_hal_interface/aidl/hearing_aid_software_encoding_aidl.cc index b6a761889b..0cf9d824ee 100644 --- a/system/audio_hal_interface/aidl/hearing_aid_software_encoding_aidl.cc +++ b/system/audio_hal_interface/aidl/hearing_aid_software_encoding_aidl.cc @@ -24,12 +24,12 @@ #include "client_interface_aidl.h" #include "osi/include/properties.h" -namespace fmt { +namespace std { template <> struct formatter<audio_usage_t> : enum_formatter<audio_usage_t> {}; template <> struct formatter<audio_content_type_t> : enum_formatter<audio_content_type_t> {}; -} // namespace fmt +} // namespace std namespace { diff --git a/system/audio_hal_interface/aidl/hfp_client_interface_aidl.h b/system/audio_hal_interface/aidl/hfp_client_interface_aidl.h index 5dbf8ad594..6b7587064d 100644 --- a/system/audio_hal_interface/aidl/hfp_client_interface_aidl.h +++ b/system/audio_hal_interface/aidl/hfp_client_interface_aidl.h @@ -170,8 +170,8 @@ private: } // namespace audio } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::audio::aidl::hfp::tHFP_CTRL_CMD> : enum_formatter<bluetooth::audio::aidl::hfp::tHFP_CTRL_CMD> {}; -} // namespace fmt +} // namespace std diff --git a/system/audio_hal_interface/hal_version_manager.cc b/system/audio_hal_interface/hal_version_manager.cc index 2068b766e9..f9843df858 100644 --- a/system/audio_hal_interface/hal_version_manager.cc +++ b/system/audio_hal_interface/hal_version_manager.cc @@ -112,7 +112,7 @@ android::sp<IBluetoothAudioProvidersFactory_2_1> HalVersionManager::GetProviders "V2_1::IBluetoothAudioProvidersFactory::getService() failed"); log::info("V2_1::IBluetoothAudioProvidersFactory::getService() returned {}{}", - fmt::ptr(providers_factory.get()), + std::format_ptr(providers_factory.get()), (providers_factory->isRemote() ? " (remote)" : " (local)")); return providers_factory; } @@ -129,7 +129,7 @@ android::sp<IBluetoothAudioProvidersFactory_2_0> HalVersionManager::GetProviders "V2_0::IBluetoothAudioProvidersFactory::getService() failed"); log::info("V2_0::IBluetoothAudioProvidersFactory::getService() returned {}{}", - fmt::ptr(providers_factory.get()), + std::format_ptr(providers_factory.get()), (providers_factory->isRemote() ? " (remote)" : " (local)")); guard.unlock(); return providers_factory; diff --git a/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc b/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc index 2926e73b96..62d5178666 100644 --- a/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc +++ b/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc @@ -39,14 +39,14 @@ typedef enum { A2DP_CTRL_GET_PRESENTATION_POSITION, } tA2DP_CTRL_CMD; -namespace fmt { +namespace std { template <> struct formatter<tA2DP_CTRL_CMD> : enum_formatter<tA2DP_CTRL_CMD> {}; template <> struct formatter<audio_usage_t> : enum_formatter<audio_usage_t> {}; template <> struct formatter<audio_content_type_t> : enum_formatter<audio_content_type_t> {}; -} // namespace fmt +} // namespace std namespace bluetooth { namespace audio { diff --git a/system/audio_hal_interface/hidl/client_interface_hidl.cc b/system/audio_hal_interface/hidl/client_interface_hidl.cc index c698727998..4bea626d5b 100644 --- a/system/audio_hal_interface/hidl/client_interface_hidl.cc +++ b/system/audio_hal_interface/hidl/client_interface_hidl.cc @@ -314,7 +314,7 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { } log::info("IBluetoothAudioProvidersFactory::openProvider() returned {}{}", - fmt::ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); + std::format_ptr(provider_.get()), (provider_->isRemote() ? " (remote)" : " (local)")); } void BluetoothAudioClientInterface::FetchAudioProvider_2_1() { @@ -376,7 +376,8 @@ void BluetoothAudioClientInterface::FetchAudioProvider_2_1() { } log::info("IBluetoothAudioProvidersFactory::openProvider() returned {}{}", - fmt::ptr(provider_2_1_.get()), (provider_2_1_->isRemote() ? " (remote)" : " (local)")); + std::format_ptr(provider_2_1_.get()), + (provider_2_1_->isRemote() ? " (remote)" : " (local)")); } BluetoothAudioSinkClientInterface::BluetoothAudioSinkClientInterface( diff --git a/system/audio_hal_interface/hidl/client_interface_hidl.h b/system/audio_hal_interface/hidl/client_interface_hidl.h index 09a9165f01..39347e79a8 100644 --- a/system/audio_hal_interface/hidl/client_interface_hidl.h +++ b/system/audio_hal_interface/hidl/client_interface_hidl.h @@ -266,8 +266,8 @@ private: } // namespace audio } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::audio::hidl::BluetoothAudioCtrlAck> : enum_formatter<bluetooth::audio::hidl::BluetoothAudioCtrlAck> {}; -} // namespace fmt +} // namespace std diff --git a/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc b/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc index f80aac6b43..b745914999 100644 --- a/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc +++ b/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc @@ -24,12 +24,12 @@ #include "client_interface_hidl.h" #include "osi/include/properties.h" -namespace fmt { +namespace std { template <> struct formatter<audio_usage_t> : enum_formatter<audio_usage_t> {}; template <> struct formatter<audio_content_type_t> : enum_formatter<audio_content_type_t> {}; -} // namespace fmt +} // namespace std namespace { diff --git a/system/bta/ag/bta_ag_int.h b/system/bta/ag/bta_ag_int.h index 21d39365a3..ce9ff6298d 100644 --- a/system/bta/ag/bta_ag_int.h +++ b/system/bta/ag/bta_ag_int.h @@ -476,11 +476,11 @@ bool bta_ag_is_sco_managed_by_audio(); */ void bta_ag_stream_suspended(); -namespace fmt { +namespace std { template <> struct formatter<tBTA_AG_SCO_APTX_SWB_SETTINGS> : enum_formatter<tBTA_AG_SCO_APTX_SWB_SETTINGS> {}; template <> struct formatter<tBTA_AG_SCO> : enum_formatter<tBTA_AG_SCO> {}; -} // namespace fmt +} // namespace std #endif /* BTA_AG_INT_H */ diff --git a/system/bta/ag/bta_ag_rfc.cc b/system/bta/ag/bta_ag_rfc.cc index 46b26b1a97..1943492759 100644 --- a/system/bta/ag/bta_ag_rfc.cc +++ b/system/bta/ag/bta_ag_rfc.cc @@ -107,7 +107,7 @@ static void bta_ag_port_cback(uint32_t /* code */, uint16_t port_handle, uint16_ static void bta_ag_mgmt_cback(const tPORT_RESULT code, uint16_t port_handle, uint16_t handle) { tBTA_AG_SCB* p_scb = bta_ag_scb_by_idx(handle); log::verbose("code={}, port_handle={}, scb_handle={}, p_scb=0x{}", code, port_handle, handle, - fmt::ptr(p_scb)); + std::format_ptr(p_scb)); if (p_scb == nullptr) { log::warn("cannot find scb, code={}, port_handle={}, handle={}", code, port_handle, handle); return; @@ -262,10 +262,10 @@ void bta_ag_start_servers(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK services) { log::error( "RFCOMM_CreateConnectionWithSecurity ERROR {}, p_scb={}, " "services=0x{:x}, mgmt_cback_index={}", - status, fmt::ptr(p_scb), services, management_callback_index); + status, std::format_ptr(p_scb), services, management_callback_index); } - log::verbose("p_scb=0x{}, services=0x{:04x}, mgmt_cback_index={}", fmt::ptr(p_scb), services, - management_callback_index); + log::verbose("p_scb=0x{}, services=0x{:04x}, mgmt_cback_index={}", std::format_ptr(p_scb), + services, management_callback_index); } } } @@ -332,7 +332,7 @@ void bta_ag_rfc_do_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) { bta_ag_uuid[p_scb->conn_service], p_scb->peer_scn, false, BTA_AG_MTU, p_scb->peer_addr, &(p_scb->conn_handle), bta_ag_mgmt_cback_tbl[management_callback_index], BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT); - log::verbose("p_scb=0x{}, conn_handle={}, mgmt_cback_index={}, status={}", fmt::ptr(p_scb), + log::verbose("p_scb=0x{}, conn_handle={}, mgmt_cback_index={}, status={}", std::format_ptr(p_scb), p_scb->conn_handle, management_callback_index, status); if (status == PORT_SUCCESS) { bta_ag_setup_port(p_scb, p_scb->conn_handle); diff --git a/system/bta/aics/include/aics/api.h b/system/bta/aics/include/aics/api.h index b81132e324..7eb76e50c8 100644 --- a/system/bta/aics/include/aics/api.h +++ b/system/bta/aics/include/aics/api.h @@ -51,9 +51,9 @@ bool isValidAudioInputGainModeValue(uint8_t data); GainMode parseGainModeField(uint8_t data); } // namespace bluetooth::aics -namespace fmt { +namespace std { template <> struct formatter<bluetooth::aics::Mute> : enum_formatter<bluetooth::aics::Mute> {}; template <> struct formatter<bluetooth::aics::GainMode> : enum_formatter<bluetooth::aics::GainMode> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/av/bta_av_aact.cc b/system/bta/av/bta_av_aact.cc index 0099c3313f..0378be7b92 100644 --- a/system/bta/av/bta_av_aact.cc +++ b/system/bta/av/bta_av_aact.cc @@ -367,7 +367,7 @@ void bta_av_proc_stream_evt(uint8_t handle, const RawAddress& bd_addr, uint8_t e uint16_t sec_len = 0; log::verbose("peer_address: {} avdt_handle: {} event=0x{:x} scb_index={} p_scb={}", bd_addr, - handle, event, scb_index, fmt::ptr(p_scb)); + handle, event, scb_index, std::format_ptr(p_scb)); if (p_data) { if (event == AVDT_SECURITY_IND_EVT) { @@ -1926,7 +1926,7 @@ void bta_av_str_stopped(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { BT_HDR* p_buf; log::info("peer {} bta_handle:0x{:x} audio_open_cnt:{}, p_data {} start:{}", p_scb->PeerAddress(), - p_scb->hndl, bta_av_cb.audio_open_cnt, fmt::ptr(p_data), start); + p_scb->hndl, bta_av_cb.audio_open_cnt, std::format_ptr(p_data), start); bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->PeerAddress()); BTM_unblock_role_switch_and_sniff_mode_for(p_scb->PeerAddress()); diff --git a/system/bta/av/bta_av_int.h b/system/bta/av/bta_av_int.h index 7d98cf2dd4..c9c176c445 100644 --- a/system/bta/av/bta_av_int.h +++ b/system/bta/av/bta_av_int.h @@ -807,9 +807,9 @@ void bta_av_vendor_offload_stop(void); void bta_av_st_rc_timer(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data); void bta_av_api_set_peer_sep(tBTA_AV_DATA* p_data); -namespace fmt { +namespace std { template <> struct formatter<tBTA_AV_RS_RES> : enum_formatter<tBTA_AV_RS_RES> {}; -} // namespace fmt +} // namespace std #endif /* BTA_AV_INT_H */ diff --git a/system/bta/av/bta_av_ssm.cc b/system/bta/av/bta_av_ssm.cc index 84d95616dc..cbf83f561d 100644 --- a/system/bta/av/bta_av_ssm.cc +++ b/system/bta/av/bta_av_ssm.cc @@ -440,13 +440,13 @@ void bta_av_ssm_execute(tBTA_AV_SCB* p_scb, uint16_t event, tBTA_AV_DATA* p_data if (previous_state != p_scb->state) { log::info("peer {} p_scb={:#x}({}) AV event=0x{:x}({}) state={}({}) -> {}({})", - p_scb->PeerAddress(), p_scb->hndl, fmt::ptr(p_scb), event, bta_av_evt_code(event), - previous_state, bta_av_sst_code(previous_state), p_scb->state, + p_scb->PeerAddress(), p_scb->hndl, std::format_ptr(p_scb), event, + bta_av_evt_code(event), previous_state, bta_av_sst_code(previous_state), p_scb->state, bta_av_sst_code(p_scb->state)); } else { log::verbose("peer {} p_scb={:#x}({}) AV event=0x{:x}({}) state={}({})", p_scb->PeerAddress(), - p_scb->hndl, fmt::ptr(p_scb), event, bta_av_evt_code(event), p_scb->state, + p_scb->hndl, std::format_ptr(p_scb), event, bta_av_evt_code(event), p_scb->state, bta_av_sst_code(p_scb->state)); } @@ -521,7 +521,7 @@ void bta_av_set_scb_sst_init(tBTA_AV_SCB* p_scb) { log::verbose("peer {} AV (hndl=0x{:x}) state={}({}) next state={}({}) p_scb={}", p_scb->PeerAddress(), p_scb->hndl, p_scb->state, bta_av_sst_code(p_scb->state), - next_state, bta_av_sst_code(next_state), fmt::ptr(p_scb)); + next_state, bta_av_sst_code(next_state), std::format_ptr(p_scb)); p_scb->state = next_state; } diff --git a/system/bta/dm/bta_dm_device_search.cc b/system/bta/dm/bta_dm_device_search.cc index c80f76396a..7c2c30e3e6 100644 --- a/system/bta/dm/bta_dm_device_search.cc +++ b/system/bta/dm/bta_dm_device_search.cc @@ -490,8 +490,9 @@ static void bta_dm_discover_name(const RawAddress& remote_bd_addr) { bta_dm_search_cb.peer_bdaddr = remote_bd_addr; log::verbose("name_discover_done = {} p_btm_inq_info 0x{} state = {}, transport={}", - bta_dm_search_cb.name_discover_done, fmt::ptr(bta_dm_search_cb.p_btm_inq_info), - bta_dm_search_get_state(), transport); + bta_dm_search_cb.name_discover_done, + std::format_ptr(bta_dm_search_cb.p_btm_inq_info), bta_dm_search_get_state(), + transport); if (bta_dm_search_cb.p_btm_inq_info) { log::verbose("appl_knows_rem_name {}", bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name); diff --git a/system/bta/dm/bta_dm_device_search_int.h b/system/bta/dm/bta_dm_device_search_int.h index 68df101863..28e3fdabd8 100644 --- a/system/bta/dm/bta_dm_device_search_int.h +++ b/system/bta/dm/bta_dm_device_search_int.h @@ -90,9 +90,9 @@ typedef struct { tBTA_DM_SEARCH_CBACK* p_csis_scan_cback; } tBTA_DM_SEARCH_CB; -namespace fmt { +namespace std { template <> struct formatter<tBTA_DM_DEV_SEARCH_EVT> : enum_formatter<tBTA_DM_DEV_SEARCH_EVT> {}; template <> struct formatter<tBTA_DM_DEVICE_SEARCH_STATE> : enum_formatter<tBTA_DM_DEVICE_SEARCH_STATE> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/dm/bta_dm_disc_int.h b/system/bta/dm/bta_dm_disc_int.h index df8d2f2444..6c89f895fd 100644 --- a/system/bta/dm/bta_dm_disc_int.h +++ b/system/bta/dm/bta_dm_disc_int.h @@ -131,10 +131,10 @@ void bta_dm_sdp_callback(const RawAddress& bd_addr, tSDP_STATUS sdp_status); void bta_dm_sdp_received_di(const RawAddress& bd_addr, tSDP_DI_GET_RECORD& di_record); #endif -namespace fmt { +namespace std { template <> struct formatter<tBTA_DM_DISC_EVT> : enum_formatter<tBTA_DM_DISC_EVT> {}; template <> struct formatter<tBTA_DM_SERVICE_DISCOVERY_STATE> : enum_formatter<tBTA_DM_SERVICE_DISCOVERY_STATE> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/dm/bta_dm_disc_sdp.cc b/system/bta/dm/bta_dm_disc_sdp.cc index f4b1b13728..588e7afe96 100644 --- a/system/bta/dm/bta_dm_disc_sdp.cc +++ b/system/bta/dm/bta_dm_disc_sdp.cc @@ -264,7 +264,7 @@ void bta_dm_sdp_result(tSDP_STATUS sdp_result, tBTA_DM_SDP_STATE* sdp_state) { // Copy the raw_data to the discovery result structure if (p_sdp_db != NULL && p_sdp_db->raw_used != 0 && p_sdp_db->raw_data != NULL) { log::verbose("raw_data used = 0x{:x} raw_data_ptr = 0x{}", p_sdp_db->raw_used, - fmt::ptr(p_sdp_db->raw_data)); + std::format_ptr(p_sdp_db->raw_data)); p_sdp_db->raw_data = NULL; // no need to free this - it is a global assigned. p_sdp_db->raw_used = 0; diff --git a/system/bta/dm/bta_dm_int.h b/system/bta/dm/bta_dm_int.h index d7757557dc..e79facd403 100644 --- a/system/bta/dm/bta_dm_int.h +++ b/system/bta/dm/bta_dm_int.h @@ -365,9 +365,9 @@ void bta_dm_ble_subrate_request(const RawAddress& bd_addr, uint16_t subrate_min, uint16_t subrate_max, uint16_t max_latency, uint16_t cont_num, uint16_t timeout); -namespace fmt { +namespace std { template <> struct formatter<tBTA_DM_CONN_STATE> : enum_formatter<tBTA_DM_CONN_STATE> {}; -} // namespace fmt +} // namespace std #endif /* BTA_DM_INT_H */ diff --git a/system/bta/gatt/bta_gattc_act.cc b/system/bta/gatt/bta_gattc_act.cc index c1a8e956ad..37ecf8f23c 100644 --- a/system/bta/gatt/bta_gattc_act.cc +++ b/system/bta/gatt/bta_gattc_act.cc @@ -837,7 +837,8 @@ void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) { bta_gattc_send_mtu_response(p_clcb, p_data, current_mtu); return; case MTU_EXCHANGE_IN_PROGRESS: - log::info("Enqueue MTU Request - waiting for response on p_clcb {}", fmt::ptr(p_clcb)); + log::info("Enqueue MTU Request - waiting for response on p_clcb {}", + std::format_ptr(p_clcb)); /* MTU request is in progress and this one will not be sent to remote * device. Just push back on the queue and response will be sent up to * the upper layer when MTU Exchange will be completed. @@ -1358,7 +1359,7 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) { auto outstanding_conn_ids = GATTC_GetAndRemoveListOfConnIdsWaitingForMtuRequest(p_clcb->bda); for (auto conn_id : outstanding_conn_ids) { tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); - log::debug("Continue MTU request clcb {}", fmt::ptr(p_clcb)); + log::debug("Continue MTU request clcb {}", std::format_ptr(p_clcb)); if (p_clcb) { log::debug("Continue MTU request for client conn_id=0x{:04x}", conn_id); bta_gattc_continue(p_clcb); diff --git a/system/bta/gatt/bta_gattc_int.h b/system/bta/gatt/bta_gattc_int.h index 070e9c574b..1bfd741348 100644 --- a/system/bta/gatt/bta_gattc_int.h +++ b/system/bta/gatt/bta_gattc_int.h @@ -532,7 +532,7 @@ inline std::string bta_gattc_state_text(const tBTA_GATTC_CB_STATE& state) { } } -namespace fmt { +namespace std { template <> struct formatter<tBTA_GATTC_CB_STATE> : enum_formatter<tBTA_GATTC_CB_STATE> {}; template <> @@ -541,6 +541,6 @@ template <> struct formatter<tBTA_GATTC_STATE> : enum_formatter<tBTA_GATTC_STATE> {}; template <> struct formatter<RobustCachingSupport> : enum_formatter<RobustCachingSupport> {}; -} // namespace fmt +} // namespace std #endif /* BTA_GATTC_INT_H */ diff --git a/system/bta/gatt/bta_gattc_utils.cc b/system/bta/gatt/bta_gattc_utils.cc index 70f528e093..cf07f89d9c 100644 --- a/system/bta/gatt/bta_gattc_utils.cc +++ b/system/bta/gatt/bta_gattc_utils.cc @@ -515,7 +515,7 @@ void bta_gattc_continue(tBTA_GATTC_CLCB* p_clcb) { /* Handled, free command below and continue with a p_q_cmd_queue */ break; case MTU_EXCHANGE_IN_PROGRESS: - log::warn("Waiting p_clcb {}", fmt::ptr(p_clcb)); + log::warn("Waiting p_clcb {}", std::format_ptr(p_clcb)); return; case MTU_EXCHANGE_NOT_DONE_YET: p_clcb->p_q_cmd_queue.pop_front(); diff --git a/system/bta/has/has_ctp.h b/system/bta/has/has_ctp.h index 3de5b46f76..4b62426f97 100644 --- a/system/bta/has/has_ctp.h +++ b/system/bta/has/has_ctp.h @@ -257,9 +257,9 @@ struct HasCtpGroupOpCoordinator { } // namespace has } // namespace bluetooth::le_audio -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::has::HasCtpNtf> : ostream_formatter {}; template <> struct formatter<bluetooth::le_audio::has::HasCtpOp> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/has/has_preset.h b/system/bta/has/has_preset.h index 48c6185241..60d8942e11 100644 --- a/system/bta/has/has_preset.h +++ b/system/bta/has/has_preset.h @@ -99,7 +99,7 @@ public: } // namespace has } // namespace bluetooth::le_audio -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::has::HasPreset> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/has/has_types.h b/system/bta/has/has_types.h index 5041838e02..2a7209809b 100644 --- a/system/bta/has/has_types.h +++ b/system/bta/has/has_types.h @@ -402,7 +402,7 @@ private: } // namespace has } // namespace bluetooth::le_audio -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::has::HasDevice> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/hearing_aid/hearing_aid_audio_source.cc b/system/bta/hearing_aid/hearing_aid_audio_source.cc index 6ea05e7d06..d1d45d5407 100644 --- a/system/bta/hearing_aid/hearing_aid_audio_source.cc +++ b/system/bta/hearing_aid/hearing_aid_audio_source.cc @@ -42,14 +42,14 @@ using namespace bluetooth; -namespace fmt { +namespace std { template <> struct formatter<tUIPC_EVENT> : enum_formatter<tUIPC_EVENT> {}; template <> struct formatter<tHEARING_AID_CTRL_ACK> : enum_formatter<tHEARING_AID_CTRL_ACK> {}; template <> struct formatter<tHEARING_AID_CTRL_CMD> : enum_formatter<tHEARING_AID_CTRL_CMD> {}; -} // namespace fmt +} // namespace std namespace { #define CASE_RETURN_STR(const) \ diff --git a/system/bta/hh/bta_hh_int.h b/system/bta/hh/bta_hh_int.h index 2f9f502ba9..2e5e185277 100644 --- a/system/bta/hh/bta_hh_int.h +++ b/system/bta/hh/bta_hh_int.h @@ -325,9 +325,9 @@ void bta_hh_dump(int fd); void bta_hh_trace_dev_db(void); #endif -namespace fmt { +namespace std { template <> struct formatter<tBTA_HH_SERVICE_STATE> : enum_formatter<tBTA_HH_SERVICE_STATE> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/bta/include/bta_ag_api.h b/system/bta/include/bta_ag_api.h index 04c5b66eac..5aa525c3fc 100644 --- a/system/bta/include/bta_ag_api.h +++ b/system/bta/include/bta_ag_api.h @@ -647,9 +647,9 @@ void BTA_AgSetScoAllowed(bool value); void BTA_AgSetActiveDevice(const RawAddress& active_device_addr); -namespace fmt { +namespace std { template <> struct formatter<tBTA_AG_RES> : enum_formatter<tBTA_AG_RES> {}; -} // namespace fmt +} // namespace std #endif /* BTA_AG_API_H */ diff --git a/system/bta/include/bta_api.h b/system/bta/include/bta_api.h index fbdf277df4..a0b9e2c32f 100644 --- a/system/bta/include/bta_api.h +++ b/system/bta/include/bta_api.h @@ -847,13 +847,13 @@ bool BTA_DmCheckLeAudioCapable(const RawAddress& address); void DumpsysBtaDm(int fd); -namespace fmt { +namespace std { template <> struct formatter<tBTA_DM_SEARCH_EVT> : enum_formatter<tBTA_DM_SEARCH_EVT> {}; template <> struct formatter<tBTA_DM_ACL_EVT> : enum_formatter<tBTA_DM_ACL_EVT> {}; template <> struct formatter<tBTA_PREF_ROLES> : enum_formatter<tBTA_PREF_ROLES> {}; -} // namespace fmt +} // namespace std #endif /* BTA_API_H */ diff --git a/system/bta/include/bta_api_data_types.h b/system/bta/include/bta_api_data_types.h index aa41dd397f..14983743c1 100644 --- a/system/bta/include/bta_api_data_types.h +++ b/system/bta/include/bta_api_data_types.h @@ -63,7 +63,7 @@ typedef struct { RawAddress bd_addr; } tBTA_DM_KEY_MISSING; -namespace fmt { +namespace std { template <> struct formatter<tBTA_STATUS> : enum_formatter<tBTA_STATUS> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/include/bta_gatt_api.h b/system/bta/include/bta_gatt_api.h index ba60da6ee4..8a8a91de9e 100644 --- a/system/bta/include/bta_gatt_api.h +++ b/system/bta/include/bta_gatt_api.h @@ -1044,9 +1044,9 @@ void BTA_GATTS_Close(tCONN_ID conn_id); // Adds bonded device for GATT server tracking service changes void BTA_GATTS_InitBonded(void); -namespace fmt { +namespace std { template <> struct formatter<tBTA_GATTC_EVT> : enum_formatter<tBTA_GATTC_EVT> {}; -} // namespace fmt +} // namespace std #endif /* BTA_GATT_API_H */ diff --git a/system/bta/include/bta_hearing_aid_api.h b/system/bta/include/bta_hearing_aid_api.h index 19e89f5489..7314d2eb23 100644 --- a/system/bta/include/bta_hearing_aid_api.h +++ b/system/bta/include/bta_hearing_aid_api.h @@ -282,7 +282,7 @@ public: static void DebugDump(int fd); }; -namespace fmt { +namespace std { template <> struct formatter<connection_update_status_t> : enum_formatter<connection_update_status_t> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/include/bta_hh_api.h b/system/bta/include/bta_hh_api.h index e59f80a8b7..976c7d2bd8 100644 --- a/system/bta/include/bta_hh_api.h +++ b/system/bta/include/bta_hh_api.h @@ -561,8 +561,8 @@ void BTA_HhRemoveDev(uint8_t dev_handle); ******************************************************************************/ void BTA_HhDump(int fd); -namespace fmt { +namespace std { template <> struct formatter<tBTA_HH_STATUS> : enum_formatter<tBTA_HH_STATUS> {}; -} // namespace fmt +} // namespace std #endif /* BTA_HH_API_H */ diff --git a/system/bta/include/bta_jv_api.h b/system/bta/include/bta_jv_api.h index 1809bf94d4..4b43cbc485 100644 --- a/system/bta/include/bta_jv_api.h +++ b/system/bta/include/bta_jv_api.h @@ -148,10 +148,10 @@ inline std::string bta_jv_conn_state_text(const tBTA_JV_CONN_STATE& state) { } } -namespace fmt { +namespace std { template <> struct formatter<tBTA_JV_CONN_STATE> : enum_formatter<tBTA_JV_CONN_STATE> {}; -} // namespace fmt +} // namespace std /* JV Connection types */ enum class tBTA_JV_CONN_TYPE { @@ -171,10 +171,10 @@ inline std::string bta_jv_conn_type_text(const tBTA_JV_CONN_TYPE& type) { RETURN_UNKNOWN_TYPE_STRING(tBTA_JV_CONN_TYPE, type); } -namespace fmt { +namespace std { template <> struct formatter<tBTA_JV_CONN_TYPE> : enum_formatter<tBTA_JV_CONN_TYPE> {}; -} // namespace fmt +} // namespace std enum tBTA_JV_EVT : uint16_t { /* Java I/F callback events */ diff --git a/system/bta/include/bta_sec_api.h b/system/bta/include/bta_sec_api.h index 7446e729f9..a0f431f754 100644 --- a/system/bta/include/bta_sec_api.h +++ b/system/bta/include/bta_sec_api.h @@ -484,7 +484,7 @@ void BTA_DmSirkSecCbRegister(tBTA_DM_SEC_CBACK* p_cback); ******************************************************************************/ void BTA_DmSirkConfirmDeviceReply(const RawAddress& bd_addr, bool accept); -namespace fmt { +namespace std { template <> struct formatter<tBTA_DM_SEC_EVT> : enum_formatter<tBTA_DM_SEC_EVT> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/jv/bta_jv_act.cc b/system/bta/jv/bta_jv_act.cc index 20e57bd478..9d4715269c 100644 --- a/system/bta/jv/bta_jv_act.cc +++ b/system/bta/jv/bta_jv_act.cc @@ -308,7 +308,7 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pc return tBTA_JV_STATUS::FAILURE; } log::verbose("max_sess={}, curr_sess={}, p_pcb={}, user={}, state={}, jv handle=0x{:x}", - p_cb->max_sess, p_cb->curr_sess, fmt::ptr(p_pcb), p_pcb->rfcomm_slot_id, + p_cb->max_sess, p_cb->curr_sess, std::format_ptr(p_pcb), p_pcb->rfcomm_slot_id, p_pcb->state, p_pcb->handle); if (p_cb->curr_sess <= 0) { @@ -319,7 +319,7 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pc case BTA_JV_ST_CL_CLOSING: case BTA_JV_ST_SR_CLOSING: log::warn("return on closing, port state={}, scn={}, p_pcb={}, user_data={}", p_pcb->state, - p_cb->scn, fmt::ptr(p_pcb), p_pcb->rfcomm_slot_id); + p_cb->scn, std::format_ptr(p_pcb), p_pcb->rfcomm_slot_id); status = tBTA_JV_STATUS::FAILURE; return status; case BTA_JV_ST_CL_OPEN: @@ -343,7 +343,7 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pc log::warn( "failed, ignore port state= {}, scn={}, p_pcb= {}, jv handle=0x{:x}, " "port_handle={}, user_data={}", - p_pcb->state, p_cb->scn, fmt::ptr(p_pcb), p_pcb->handle, p_pcb->port_handle, + p_pcb->state, p_cb->scn, std::format_ptr(p_pcb), p_pcb->handle, p_pcb->port_handle, p_pcb->rfcomm_slot_id); status = tBTA_JV_STATUS::FAILURE; break; @@ -560,7 +560,7 @@ static tBTA_JV_PM_CB* bta_jv_alloc_set_pm_profile_cb(uint32_t jv_handle, tBTA_JV } } log::verbose("handle=0x{:x}, app_id={}, idx={}, BTA_JV_PM_MAX_NUM={}, pp_cb={}", jv_handle, - app_id, i, BTA_JV_PM_MAX_NUM, fmt::ptr(pp_cb)); + app_id, i, BTA_JV_PM_MAX_NUM, std::format_ptr(pp_cb)); break; } } @@ -827,7 +827,8 @@ static void bta_jv_start_discovery_cback(uint32_t rfcomm_slot_id, const RawAddre tSDP_DISC_REC* p_sdp_rec = NULL; p_sdp_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceUUIDInDb( p_bta_jv_cfg->p_sdp_db, bta_jv_cb.sdp_cb.uuid, p_sdp_rec); - log::verbose("bta_jv_cb.uuid={} p_sdp_rec={}", bta_jv_cb.sdp_cb.uuid, fmt::ptr(p_sdp_rec)); + log::verbose("bta_jv_cb.uuid={} p_sdp_rec={}", bta_jv_cb.sdp_cb.uuid, + std::format_ptr(p_sdp_rec)); if (p_sdp_rec && get_legacy_stack_sdp_api()->record.SDP_FindProtocolListElemInRec( p_sdp_rec, UUID_PROTOCOL_RFCOMM, &pe)) { bta_jv = { @@ -1338,7 +1339,8 @@ void bta_jv_l2cap_write(uint32_t handle, uint32_t req_id, BT_HDR* msg, uint32_t static int bta_jv_port_data_co_cback(uint16_t port_handle, uint8_t* buf, uint16_t len, int type) { tBTA_JV_RFC_CB* p_cb = bta_jv_rfc_port_to_cb(port_handle); tBTA_JV_PCB* p_pcb = bta_jv_rfc_port_to_pcb(port_handle); - log::verbose("p_cb={}, p_pcb={}, len={}, type={}", fmt::ptr(p_cb), fmt::ptr(p_pcb), len, type); + log::verbose("p_cb={}, p_pcb={}, len={}, type={}", std::format_ptr(p_cb), std::format_ptr(p_pcb), + len, type); if (p_pcb != NULL) { switch (type) { case DATA_CO_CALLBACK_TYPE_INCOMING: @@ -1588,13 +1590,13 @@ static void bta_jv_port_mgmt_sr_cback(const tPORT_RESULT code, uint16_t port_han uint16_t lcid; log::verbose("code={}, port_handle={}", code, port_handle); if (NULL == p_cb || NULL == p_cb->p_cback) { - log::error("p_cb={}, p_cb->p_cback={}", fmt::ptr(p_cb), - fmt::ptr(p_cb ? p_cb->p_cback : nullptr)); + log::error("p_cb={}, p_cb->p_cback={}", std::format_ptr(p_cb), + std::format_ptr(p_cb ? p_cb->p_cback : nullptr)); return; } uint32_t rfcomm_slot_id = p_pcb->rfcomm_slot_id; log::verbose("code={}, port_handle=0x{:x}, handle=0x{:x}, p_pcb{}, user={}", code, port_handle, - p_cb->handle, fmt::ptr(p_pcb), p_pcb->rfcomm_slot_id); + p_cb->handle, std::format_ptr(p_pcb), p_pcb->rfcomm_slot_id); int status = PORT_CheckConnection(port_handle, &rem_bda, &lcid); int failed = true; @@ -1659,8 +1661,8 @@ static void bta_jv_port_event_sr_cback(uint32_t code, uint16_t port_handle) { tBTA_JV evt_data; if (NULL == p_cb || NULL == p_cb->p_cback) { - log::error("p_cb={}, p_cb->p_cback={}", fmt::ptr(p_cb), - fmt::ptr(p_cb ? p_cb->p_cback : nullptr)); + log::error("p_cb={}, p_cb->p_cback={}", std::format_ptr(p_cb), + std::format_ptr(p_cb ? p_cb->p_cback : nullptr)); return; } @@ -1861,7 +1863,7 @@ void bta_jv_rfcomm_stop_server(uint32_t handle, uint32_t rfcomm_slot_id) { if (!find_rfc_pcb(rfcomm_slot_id, &p_cb, &p_pcb)) { return; } - log::verbose("p_pcb={}, p_pcb->port_handle={}", fmt::ptr(p_pcb), p_pcb->port_handle); + log::verbose("p_pcb={}, p_pcb->port_handle={}", std::format_ptr(p_pcb), p_pcb->port_handle); bta_jv_free_rfc_cb(p_cb, p_pcb); } @@ -1969,7 +1971,7 @@ static void bta_jv_pm_conn_idle(tBTA_JV_PM_CB* p_cb) { ******************************************************************************/ static void bta_jv_pm_state_change(tBTA_JV_PM_CB* p_cb, const tBTA_JV_CONN_STATE state) { log::verbose("p_cb={}, handle=0x{:x}, busy/idle_state={}, app_id={}, conn_state={}", - fmt::ptr(p_cb), p_cb->handle, p_cb->state, p_cb->app_id, + std::format_ptr(p_cb), p_cb->handle, p_cb->state, p_cb->app_id, bta_jv_conn_state_text(state)); switch (state) { diff --git a/system/bta/le_audio/client.cc b/system/bta/le_audio/client.cc index 8b668c3892..8d5fbb1a24 100644 --- a/system/bta/le_audio/client.cc +++ b/system/bta/le_audio/client.cc @@ -213,10 +213,10 @@ std::ostream& operator<<(std::ostream& os, const AudioState& audio_state) { return os; } -namespace fmt { +namespace std { template <> struct formatter<AudioState> : ostream_formatter {}; -} // namespace fmt +} // namespace std namespace { void le_audio_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data); @@ -828,7 +828,7 @@ public: } } - log::debug("New group {}, id: {}", fmt::ptr(new_group), new_group->group_id_); + log::debug("New group {}, id: {}", std::format_ptr(new_group), new_group->group_id_); /* If device was in the group and it was not removed by the application, * lets do it now @@ -869,8 +869,8 @@ public: log::debug("group is null"); return; } - log::debug("Group {}, id: {}, size: {}, is cig_state {}", fmt::ptr(group), group->group_id_, - group->Size(), ToString(group->cig.GetState())); + log::debug("Group {}, id: {}, size: {}, is cig_state {}", std::format_ptr(group), + group->group_id_, group->Size(), ToString(group->cig.GetState())); if (group->IsEmpty() && (group->cig.GetState() == bluetooth::le_audio::types::CigState::NONE)) { lastNotifiedGroupStreamStatusMap_.erase(group->group_id_); aseGroups_.Remove(group->group_id_); @@ -2691,7 +2691,8 @@ public: * issues */ if (group == nullptr || !group->IsEnabled()) { - log::error("Group id {} ({}) disabled or null", leAudioDevice->group_id_, fmt::ptr(group)); + log::error("Group id {} ({}) disabled or null", leAudioDevice->group_id_, + std::format_ptr(group)); return; } @@ -2805,7 +2806,7 @@ public: void OnServiceChangeEvent(const RawAddress& address) { LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); if (!leAudioDevice) { - log::warn("Skipping unknown leAudioDevice {} ({})", address, fmt::ptr(leAudioDevice)); + log::warn("Skipping unknown leAudioDevice {} ({})", address, std::format_ptr(leAudioDevice)); return; } @@ -2864,7 +2865,7 @@ public: LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); if (!leAudioDevice || (leAudioDevice->conn_id_ == GATT_INVALID_CONN_ID)) { log::verbose("skipping unknown leAudioDevice, address {} ({})", address, - fmt::ptr(leAudioDevice)); + std::format_ptr(leAudioDevice)); return; } diff --git a/system/bta/le_audio/client_parser.h b/system/bta/le_audio/client_parser.h index 1aaf4b3b8a..e9e4756321 100644 --- a/system/bta/le_audio/client_parser.h +++ b/system/bta/le_audio/client_parser.h @@ -22,6 +22,7 @@ #pragma once +#include <memory> #include <vector> #include "le_audio_types.h" diff --git a/system/bta/le_audio/codec_interface.h b/system/bta/le_audio/codec_interface.h index 7e99fc9189..8841bbaa59 100644 --- a/system/bta/le_audio/codec_interface.h +++ b/system/bta/le_audio/codec_interface.h @@ -73,8 +73,8 @@ private: } // namespace bluetooth::le_audio -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::CodecInterface::Status> : enum_formatter<bluetooth::le_audio::CodecInterface::Status> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/le_audio/codec_manager.cc b/system/bta/le_audio/codec_manager.cc index eb0efb545f..9977fec885 100644 --- a/system/bta/le_audio/codec_manager.cc +++ b/system/bta/le_audio/codec_manager.cc @@ -211,8 +211,9 @@ public: bool UpdateActiveUnicastAudioHalClient(LeAudioSourceAudioHalClient* source_unicast_client, LeAudioSinkAudioHalClient* sink_unicast_client, bool is_active) { - log::debug("local_source: {}, local_sink: {}, is_active: {}", fmt::ptr(source_unicast_client), - fmt::ptr(sink_unicast_client), is_active); + log::debug("local_source: {}, local_sink: {}, is_active: {}", + std::format_ptr(source_unicast_client), std::format_ptr(sink_unicast_client), + is_active); if (source_unicast_client == nullptr && sink_unicast_client == nullptr) { return false; @@ -221,13 +222,13 @@ public: if (is_active) { if (source_unicast_client && unicast_local_source_hal_client != nullptr) { log::error("Trying to override previous source hal client {}", - fmt::ptr(unicast_local_source_hal_client)); + std::format_ptr(unicast_local_source_hal_client)); return false; } if (sink_unicast_client && unicast_local_sink_hal_client != nullptr) { log::error("Trying to override previous sink hal client {}", - fmt::ptr(unicast_local_sink_hal_client)); + std::format_ptr(unicast_local_sink_hal_client)); return false; } @@ -243,14 +244,16 @@ public: } if (source_unicast_client && source_unicast_client != unicast_local_source_hal_client) { - log::error("local source session does not match {} != {}", fmt::ptr(source_unicast_client), - fmt::ptr(unicast_local_source_hal_client)); + log::error("local source session does not match {} != {}", + std::format_ptr(source_unicast_client), + std::format_ptr(unicast_local_source_hal_client)); return false; } if (sink_unicast_client && sink_unicast_client != unicast_local_sink_hal_client) { - log::error("local source session does not match {} != {}", fmt::ptr(sink_unicast_client), - fmt::ptr(unicast_local_sink_hal_client)); + log::error("local source session does not match {} != {}", + std::format_ptr(sink_unicast_client), + std::format_ptr(unicast_local_sink_hal_client)); return false; } @@ -267,7 +270,8 @@ public: bool UpdateActiveBroadcastAudioHalClient(LeAudioSourceAudioHalClient* source_broadcast_client, bool is_active) { - log::debug("local_source: {},is_active: {}", fmt::ptr(source_broadcast_client), is_active); + log::debug("local_source: {},is_active: {}", std::format_ptr(source_broadcast_client), + is_active); if (source_broadcast_client == nullptr) { return false; @@ -276,7 +280,7 @@ public: if (is_active) { if (broadcast_local_source_hal_client != nullptr) { log::error("Trying to override previous source hal client {}", - fmt::ptr(broadcast_local_source_hal_client)); + std::format_ptr(broadcast_local_source_hal_client)); return false; } broadcast_local_source_hal_client = source_broadcast_client; @@ -284,8 +288,9 @@ public: } if (source_broadcast_client != broadcast_local_source_hal_client) { - log::error("local source session does not match {} != {}", fmt::ptr(source_broadcast_client), - fmt::ptr(broadcast_local_source_hal_client)); + log::error("local source session does not match {} != {}", + std::format_ptr(source_broadcast_client), + std::format_ptr(broadcast_local_source_hal_client)); return false; } diff --git a/system/bta/le_audio/codec_manager.h b/system/bta/le_audio/codec_manager.h index b41bb3b766..1a86a9d4b0 100644 --- a/system/bta/le_audio/codec_manager.h +++ b/system/bta/le_audio/codec_manager.h @@ -145,8 +145,8 @@ std::ostream& operator<<(std::ostream& os, const CodecManager::UnicastConfigurationRequirements& req); } // namespace bluetooth::le_audio -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::CodecManager::UnicastConfigurationRequirements> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/le_audio/device_groups.cc b/system/bta/le_audio/device_groups.cc index f186ad9da6..192f3e9058 100644 --- a/system/bta/le_audio/device_groups.cc +++ b/system/bta/le_audio/device_groups.cc @@ -139,7 +139,7 @@ int LeAudioDeviceGroup::NumOfAvailableForDirection(int direction) const { } void LeAudioDeviceGroup::ClearSinksFromConfiguration(void) { - log::info("Group {}, group_id {}", fmt::ptr(this), group_id_); + log::info("Group {}, group_id {}", std::format_ptr(this), group_id_); auto direction = types::kLeAudioDirectionSink; stream_conf.stream_params.get(direction).clear(); @@ -147,7 +147,7 @@ void LeAudioDeviceGroup::ClearSinksFromConfiguration(void) { } void LeAudioDeviceGroup::ClearSourcesFromConfiguration(void) { - log::info("Group {}, group_id {}", fmt::ptr(this), group_id_); + log::info("Group {}, group_id {}", std::format_ptr(this), group_id_); auto direction = types::kLeAudioDirectionSource; stream_conf.stream_params.get(direction).clear(); @@ -1173,7 +1173,7 @@ bool LeAudioDeviceGroup::HaveAllCisesDisconnected(void) const { } uint8_t LeAudioDeviceGroup::CigConfiguration::GetFirstFreeCisId(CisType cis_type) const { - log::info("Group: {}, group_id: {} cis_type: {}", fmt::ptr(group_), group_->group_id_, + log::info("Group: {}, group_id: {} cis_type: {}", std::format_ptr(group_), group_->group_id_, static_cast<int>(cis_type)); for (size_t id = 0; id < cises.size(); id++) { if (cises[id].addr.IsEmpty() && cises[id].type == cis_type) { @@ -1243,7 +1243,7 @@ int LeAudioDeviceGroup::GetAseCount(uint8_t direction) const { } void LeAudioDeviceGroup::CigConfiguration::GenerateCisIds(LeAudioContextType context_type) { - log::info("Group {}, group_id: {}, context_type: {}", fmt::ptr(group_), group_->group_id_, + log::info("Group {}, group_id: {}, context_type: {}", std::format_ptr(group_), group_->group_id_, bluetooth::common::ToString(context_type)); if (cises.size() > 0) { @@ -1439,7 +1439,7 @@ void LeAudioDeviceGroup::CigConfiguration::AssignCisConnHandles( void LeAudioDeviceGroup::AssignCisConnHandlesToAses(LeAudioDevice* leAudioDevice) { log::assert_that(leAudioDevice, "Invalid device"); - log::info("group: {}, group_id: {}, device: {}", fmt::ptr(this), group_id_, + log::info("group: {}, group_id: {}, device: {}", std::format_ptr(this), group_id_, leAudioDevice->address_); /* Assign all CIS connection handles to ases */ @@ -1470,7 +1470,7 @@ void LeAudioDeviceGroup::AssignCisConnHandlesToAses(void) { LeAudioDevice* leAudioDevice = GetFirstActiveDevice(); log::assert_that(leAudioDevice, "Shouldn't be called without an active device."); - log::info("Group {}, group_id {}", fmt::ptr(this), group_id_); + log::info("Group {}, group_id {}", std::format_ptr(this), group_id_); /* Assign all CIS connection handles to ases */ for (; leAudioDevice != nullptr; leAudioDevice = GetNextActiveDevice(leAudioDevice)) { @@ -1482,7 +1482,7 @@ void LeAudioDeviceGroup::CigConfiguration::UnassignCis(LeAudioDevice* leAudioDev uint16_t conn_handle) { log::assert_that(leAudioDevice, "Invalid device"); - log::info("Group {}, group_id {}, device: {}, conn_handle: {:#x}", fmt::ptr(group_), + log::info("Group {}, group_id {}, device: {}, conn_handle: {:#x}", std::format_ptr(group_), group_->group_id_, leAudioDevice->address_, conn_handle); for (struct bluetooth::le_audio::types::cis& cis_entry : cises) { diff --git a/system/bta/le_audio/le_audio_client_test.cc b/system/bta/le_audio/le_audio_client_test.cc index c2398ffe06..2c7ecbb7e9 100644 --- a/system/bta/le_audio/le_audio_client_test.cc +++ b/system/bta/le_audio/le_audio_client_test.cc @@ -1318,7 +1318,7 @@ protected: log::info( ", sink ase to delete. Cis handle: {}, ase pointer: " "{}", - (int)(pair.first), fmt::ptr(+ases.sink)); + (int)(pair.first), std::format_ptr(+ases.sink)); if (ases.sink) { stream_conf->stream_params.sink.num_of_devices--; stream_conf->stream_params.sink.num_of_channels -= @@ -1342,7 +1342,7 @@ protected: auto ases = leAudioDevice->GetAsesByCisConnHdl(pair.first); log::info(", source to delete. Cis handle: {}, ase pointer: {}", - (int)(pair.first), fmt::ptr(ases.source)); + (int)(pair.first), std::format_ptr(ases.source)); if (ases.source) { stream_conf->stream_params.source.num_of_devices--; stream_conf->stream_params.source.num_of_channels -= @@ -1378,7 +1378,7 @@ protected: log::info( ", sink ase to delete. Cis handle: {}, ase " "pointer: {}", - (int)(pair.first), fmt::ptr(+ases.sink)); + (int)(pair.first), std::format_ptr(+ases.sink)); if (ases.sink) { stream_conf->stream_params.sink.num_of_devices--; stream_conf->stream_params.sink.num_of_channels -= @@ -1403,7 +1403,7 @@ protected: log::info( ", source to delete. Cis handle: {}, ase pointer: " "{}", - (int)(pair.first), fmt::ptr(+ases.source)); + (int)(pair.first), std::format_ptr(+ases.source)); if (ases.source) { stream_conf->stream_params.source.num_of_devices--; stream_conf->stream_params.source.num_of_channels -= diff --git a/system/bta/le_audio/le_audio_health_status.h b/system/bta/le_audio/le_audio_health_status.h index 62b6a17ec1..95f0aba3d8 100644 --- a/system/bta/le_audio/le_audio_health_status.h +++ b/system/bta/le_audio/le_audio_health_status.h @@ -159,11 +159,11 @@ inline std::ostream& operator<<(std::ostream& os, } } // namespace bluetooth::le_audio -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::LeAudioHealthDeviceStatType> : enum_formatter<bluetooth::le_audio::LeAudioHealthDeviceStatType> {}; template <> struct formatter<bluetooth::le_audio::LeAudioHealthGroupStatType> : enum_formatter<bluetooth::le_audio::LeAudioHealthGroupStatType> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/le_audio/le_audio_types.h b/system/bta/le_audio/le_audio_types.h index 85bb1beed4..a0c5f364c7 100644 --- a/system/bta/le_audio/le_audio_types.h +++ b/system/bta/le_audio/le_audio_types.h @@ -28,6 +28,7 @@ #include <bit> #include <bitset> #include <map> +#include <memory> #include <optional> #include <string> #include <variant> @@ -1329,7 +1330,7 @@ void AppendMetadataLtvEntryForStreamingContext(std::vector<uint8_t>& metadata, uint8_t GetMaxCodecFramesPerSduFromPac(const types::acs_ac_record* pac_record); } // namespace bluetooth::le_audio -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::DsaMode> : enum_formatter<bluetooth::le_audio::DsaMode> {}; template <> @@ -1338,4 +1339,4 @@ struct formatter<bluetooth::le_audio::types::CisType> template <> struct formatter<bluetooth::le_audio::types::LeAudioConfigurationStrategy> : enum_formatter<bluetooth::le_audio::types::LeAudioConfigurationStrategy> {}; -} // namespace fmt +} // namespace std diff --git a/system/bta/le_audio/le_audio_utils.cc b/system/bta/le_audio/le_audio_utils.cc index b4b89694a8..3b899267c7 100644 --- a/system/bta/le_audio/le_audio_utils.cc +++ b/system/bta/le_audio/le_audio_utils.cc @@ -34,7 +34,7 @@ using bluetooth::common::ToString; using bluetooth::le_audio::types::AudioContexts; using bluetooth::le_audio::types::LeAudioContextType; -namespace fmt { +namespace std { template <> struct formatter<audio_usage_t> : enum_formatter<audio_usage_t> {}; template <> @@ -43,7 +43,7 @@ template <> struct formatter<audio_source_t> : enum_formatter<audio_source_t> {}; template <> struct formatter<audio_devices_t> : enum_formatter<audio_devices_t> {}; -} // namespace fmt +} // namespace std namespace bluetooth::le_audio { namespace utils { diff --git a/system/bta/le_audio/state_machine.cc b/system/bta/le_audio/state_machine.cc index 1f01b3b763..cc59c4dad7 100644 --- a/system/bta/le_audio/state_machine.cc +++ b/system/bta/le_audio/state_machine.cc @@ -541,7 +541,7 @@ public: ToString(group->cig.GetState())); group->cig.SetState(CigState::CREATED); - log::info("Group: {}, id: {} cig state: {}, number of cis handles: {}", fmt::ptr(group), + log::info("Group: {}, id: {} cig state: {}, number of cis handles: {}", std::format_ptr(group), group->group_id_, ToString(group->cig.GetState()), static_cast<int>(conn_handles.size())); @@ -793,17 +793,17 @@ public: } void RemoveCigForGroup(LeAudioDeviceGroup* group) { - log::debug("Group: {}, id: {} cig state: {}", fmt::ptr(group), group->group_id_, + log::debug("Group: {}, id: {} cig state: {}", std::format_ptr(group), group->group_id_, ToString(group->cig.GetState())); if (group->cig.GetState() != CigState::CREATED) { - log::warn("Group: {}, id: {} cig state: {} cannot be removed", fmt::ptr(group), + log::warn("Group: {}, id: {} cig state: {} cannot be removed", std::format_ptr(group), group->group_id_, ToString(group->cig.GetState())); return; } group->cig.SetState(CigState::REMOVING); IsoManager::GetInstance()->RemoveCig(group->group_id_); - log::debug("Group: {}, id: {} cig state: {}", fmt::ptr(group), group->group_id_, + log::debug("Group: {}, id: {} cig state: {}", std::format_ptr(group), group->group_id_, ToString(group->cig.GetState())); log_history_->AddLogHistory(kLogStateMachineTag, group->group_id_, RawAddress::kEmpty, kLogCigRemoveOp); @@ -1501,12 +1501,12 @@ private: uint8_t packing, framing, sca; std::vector<EXT_CIS_CFG> cis_cfgs; - log::debug("Group: {}, id: {} cig state: {}", fmt::ptr(group), group->group_id_, + log::debug("Group: {}, id: {} cig state: {}", std::format_ptr(group), group->group_id_, ToString(group->cig.GetState())); if (group->cig.GetState() != CigState::NONE) { - log::warn("Group {}, id: {} has invalid cig state: {}", fmt::ptr(group), group->group_id_, - ToString(group->cig.GetState())); + log::warn("Group {}, id: {} has invalid cig state: {}", std::format_ptr(group), + group->group_id_, ToString(group->cig.GetState())); return false; } @@ -1620,7 +1620,7 @@ private: group->cig.SetState(CigState::CREATING); IsoManager::GetInstance()->CreateCig(group->group_id_, std::move(param)); - log::debug("Group: {}, id: {} cig state: {}", fmt::ptr(group), group->group_id_, + log::debug("Group: {}, id: {} cig state: {}", std::format_ptr(group), group->group_id_, ToString(group->cig.GetState())); return true; } diff --git a/system/bta/sys/bta_sys.h b/system/bta/sys/bta_sys.h index e1bca2fdbe..e1a9e5e803 100644 --- a/system/bta/sys/bta_sys.h +++ b/system/bta/sys/bta_sys.h @@ -260,11 +260,11 @@ void bta_sys_cust_eir_register(tBTA_SYS_CUST_EIR_CBACK* p_cback); void bta_sys_add_cust_uuid(const tBTA_CUSTOM_UUID& curr); void bta_sys_remove_cust_uuid(const tBTA_CUSTOM_UUID& curr); -namespace fmt { +namespace std { template <> struct formatter<tBTA_SYS_ID> : enum_formatter<tBTA_SYS_ID> {}; template <> struct formatter<tBTA_SYS_CONN_STATUS> : enum_formatter<tBTA_SYS_CONN_STATUS> {}; -} // namespace fmt +} // namespace std #endif /* BTA_SYS_H */ diff --git a/system/bta/test/bta_api_test.cc b/system/bta/test/bta_api_test.cc index 0075fa560a..ccf8bdfd2c 100644 --- a/system/bta/test/bta_api_test.cc +++ b/system/bta/test/bta_api_test.cc @@ -18,10 +18,10 @@ #include <base/functional/bind.h> #include <base/location.h> -#include <fmt/format.h> #include <gtest/gtest.h> #include <cstdint> +#include <format> #include <utility> #include <vector> @@ -47,7 +47,7 @@ TEST_F(BtaApiTest, bta_status_text) { for (const auto& status : statuses) { ASSERT_STREQ(status.second.c_str(), bta_status_text(status.first).c_str()); } - auto unknown = fmt::format("UNKNOWN[{}]", std::numeric_limits<uint8_t>::max()); + auto unknown = std::format("UNKNOWN[{}]", std::numeric_limits<uint8_t>::max()); ASSERT_STREQ( unknown.c_str(), bta_status_text(static_cast<tBTA_STATUS>(std::numeric_limits<uint8_t>::max())).c_str()); diff --git a/system/bta/test/bta_disc_test.cc b/system/bta/test/bta_disc_test.cc index 0979226b9d..72e446c122 100644 --- a/system/bta/test/bta_disc_test.cc +++ b/system/bta/test/bta_disc_test.cc @@ -20,7 +20,6 @@ #include <bluetooth/log.h> #include <com_android_bluetooth_flags.h> #include <flag_macros.h> -#include <fmt/format.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <sys/socket.h> diff --git a/system/bta/test/bta_dm_test.cc b/system/bta/test/bta_dm_test.cc index e4d2fb9f91..91a8390172 100644 --- a/system/bta/test/bta_dm_test.cc +++ b/system/bta/test/bta_dm_test.cc @@ -19,10 +19,10 @@ #include <bluetooth/log.h> #include <com_android_bluetooth_flags.h> #include <flag_macros.h> -#include <fmt/format.h> #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <format> #include <string> #include "bta/dm/bta_dm_device_search_int.h" @@ -427,11 +427,10 @@ TEST_F(BtaDmTest, bta_dm_search_evt_text) { for (const auto& event : events) { ASSERT_STREQ(event.second.c_str(), bta_dm_search_evt_text(event.first).c_str()); } - ASSERT_STREQ( - fmt::format("UNKNOWN[{}]", std::numeric_limits<uint8_t>::max()).c_str(), - bta_dm_search_evt_text( - static_cast<tBTA_DM_SEARCH_EVT>(std::numeric_limits<uint8_t>::max())) - .c_str()); + ASSERT_STREQ(std::format("UNKNOWN[{}]", std::numeric_limits<uint8_t>::max()).c_str(), + bta_dm_search_evt_text( + static_cast<tBTA_DM_SEARCH_EVT>(std::numeric_limits<uint8_t>::max())) + .c_str()); } TEST_F(BtaDmTest, bta_dm_remote_name_cmpl) { diff --git a/system/bta/test/bta_gatt_client_test.cc b/system/bta/test/bta_gatt_client_test.cc index 5dca10548e..3c19614768 100644 --- a/system/bta/test/bta_gatt_client_test.cc +++ b/system/bta/test/bta_gatt_client_test.cc @@ -14,11 +14,11 @@ * limitations under the License. */ -#include <fmt/format.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <sys/socket.h> +#include <format> #include <string> #include "bta/dm/bta_dm_gatt_client.h" @@ -54,11 +54,11 @@ TEST_F(BtaDiscTest, gatt_history_callback) { }; // C string - gatt_history_callback(fmt::format("{}", a[0].c_str())); + gatt_history_callback(std::format("{}", a[0].c_str())); // Cpp string gatt_history_callback(a[1]); // Third entry for "fun" - gatt_history_callback(fmt::format("{}", a[2].c_str())); + gatt_history_callback(std::format("{}", a[2].c_str())); std::vector<bluetooth::common::TimestampedEntry<std::string>> history = bluetooth::legacy::testing::PullCopyOfGattHistory(); diff --git a/system/bta/test/bta_sec_test.cc b/system/bta/test/bta_sec_test.cc index ddf83e5e5d..20b82cc480 100644 --- a/system/bta/test/bta_sec_test.cc +++ b/system/bta/test/bta_sec_test.cc @@ -14,7 +14,6 @@ * limitations under the License. */ -#include <fmt/format.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <sys/socket.h> diff --git a/system/btif/co/bta_pan_co.cc b/system/btif/co/bta_pan_co.cc index 558149239d..2928373e20 100644 --- a/system/btif/co/bta_pan_co.cc +++ b/system/btif/co/bta_pan_co.cc @@ -122,7 +122,7 @@ void bta_pan_co_tx_path(uint16_t handle, uint8_t app_id) { log::error("cannot find pan connection"); return; } else if (conn->state != PAN_STATE_OPEN) { - log::error("conn is not opened, conn:{}, conn->state:{}", fmt::ptr(conn), conn->state); + log::error("conn is not opened, conn:{}, conn->state:{}", std::format_ptr(conn), conn->state); return; } diff --git a/system/btif/include/btif_a2dp_sink.h b/system/btif/include/btif_a2dp_sink.h index 2c71f655ae..81d4bff29b 100644 --- a/system/btif/include/btif_a2dp_sink.h +++ b/system/btif/include/btif_a2dp_sink.h @@ -133,9 +133,9 @@ void btif_a2dp_sink_set_audio_track_gain(float gain); // Get audio track handle void* btif_a2dp_sink_get_audio_track(void); -namespace fmt { +namespace std { template <> struct formatter<btif_a2dp_sink_focus_state_t> : enum_formatter<btif_a2dp_sink_focus_state_t> {}; -} // namespace fmt +} // namespace std #endif /* BTIF_A2DP_SINK_H */ diff --git a/system/btif/include/btif_bqr.h b/system/btif/include/btif_bqr.h index 38bfa8badc..e1ec64c149 100644 --- a/system/btif/include/btif_bqr.h +++ b/system/btif/include/btif_bqr.h @@ -530,10 +530,10 @@ void SetLmpLlMessageTraceLogFd(int fd); } // namespace bqr } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::bqr::BqrReportAction> : enum_formatter<bluetooth::bqr::BqrReportAction> {}; template <> struct formatter<bluetooth::bqr::BqrVseSubEvt> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/btif/include/btif_hd.h b/system/btif/include/btif_hd.h index 055811800c..feaa6784c9 100644 --- a/system/btif/include/btif_hd.h +++ b/system/btif/include/btif_hd.h @@ -45,9 +45,9 @@ bt_status_t btif_hd_execute_service(bool b_enable); void btif_hd_remove_device(RawAddress bd_addr); void btif_hd_service_registration(); -namespace fmt { +namespace std { template <> struct formatter<BTIF_HD_STATUS> : enum_formatter<BTIF_HD_STATUS> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/btif/include/btif_hh.h b/system/btif/include/btif_hh.h index a0774c5376..c55ddedec2 100644 --- a/system/btif/include/btif_hh.h +++ b/system/btif/include/btif_hh.h @@ -173,9 +173,9 @@ namespace bluetooth::legacy::testing { void bte_hh_evt(tBTA_HH_EVT event, tBTA_HH* p_data); } // namespace bluetooth::legacy::testing -namespace fmt { +namespace std { template <> struct formatter<BTIF_HH_STATUS> : enum_formatter<BTIF_HH_STATUS> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/btif/src/btif_a2dp.cc b/system/btif/src/btif_a2dp.cc index f7632bfa9d..63e6c6c74a 100644 --- a/system/btif/src/btif_a2dp.cc +++ b/system/btif/src/btif_a2dp.cc @@ -52,7 +52,7 @@ void btif_a2dp_on_idle(const RawAddress& /*peer_addr*/, const A2dpType local_a2d bool btif_a2dp_on_started(const RawAddress& peer_addr, tBTA_AV_START* p_av_start, const A2dpType local_a2dp_type) { - log::info("## ON A2DP STARTED ## peer {} p_av_start:{}", peer_addr, fmt::ptr(p_av_start)); + log::info("## ON A2DP STARTED ## peer {} p_av_start:{}", peer_addr, std::format_ptr(p_av_start)); if (p_av_start == NULL) { auto status = BluetoothAudioStatus::SUCCESS; @@ -95,7 +95,7 @@ bool btif_a2dp_on_started(const RawAddress& peer_addr, tBTA_AV_START* p_av_start } void btif_a2dp_on_stopped(tBTA_AV_SUSPEND* p_av_suspend, const A2dpType local_a2dp_type) { - log::info("## ON A2DP STOPPED ## p_av_suspend={}", fmt::ptr(p_av_suspend)); + log::info("## ON A2DP STOPPED ## p_av_suspend={}", std::format_ptr(p_av_suspend)); const uint8_t peer_type_sep = btif_av_get_peer_sep(local_a2dp_type); if (peer_type_sep == AVDT_TSEP_SRC) { @@ -111,7 +111,7 @@ void btif_a2dp_on_stopped(tBTA_AV_SUSPEND* p_av_suspend, const A2dpType local_a2 } void btif_a2dp_on_suspended(tBTA_AV_SUSPEND* p_av_suspend, const A2dpType local_a2dp_type) { - log::info("## ON A2DP SUSPENDED ## p_av_suspend={}", fmt::ptr(p_av_suspend)); + log::info("## ON A2DP SUSPENDED ## p_av_suspend={}", std::format_ptr(p_av_suspend)); const uint8_t peer_type_sep = btif_av_get_peer_sep(local_a2dp_type); if (peer_type_sep == AVDT_TSEP_SRC) { btif_a2dp_sink_on_suspended(p_av_suspend); diff --git a/system/btif/src/btif_av.cc b/system/btif/src/btif_av.cc index ce8d74fb8b..34d081c8ee 100644 --- a/system/btif/src/btif_av.cc +++ b/system/btif/src/btif_av.cc @@ -1553,7 +1553,8 @@ bool BtifAvSink::AllowedToConnect(const RawAddress& peer_address) const { if ((btif_a2dp_sink_get_audio_track() != nullptr) && (peer->PeerAddress() != peer_address)) { log::info("there is another peer with audio track({}), another={}, peer={}", - fmt::ptr(btif_a2dp_sink_get_audio_track()), peer->PeerAddress(), peer_address); + std::format_ptr(btif_a2dp_sink_get_audio_track()), peer->PeerAddress(), + peer_address); connected++; } break; diff --git a/system/btif/src/btif_core.cc b/system/btif/src/btif_core.cc index c5a723d09b..73fe810e23 100644 --- a/system/btif/src/btif_core.cc +++ b/system/btif/src/btif_core.cc @@ -379,7 +379,7 @@ static bt_status_t btif_in_get_remote_device_properties(RawAddress* bd_addr) { } static void btif_core_storage_adapter_write(bt_property_t* prop) { - log::verbose("type: {}, len {}, {}", prop->type, prop->len, fmt::ptr(prop->val)); + log::verbose("type: {}, len {}, {}", prop->type, prop->len, std::format_ptr(prop->val)); bt_status_t status = btif_storage_set_adapter_property(prop); GetInterfaceToProfiles()->events->invoke_adapter_properties_cb(status, 1, prop); } @@ -550,7 +550,7 @@ void btif_set_scan_mode(bt_scan_mode_t mode) { void btif_set_adapter_property(bt_property_t* property) { log::verbose("btif_set_adapter_property type: {}, len {}, {}", property->type, property->len, - fmt::ptr(property->val)); + std::format_ptr(property->val)); switch (property->type) { case BT_PROPERTY_BDNAME: { diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc index 70762b7c64..f50bd55456 100644 --- a/system/btif/src/btif_dm.cc +++ b/system/btif/src/btif_dm.cc @@ -177,11 +177,11 @@ struct btif_dm_pairing_cb_t { ServiceDiscoveryState sdp_over_classic; }; -namespace fmt { +namespace std { template <> struct formatter<btif_dm_pairing_cb_t::ServiceDiscoveryState> : enum_formatter<btif_dm_pairing_cb_t::ServiceDiscoveryState> {}; -} // namespace fmt +} // namespace std // TODO(jpawlowski): unify ? // btif_dm_local_key_id_t == tBTM_BLE_LOCAL_ID_KEYS == tBTA_BLE_LOCAL_ID_KEYS diff --git a/system/btif/src/btif_pan.cc b/system/btif/src/btif_pan.cc index 21d95ae0b4..1b45e9e6e2 100644 --- a/system/btif/src/btif_pan.cc +++ b/system/btif/src/btif_pan.cc @@ -470,7 +470,7 @@ btpan_conn_t* btpan_find_conn_addr(const RawAddress& addr) { static void btpan_open_conn(btpan_conn_t* conn, tBTA_PAN* p_data) { log::verbose("btpan_open_conn: local_role:{}, peer_role: {}, handle:{}, conn: {}", p_data->open.local_role, p_data->open.peer_role, p_data->open.handle, - fmt::ptr(conn)); + std::format_ptr(conn)); if (conn == NULL) { conn = btpan_new_conn(p_data->open.handle, p_data->open.bd_addr, p_data->open.local_role, @@ -500,7 +500,7 @@ static void btpan_open_conn(btpan_conn_t* conn, tBTA_PAN* p_data) { } static void btpan_close_conn(btpan_conn_t* conn) { - log::verbose("btpan_close_conn: {}", fmt::ptr(conn)); + log::verbose("btpan_close_conn: {}", std::format_ptr(conn)); if (conn && conn->state == PAN_STATE_OPEN) { log::verbose("btpan_close_conn: PAN_STATE_OPEN"); diff --git a/system/btif/src/btif_profile_queue.cc b/system/btif/src/btif_profile_queue.cc index 38d00f470f..3e6e0aab25 100644 --- a/system/btif/src/btif_profile_queue.cc +++ b/system/btif/src/btif_profile_queue.cc @@ -55,7 +55,7 @@ public: : address_(address), uuid_(uuid), busy_(false), connect_cb_(connect_cb) {} std::string ToString() const { - return fmt::format("address={} UUID={:04X} busy={}", address_, uuid_, busy_); + return std::format("address={} UUID={:04X} busy={}", address_, uuid_, busy_); } const RawAddress& address() const { return address_; } diff --git a/system/btif/src/btif_sdp_server.cc b/system/btif/src/btif_sdp_server.cc index c7c29188dd..6d3dfd4e03 100644 --- a/system/btif/src/btif_sdp_server.cc +++ b/system/btif/src/btif_sdp_server.cc @@ -72,10 +72,10 @@ typedef struct { bluetooth_sdp_record* record_data; } sdp_slot_t; -namespace fmt { +namespace std { template <> struct formatter<sdp_state_t> : enum_formatter<sdp_state_t> {}; -} // namespace fmt +} // namespace std #define MAX_SDP_SLOTS 128 static sdp_slot_t sdp_slots[MAX_SDP_SLOTS]; diff --git a/system/btif/src/btif_sock_rfc.cc b/system/btif/src/btif_sock_rfc.cc index 84c80bfb22..e8bf6b42fe 100644 --- a/system/btif/src/btif_sock_rfc.cc +++ b/system/btif/src/btif_sock_rfc.cc @@ -742,7 +742,8 @@ static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id) { break; } if (p_data->scn == 0) { - log::error("Unable to allocate scn: all resources exhausted. slot found: {}", fmt::ptr(rs)); + log::error("Unable to allocate scn: all resources exhausted. slot found: {}", + std::format_ptr(rs)); cleanup_rfc_slot(rs); break; } @@ -789,7 +790,7 @@ static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id) { } if (!create_server_sdp_record(slot)) { - log::error("cannot start server, slot found: {}", fmt::ptr(slot)); + log::error("cannot start server, slot found: {}", std::format_ptr(slot)); cleanup_rfc_slot(slot); break; } diff --git a/system/common/message_loop_thread.h b/system/common/message_loop_thread.h index 3c842a01e7..301a4848a7 100644 --- a/system/common/message_loop_thread.h +++ b/system/common/message_loop_thread.h @@ -217,7 +217,7 @@ inline std::ostream& operator<<(std::ostream& os, const bluetooth::common::Messa } // namespace common } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::common::MessageLoopThread> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/common/metrics.cc b/system/common/metrics.cc index 90539a7447..49b73a01c3 100644 --- a/system/common/metrics.cc +++ b/system/common/metrics.cc @@ -42,7 +42,7 @@ #include "osi/include/osi.h" #include "types/raw_address.h" -namespace fmt { +namespace std { template <> struct formatter<android::bluetooth::DirectionEnum> : enum_formatter<android::bluetooth::DirectionEnum> {}; @@ -58,7 +58,7 @@ struct formatter<android::bluetooth::AddressTypeEnum> template <> struct formatter<android::bluetooth::DeviceInfoSrcEnum> : enum_formatter<android::bluetooth::DeviceInfoSrcEnum> {}; -} // namespace fmt +} // namespace std namespace bluetooth { namespace common { diff --git a/system/device/src/interop.cc b/system/device/src/interop.cc index 0768aa0b3d..1c8798e366 100644 --- a/system/device/src/interop.cc +++ b/system/device/src/interop.cc @@ -181,10 +181,10 @@ typedef struct { } entry_type; } interop_db_entry_t; -namespace fmt { +namespace std { template <> struct formatter<interop_bl_type> : enum_formatter<interop_bl_type> {}; -} // namespace fmt +} // namespace std static const char* interop_feature_string_(const interop_feature_t feature); static void interop_free_entry_(void* data); @@ -264,7 +264,7 @@ void interop_database_add(const uint16_t feature, const RawAddress* addr, size_t void interop_database_clear() { log::debug("interop_is_initialized: {} interop_list: {}", interop_is_initialized, - fmt::ptr(interop_list)); + std::format_ptr(interop_list)); if (interop_is_initialized && interop_list) { for (int feature = BEGINNING_OF_INTEROP_LIST; feature != END_OF_INTEROP_LIST; feature++) { diff --git a/system/gd/hal/snoop_logger.cc b/system/gd/hal/snoop_logger.cc index 0fc1939d7c..d08ad0b78c 100644 --- a/system/gd/hal/snoop_logger.cc +++ b/system/gd/hal/snoop_logger.cc @@ -1409,12 +1409,12 @@ void SnoopLogger::LogTracePoint(const HciPacket& packet, Direction direction, Pa 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), + std::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), + std::string message = std::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()); @@ -1423,7 +1423,7 @@ void SnoopLogger::LogTracePoint(const HciPacket& packet, Direction direction, Pa case PacketType::CMD: { uint16_t op_code = packet[0] | (packet[1] << 8); - std::string message = fmt::format("BTSL:{}/{}/{}/{:04x}", static_cast<uint8_t>(type), + std::string message = std::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()); @@ -1432,15 +1432,15 @@ void SnoopLogger::LogTracePoint(const HciPacket& packet, Direction direction, Pa 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); + std::string message = + std::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), + std::string message = std::format("BTSL:{}/{}/{}", static_cast<uint8_t>(type), static_cast<uint8_t>(direction), packet.size()); ATRACE_INSTANT_FOR_TRACK(LOG_TAG, message.c_str()); diff --git a/system/gd/hal/snoop_logger.h b/system/gd/hal/snoop_logger.h index bcd406cc9d..f3a4add0da 100644 --- a/system/gd/hal/snoop_logger.h +++ b/system/gd/hal/snoop_logger.h @@ -343,8 +343,8 @@ private: } // namespace hal } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::hal::profile_type_t> : enum_formatter<bluetooth::hal::profile_type_t> { }; -} // namespace fmt +} // namespace std diff --git a/system/gd/hci/acl_manager/round_robin_scheduler.h b/system/gd/hci/acl_manager/round_robin_scheduler.h index 8d51ccd86a..61be5f1147 100644 --- a/system/gd/hci/acl_manager/round_robin_scheduler.h +++ b/system/gd/hci/acl_manager/round_robin_scheduler.h @@ -89,8 +89,8 @@ private: } // namespace hci } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::hci::acl_manager::RoundRobinScheduler::ConnectionType> : enum_formatter<bluetooth::hci::acl_manager::RoundRobinScheduler::ConnectionType> {}; -} // namespace fmt +} // namespace std diff --git a/system/gd/hci/address.h b/system/gd/hci/address.h index d3626fd0fb..b7e2bdeade 100644 --- a/system/gd/hci/address.h +++ b/system/gd/hci/address.h @@ -114,15 +114,15 @@ struct hash<bluetooth::hci::Address> { #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bluetooth::hci::Address> : formatter<std::string> { template <class Context> typename Context::iterator format(const bluetooth::hci::Address& address, Context& ctx) const { std::string repr = address.ToRedactedStringForLogging(); - return fmt::formatter<std::string>::format(repr, ctx); + return std::formatter<std::string>::format(repr, ctx); } }; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h> diff --git a/system/gd/hci/address_with_type.h b/system/gd/hci/address_with_type.h index 0c3eb5e00a..c196989838 100644 --- a/system/gd/hci/address_with_type.h +++ b/system/gd/hci/address_with_type.h @@ -155,16 +155,16 @@ struct hash<bluetooth::hci::AddressWithType> { #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bluetooth::hci::AddressWithType> : formatter<std::string> { template <class Context> typename Context::iterator format(const bluetooth::hci::AddressWithType& address, Context& ctx) const { std::string repr = address.ToRedactedStringForLogging(); - return fmt::formatter<std::string>::format(repr, ctx); + return std::formatter<std::string>::format(repr, ctx); } }; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h> diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc index 1f88332043..38415f59cb 100644 --- a/system/gd/hci/controller.cc +++ b/system/gd/hci/controller.cc @@ -1560,9 +1560,9 @@ std::string Controller::ToString() const { return "Controller"; } template <typename OutputT> void Controller::impl::dump(OutputT&& out) const { - fmt::format_to(out, "\nHCI Controller Dumpsys:\n"); + std::format_to(out, "\nHCI Controller Dumpsys:\n"); - fmt::format_to(out, + std::format_to(out, " local_version_information:\n" " hci_version: {}\n" " hci_revision: 0x{:x}\n" @@ -1575,7 +1575,7 @@ void Controller::impl::dump(OutputT&& out) const { local_version_information_.lmp_subversion_, local_version_information_.manufacturer_name_); - fmt::format_to(out, + std::format_to(out, " buffer_size:\n" " acl_data_packet_length: {}\n" " total_num_acl_data_packets: {}\n" @@ -1583,7 +1583,7 @@ void Controller::impl::dump(OutputT&& out) const { " total_num_sco_data_packets: {}\n", acl_buffer_length_, acl_buffers_, sco_buffer_length_, sco_buffers_); - fmt::format_to(out, + std::format_to(out, " le_buffer_size:\n" " le_acl_data_packet_length: {}\n" " total_num_le_acl_data_packets: {}\n" @@ -1592,7 +1592,7 @@ void Controller::impl::dump(OutputT&& out) const { le_buffer_size_.le_data_packet_length_, le_buffer_size_.total_num_le_packets_, iso_buffer_size_.le_data_packet_length_, iso_buffer_size_.total_num_le_packets_); - fmt::format_to(out, + std::format_to(out, " le_maximum_data_length:\n" " supported_max_tx_octets: {}\n" " supported_max_tx_time: {}\n" @@ -1603,7 +1603,7 @@ void Controller::impl::dump(OutputT&& out) const { le_maximum_data_length_.supported_max_rx_octets_, le_maximum_data_length_.supported_max_rx_time_); - fmt::format_to(out, + std::format_to(out, " le_accept_list_size: {}\n" " le_resolving_list_size: {}\n" " le_maximum_advertising_data_length: {}\n" @@ -1615,7 +1615,7 @@ void Controller::impl::dump(OutputT&& out) const { le_suggested_default_data_length_, le_number_supported_advertising_sets_, le_periodic_advertiser_list_size_, le_supported_states_); - fmt::format_to(out, + std::format_to(out, " local_supported_features:\n" " page0: 0x{:016x}\n" " page1: 0x{:016x}\n" @@ -1625,16 +1625,16 @@ void Controller::impl::dump(OutputT&& out) const { extended_lmp_features_array_[0], extended_lmp_features_array_[1], extended_lmp_features_array_[2], le_local_supported_features_); - fmt::format_to(out, " local_supported_commands: ["); + std::format_to(out, " local_supported_commands: ["); for (size_t i = 0; i < local_supported_commands_.size(); i++) { if ((i % 8) == 0) { - fmt::format_to(out, "\n "); + std::format_to(out, "\n "); } - fmt::format_to(out, " 0x{:02x},", local_supported_commands_[i]); + std::format_to(out, " 0x{:02x},", local_supported_commands_[i]); } - fmt::format_to(out, "\n ]\n"); + std::format_to(out, "\n ]\n"); - fmt::format_to( + std::format_to( out, " vendor_capabilities:\n" " is_supported: {}\n" diff --git a/system/gd/hci/distance_measurement_manager.h b/system/gd/hci/distance_measurement_manager.h index 70739c39e4..93f0f5ab20 100644 --- a/system/gd/hci/distance_measurement_manager.h +++ b/system/gd/hci/distance_measurement_manager.h @@ -119,8 +119,8 @@ private: } // namespace hci } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::hci::DistanceMeasurementMethod> : enum_formatter<bluetooth::hci::DistanceMeasurementMethod> {}; -} // namespace fmt +} // namespace std diff --git a/system/gd/hci/facade/le_acl_manager_facade.cc b/system/gd/hci/facade/le_acl_manager_facade.cc index e80cad40a3..3e7ff96892 100644 --- a/system/gd/hci/facade/le_acl_manager_facade.cc +++ b/system/gd/hci/facade/le_acl_manager_facade.cc @@ -36,11 +36,11 @@ using ::grpc::ServerContext; using ::bluetooth::packet::RawBuilder; -namespace fmt { +namespace std { template <> struct formatter<blueberry::facade::BluetoothAddressTypeEnum> : enum_formatter<blueberry::facade::BluetoothAddressTypeEnum> {}; -} // namespace fmt +} // namespace std namespace bluetooth { namespace hci { diff --git a/system/gd/hci/le_advertising_manager.h b/system/gd/hci/le_advertising_manager.h index 52d0802ab0..aa3fbbdb16 100644 --- a/system/gd/hci/le_advertising_manager.h +++ b/system/gd/hci/le_advertising_manager.h @@ -185,8 +185,8 @@ private: } // namespace hci } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::hci::AdvertiserAddressType> : enum_formatter<bluetooth::hci::AdvertiserAddressType> {}; -} // namespace fmt +} // namespace std diff --git a/system/gd/os/android/metrics.cc b/system/gd/os/android/metrics.cc index 69563654c6..d4185ef31b 100644 --- a/system/gd/os/android/metrics.cc +++ b/system/gd/os/android/metrics.cc @@ -31,7 +31,7 @@ #include "hardware/bt_av.h" #include "hci/hci_packets.h" -namespace fmt { +namespace std { template <> struct formatter<android::bluetooth::DirectionEnum> : enum_formatter<android::bluetooth::DirectionEnum> {}; @@ -51,7 +51,7 @@ template <> struct formatter<android::bluetooth::EventType> : enum_formatter<android::bluetooth::EventType> {}; template <> struct formatter<android::bluetooth::State> : enum_formatter<android::bluetooth::State> {}; -} // namespace fmt +} // namespace std namespace bluetooth { namespace os { diff --git a/system/gd/os/internal/wakelock_native.h b/system/gd/os/internal/wakelock_native.h index 82c7069f57..f1eedbc6c2 100644 --- a/system/gd/os/internal/wakelock_native.h +++ b/system/gd/os/internal/wakelock_native.h @@ -52,8 +52,8 @@ private: } // namespace os } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::os::internal::WakelockNative::StatusCode> : enum_formatter<bluetooth::os::internal::WakelockNative::StatusCode> {}; -} // namespace fmt +} // namespace std diff --git a/system/gd/packet/parser/gen_cpp.cc b/system/gd/packet/parser/gen_cpp.cc index 199624f6e3..7dd2deee07 100644 --- a/system/gd/packet/parser/gen_cpp.cc +++ b/system/gd/packet/parser/gen_cpp.cc @@ -271,7 +271,7 @@ using ::bluetooth::packet::RawBuilder; namespace_prefix += "::"; } - out_file << "#if __has_include(<bluetooth/log.h>)" << std::endl << "namespace fmt {" << std::endl; + out_file << "#if __has_include(<bluetooth/log.h>)" << std::endl << "namespace std {" << std::endl; for (const auto& e : decls.type_defs_queue_) { if (e.second->GetDefinitionType() == TypeDef::Type::ENUM) { const auto* enum_def = static_cast<const EnumDef*>(e.second); @@ -281,7 +281,7 @@ using ::bluetooth::packet::RawBuilder; << std::endl; } } - out_file << "} // namespace fmt" << std::endl + out_file << "} // namespace std" << std::endl << "#endif // __has_include(<bluetooth/log.h>)" << std::endl; out_file.close(); diff --git a/system/include/hardware/avrcp/avrcp_logging_helper.h b/system/include/hardware/avrcp/avrcp_logging_helper.h index 5ae1f4076e..c53d2ec34e 100644 --- a/system/include/hardware/avrcp/avrcp_logging_helper.h +++ b/system/include/hardware/avrcp/avrcp_logging_helper.h @@ -41,7 +41,7 @@ inline std::string CTypeText(const CType& type) { CASE_RETURN_TEXT(CType::CHANGED); CASE_RETURN_TEXT(CType::INTERIM); default: - return fmt::format("Unknown CType: 0x{:x}", (uint8_t)type); + return std::format("Unknown CType: 0x{:x}", (uint8_t)type); } } @@ -56,7 +56,7 @@ inline std::string OpcodeText(const Opcode& opcode) { CASE_RETURN_TEXT(Opcode::SUBUNIT_INFO); CASE_RETURN_TEXT(Opcode::PASS_THROUGH); default: - return fmt::format("Unknown Opcode: 0x{:x}", (uint8_t)opcode); + return std::format("Unknown Opcode: 0x{:x}", (uint8_t)opcode); } } @@ -78,7 +78,7 @@ inline std::string CommandPduText(const CommandPdu& pdu) { CASE_RETURN_TEXT(CommandPdu::SET_ADDRESSED_PLAYER); CASE_RETURN_TEXT(CommandPdu::PLAY_ITEM); default: - return fmt::format("Unknown Command PDU: 0x{:x}", (uint8_t)pdu); + return std::format("Unknown Command PDU: 0x{:x}", (uint8_t)pdu); } } @@ -90,7 +90,7 @@ inline std::string PacketTypeText(const PacketType& type) { switch (type) { CASE_RETURN_TEXT(PacketType::SINGLE); default: - return fmt::format("Unknown Packet Type: 0x{:x}", (uint8_t)type); + return std::format("Unknown Packet Type: 0x{:x}", (uint8_t)type); } } @@ -103,7 +103,7 @@ inline std::string CapabilityText(const Capability& cap) { CASE_RETURN_TEXT(Capability::COMPANY_ID); CASE_RETURN_TEXT(Capability::EVENTS_SUPPORTED); default: - return fmt::format("Unknown Capability: 0x{:x}", (uint8_t)cap); + return std::format("Unknown Capability: 0x{:x}", (uint8_t)cap); } } @@ -123,7 +123,7 @@ inline std::string EventText(const Event& event) { CASE_RETURN_TEXT(Event::UIDS_CHANGED); CASE_RETURN_TEXT(Event::VOLUME_CHANGED); default: - return fmt::format("Unknown Event: 0x{:x}", (uint8_t)event); + return std::format("Unknown Event: 0x{:x}", (uint8_t)event); } } @@ -142,7 +142,7 @@ inline std::string AttributeText(const Attribute& attr) { CASE_RETURN_TEXT(Attribute::PLAYING_TIME); CASE_RETURN_TEXT(Attribute::DEFAULT_COVER_ART); default: - return fmt::format("Unknown Attribute Value: 0x{:x}", (uint32_t)attr); + return std::format("Unknown Attribute Value: 0x{:x}", (uint32_t)attr); } } @@ -176,7 +176,7 @@ inline std::string StatusText(const Status& status) { CASE_RETURN_TEXT(Status::NO_AVAILABLE_PLAYERS); CASE_RETURN_TEXT(Status::ADDRESSED_PLAYER_CHANGED); default: - return fmt::format("Unknown Status: 0x{:x}", (uint8_t)status); + return std::format("Unknown Status: 0x{:x}", (uint8_t)status); } } @@ -191,7 +191,7 @@ inline std::string BrowsePduText(const BrowsePdu& pdu) { CASE_RETURN_TEXT(BrowsePdu::CHANGE_PATH); CASE_RETURN_TEXT(BrowsePdu::GET_ITEM_ATTRIBUTES); default: - return fmt::format("Unknown Browse PDU: 0x{:x}", (uint8_t)pdu); + return std::format("Unknown Browse PDU: 0x{:x}", (uint8_t)pdu); } } @@ -206,7 +206,7 @@ inline std::string ScopeText(const Scope& scope) { CASE_RETURN_TEXT(Scope::SEARCH); CASE_RETURN_TEXT(Scope::NOW_PLAYING); default: - return fmt::format("Unknown Scope: 0x{:x}", (uint8_t)scope); + return std::format("Unknown Scope: 0x{:x}", (uint8_t)scope); } } @@ -217,7 +217,7 @@ inline std::string DirectionText(const Direction& dir) { CASE_RETURN_TEXT(Direction::UP); CASE_RETURN_TEXT(Direction::DOWN); default: - return fmt::format("Unknown Direction: 0x{:x}", (uint8_t)dir); + return std::format("Unknown Direction: 0x{:x}", (uint8_t)dir); } } @@ -230,7 +230,7 @@ inline std::string KeyStateText(const KeyState& state) { CASE_RETURN_TEXT(KeyState::PUSHED); CASE_RETURN_TEXT(KeyState::RELEASED); default: - return fmt::format("Unknown KeyState: 0x{:x}", (uint8_t)state); + return std::format("Unknown KeyState: 0x{:x}", (uint8_t)state); } } @@ -245,7 +245,7 @@ inline std::string PlayerAttributeText(const PlayerAttribute& attr) { CASE_RETURN_TEXT(PlayerAttribute::SHUFFLE); CASE_RETURN_TEXT(PlayerAttribute::SCAN); } - return fmt::format("Unknown Player Attribute: 0x{:x}", (uint8_t)attr); + return std::format("Unknown Player Attribute: 0x{:x}", (uint8_t)attr); } inline std::ostream& operator<<(std::ostream& os, const PlayerAttribute& attr) { @@ -259,7 +259,7 @@ inline std::string PlayerRepeatValueText(const PlayerRepeatValue& val) { CASE_RETURN_TEXT(PlayerRepeatValue::ALL); CASE_RETURN_TEXT(PlayerRepeatValue::GROUP); } - return fmt::format("Unknown Player Repeat Value: 0x{:x}", (uint8_t)val); + return std::format("Unknown Player Repeat Value: 0x{:x}", (uint8_t)val); } inline std::ostream& operator<<(std::ostream& os, const PlayerRepeatValue& val) { @@ -272,7 +272,7 @@ inline std::string PlayerShuffleValueText(const PlayerShuffleValue& val) { CASE_RETURN_TEXT(PlayerShuffleValue::ALL); CASE_RETURN_TEXT(PlayerShuffleValue::GROUP); } - return fmt::format("Unknown Player Shuffle Value: 0x{:x}", (uint8_t)val); + return std::format("Unknown Player Shuffle Value: 0x{:x}", (uint8_t)val); } inline std::ostream& operator<<(std::ostream& os, const PlayerShuffleValue& val) { @@ -282,7 +282,7 @@ inline std::ostream& operator<<(std::ostream& os, const PlayerShuffleValue& val) } // namespace avrcp } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::avrcp::CType> : ostream_formatter {}; template <> @@ -313,4 +313,4 @@ template <> struct formatter<bluetooth::avrcp::PlayerRepeatValue> : ostream_formatter {}; template <> struct formatter<bluetooth::avrcp::PlayerShuffleValue> : ostream_formatter {}; -} // namespace fmt +} // namespace std diff --git a/system/include/hardware/bluetooth.h b/system/include/hardware/bluetooth.h index 5ae5549dc5..5593e6b646 100644 --- a/system/include/hardware/bluetooth.h +++ b/system/include/hardware/bluetooth.h @@ -1000,7 +1000,7 @@ typedef struct { #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bt_status_t> : enum_formatter<bt_status_t> {}; template <> @@ -1009,7 +1009,7 @@ template <> struct formatter<bt_bond_state_t> : enum_formatter<bt_bond_state_t> {}; template <> struct formatter<bt_property_type_t> : enum_formatter<bt_property_type_t> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/include/hardware/bt_av.h b/system/include/hardware/bt_av.h index c6a9d7ae5c..b839cb048f 100644 --- a/system/include/hardware/bt_av.h +++ b/system/include/hardware/bt_av.h @@ -21,6 +21,7 @@ #include <hardware/bluetooth.h> #include <optional> +#include <sstream> #include <vector> #include "types/raw_address.h" @@ -286,7 +287,7 @@ typedef struct { __END_DECLS -namespace fmt { +namespace std { template <> struct formatter<btav_connection_state_t> : enum_formatter<btav_connection_state_t> {}; template <> @@ -306,6 +307,6 @@ struct formatter<btav_a2dp_codec_channel_mode_t> : enum_formatter<btav_a2dp_code template <> struct formatter<btav_a2dp_scmst_enable_status_t> : enum_formatter<btav_a2dp_scmst_enable_status_t> {}; -} // namespace fmt +} // namespace std #endif /* ANDROID_INCLUDE_BT_AV_H */ diff --git a/system/include/hardware/bt_common_types.h b/system/include/hardware/bt_common_types.h index e3d6b39901..d7b6cc42a3 100644 --- a/system/include/hardware/bt_common_types.h +++ b/system/include/hardware/bt_common_types.h @@ -150,10 +150,10 @@ struct MsftAdvMonitor { #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bt_gatt_db_attribute_type_t> : enum_formatter<bt_gatt_db_attribute_type_t> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ diff --git a/system/include/hardware/bt_gmap.h b/system/include/hardware/bt_gmap.h index bc3e669556..7d722fb954 100644 --- a/system/include/hardware/bt_gmap.h +++ b/system/include/hardware/bt_gmap.h @@ -44,7 +44,7 @@ enum class UGGFeatureBitMask : uint8_t { } // namespace gmap } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::gmap::RolesBitMask> : enum_formatter<bluetooth::gmap::RolesBitMask> {}; template <> @@ -53,4 +53,4 @@ struct formatter<bluetooth::gmap::UGTFeatureBitMask> template <> struct formatter<bluetooth::gmap::UGGFeatureBitMask> : enum_formatter<bluetooth::gmap::UGGFeatureBitMask> {}; -} // namespace fmt +} // namespace std diff --git a/system/include/hardware/bt_hd.h b/system/include/hardware/bt_hd.h index f86e2ee22f..0a4c78fa19 100644 --- a/system/include/hardware/bt_hd.h +++ b/system/include/hardware/bt_hd.h @@ -120,10 +120,10 @@ __END_DECLS #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bthd_report_type_t> : enum_formatter<bthd_report_type_t> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/include/hardware/bt_hf.h b/system/include/hardware/bt_hf.h index 48771e2145..48ff4d1b4d 100644 --- a/system/include/hardware/bt_hf.h +++ b/system/include/hardware/bt_hf.h @@ -118,7 +118,7 @@ typedef enum { } // namespace headset } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::headset::bthf_connection_state_t> : enum_formatter<bluetooth::headset::bthf_connection_state_t> {}; @@ -149,4 +149,4 @@ struct formatter<bluetooth::headset::bthf_swb_codec_t> template <> struct formatter<bluetooth::headset::bthf_swb_config_t> : enum_formatter<bluetooth::headset::bthf_swb_config_t> {}; -} // namespace fmt +} // namespace std diff --git a/system/include/hardware/bt_hf_client.h b/system/include/hardware/bt_hf_client.h index fe4c98b3e6..24a1c109eb 100644 --- a/system/include/hardware/bt_hf_client.h +++ b/system/include/hardware/bt_hf_client.h @@ -384,8 +384,8 @@ typedef struct { bt_status_t (*send_android_at)(const RawAddress* bd_addr, const char* arg); } bthf_client_interface_t; -namespace fmt { +namespace std { template <> struct formatter<bthf_client_connection_state_t> : enum_formatter<bthf_client_connection_state_t> { }; -} // namespace fmt +} // namespace std diff --git a/system/include/hardware/bt_hh.h b/system/include/hardware/bt_hh.h index b326fc1324..38f41ff44a 100644 --- a/system/include/hardware/bt_hh.h +++ b/system/include/hardware/bt_hh.h @@ -232,14 +232,14 @@ __END_DECLS #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bthh_connection_state_t> : enum_formatter<bthh_connection_state_t> {}; template <> struct formatter<bthh_protocol_mode_t> : enum_formatter<bthh_protocol_mode_t> {}; template <> struct formatter<bthh_report_type_t> : enum_formatter<bthh_report_type_t> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/include/hardware/bt_le_audio.h b/system/include/hardware/bt_le_audio.h index 8feb83f090..91ce17c388 100644 --- a/system/include/hardware/bt_le_audio.h +++ b/system/include/hardware/bt_le_audio.h @@ -547,7 +547,7 @@ public: } /* namespace le_audio */ } /* namespace bluetooth */ -namespace fmt { +namespace std { template <> struct formatter<bluetooth::le_audio::btle_audio_codec_index_t> : enum_formatter<bluetooth::le_audio::btle_audio_codec_index_t> {}; @@ -566,4 +566,4 @@ struct formatter<bluetooth::le_audio::btle_audio_frame_duration_index_t> template <> struct formatter<bluetooth::le_audio::GroupStreamStatus> : enum_formatter<bluetooth::le_audio::GroupStreamStatus> {}; -} // namespace fmt +} // namespace std diff --git a/system/include/hardware/bt_pan.h b/system/include/hardware/bt_pan.h index 95ce4ac469..bf8d615143 100644 --- a/system/include/hardware/bt_pan.h +++ b/system/include/hardware/bt_pan.h @@ -83,10 +83,10 @@ typedef struct { void (*cleanup)(void); } btpan_interface_t; -namespace fmt { +namespace std { template <> struct formatter<btpan_connection_state_t> : enum_formatter<btpan_connection_state_t> {}; template <> struct formatter<btpan_control_state_t> : enum_formatter<btpan_control_state_t> {}; -} // namespace fmt +} // namespace std diff --git a/system/include/hardware/bt_rc.h b/system/include/hardware/bt_rc.h index d6a984e479..7438c938dd 100644 --- a/system/include/hardware/bt_rc.h +++ b/system/include/hardware/bt_rc.h @@ -680,7 +680,7 @@ __END_DECLS #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<btrc_status_t> : enum_formatter<btrc_status_t> {}; template <> @@ -689,7 +689,7 @@ template <> struct formatter<btrc_remote_features_t> : enum_formatter<btrc_remote_features_t> {}; template <> struct formatter<btrc_notification_type_t> : enum_formatter<btrc_notification_type_t> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/include/hardware/bt_sdp.h b/system/include/hardware/bt_sdp.h index 8246bc74ab..d595637af4 100644 --- a/system/include/hardware/bt_sdp.h +++ b/system/include/hardware/bt_sdp.h @@ -178,9 +178,9 @@ __END_DECLS #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bluetooth_sdp_types> : enum_formatter<bluetooth_sdp_types> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/include/hardware/bt_sock.h b/system/include/hardware/bt_sock.h index fd28ff3e91..ad8cc459e2 100644 --- a/system/include/hardware/bt_sock.h +++ b/system/include/hardware/bt_sock.h @@ -125,9 +125,9 @@ __END_DECLS #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<btsock_type_t> : enum_formatter<btsock_type_t> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/include/hardware/bt_vc.h b/system/include/hardware/bt_vc.h index 10ede4faad..50adebe13d 100644 --- a/system/include/hardware/bt_vc.h +++ b/system/include/hardware/bt_vc.h @@ -150,11 +150,11 @@ public: } /* namespace vc */ } /* namespace bluetooth */ -namespace fmt { +namespace std { template <> struct formatter<bluetooth::vc::VolumeInputType> : enum_formatter<bluetooth::vc::VolumeInputType> { }; template <> struct formatter<bluetooth::vc::VolumeInputStatus> : enum_formatter<bluetooth::vc::VolumeInputStatus> {}; -} // namespace fmt +} // namespace std diff --git a/system/include/macros.h b/system/include/macros.h index 1bf83cd7b9..9fb3891515 100644 --- a/system/include/macros.h +++ b/system/include/macros.h @@ -27,11 +27,11 @@ #define CASE_RETURN_STRING(enumerator) \ case enumerator: \ - return fmt::format(#enumerator "(0x{:x})", static_cast<uint64_t>(enumerator)) + return std::format(#enumerator "(0x{:x})", static_cast<uint64_t>(enumerator)) #define CASE_RETURN_STRING_HEX04(enumerator) \ case enumerator: \ - return fmt::format(#enumerator "(0x{:04x})", static_cast<uint64_t>(enumerator)) + return std::format(#enumerator "(0x{:04x})", static_cast<uint64_t>(enumerator)) #define RETURN_UNKNOWN_TYPE_STRING(type, variable) \ - return fmt::format("Unknown {}(0x{:x})", #type, static_cast<uint64_t>(variable)) + return std::format("Unknown {}(0x{:x})", #type, static_cast<uint64_t>(variable)) diff --git a/system/log/include/bluetooth/log.h b/system/log/include/bluetooth/log.h index b8921c6f1c..34cb605204 100644 --- a/system/log/include/bluetooth/log.h +++ b/system/log/include/bluetooth/log.h @@ -16,9 +16,10 @@ #pragma once -#include <fmt/core.h> -#include <fmt/ranges.h> -#include <fmt/std.h> +#include <atomic> +#include <format> +#include <sstream> +#include <string_view> #ifndef LOG_TAG #define LOG_TAG "bluetooth" @@ -53,8 +54,8 @@ struct source_location { /// Write a single log line. /// The implementation of this function is dependent on the backend. -void vlog(Level level, char const* tag, source_location location, fmt::string_view fmt, - fmt::format_args vargs); +void vlog(Level level, char const* tag, source_location location, std::string_view fmt, + std::format_args vargs); /// Capture invalid parameter values that would cause runtime /// formatting errors. @@ -85,16 +86,15 @@ char*& format_replace(char*& arg) { template <Level level, typename... T> struct log { - log(fmt::format_string<T...> fmt, T&&... args, source_location location = source_location()) { - vlog(level, LOG_TAG, location, static_cast<fmt::string_view>(fmt), - fmt::make_format_args(format_replace(args)...)); + log(std::format_string<T...> fmt, T&&... args, source_location location = source_location()) { + vlog(level, LOG_TAG, location, fmt.get(), std::make_format_args(format_replace(args)...)); } }; #if (__cplusplus >= 202002L && defined(__GNUC__) && !defined(__clang__)) template <int level, typename... T> -log(fmt::format_string<T...>, T&&...) -> log<level, T...>; +log(std::format_string<T...>, T&&...) -> log<level, T...>; #endif @@ -139,61 +139,60 @@ struct verbose : log_internal::log<log_internal::kVerbose, T...> { }; template <typename... T> -error(fmt::format_string<T...>, T&&...) -> error<T...>; +error(std::format_string<T...>, T&&...) -> error<T...>; template <typename... T> -warn(fmt::format_string<T...>, T&&...) -> warn<T...>; +warn(std::format_string<T...>, T&&...) -> warn<T...>; template <typename... T> -info(fmt::format_string<T...>, T&&...) -> info<T...>; +info(std::format_string<T...>, T&&...) -> info<T...>; template <typename... T> -debug(fmt::format_string<T...>, T&&...) -> debug<T...>; +debug(std::format_string<T...>, T&&...) -> debug<T...>; template <typename... T> -verbose(fmt::format_string<T...>, T&&...) -> verbose<T...>; +verbose(std::format_string<T...>, T&&...) -> verbose<T...>; #endif // GCC / C++20 [[noreturn]] [[maybe_unused]] static void fatal( - fmt::format_string<> fmt, + std::format_string<> fmt, log_internal::source_location location = log_internal::source_location()) { - vlog(log_internal::kFatal, LOG_TAG, location, static_cast<fmt::string_view>(fmt), - fmt::make_format_args()); + vlog(log_internal::kFatal, LOG_TAG, location, fmt.get(), std::make_format_args()); std::abort(); // Enforce [[noreturn]] } template <typename T0> [[noreturn]] [[maybe_unused]] static void fatal( - fmt::format_string<T0> fmt, T0&& arg0, + std::format_string<T0> fmt, T0&& arg0, log_internal::source_location location = log_internal::source_location()) { - vlog(log_internal::kFatal, LOG_TAG, location, static_cast<fmt::string_view>(fmt), - fmt::make_format_args(log_internal::format_replace(arg0))); + vlog(log_internal::kFatal, LOG_TAG, location, fmt.get(), + std::make_format_args(log_internal::format_replace(arg0))); std::abort(); // Enforce [[noreturn]] } template <typename T0, typename T1> [[noreturn]] [[maybe_unused]] static void fatal( - fmt::format_string<T0, T1> fmt, T0&& arg0, T1&& arg1, + std::format_string<T0, T1> fmt, T0&& arg0, T1&& arg1, log_internal::source_location location = log_internal::source_location()) { - vlog(log_internal::kFatal, LOG_TAG, location, static_cast<fmt::string_view>(fmt), - fmt::make_format_args(log_internal::format_replace(arg0), + vlog(log_internal::kFatal, LOG_TAG, location, fmt.get(), + std::make_format_args(log_internal::format_replace(arg0), log_internal::format_replace(arg1))); std::abort(); // Enforce [[noreturn]] } template <typename T0, typename T1, typename T2> [[noreturn]] [[maybe_unused]] static void fatal( - fmt::format_string<T0, T1, T2> fmt, T0&& arg0, T1&& arg1, T2&& arg2, + std::format_string<T0, T1, T2> fmt, T0&& arg0, T1&& arg1, T2&& arg2, log_internal::source_location location = log_internal::source_location()) { - vlog(log_internal::kFatal, LOG_TAG, location, static_cast<fmt::string_view>(fmt), - fmt::make_format_args(log_internal::format_replace(arg0), log_internal::format_replace(arg1), + vlog(log_internal::kFatal, LOG_TAG, location, fmt.get(), + std::make_format_args(log_internal::format_replace(arg0), log_internal::format_replace(arg1), log_internal::format_replace(arg2))); std::abort(); // Enforce [[noreturn]] } template <typename T0, typename T1, typename T2, typename T3> [[noreturn]] [[maybe_unused]] static void fatal( - fmt::format_string<T0, T1, T2, T3> fmt, T0&& arg0, T1&& arg1, T2&& arg2, T3&& arg3, + std::format_string<T0, T1, T2, T3> fmt, T0&& arg0, T1&& arg1, T2&& arg2, T3&& arg3, log_internal::source_location location = log_internal::source_location()) { - vlog(log_internal::kFatal, LOG_TAG, location, static_cast<fmt::string_view>(fmt), - fmt::make_format_args(log_internal::format_replace(arg0), log_internal::format_replace(arg1), + vlog(log_internal::kFatal, LOG_TAG, location, fmt.get(), + std::make_format_args(log_internal::format_replace(arg0), log_internal::format_replace(arg1), log_internal::format_replace(arg2), log_internal::format_replace(arg3))); std::abort(); // Enforce [[noreturn]] @@ -201,21 +200,63 @@ template <typename T0, typename T1, typename T2, typename T3> template <typename... T> struct assert_that { - assert_that(bool cond, fmt::format_string<T...> fmt, T&&... args, + assert_that(bool cond, std::format_string<T...> fmt, T&&... args, log_internal::source_location location = log_internal::source_location()) { if (!cond) { - vlog(log_internal::kFatal, LOG_TAG, location, static_cast<fmt::string_view>(fmt), - fmt::make_format_args(log_internal::format_replace(args)...)); + vlog(log_internal::kFatal, LOG_TAG, location, fmt.get(), + std::make_format_args(log_internal::format_replace(args)...)); } } }; template <typename... T> -assert_that(bool, fmt::format_string<T...>, T&&...) -> assert_that<T...>; +assert_that(bool, std::format_string<T...>, T&&...) -> assert_that<T...>; } // namespace bluetooth::log -namespace fmt { +namespace std { + +/// Helper to format a pointer value as the memory address. +/// Use this helper as `std::format("{}", std::format_ptr(value));`. +template <typename T> +const void* format_ptr(T* ptr) { + return reinterpret_cast<const void*>(ptr); +} + +/// Derive formatter for std::atomic<T> types where T is formattable. +/// The formatter uses the default memory order `std::memory_order_seq_cst` +/// for reading the value. +template <typename T, typename CharT> +struct formatter<std::atomic<T>, CharT> : formatter<T, CharT> { + template <typename Context> + auto format(const std::atomic<T>& v, Context& ctx) const -> decltype(ctx.out()) { + return formatter<T, CharT>::format(v.load(), ctx); + } +}; + +/// Default formatter implementation for formatting +/// types overloading the ostream `operator<<`. +/// +/// Enable this formatter in the code by declaring: +/// ``` +/// template<> +/// struct std::formatter<T> : ostream_formatter {}; +/// ``` +template <typename CharT> +struct basic_ostream_formatter : formatter<basic_string_view<CharT>, CharT> { + void set_debug_format() = delete; + + template <typename T, typename Context> + auto format(const T& value, Context& ctx) const -> decltype(ctx.out()) { + auto&& output = std::basic_stringstream<CharT>(); + output.imbue(std::locale::classic()); // The default is always unlocalized. + output << value; + output.exceptions(std::ios_base::failbit | std::ios_base::badbit); + return formatter<basic_string_view<CharT>, CharT>::format(output.str(), ctx); + } +}; + +using ostream_formatter = basic_ostream_formatter<char>; /// Default formatter implementation for formatting /// enum class values to the underlying type. @@ -223,13 +264,13 @@ namespace fmt { /// Enable this formatter in the code by declaring: /// ``` /// template<> -/// struct fmt::formatter<EnumT> : enum_formatter<EnumT> {}; +/// struct std::formatter<EnumT> : enum_formatter<EnumT> {}; /// ``` template <typename EnumT, class CharT = char> -struct enum_formatter : fmt::formatter<std::underlying_type_t<EnumT>, CharT> { +struct enum_formatter : std::formatter<std::underlying_type_t<EnumT>, CharT> { template <class Context> typename Context::iterator format(EnumT value, Context& ctx) const { - return fmt::formatter<std::underlying_type_t<EnumT>, CharT>::format( + return std::formatter<std::underlying_type_t<EnumT>, CharT>::format( static_cast<std::underlying_type_t<EnumT>>(value), ctx); } }; @@ -241,14 +282,14 @@ struct enum_formatter : fmt::formatter<std::underlying_type_t<EnumT>, CharT> { /// Enable this formatter in the code by declaring: /// ``` /// template<> -/// struct fmt::formatter<T> : string_formatter<T, &T_to_str> {}; +/// struct std::formatter<T> : string_formatter<T, &T_to_str> {}; /// ``` template <typename T, std::string (*F)(const T&), class CharT = char> -struct string_formatter : fmt::formatter<std::string> { +struct string_formatter : std::formatter<std::string> { template <class Context> typename Context::iterator format(const T& value, Context& ctx) const { - return fmt::formatter<std::string>::format(F(value), ctx); + return std::formatter<std::string>::format(F(value), ctx); } }; -} // namespace fmt +} // namespace std diff --git a/system/log/src/truncating_buffer_test.cc b/system/log/src/truncating_buffer_test.cc index a0b4a099af..3940a082a0 100644 --- a/system/log/src/truncating_buffer_test.cc +++ b/system/log/src/truncating_buffer_test.cc @@ -18,17 +18,18 @@ #include "truncating_buffer.h" -#include <fmt/format.h> #include <gtest/gtest.h> +#include <format> + using namespace bluetooth::log_internal; TEST(TruncatingBufferTest, 1byte) { EXPECT_EQ(sizeof("ab"), 3); truncating_buffer<2> buffer_1; truncating_buffer<3> buffer_2; - fmt::format_to(std::back_insert_iterator(buffer_1), "ab"); - fmt::format_to(std::back_insert_iterator(buffer_2), "ab"); + std::format_to(std::back_insert_iterator(buffer_1), "ab"); + std::format_to(std::back_insert_iterator(buffer_2), "ab"); EXPECT_STREQ(buffer_1.c_str(), "a"); EXPECT_STREQ(buffer_2.c_str(), "ab"); } @@ -38,9 +39,9 @@ TEST(TruncatingBufferTest, 2bytes) { truncating_buffer<3> buffer_1; truncating_buffer<4> buffer_2; truncating_buffer<5> buffer_3; - fmt::format_to(std::back_insert_iterator(buffer_1), "αβ"); - fmt::format_to(std::back_insert_iterator(buffer_2), "αβ"); - fmt::format_to(std::back_insert_iterator(buffer_3), "αβ"); + std::format_to(std::back_insert_iterator(buffer_1), "αβ"); + std::format_to(std::back_insert_iterator(buffer_2), "αβ"); + std::format_to(std::back_insert_iterator(buffer_3), "αβ"); EXPECT_STREQ(buffer_1.c_str(), "α"); EXPECT_STREQ(buffer_2.c_str(), "α"); EXPECT_STREQ(buffer_3.c_str(), "αβ"); @@ -52,10 +53,10 @@ TEST(TruncatingBufferTest, 3bytes) { truncating_buffer<5> buffer_2; truncating_buffer<6> buffer_3; truncating_buffer<7> buffer_4; - fmt::format_to(std::back_insert_iterator(buffer_1), "ພຮ"); - fmt::format_to(std::back_insert_iterator(buffer_2), "ພຮ"); - fmt::format_to(std::back_insert_iterator(buffer_3), "ພຮ"); - fmt::format_to(std::back_insert_iterator(buffer_4), "ພຮ"); + std::format_to(std::back_insert_iterator(buffer_1), "ພຮ"); + std::format_to(std::back_insert_iterator(buffer_2), "ພຮ"); + std::format_to(std::back_insert_iterator(buffer_3), "ພຮ"); + std::format_to(std::back_insert_iterator(buffer_4), "ພຮ"); EXPECT_STREQ(buffer_1.c_str(), "ພ"); EXPECT_STREQ(buffer_2.c_str(), "ພ"); EXPECT_STREQ(buffer_3.c_str(), "ພ"); @@ -69,11 +70,11 @@ TEST(TruncatingBufferTest, 4bytes) { truncating_buffer<7> buffer_3; truncating_buffer<8> buffer_4; truncating_buffer<9> buffer_5; - fmt::format_to(std::back_insert_iterator(buffer_1), "𐎡𐎪"); - fmt::format_to(std::back_insert_iterator(buffer_2), "𐎡𐎪"); - fmt::format_to(std::back_insert_iterator(buffer_3), "𐎡𐎪"); - fmt::format_to(std::back_insert_iterator(buffer_4), "𐎡𐎪"); - fmt::format_to(std::back_insert_iterator(buffer_5), "𐎡𐎪"); + std::format_to(std::back_insert_iterator(buffer_1), "𐎡𐎪"); + std::format_to(std::back_insert_iterator(buffer_2), "𐎡𐎪"); + std::format_to(std::back_insert_iterator(buffer_3), "𐎡𐎪"); + std::format_to(std::back_insert_iterator(buffer_4), "𐎡𐎪"); + std::format_to(std::back_insert_iterator(buffer_5), "𐎡𐎪"); EXPECT_STREQ(buffer_1.c_str(), "𐎡"); EXPECT_STREQ(buffer_2.c_str(), "𐎡"); EXPECT_STREQ(buffer_3.c_str(), "𐎡"); diff --git a/system/log/src/vlog_android.cc b/system/log/src/vlog_android.cc index 6f4ef34ff6..53b195cabf 100644 --- a/system/log/src/vlog_android.cc +++ b/system/log/src/vlog_android.cc @@ -25,8 +25,8 @@ static constexpr std::string_view kAndroidRepoLocation = "packages/modules/Bluet static constexpr size_t kBufferSize = 1024; -void vlog(Level level, char const* tag, source_location location, fmt::string_view fmt, - fmt::format_args vargs) { +void vlog(Level level, char const* tag, source_location location, std::string_view fmt, + std::format_args vargs) { // Check if log is enabled. if (!__android_log_is_loggable(level, "bluetooth", ANDROID_LOG_INFO)) { return; @@ -44,9 +44,9 @@ void vlog(Level level, char const* tag, source_location location, fmt::string_vi // In order to have consistent logs we include it manually in the log // message. truncating_buffer<kBufferSize> buffer; - fmt::format_to(std::back_insert_iterator(buffer), "{}:{} {}: ", file_name, location.line, + std::format_to(std::back_insert_iterator(buffer), "{}:{} {}: ", file_name, location.line, location.function_name); - fmt::vformat_to(std::back_insert_iterator(buffer), fmt, vargs); + std::vformat_to(std::back_insert_iterator(buffer), fmt, vargs); // Send message to liblog. struct __android_log_message message = { diff --git a/system/log/src/vlog_syslog.cc b/system/log/src/vlog_syslog.cc index 73d7ec64e8..890fc39852 100644 --- a/system/log/src/vlog_syslog.cc +++ b/system/log/src/vlog_syslog.cc @@ -48,8 +48,8 @@ Level GetDefaultLogLevel() { return gDefaultLogLevel; } // Default value for $MaxMessageSize for rsyslog. static constexpr size_t kBufferSize = 8192; -void vlog(Level level, char const* tag, source_location location, fmt::string_view fmt, - fmt::format_args vargs) { +void vlog(Level level, char const* tag, source_location location, std::string_view fmt, + std::format_args vargs) { // Filter out logs that don't meet level requirement. Level current_level = GetLogLevelForTag(tag); if (level < current_level) { @@ -82,11 +82,11 @@ void vlog(Level level, char const* tag, source_location location, fmt::string_vi truncating_buffer<kBufferSize> buffer; // Format file, line. - fmt::format_to(std::back_insert_iterator(buffer), "{} {}:{} {}: ", tag, location.file_name, + std::format_to(std::back_insert_iterator(buffer), "{} {}:{} {}: ", tag, location.file_name, location.line, location.function_name); // Format message. - fmt::vformat_to(std::back_insert_iterator(buffer), fmt, vargs); + std::vformat_to(std::back_insert_iterator(buffer), fmt, vargs); // Print to vsyslog. syslog(LOG_USER | severity, "%s", buffer.c_str()); diff --git a/system/main/shim/acl.cc b/system/main/shim/acl.cc index 44c3a05fab..da5afc6dc8 100644 --- a/system/main/shim/acl.cc +++ b/system/main/shim/acl.cc @@ -123,16 +123,16 @@ struct hash<ConnectAddressWithType> { }; } // namespace std -namespace fmt { +namespace std { template <> struct formatter<ConnectAddressWithType> : formatter<std::string> { template <class Context> typename Context::iterator format(const ConnectAddressWithType& address, Context& ctx) const { std::string repr = address.ToRedactedStringForLogging(); - return fmt::formatter<std::string>::format(repr, ctx); + return std::formatter<std::string>::format(repr, ctx); } }; -} // namespace fmt +} // namespace std namespace { diff --git a/system/pdl/hci/include/hci/address.h b/system/pdl/hci/include/hci/address.h index 8e27da1afa..bc9c8d9127 100644 --- a/system/pdl/hci/include/hci/address.h +++ b/system/pdl/hci/include/hci/address.h @@ -114,15 +114,15 @@ struct hash<bluetooth::hci::Address> { #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bluetooth::hci::Address> : formatter<std::string> { template <class Context> typename Context::iterator format(const bluetooth::hci::Address& address, Context& ctx) const { std::string repr = address.ToRedactedStringForLogging(); - return fmt::formatter<std::string>::format(repr, ctx); + return std::formatter<std::string>::format(repr, ctx); } }; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/profile/avrcp/avrcp_sdp_service.h b/system/profile/avrcp/avrcp_sdp_service.h index dace6b8875..6f4b9ef59e 100644 --- a/system/profile/avrcp/avrcp_sdp_service.h +++ b/system/profile/avrcp/avrcp_sdp_service.h @@ -19,6 +19,7 @@ #include <bluetooth/log.h> #include <cstdint> +#include <memory> #include "avrcp_sdp_records.h" diff --git a/system/profile/avrcp/device.cc b/system/profile/avrcp/device.cc index 0201858318..a5012e8389 100644 --- a/system/profile/avrcp/device.cc +++ b/system/profile/avrcp/device.cc @@ -44,7 +44,7 @@ extern bool btif_av_both_enable(void); extern bool btif_av_src_sink_coexist_enabled(void); template <> -struct fmt::formatter<bluetooth::avrcp::PlayState> : enum_formatter<bluetooth::avrcp::PlayState> {}; +struct std::formatter<bluetooth::avrcp::PlayState> : enum_formatter<bluetooth::avrcp::PlayState> {}; namespace bluetooth { namespace avrcp { diff --git a/system/rust/src/gatt/ffi/gatt_shim.h b/system/rust/src/gatt/ffi/gatt_shim.h index 0ddbab0c96..e159831a06 100644 --- a/system/rust/src/gatt/ffi/gatt_shim.h +++ b/system/rust/src/gatt/ffi/gatt_shim.h @@ -58,8 +58,8 @@ private: } // namespace gatt } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<bluetooth::gatt::AttributeBackingType> : enum_formatter<bluetooth::gatt::AttributeBackingType> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/a2dp/a2dp_aac_encoder.cc b/system/stack/a2dp/a2dp_aac_encoder.cc index db455cda32..841ef48dbd 100644 --- a/system/stack/a2dp/a2dp_aac_encoder.cc +++ b/system/stack/a2dp/a2dp_aac_encoder.cc @@ -49,10 +49,10 @@ using namespace bluetooth; -namespace fmt { +namespace std { template <> struct formatter<AACENC_ERROR> : enum_formatter<AACENC_ERROR> {}; -} // namespace fmt +} // namespace std typedef struct { uint32_t sample_rate; diff --git a/system/stack/a2dp/a2dp_codec_config.cc b/system/stack/a2dp/a2dp_codec_config.cc index 2469cbcbb7..9155dabf52 100644 --- a/system/stack/a2dp/a2dp_codec_config.cc +++ b/system/stack/a2dp/a2dp_codec_config.cc @@ -1665,7 +1665,7 @@ std::string A2DP_CodecInfoString(const uint8_t* p_codec_info) { break; } - return fmt::format("Unsupported codec type: {:x}", codec_type); + return std::format("Unsupported codec type: {:x}", codec_type); } int A2DP_GetEecoderEffectiveFrameSize(const uint8_t* p_codec_info) { diff --git a/system/stack/a2dp/a2dp_sbc_decoder.cc b/system/stack/a2dp/a2dp_sbc_decoder.cc index b3d288107b..d59f4ae4ef 100644 --- a/system/stack/a2dp/a2dp_sbc_decoder.cc +++ b/system/stack/a2dp/a2dp_sbc_decoder.cc @@ -31,10 +31,10 @@ using namespace bluetooth; -namespace fmt { +namespace std { template <> struct formatter<OI_STATUS> : enum_formatter<OI_STATUS> {}; -} // namespace fmt +} // namespace std typedef struct { OI_CODEC_SBC_DECODER_CONTEXT decoder_context; diff --git a/system/stack/a2dp/a2dp_vendor.cc b/system/stack/a2dp/a2dp_vendor.cc index 74f1b5cbad..28a27c7cb6 100644 --- a/system/stack/a2dp/a2dp_vendor.cc +++ b/system/stack/a2dp/a2dp_vendor.cc @@ -541,5 +541,5 @@ std::string A2DP_VendorCodecInfoString(const uint8_t* p_codec_info) { // Add checks based on <vendor_id, codec_id> - return fmt::format("Unsupported codec vendor_id: 0x{:x} codec_id: 0x{:x}", vendor_id, codec_id); + return std::format("Unsupported codec vendor_id: 0x{:x} codec_id: 0x{:x}", vendor_id, codec_id); } diff --git a/system/stack/a2dp/a2dp_vendor_ldac_decoder.cc b/system/stack/a2dp/a2dp_vendor_ldac_decoder.cc index 0571216767..9c13d50160 100644 --- a/system/stack/a2dp/a2dp_vendor_ldac_decoder.cc +++ b/system/stack/a2dp/a2dp_vendor_ldac_decoder.cc @@ -34,10 +34,10 @@ using namespace bluetooth; -namespace fmt { +namespace std { template <> struct formatter<LDACBT_SMPL_FMT_T> : enum_formatter<LDACBT_SMPL_FMT_T> {}; -} // namespace fmt +} // namespace std // // Decoder for LDAC Source Codec diff --git a/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc b/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc index c2a04d64b4..4dd4a6ed60 100644 --- a/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc +++ b/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc @@ -61,10 +61,10 @@ using namespace bluetooth; -namespace fmt { +namespace std { template <> struct formatter<LDACBT_SMPL_FMT_T> : enum_formatter<LDACBT_SMPL_FMT_T> {}; -} // namespace fmt +} // namespace std typedef struct { uint32_t sample_rate; diff --git a/system/stack/avct/avct_api.cc b/system/stack/avct/avct_api.cc index 2c3db70911..33d58126c0 100644 --- a/system/stack/avct/avct_api.cc +++ b/system/stack/avct/avct_api.cc @@ -457,7 +457,7 @@ void AVCT_Dumpsys(int fd) { if (ccb.p_lcb) { // tAVCT_LCB LOG_DUMPSYS(fd, " Link : peer:%s lcid:0x%04x sm_state:%-24s ch_state:%s conflict_lcid:0x%04x", - fmt::format("{}", ccb.p_lcb->peer_addr).c_str(), ccb.p_lcb->ch_lcid, + std::format("{}", ccb.p_lcb->peer_addr).c_str(), ccb.p_lcb->ch_lcid, avct_sm_state_text(ccb.p_lcb->state).c_str(), avct_ch_state_text(ccb.p_lcb->ch_state).c_str(), ccb.p_lcb->conflict_lcid); } else { @@ -467,7 +467,7 @@ void AVCT_Dumpsys(int fd) { if (ccb.p_bcb) { // tAVCT_BCB LOG_DUMPSYS(fd, " Browse: peer:%s lcid:0x%04x sm_state:%-24s ch_state:%s conflict_lcid:0x%04x", - fmt::format("{}", ccb.p_bcb->peer_addr).c_str(), ccb.p_bcb->ch_lcid, + std::format("{}", ccb.p_bcb->peer_addr).c_str(), ccb.p_bcb->ch_lcid, avct_sm_state_text(ccb.p_bcb->state).c_str(), avct_ch_state_text(ccb.p_bcb->ch_state).c_str(), ccb.p_bcb->conflict_lcid); } else { diff --git a/system/stack/avdt/avdt_ad.cc b/system/stack/avdt/avdt_ad.cc index 92535cb84b..36b395dcf7 100644 --- a/system/stack/avdt/avdt_ad.cc +++ b/system/stack/avdt/avdt_ad.cc @@ -289,8 +289,8 @@ void avdt_ad_tc_close_ind(AvdtpTransportChannel* p_tbl) { AvdtpScb* p_scb; tAVDT_SCB_TC_CLOSE close; - log::verbose("p_tbl: {} state: {} tcid: {} type: {} ccb_idx: {} scb_hdl: {}", fmt::ptr(p_tbl), - tc_state_text(p_tbl->state), p_tbl->tcid, + log::verbose("p_tbl: {} state: {} tcid: {} type: {} ccb_idx: {} scb_hdl: {}", + std::format_ptr(p_tbl), tc_state_text(p_tbl->state), p_tbl->tcid, tc_type_text(avdt_ad_tcid_to_type(p_tbl->tcid)), p_tbl->ccb_idx, avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); @@ -338,8 +338,8 @@ void avdt_ad_tc_open_ind(AvdtpTransportChannel* p_tbl) { tAVDT_OPEN open; tAVDT_EVT_HDR evt; - log::verbose("p_tbl: {} state: {} tcid: {} type: {} ccb_idx: {} scb_hdl: {}", fmt::ptr(p_tbl), - tc_state_text(p_tbl->state), p_tbl->tcid, + log::verbose("p_tbl: {} state: {} tcid: {} type: {} ccb_idx: {} scb_hdl: {}", + std::format_ptr(p_tbl), tc_state_text(p_tbl->state), p_tbl->tcid, tc_type_text(avdt_ad_tcid_to_type(p_tbl->tcid)), p_tbl->ccb_idx, avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); @@ -401,7 +401,7 @@ void avdt_ad_tc_cong_ind(AvdtpTransportChannel* p_tbl, bool is_congested) { AvdtpScb* p_scb; log::verbose("p_tbl: {} state: {} tcid: {} type: {} ccb_idx: {} scb_hdl: {} is_congested: {}", - fmt::ptr(p_tbl), tc_state_text(p_tbl->state), p_tbl->tcid, + std::format_ptr(p_tbl), tc_state_text(p_tbl->state), p_tbl->tcid, tc_type_text(avdt_ad_tcid_to_type(p_tbl->tcid)), p_tbl->ccb_idx, avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl, is_congested); @@ -515,7 +515,7 @@ void avdt_ad_open_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb, uint8_t ro p_tbl->tcid = avdt_ad_type_to_tcid(type, p_scb); p_tbl->my_mtu = kAvdtpMtu; - log::verbose("p_tbl: {} state: {} tcid: {} type: {} role: {} my_mtu: {}", fmt::ptr(p_tbl), + log::verbose("p_tbl: {} state: {} tcid: {} type: {} role: {} my_mtu: {}", std::format_ptr(p_tbl), tc_state_text(p_tbl->state), p_tbl->tcid, tc_type_text(type), role, p_tbl->my_mtu); if (type != AVDT_CHAN_SIG) { @@ -574,9 +574,9 @@ void avdt_ad_close_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb) { AvdtpTransportChannel* p_tbl; p_tbl = avdt_ad_tc_tbl_by_type(type, p_ccb, p_scb); - log::verbose("p_tbl: {} state: {} tcid: {} type: {} ccb_idx: {} scb_hdl: {}", fmt::ptr(p_tbl), - tc_state_text(p_tbl->state), p_tbl->tcid, tc_type_text(type), p_tbl->ccb_idx, - avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); + log::verbose("p_tbl: {} state: {} tcid: {} type: {} ccb_idx: {} scb_hdl: {}", + std::format_ptr(p_tbl), tc_state_text(p_tbl->state), p_tbl->tcid, tc_type_text(type), + p_tbl->ccb_idx, avdtp_cb.ad.rt_tbl[p_tbl->ccb_idx][p_tbl->tcid].scb_hdl); switch (p_tbl->state) { case AVDT_AD_ST_UNUSED: diff --git a/system/stack/avdt/avdt_ccb.cc b/system/stack/avdt/avdt_ccb.cc index e47824385a..66eae28753 100644 --- a/system/stack/avdt/avdt_ccb.cc +++ b/system/stack/avdt/avdt_ccb.cc @@ -366,7 +366,7 @@ void avdt_ccb_event(AvdtpCcb* p_ccb, uint8_t event, tAVDT_CCB_EVT* p_data) { int i; log::verbose("CCB ccb={} event={} state={} p_ccb={}", avdt_ccb_to_idx(p_ccb), - avdt_ccb_evt_str[event], avdt_ccb_st_str[p_ccb->state], fmt::ptr(p_ccb)); + avdt_ccb_evt_str[event], avdt_ccb_st_str[p_ccb->state], std::format_ptr(p_ccb)); /* look up the state table for the current state */ state_table = avdt_ccb_st_tbl[p_ccb->state]; @@ -457,7 +457,7 @@ AvdtpCcb* avdt_ccb_alloc_by_channel_index(const RawAddress& bd_addr, uint8_t cha } p_ccb->Allocate(bd_addr); log::verbose("allocated (index {}) peer={} p_ccb={}", channel_index, p_ccb->peer_addr, - fmt::ptr(p_ccb)); + std::format_ptr(p_ccb)); return p_ccb; } @@ -484,7 +484,7 @@ void AvdtpCcb::Allocate(const RawAddress& peer_address) { ******************************************************************************/ void avdt_ccb_dealloc(AvdtpCcb* p_ccb, tAVDT_CCB_EVT* /* p_data */) { log::verbose("deallocated (index {}) peer={} p_ccb={}", avdt_ccb_to_idx(p_ccb), p_ccb->peer_addr, - fmt::ptr(p_ccb)); + std::format_ptr(p_ccb)); p_ccb->ResetCcb(); } diff --git a/system/stack/avdt/avdt_ccb_act.cc b/system/stack/avdt/avdt_ccb_act.cc index 9f8557f4b5..168d7ee0f3 100644 --- a/system/stack/avdt/avdt_ccb_act.cc +++ b/system/stack/avdt/avdt_ccb_act.cc @@ -1026,7 +1026,7 @@ void avdt_ccb_ll_opened(AvdtpCcb* p_ccb, tAVDT_CCB_EVT* p_data) { tAVDT_CTRL avdt_ctrl; log::verbose("peer {} BtaAvScbIndex={} p_ccb={}", p_ccb->peer_addr, p_ccb->BtaAvScbIndex(), - fmt::ptr(p_ccb)); + std::format_ptr(p_ccb)); p_ccb->ll_opened = true; if (!p_ccb->p_conn_cback) { diff --git a/system/stack/avdt/avdt_int.h b/system/stack/avdt/avdt_int.h index 09eb424367..09aa55793c 100644 --- a/system/stack/avdt/avdt_int.h +++ b/system/stack/avdt/avdt_int.h @@ -352,12 +352,12 @@ inline std::string tc_type_text(uint8_t type) { } } -namespace fmt { +namespace std { template <> struct formatter<tTRANSPORT_CHANNEL_STATE> : enum_formatter<tTRANSPORT_CHANNEL_STATE> {}; template <> struct formatter<tTRANSPORT_CHANNEL_TYPE> : enum_formatter<tTRANSPORT_CHANNEL_TYPE> {}; -} // namespace fmt +} // namespace std /***************************************************************************** * data types diff --git a/system/stack/avdt/avdt_scb.cc b/system/stack/avdt/avdt_scb.cc index 67be1b9d62..6f4eefa173 100644 --- a/system/stack/avdt/avdt_scb.cc +++ b/system/stack/avdt/avdt_scb.cc @@ -760,8 +760,8 @@ void avdt_scb_event(AvdtpScb* p_scb, uint8_t event, tAVDT_SCB_EVT* p_data) { uint8_t action; log::verbose("SCB hdl={} event={}/{} state={} p_avdt_scb={} scb_index={}", avdt_scb_to_hdl(p_scb), - event, avdt_scb_evt_str[event], avdt_scb_st_str[p_scb->state], fmt::ptr(p_scb), - p_scb->stream_config.scb_index); + event, avdt_scb_evt_str[event], avdt_scb_st_str[p_scb->state], + std::format_ptr(p_scb), p_scb->stream_config.scb_index); /* Check that we only send AVDT_SCB_API_WRITE_REQ_EVT to the active stream * device */ @@ -925,7 +925,7 @@ AvdtpScb* avdt_scb_by_hdl(uint8_t hdl) { return nullptr; } - log::verbose("SCB for handle {} found: p_scb={} scb_index={}", hdl, fmt::ptr(p_scb), + log::verbose("SCB for handle {} found: p_scb={} scb_index={}", hdl, std::format_ptr(p_scb), p_scb->stream_config.scb_index); return p_scb; } diff --git a/system/stack/avdt/avdt_scb_act.cc b/system/stack/avdt/avdt_scb_act.cc index 4f7c1f55db..45a7a4112d 100644 --- a/system/stack/avdt/avdt_scb_act.cc +++ b/system/stack/avdt/avdt_scb_act.cc @@ -553,7 +553,7 @@ void avdt_scb_hdl_security_rsp(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) { * ******************************************************************************/ void avdt_scb_hdl_setconfig_cmd(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) { - log::verbose("p_scb->in_use={} p_avdt_scb={} scb_index={}", p_scb->in_use, fmt::ptr(p_scb), + log::verbose("p_scb->in_use={} p_avdt_scb={} scb_index={}", p_scb->in_use, std::format_ptr(p_scb), p_scb->stream_config.scb_index); if (p_scb->in_use) { @@ -586,8 +586,8 @@ void avdt_scb_hdl_setconfig_cmd(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) { log::error( "mismatch in AVDTP SCB/CCB state: (p_scb->p_ccb={} != p_ccb={}): " "p_scb={} scb_handle={} ccb_idx={}", - fmt::ptr(p_scb->p_ccb), fmt::ptr(p_ccb), fmt::ptr(p_scb), p_scb->ScbHandle(), - p_data->msg.config_cmd.hdr.ccb_idx); + std::format_ptr(p_scb->p_ccb), std::format_ptr(p_ccb), std::format_ptr(p_scb), + p_scb->ScbHandle(), p_data->msg.config_cmd.hdr.ccb_idx); avdt_scb_rej_not_in_use(p_scb, p_data); return; } @@ -1016,7 +1016,7 @@ void avdt_scb_hdl_write_req(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) { void avdt_scb_snd_abort_req(AvdtpScb* p_scb, tAVDT_SCB_EVT* /* p_data */) { tAVDT_EVT_HDR hdr; - log::verbose("p_scb->p_ccb={}", fmt::ptr(p_scb->p_ccb)); + log::verbose("p_scb->p_ccb={}", std::format_ptr(p_scb->p_ccb)); if (p_scb->p_ccb != NULL) { p_scb->role = AVDT_CLOSE_INT; @@ -1286,8 +1286,8 @@ void avdt_scb_snd_setconfig_req(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) { log::error( "mismatch in AVDTP SCB/CCB state: (p_scb->p_ccb={} != p_ccb={}): " "p_scb={} scb_handle={} ccb_idx={}", - fmt::ptr(p_scb->p_ccb), fmt::ptr(p_ccb), fmt::ptr(p_scb), p_scb->ScbHandle(), - p_data->msg.config_cmd.hdr.ccb_idx); + std::format_ptr(p_scb->p_ccb), std::format_ptr(p_ccb), std::format_ptr(p_scb), + p_scb->ScbHandle(), p_data->msg.config_cmd.hdr.ccb_idx); avdt_scb_rej_not_in_use(p_scb, p_data); return; } diff --git a/system/stack/avrc/avrc_api.cc b/system/stack/avrc/avrc_api.cc index 273017d07e..13184ed058 100644 --- a/system/stack/avrc/avrc_api.cc +++ b/system/stack/avrc/avrc_api.cc @@ -199,7 +199,7 @@ void avrc_send_next_vendor_cmd(uint8_t handle) { p_next_cmd->layer_specific &= 0xFF; /* AVCT_DATA_CTRL or AVCT_DATA_BROWSE */ log::verbose("AVRC: Dequeuing command 0x{} (handle=0x{:02x}, label=0x{:02x})", - fmt::ptr(p_next_cmd), handle, next_label); + std::format_ptr(p_next_cmd), handle, next_label); /* Send the message */ if ((AVCT_MsgReq(handle, next_label, AVCT_CMD, p_next_cmd)) == AVCT_SUCCESS) { @@ -1309,8 +1309,8 @@ uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype, BT_HDR* p_pkt * command * is received (exception is continuation request command * must sent that to get additional response frags) */ - log::verbose("AVRC: Enqueuing command 0x{} (handle=0x{:02x}, label=0x{:02x})", fmt::ptr(p_pkt), - handle, label); + log::verbose("AVRC: Enqueuing command 0x{} (handle=0x{:02x}, label=0x{:02x})", + std::format_ptr(p_pkt), handle, label); /* label in BT_HDR (will need this later when the command is dequeued) */ p_pkt->layer_specific = (label << 8) | (p_pkt->layer_specific & 0xFF); diff --git a/system/stack/avrc/avrc_bld_ct.cc b/system/stack/avrc/avrc_bld_ct.cc index 7ad5f17c23..d6416076e7 100644 --- a/system/stack/avrc/avrc_bld_ct.cc +++ b/system/stack/avrc/avrc_bld_ct.cc @@ -582,8 +582,8 @@ tAVRC_STS AVRC_BldCommand(tAVRC_COMMAND* p_cmd, BT_HDR** pp_pkt) { bool alloc = false; log::verbose("AVRC_BldCommand: pdu={:x} status={:x}", p_cmd->cmd.pdu, p_cmd->cmd.status); if (!p_cmd || !pp_pkt) { - log::verbose("AVRC_BldCommand. Invalid parameters passed. p_cmd={}, pp_pkt={}", fmt::ptr(p_cmd), - fmt::ptr(pp_pkt)); + log::verbose("AVRC_BldCommand. Invalid parameters passed. p_cmd={}, pp_pkt={}", + std::format_ptr(p_cmd), std::format_ptr(pp_pkt)); return AVRC_STS_BAD_PARAM; } diff --git a/system/stack/avrc/avrc_bld_tg.cc b/system/stack/avrc/avrc_bld_tg.cc index b90a833a0b..d07ff6500e 100644 --- a/system/stack/avrc/avrc_bld_tg.cc +++ b/system/stack/avrc/avrc_bld_tg.cc @@ -66,7 +66,7 @@ static tAVRC_STS avrc_bld_get_capability_rsp(tAVRC_GET_CAPS_RSP* p_rsp, BT_HDR* tAVRC_STS status = AVRC_STS_NO_ERROR; if (!(AVRC_IS_VALID_CAP_ID(p_rsp->capability_id))) { - log::error("bad parameter. p_rsp: {}", fmt::ptr(p_rsp)); + log::error("bad parameter. p_rsp: {}", std::format_ptr(p_rsp)); status = AVRC_STS_BAD_PARAM; return status; } @@ -1359,8 +1359,8 @@ tAVRC_STS AVRC_BldResponse(uint8_t handle, tAVRC_RESPONSE* p_rsp, BT_HDR** pp_pk uint16_t peer_mtu; if (!p_rsp || !pp_pkt) { - log::verbose("Invalid parameters passed. p_rsp={}, pp_pkt={}", fmt::ptr(p_rsp), - fmt::ptr(pp_pkt)); + log::verbose("Invalid parameters passed. p_rsp={}, pp_pkt={}", std::format_ptr(p_rsp), + std::format_ptr(pp_pkt)); return AVRC_STS_BAD_PARAM; } diff --git a/system/stack/bnep/bnep_utils.cc b/system/stack/bnep/bnep_utils.cc index 921e16992c..0740451fda 100644 --- a/system/stack/bnep/bnep_utils.cc +++ b/system/stack/bnep/bnep_utils.cc @@ -724,7 +724,8 @@ uint8_t* bnep_process_control_packet(tBNEP_CONN* p_bcb, uint8_t* p, uint16_t* re if (rem_len != NULL) { *rem_len = 0; } - log::verbose("invalid packet: p = {} rem_len = {}", fmt::ptr(p), fmt::ptr(rem_len)); + log::verbose("invalid packet: p = {} rem_len = {}", std::format_ptr(p), + std::format_ptr(rem_len)); return NULL; } uint16_t rem_len_orig = *rem_len; diff --git a/system/stack/btm/btm_ble_sec.cc b/system/stack/btm/btm_ble_sec.cc index 71a0aefc51..7ae82b335b 100644 --- a/system/stack/btm/btm_ble_sec.cc +++ b/system/stack/btm/btm_ble_sec.cc @@ -102,7 +102,7 @@ void BTM_SecAddBleDevice(const RawAddress& bd_addr, tBT_DEVICE_TYPE dev_type, p_dev_rec->conn_params.peripheral_latency = BTM_BLE_CONN_PARAM_UNDEF; log::debug("Device added, handle=0x{:x}, p_dev_rec={}, bd_addr={}", p_dev_rec->ble_hci_handle, - fmt::ptr(p_dev_rec), bd_addr); + std::format_ptr(p_dev_rec), bd_addr); if (com::android::bluetooth::flags::name_discovery_for_le_pairing() && btif_storage_get_stored_remote_name(bd_addr, @@ -1793,7 +1793,7 @@ bool BTM_BleDataSignature(const RawAddress& bd_addr, uint8_t* p_text, uint16_t l BTM_CMAC_TLEN_SIZE, p_mac); p_rec->sec_rec.increment_sign_counter(true); - log::verbose("p_mac = {}", fmt::ptr(p_mac)); + log::verbose("p_mac = {}", std::format_ptr(p_mac)); log::verbose("p_mac[0]=0x{:02x} p_mac[1]=0x{:02x} p_mac[2]=0x{:02x} p_mac[3]=0x{:02x}", *p_mac, *(p_mac + 1), *(p_mac + 2), *(p_mac + 3)); log::verbose("p_mac[4]=0x{:02x} p_mac[5]=0x{:02x} p_mac[6]=0x{:02x} p_mac[7]=0x{:02x}", diff --git a/system/stack/btm/btm_ble_sec.h b/system/stack/btm/btm_ble_sec.h index 25e5e8fb81..cae65482cb 100644 --- a/system/stack/btm/btm_ble_sec.h +++ b/system/stack/btm/btm_ble_sec.h @@ -68,8 +68,8 @@ uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr); tBTM_STATUS btm_ble_start_sec_check(const RawAddress& bd_addr, uint16_t psm, bool is_originator, tBTM_SEC_CALLBACK* p_callback, void* p_ref_data); -namespace fmt { +namespace std { template <> struct formatter<tBTM_BLE_SEC_REQ_ACT> : string_formatter<tBTM_BLE_SEC_REQ_ACT, &btm_ble_sec_req_act_text> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/btm/btm_dev.cc b/system/stack/btm/btm_dev.cc index d4edde046c..6712527fe7 100644 --- a/system/stack/btm/btm_dev.cc +++ b/system/stack/btm/btm_dev.cc @@ -90,9 +90,9 @@ void BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, LinkKey li if (!p_dev_rec) { p_dev_rec = btm_sec_allocate_dev_rec(); log::info( - "Caching new record from config file device: {}, dev_class: 0x{:02x}, " + "Caching new record from config file device: {}, dev_class: {:02x}:{:02x}:{:02x}, " "link_key_type: 0x{:x}", - bd_addr, fmt::join(dev_class, ""), key_type); + bd_addr, dev_class[0], dev_class[1], dev_class[2], key_type); p_dev_rec->bd_addr = bd_addr; p_dev_rec->hci_handle = @@ -109,9 +109,9 @@ void BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, LinkKey li } } else { log::info( - "Caching existing record from config file device: {}, dev_class: " - "0x{:02x}, link_key_type: 0x{:x}", - bd_addr, fmt::join(dev_class, ""), key_type); + "Caching existing record from config file device: {}," + " dev_class: {:02x}:{:02x}:{:02x}, link_key_type: 0x{:x}", + bd_addr, dev_class[0], dev_class[1], dev_class[2], key_type); /* "Bump" timestamp for existing record */ p_dev_rec->timestamp = btm_sec_cb.dev_rec_count++; diff --git a/system/stack/btm/btm_iso_impl.h b/system/stack/btm/btm_iso_impl.h index 5e563e9860..cdda94f0a2 100644 --- a/system/stack/btm/btm_iso_impl.h +++ b/system/stack/btm/btm_iso_impl.h @@ -95,11 +95,11 @@ struct iso_impl { iso_impl() { iso_credits_ = shim::GetController()->GetControllerIsoBufferSize().total_num_le_packets_; iso_buffer_size_ = shim::GetController()->GetControllerIsoBufferSize().le_data_packet_length_; - log::info("{} created, iso credits: {}, buffer size: {}.", fmt::ptr(this), iso_credits_.load(), - iso_buffer_size_); + log::info("{} created, iso credits: {}, buffer size: {}.", std::format_ptr(this), + iso_credits_.load(), iso_buffer_size_); } - ~iso_impl() { log::info("{} removed.", fmt::ptr(this)); } + ~iso_impl() { log::info("{} removed.", std::format_ptr(this)); } void handle_register_cis_callbacks(CigCallbacks* callbacks) { log::assert_that(callbacks != nullptr, "Invalid CIG callbacks"); diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc index d19b9ae343..7c329b4ba2 100644 --- a/system/stack/btm/btm_sec.cc +++ b/system/stack/btm/btm_sec.cc @@ -396,7 +396,7 @@ static bool access_secure_service_from_temp_bond(const tBTM_SEC_DEV_REC* p_dev_r * ******************************************************************************/ bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info) { - log::info("p_cb_info->p_le_callback == 0x{}", fmt::ptr(p_cb_info->p_le_callback)); + log::info("p_cb_info->p_le_callback == 0x{}", std::format_ptr(p_cb_info->p_le_callback)); if (p_cb_info->p_le_callback) { log::verbose("SMP_Register( btm_proc_smp_cback )"); SMP_Register(btm_proc_smp_cback); @@ -410,7 +410,7 @@ bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info) { } btm_sec_cb.api = *p_cb_info; - log::info("btm_sec_cb.api.p_le_callback = 0x{}", fmt::ptr(btm_sec_cb.api.p_le_callback)); + log::info("btm_sec_cb.api.p_le_callback = 0x{}", std::format_ptr(btm_sec_cb.api.p_le_callback)); log::verbose("application registered"); return true; } @@ -1611,8 +1611,8 @@ tBTM_STATUS btm_sec_l2cap_access_req_by_requirement(const RawAddress& bd_addr, rc = btm_sec_execute_procedure(p_dev_rec); if (rc != tBTM_STATUS::BTM_CMD_STARTED) { - log::verbose("p_dev_rec={}, clearing callback. old p_callback={}", fmt::ptr(p_dev_rec), - fmt::ptr(p_dev_rec->sec_rec.p_callback)); + log::verbose("p_dev_rec={}, clearing callback. old p_callback={}", std::format_ptr(p_dev_rec), + std::format_ptr(p_dev_rec->sec_rec.p_callback)); p_dev_rec->sec_rec.p_callback = NULL; (*p_callback)(bd_addr, transport, p_dev_rec->sec_rec.p_ref_data, rc); } @@ -2048,8 +2048,8 @@ void btm_sec_abort_access_req(const RawAddress& bd_addr) { p_dev_rec->sec_rec.classic_link = tSECURITY_STATE::IDLE; - log::verbose("clearing callback. p_dev_rec={}, p_callback={}", fmt::ptr(p_dev_rec), - fmt::ptr(p_dev_rec->sec_rec.p_callback)); + log::verbose("clearing callback. p_dev_rec={}, p_callback={}", std::format_ptr(p_dev_rec), + std::format_ptr(p_dev_rec->sec_rec.p_callback)); p_dev_rec->sec_rec.p_callback = NULL; } @@ -2252,7 +2252,7 @@ void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr, const uint8_ if ((btm_sec_cb.pairing_state == BTM_PAIR_STATE_WAIT_LOCAL_PIN) && (btm_sec_cb.pairing_bda == bd_addr)) { log::verbose("delayed pin now being requested flags:0x{:x}, (p_pin_callback=0x{})", - btm_sec_cb.pairing_flags, fmt::ptr(btm_sec_cb.api.p_pin_callback)); + btm_sec_cb.pairing_flags, std::format_ptr(btm_sec_cb.api.p_pin_callback)); if ((btm_sec_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0 && btm_sec_cb.api.p_pin_callback) { @@ -3356,8 +3356,8 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, uint8_t encr_en if (!p_dev_rec->sec_rec.is_security_state_bredr_encrypting()) { if (tSECURITY_STATE::DELAY_FOR_ENC == p_dev_rec->sec_rec.classic_link) { p_dev_rec->sec_rec.classic_link = tSECURITY_STATE::IDLE; - log::verbose("clearing callback. p_dev_rec={}, p_callback={}", fmt::ptr(p_dev_rec), - fmt::ptr(p_dev_rec->sec_rec.p_callback)); + log::verbose("clearing callback. p_dev_rec={}, p_callback={}", std::format_ptr(p_dev_rec), + std::format_ptr(p_dev_rec->sec_rec.p_callback)); p_dev_rec->sec_rec.p_callback = NULL; l2cu_resubmit_pending_sec_req(&p_dev_rec->bd_addr); return; @@ -4364,7 +4364,8 @@ void btm_sec_pin_code_request(const RawAddress p_bda) { log::warn( "btm_sec_pin_code_request(): Pairing disabled:{}; PIN callback:{}, Dev " "Rec:{}!", - p_cb->pairing_disabled, fmt::ptr(p_cb->api.p_pin_callback), fmt::ptr(p_dev_rec)); + p_cb->pairing_disabled, std::format_ptr(p_cb->api.p_pin_callback), + std::format_ptr(p_dev_rec)); btsnd_hcic_pin_code_neg_reply(p_bda); } else { diff --git a/system/stack/btm/btm_sec_int_types.h b/system/stack/btm/btm_sec_int_types.h index 8d960d63d3..02f7b5a368 100644 --- a/system/stack/btm/btm_sec_int_types.h +++ b/system/stack/btm/btm_sec_int_types.h @@ -100,7 +100,7 @@ typedef struct tBTM_SEC_DEVCB { typedef uint8_t tBTM_SEC_ACTION; -namespace fmt { +namespace std { template <> struct formatter<tBTM_PAIRING_STATE> : enum_formatter<tBTM_PAIRING_STATE> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/btm/hfp_msbc_decoder.cc b/system/stack/btm/hfp_msbc_decoder.cc index 21666b4284..ccfbeea49f 100644 --- a/system/stack/btm/hfp_msbc_decoder.cc +++ b/system/stack/btm/hfp_msbc_decoder.cc @@ -32,10 +32,10 @@ using namespace bluetooth; -namespace fmt { +namespace std { template <> struct formatter<OI_STATUS> : enum_formatter<OI_STATUS> {}; -} // namespace fmt +} // namespace std typedef struct { OI_CODEC_SBC_DECODER_CONTEXT decoder_context; diff --git a/system/stack/btm/neighbor_inquiry.h b/system/stack/btm/neighbor_inquiry.h index be4facec6b..d4a13e9b5c 100644 --- a/system/stack/btm/neighbor_inquiry.h +++ b/system/stack/btm/neighbor_inquiry.h @@ -235,7 +235,7 @@ struct tBTM_INQUIRY_VAR_ST { bool btm_inq_find_bdaddr(const RawAddress& p_bda); tINQ_DB_ENT* btm_inq_db_find(const RawAddress& p_bda); -namespace fmt { +namespace std { template <> struct formatter<tBTM_INQUIRY_CMPL::STATUS> : enum_formatter<tBTM_INQUIRY_CMPL::STATUS> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/btm/security_device_record.h b/system/stack/btm/security_device_record.h index e6608903a4..d72e1c078b 100644 --- a/system/stack/btm/security_device_record.h +++ b/system/stack/btm/security_device_record.h @@ -381,9 +381,9 @@ public: tBTM_SEC_REC sec_rec; }; -namespace fmt { +namespace std { template <> struct formatter<tSECURITY_STATE> : string_formatter<tSECURITY_STATE, &security_state_text> {}; template <> struct formatter<tBLE_RAND_ADDR_TYPE> : enum_formatter<tBLE_RAND_ADDR_TYPE> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/eatt/eatt_impl.h b/system/stack/eatt/eatt_impl.h index 92c5cce3ec..c746695cb7 100644 --- a/system/stack/eatt/eatt_impl.h +++ b/system/stack/eatt/eatt_impl.h @@ -922,7 +922,8 @@ struct eatt_impl { } void upper_tester_connect(const RawAddress& bd_addr, eatt_device* eatt_dev, uint8_t role) { - log::info("L2CAP Upper tester enabled, {} ({}), role: {}({})", bd_addr, fmt::ptr(eatt_dev), + log::info("L2CAP Upper tester enabled, {} ({}), role: {}({})", bd_addr, + std::format_ptr(eatt_dev), role == HCI_ROLE_CENTRAL ? "HCI_ROLE_CENTRAL" : "HCI_ROLE_PERIPHERAL", role); auto num_of_chan = stack_config_get_interface()->get_pts_l2cap_ecoc_initial_chan_cnt(); diff --git a/system/stack/gatt/att_protocol.cc b/system/stack/gatt/att_protocol.cc index 8360b81406..2a5825b13e 100644 --- a/system/stack/gatt/att_protocol.cc +++ b/system/stack/gatt/att_protocol.cc @@ -470,7 +470,7 @@ static tGATT_STATUS attp_cl_send_cmd(tGATT_TCB& tcb, tGATT_CLCB* p_clcb, uint8_t if (gatt_tcb_is_cid_busy(tcb, p_clcb->cid) && cmd_code != GATT_HANDLE_VALUE_CONF) { if (gatt_cmd_enq(tcb, p_clcb, true, cmd_code, p_cmd)) { - log::debug("Enqueued ATT command {} conn_id=0x{:04x}, cid={}", fmt::ptr(p_clcb), + log::debug("Enqueued ATT command {} conn_id=0x{:04x}, cid={}", std::format_ptr(p_clcb), p_clcb->conn_id, p_clcb->cid); return GATT_CMD_STARTED; } @@ -484,7 +484,7 @@ static tGATT_STATUS attp_cl_send_cmd(tGATT_TCB& tcb, tGATT_CLCB* p_clcb, uint8_t tGATT_STATUS att_ret = attp_send_msg_to_l2cap(tcb, p_clcb->cid, p_cmd); if (att_ret != GATT_CONGESTED && att_ret != GATT_SUCCESS) { log::warn("Unable to send ATT command to l2cap layer {} conn_id=0x{:04x}, cid={}", - fmt::ptr(p_clcb), p_clcb->conn_id, p_clcb->cid); + std::format_ptr(p_clcb), p_clcb->conn_id, p_clcb->cid); return GATT_INTERNAL_ERROR; } @@ -492,7 +492,7 @@ static tGATT_STATUS attp_cl_send_cmd(tGATT_TCB& tcb, tGATT_CLCB* p_clcb, uint8_t return att_ret; } - log::debug("Starting ATT response timer {} conn_id=0x{:04x}, cid={}", fmt::ptr(p_clcb), + log::debug("Starting ATT response timer {} conn_id=0x{:04x}, cid={}", std::format_ptr(p_clcb), p_clcb->conn_id, p_clcb->cid); gatt_start_rsp_timer(p_clcb); if (!gatt_cmd_enq(tcb, p_clcb, false, cmd_code, NULL)) { diff --git a/system/stack/gatt/gatt_cl.cc b/system/stack/gatt/gatt_cl.cc index 6093d572ee..9a241813ae 100644 --- a/system/stack/gatt/gatt_cl.cc +++ b/system/stack/gatt/gatt_cl.cc @@ -1075,7 +1075,7 @@ static void gatt_process_read_rsp(tGATT_TCB& tcb, tGATT_CLCB* p_clcb, uint8_t /* } } else /* exception, should not happen */ { - log::error("attr offset = {} p_attr_buf = {}", offset, fmt::ptr(p_clcb->p_attr_buf)); + log::error("attr offset = {} p_attr_buf = {}", offset, std::format_ptr(p_clcb->p_attr_buf)); gatt_end_operation(p_clcb, GATT_NO_RESOURCES, (void*)p_clcb->p_attr_buf); } } diff --git a/system/stack/gatt/gatt_int.h b/system/stack/gatt/gatt_int.h index 88c8b88ab6..3ceaa21020 100644 --- a/system/stack/gatt/gatt_int.h +++ b/system/stack/gatt/gatt_int.h @@ -702,9 +702,9 @@ BT_HDR* attp_build_value_cmd(uint16_t payload_size, uint8_t op_code, uint16_t ha } // namespace legacy } // namespace bluetooth -namespace fmt { +namespace std { template <> struct formatter<tGATT_CH_STATE> : enum_formatter<tGATT_CH_STATE> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/stack/gatt/gatt_sr.cc b/system/stack/gatt/gatt_sr.cc index 8b67f2e204..aad7b1f89e 100644 --- a/system/stack/gatt/gatt_sr.cc +++ b/system/stack/gatt/gatt_sr.cc @@ -145,7 +145,7 @@ void gatt_dequeue_sr_cmd(tGATT_TCB& tcb, uint16_t cid) { /* Double check in case any buffers are queued */ log::verbose("gatt_dequeue_sr_cmd cid: 0x{:x}", cid); if (p_cmd->p_rsp_msg) { - log::error("free tcb.sr_cmd.p_rsp_msg = {}", fmt::ptr(p_cmd->p_rsp_msg)); + log::error("free tcb.sr_cmd.p_rsp_msg = {}", std::format_ptr(p_cmd->p_rsp_msg)); } osi_free_and_reset((void**)&p_cmd->p_rsp_msg); diff --git a/system/stack/gatt/gatt_utils.cc b/system/stack/gatt/gatt_utils.cc index 73e08dc6e2..73880e3cd4 100644 --- a/system/stack/gatt/gatt_utils.cc +++ b/system/stack/gatt/gatt_utils.cc @@ -1254,8 +1254,8 @@ void gatt_clcb_invalidate(tGATT_TCB* p_tcb, const tGATT_CLCB* p_clcb) { if (!p_tcb->pending_enc_clcb.empty()) { for (size_t i = 0; i < p_tcb->pending_enc_clcb.size(); i++) { if (p_tcb->pending_enc_clcb.at(i) == p_clcb) { - log::warn("Removing clcb ({}) for conn id=0x{:04x} from pending_enc_clcb", fmt::ptr(p_clcb), - p_clcb->conn_id); + log::warn("Removing clcb ({}) for conn id=0x{:04x} from pending_enc_clcb", + std::format_ptr(p_clcb), p_clcb->conn_id); p_tcb->pending_enc_clcb.at(i) = NULL; break; } @@ -1287,14 +1287,14 @@ void gatt_clcb_invalidate(tGATT_TCB* p_tcb, const tGATT_CLCB* p_clcb) { if (iter->to_send) { /* If command was not send, just remove the entire element */ cl_cmd_q_p->erase(iter); - log::warn("Removing scheduled clcb ({}) for conn_id=0x{:04x}", fmt::ptr(p_clcb), + log::warn("Removing scheduled clcb ({}) for conn_id=0x{:04x}", std::format_ptr(p_clcb), p_clcb->conn_id); } else { /* If command has been sent, just invalidate p_clcb pointer for proper * response handling */ iter->p_clcb = NULL; log::warn("Invalidating clcb ({}) for already sent request on conn_id=0x{:04x}", - fmt::ptr(p_clcb), p_clcb->conn_id); + std::format_ptr(p_clcb), p_clcb->conn_id); } } /******************************************************************************* @@ -1815,7 +1815,7 @@ void gatt_end_operation(tGATT_CLCB* p_clcb, tGATT_STATUS status, void* p_data) { (*p_cmpl_cb)(conn_id, op, status, &cb_data); } else { log::warn("not sent out op={} p_disc_cmpl_cb:{} p_cmpl_cb:{}", operation, - fmt::ptr(p_disc_cmpl_cb), fmt::ptr(p_cmpl_cb)); + std::format_ptr(p_disc_cmpl_cb), std::format_ptr(p_cmpl_cb)); } } diff --git a/system/stack/hid/hid_conn.h b/system/stack/hid/hid_conn.h index 77d0fa6132..1611db4ffe 100644 --- a/system/stack/hid/hid_conn.h +++ b/system/stack/hid/hid_conn.h @@ -78,9 +78,9 @@ typedef struct hid_conn { #define HIDD_SEC_CHN 3 -namespace fmt { +namespace std { template <> struct formatter<tHID_CONN_STATE> : enum_formatter<tHID_CONN_STATE> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/stack/include/a2dp_constants.h b/system/stack/include/a2dp_constants.h index 090c25a315..e766fff768 100644 --- a/system/stack/include/a2dp_constants.h +++ b/system/stack/include/a2dp_constants.h @@ -167,11 +167,11 @@ enum tA2DP_STATUS : uint8_t { A2DP_NOT_SUPPORTED_CODEC_PARAMETER = 0xE3, }; -namespace fmt { +namespace std { template <> struct formatter<bluetooth::a2dp::CodecId> : enum_formatter<bluetooth::a2dp::CodecId> {}; template <> struct formatter<tA2DP_CODEC_TYPE> : enum_formatter<tA2DP_CODEC_TYPE> {}; template <> struct formatter<tA2DP_STATUS> : enum_formatter<tA2DP_STATUS> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/bt_psm_types.h b/system/stack/include/bt_psm_types.h index 3f0716110b..a781188be3 100644 --- a/system/stack/include/bt_psm_types.h +++ b/system/stack/include/bt_psm_types.h @@ -70,7 +70,7 @@ inline std::string bt_psm_text(const tBT_PSM& psm) { inline std::string psm_to_text(uint16_t psm) { return bt_psm_text(static_cast<tBT_PSM>(psm)); } -namespace fmt { +namespace std { template <> struct formatter<tBT_PSM> : enum_formatter<tBT_PSM> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/btm_api_types.h b/system/stack/include/btm_api_types.h index 3f167bb8ce..2c2ccf211d 100644 --- a/system/stack/include/btm_api_types.h +++ b/system/stack/include/btm_api_types.h @@ -197,7 +197,7 @@ inline std::string bta_ag_uuid_codec_text(const tBTA_AG_UUID_CODEC result) { CASE_RETURN_TEXT(tBTA_AG_UUID_CODEC::UUID_CODEC_MSBC); CASE_RETURN_TEXT(tBTA_AG_UUID_CODEC::UUID_CODEC_LC3); default: - return fmt::format("UNKNOWN Codec with id {}", + return std::format("UNKNOWN Codec with id {}", static_cast<std::underlying_type_t<tBTA_AG_UUID_CODEC>>(result)); } } diff --git a/system/stack/include/btm_ble_api_types.h b/system/stack/include/btm_ble_api_types.h index db5ae7a029..9a1679768b 100644 --- a/system/stack/include/btm_ble_api_types.h +++ b/system/stack/include/btm_ble_api_types.h @@ -517,9 +517,9 @@ typedef struct { typedef void(tBTM_BLE_CTRL_FEATURES_CBACK)(tHCI_STATUS status); -namespace fmt { +namespace std { template <> struct formatter<tBTM_BLE_CONN_TYPE> : enum_formatter<tBTM_BLE_CONN_TYPE> {}; -} // namespace fmt +} // namespace std #endif // BTM_BLE_API_TYPES_H diff --git a/system/stack/include/btm_sec_api_types.h b/system/stack/include/btm_sec_api_types.h index 6b21574ed1..d04974f259 100644 --- a/system/stack/include/btm_sec_api_types.h +++ b/system/stack/include/btm_sec_api_types.h @@ -525,9 +525,9 @@ inline std::string bond_type_text(const tBTM_BOND_TYPE& bond_type) { } } -namespace fmt { +namespace std { template <> struct formatter<tBTM_BLE_SEC_ACT> : enum_formatter<tBTM_BLE_SEC_ACT> {}; template <> struct formatter<tBTM_BOND_TYPE> : enum_formatter<tBTM_BOND_TYPE> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/btm_status.h b/system/stack/include/btm_status.h index 97247dc2f2..a33a4b6a87 100644 --- a/system/stack/include/btm_status.h +++ b/system/stack/include/btm_status.h @@ -98,7 +98,7 @@ inline std::string btm_status_text(const tBTM_STATUS& status) { } } -namespace fmt { +namespace std { template <> struct formatter<tBTM_STATUS> : enum_formatter<tBTM_STATUS> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/gatt_api.h b/system/stack/include/gatt_api.h index 804d6390a2..3b751e10cf 100644 --- a/system/stack/include/gatt_api.h +++ b/system/stack/include/gatt_api.h @@ -1287,7 +1287,7 @@ void gatt_load_bonded(void); void gatt_tcb_dump(int fd); -namespace fmt { +namespace std { template <> struct formatter<GattStatus> : enum_formatter<GattStatus> {}; template <> @@ -1298,6 +1298,6 @@ template <> struct formatter<tGATT_OP_CODE> : enum_formatter<tGATT_OP_CODE> {}; template <> struct formatter<tGATT_DISC_TYPE> : enum_formatter<tGATT_DISC_TYPE> {}; -} // namespace fmt +} // namespace std #endif /* GATT_API_H */ diff --git a/system/stack/include/hci_error_code.h b/system/stack/include/hci_error_code.h index 04ebb4700a..3d4b50c745 100644 --- a/system/stack/include/hci_error_code.h +++ b/system/stack/include/hci_error_code.h @@ -247,7 +247,7 @@ inline tHCI_REASON to_hci_reason_code(const uint8_t& reason_code) { return static_cast<tHCI_REASON>(reason_code); } -namespace fmt { +namespace std { template <> struct formatter<tHCI_ERROR_CODE> : enum_formatter<tHCI_ERROR_CODE> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/hiddefs.h b/system/stack/include/hiddefs.h index 4e8743d94d..583c302d1f 100644 --- a/system/stack/include/hiddefs.h +++ b/system/stack/include/hiddefs.h @@ -181,9 +181,9 @@ typedef struct sdp_info { tSDP_DISC_REC* p_sdp_layer_rec; } tHID_DEV_SDP_INFO; -namespace fmt { +namespace std { template <> struct formatter<tHID_STATUS> : enum_formatter<tHID_STATUS> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/stack/include/l2cap_types.h b/system/stack/include/l2cap_types.h index e0927e96aa..311dab7528 100644 --- a/system/stack/include/l2cap_types.h +++ b/system/stack/include/l2cap_types.h @@ -163,9 +163,9 @@ constexpr uint16_t L2CAP_LE_MIN_MPS = 23; constexpr uint16_t L2CAP_LE_MAX_MPS = 65533; constexpr uint16_t L2CAP_LE_CREDIT_MAX = 65535; -namespace fmt { +namespace std { template <> struct formatter<tL2CAP_LATENCY> : enum_formatter<tL2CAP_LATENCY> {}; template <> struct formatter<tL2CAP_PRIORITY> : enum_formatter<tL2CAP_PRIORITY> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/l2cdefs.h b/system/stack/include/l2cdefs.h index b5985297be..88ed7a76d3 100644 --- a/system/stack/include/l2cdefs.h +++ b/system/stack/include/l2cdefs.h @@ -545,11 +545,11 @@ constexpr uint16_t L2CAP_SDU_LENGTH_LE_MAX = 0xffff; /* Mask for sequence numbers (range 0 - 63) */ #define L2CAP_FCR_SEQ_MODULO 0x3F -namespace fmt { +namespace std { template <> struct formatter<tL2CAP_CONN> : enum_formatter<tL2CAP_CONN> {}; template <> struct formatter<tL2CAP_CID_FIXED> : enum_formatter<tL2CAP_CID_FIXED> {}; template <> struct formatter<tL2CAP_LE_RESULT_CODE> : enum_formatter<tL2CAP_LE_RESULT_CODE> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/pan_api.h b/system/stack/include/pan_api.h index 677ab4494a..9246f2aa39 100644 --- a/system/stack/include/pan_api.h +++ b/system/stack/include/pan_api.h @@ -422,9 +422,9 @@ void PAN_Init(void); void PAN_Dumpsys(int fd); -namespace fmt { +namespace std { template <> struct formatter<tPAN_RESULT> : enum_formatter<tPAN_RESULT> {}; -} // namespace fmt +} // namespace std #endif /* PAN_API_H */ diff --git a/system/stack/include/port_api.h b/system/stack/include/port_api.h index ae511a49ec..e2986740f1 100644 --- a/system/stack/include/port_api.h +++ b/system/stack/include/port_api.h @@ -179,10 +179,10 @@ inline std::string port_result_text(const tPORT_RESULT& result) { RETURN_UNKNOWN_TYPE_STRING(tPORT_RESULT, result); } -namespace fmt { +namespace std { template <> struct formatter<tPORT_RESULT> : enum_formatter<tPORT_RESULT> {}; -} // namespace fmt +} // namespace std typedef void(tPORT_MGMT_CALLBACK)(const tPORT_RESULT code, uint16_t port_handle); diff --git a/system/stack/include/sdp_status.h b/system/stack/include/sdp_status.h index d709dd5038..cebcd9697c 100644 --- a/system/stack/include/sdp_status.h +++ b/system/stack/include/sdp_status.h @@ -87,7 +87,7 @@ inline std::string sdp_status_text(const tSDP_STATUS& status) { } const auto sdp_result_text = sdp_status_text; -namespace fmt { +namespace std { template <> struct formatter<tSDP_STATUS> : enum_formatter<tSDP_STATUS> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/include/smp_api_types.h b/system/stack/include/smp_api_types.h index 693faa8b26..922de8b898 100644 --- a/system/stack/include/smp_api_types.h +++ b/system/stack/include/smp_api_types.h @@ -228,13 +228,13 @@ typedef tBTM_STATUS(tSMP_CALLBACK)(tSMP_EVT event, const RawAddress& bd_addr, * Manager requires verification from CSIP.*/ typedef tBTM_STATUS(tSMP_SIRK_CALLBACK)(const RawAddress& bd_addr); -namespace fmt { +namespace std { template <> struct formatter<tSMP_OOB_DATA_TYPE> : enum_formatter<tSMP_OOB_DATA_TYPE> {}; template <> struct formatter<tSMP_SEC_LEVEL> : enum_formatter<tSMP_SEC_LEVEL> {}; template <> struct formatter<tSMP_EVT> : enum_formatter<tSMP_EVT> {}; -} // namespace fmt +} // namespace std #endif // SMP_API_TYPES_H diff --git a/system/stack/include/smp_status.h b/system/stack/include/smp_status.h index dce8778b8a..5c8b6f16f4 100644 --- a/system/stack/include/smp_status.h +++ b/system/stack/include/smp_status.h @@ -95,7 +95,7 @@ inline std::string smp_status_text(const tSMP_STATUS& status) { } } -namespace fmt { +namespace std { template <> struct formatter<tSMP_STATUS> : enum_formatter<tSMP_STATUS> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/l2cap/l2c_api.cc b/system/stack/l2cap/l2c_api.cc index 99b0276413..2b67132edb 100644 --- a/system/stack/l2cap/l2c_api.cc +++ b/system/stack/l2cap/l2c_api.cc @@ -320,7 +320,7 @@ uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& p_bd_addr) { p_lcb = l2cu_allocate_lcb(p_bd_addr, false, BT_TRANSPORT_BR_EDR); /* currently use BR/EDR for ERTM mode l2cap connection */ if (p_lcb == nullptr) { - log::warn("connection not started for PSM=0x{:x}, p_lcb={}", psm, fmt::ptr(p_lcb)); + log::warn("connection not started for PSM=0x{:x}, p_lcb={}", psm, std::format_ptr(p_lcb)); return 0; } l2cu_create_conn_br_edr(p_lcb); @@ -520,7 +520,7 @@ uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr, tL2CAP_ if ((p_lcb == NULL) /* currently use BR/EDR for ERTM mode l2cap connection */ || (!l2cu_create_conn_le(p_lcb))) { - log::warn("conn not started for PSM: 0x{:04x} p_lcb: 0x{}", psm, fmt::ptr(p_lcb)); + log::warn("conn not started for PSM: 0x{:04x} p_lcb: 0x{}", psm, std::format_ptr(p_lcb)); return 0; } } @@ -1540,7 +1540,7 @@ uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) { "L2CA_FlushChannel (FLUSH) CID: 0x{:04x} NumToFlush: {} QC: {} " "pFirst: 0x{}", lcid, num_to_flush, fixed_queue_length(p_ccb->xmit_hold_q), - fmt::ptr(fixed_queue_try_peek_first(p_ccb->xmit_hold_q))); + std::format_ptr(fixed_queue_try_peek_first(p_ccb->xmit_hold_q))); } else { log::verbose("L2CA_FlushChannel (QUERY) CID: 0x{:04x}", lcid); } diff --git a/system/stack/l2cap/l2c_csm.cc b/system/stack/l2cap/l2c_csm.cc index ba438765eb..42b451cd48 100644 --- a/system/stack/l2cap/l2c_csm.cc +++ b/system/stack/l2cap/l2c_csm.cc @@ -1688,7 +1688,8 @@ void l2c_enqueue_peer_data(tL2C_CCB* p_ccb, BT_HDR* p_buf) { log::error( "empty queue: p_ccb = {} p_ccb->in_use = {} p_ccb->chnl_state = {} " "p_ccb->local_cid = {} p_ccb->remote_cid = {}", - fmt::ptr(p_ccb), p_ccb->in_use, p_ccb->chnl_state, p_ccb->local_cid, p_ccb->remote_cid); + std::format_ptr(p_ccb), p_ccb->in_use, p_ccb->chnl_state, p_ccb->local_cid, + p_ccb->remote_cid); } else { fixed_queue_enqueue(p_ccb->xmit_hold_q, p_buf); } diff --git a/system/stack/l2cap/l2c_int.h b/system/stack/l2cap/l2c_int.h index 02a1fa66ad..0077cab5bf 100644 --- a/system/stack/l2cap/l2c_int.h +++ b/system/stack/l2cap/l2c_int.h @@ -854,11 +854,11 @@ void l2cble_process_subrate_change_evt(uint16_t handle, uint8_t status, uint16_t uint16_t peripheral_latency, uint16_t cont_num, uint16_t timeout); -namespace fmt { +namespace std { template <> struct formatter<tL2C_LINK_STATE> : enum_formatter<tL2C_LINK_STATE> {}; template <> struct formatter<tL2CEVT> : enum_formatter<tL2CEVT> {}; template <> struct formatter<tL2C_CHNL_STATE> : enum_formatter<tL2C_CHNL_STATE> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/l2cap/l2c_utils.cc b/system/stack/l2cap/l2c_utils.cc index 0e923a559c..3a057ec508 100644 --- a/system/stack/l2cap/l2c_utils.cc +++ b/system/stack/l2cap/l2c_utils.cc @@ -1165,7 +1165,7 @@ void l2cu_enqueue_ccb(tL2C_CCB* p_ccb) { if ((!p_ccb->in_use) || (p_q == NULL)) { log::error("CID: 0x{:04x} ERROR in_use: {} p_lcb: {}", p_ccb->local_cid, p_ccb->in_use, - fmt::ptr(p_ccb->p_lcb)); + std::format_ptr(p_ccb->p_lcb)); return; } @@ -1251,8 +1251,8 @@ void l2cu_dequeue_ccb(tL2C_CCB* p_ccb) { log::error( "l2cu_dequeue_ccb CID: 0x{:04x} ERROR in_use: {} p_lcb: 0x{} p_q: " "0x{} p_q->p_first_ccb: 0x{}", - p_ccb->local_cid, p_ccb->in_use, fmt::ptr(p_ccb->p_lcb), fmt::ptr(p_q), - fmt::ptr(p_q ? p_q->p_first_ccb : 0)); + p_ccb->local_cid, p_ccb->in_use, std::format_ptr(p_ccb->p_lcb), std::format_ptr(p_q), + std::format_ptr(p_q ? p_q->p_first_ccb : 0)); return; } @@ -2602,7 +2602,7 @@ void l2cu_resubmit_pending_sec_req(const RawAddress* p_bda) { tL2C_CCB* p_next_ccb; int xx; - log::verbose("l2cu_resubmit_pending_sec_req p_bda: 0x{}", fmt::ptr(p_bda)); + log::verbose("l2cu_resubmit_pending_sec_req p_bda: 0x{}", std::format_ptr(p_bda)); /* If we are called with a BDA, only resubmit for that BDA */ if (p_bda) { diff --git a/system/stack/pan/pan_int.h b/system/stack/pan/pan_int.h index f64f2ae6a7..32d832a416 100644 --- a/system/stack/pan/pan_int.h +++ b/system/stack/pan/pan_int.h @@ -128,9 +128,9 @@ void pan_dump_status(void); /******************************************************************************/ -namespace fmt { +namespace std { template <> struct formatter<tPAN_STATE> : enum_formatter<tPAN_STATE> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/stack/rfcomm/port_api.cc b/system/stack/rfcomm/port_api.cc index 6676eac767..6786e88d02 100644 --- a/system/stack/rfcomm/port_api.cc +++ b/system/stack/rfcomm/port_api.cc @@ -143,7 +143,7 @@ int RFCOMM_CreateConnectionWithSecurity(uint16_t uuid, uint8_t scn, bool is_serv "bd_addr={}, scn={}, is_server={}, mtu={}, uuid=0x{:x}, dlci={}, p_mcb={}, port={}", static_cast<int>(p_port->state), static_cast<int>(p_port->rfc.state), p_port->rfc.p_mcb ? p_port->rfc.p_mcb->state : 0, bd_addr, scn, is_server, mtu, - uuid, dlci, fmt::ptr(p_mcb), p_port->handle); + uuid, dlci, std::format_ptr(p_mcb), p_port->handle); *p_handle = p_port->handle; return PORT_ALREADY_OPENED; } @@ -214,7 +214,8 @@ int RFCOMM_CreateConnectionWithSecurity(uint16_t uuid, uint8_t scn, bool is_serv log::info( "bd_addr={}, scn={}, is_server={}, mtu={}, uuid=0x{:x}, dlci={}, " "signal_state=0x{:x}, p_port={}", - bd_addr, scn, is_server, mtu, uuid, dlci, p_port->default_signal_state, fmt::ptr(p_port)); + bd_addr, scn, is_server, mtu, uuid, dlci, p_port->default_signal_state, + std::format_ptr(p_port)); // If this is not initiator of the connection need to just wait if (p_port->is_server) { @@ -410,7 +411,7 @@ int PORT_ClearKeepHandleFlag(uint16_t handle) { * ******************************************************************************/ int PORT_SetDataCOCallback(uint16_t handle, tPORT_DATA_CO_CALLBACK* p_port_cb) { - log::verbose("handle:{} cb 0x{}", handle, fmt::ptr(p_port_cb)); + log::verbose("handle:{} cb 0x{}", handle, std::format_ptr(p_port_cb)); tPORT* p_port = get_port_from_handle(handle); if (p_port == nullptr) { @@ -445,7 +446,7 @@ int PORT_CheckConnection(uint16_t handle, RawAddress* bd_addr, uint16_t* p_lcid) return PORT_BAD_HANDLE; } log::verbose("handle={}, in_use={}, port_state={}, p_mcb={}, peer_ready={}, rfc_state={}", handle, - p_port->in_use, p_port->state, fmt::ptr(p_port->rfc.p_mcb), + p_port->in_use, p_port->state, std::format_ptr(p_port->rfc.p_mcb), p_port->rfc.p_mcb ? p_port->rfc.p_mcb->peer_ready : -1, p_port->rfc.state); if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) { diff --git a/system/stack/rfcomm/port_int.h b/system/stack/rfcomm/port_int.h index f4773d5844..8fcbf845fd 100644 --- a/system/stack/rfcomm/port_int.h +++ b/system/stack/rfcomm/port_int.h @@ -141,10 +141,10 @@ inline std::string port_connection_state_text(const tPORT_CONNECTION_STATE& stat RETURN_UNKNOWN_TYPE_STRING(tPORT_CONNECTION_STATE, state); } -namespace fmt { +namespace std { template <> struct formatter<tPORT_CONNECTION_STATE> : enum_formatter<tPORT_CONNECTION_STATE> {}; -} // namespace fmt +} // namespace std /* * Define control block containing information about PORT connection diff --git a/system/stack/rfcomm/port_rfc.cc b/system/stack/rfcomm/port_rfc.cc index be15fb1217..1f8ba0b5ad 100644 --- a/system/stack/rfcomm/port_rfc.cc +++ b/system/stack/rfcomm/port_rfc.cc @@ -65,7 +65,7 @@ void port_get_credits(tPORT* p_port, uint8_t k); * ******************************************************************************/ int port_open_continue(tPORT* p_port) { - log::verbose("port_open_continue, p_port:{}", fmt::ptr(p_port)); + log::verbose("port_open_continue, p_port:{}", std::format_ptr(p_port)); /* Check if multiplexer channel has already been established */ tRFC_MCB* p_mcb = rfc_alloc_multiplexer_channel(p_port->bd_addr, true); @@ -263,7 +263,8 @@ void PORT_StartInd(tRFC_MCB* p_mcb) { p_port = &rfc_cb.port.port[0]; for (i = 0; i < MAX_RFC_PORTS; i++, p_port++) { if ((p_port->rfc.p_mcb == NULL) || (p_port->rfc.p_mcb == p_mcb)) { - log::verbose("PORT_StartInd, RFCOMM_StartRsp RFCOMM_SUCCESS: p_mcb:{}", fmt::ptr(p_mcb)); + log::verbose("PORT_StartInd, RFCOMM_StartRsp RFCOMM_SUCCESS: p_mcb:{}", + std::format_ptr(p_mcb)); RFCOMM_StartRsp(p_mcb, RFCOMM_SUCCESS); return; } @@ -289,7 +290,7 @@ void PORT_ParNegInd(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint8_t cl, uin p_port = port_find_dlci_port(dlci); if (!p_port) { log::error("Disconnect RFCOMM, port not found, dlci={}, p_mcb={}, bd_addr={}", dlci, - fmt::ptr(p_mcb), p_mcb->bd_addr); + std::format_ptr(p_mcb), p_mcb->bd_addr); /* If the port cannot be opened, send a DM. Per Errata 1205 */ rfc_send_dm(p_mcb, dlci, false); /* check if this is the last port open, some headsets have @@ -416,8 +417,8 @@ void PORT_ParNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint8_t cl, uin void PORT_DlcEstablishInd(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu) { tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); - log::verbose("p_mcb:{}, dlci:{} mtu:{}i, p_port:{}, bd_addr:{}", fmt::ptr(p_mcb), dlci, mtu, - fmt::ptr(p_port), p_mcb->bd_addr); + log::verbose("p_mcb:{}, dlci:{} mtu:{}i, p_port:{}, bd_addr:{}", std::format_ptr(p_mcb), dlci, + mtu, std::format_ptr(p_port), p_mcb->bd_addr); if (!p_port) { /* This can be a first request for this port */ @@ -787,7 +788,7 @@ void PORT_DataInd(tRFC_MCB* p_mcb, uint8_t dlci, BT_HDR* p_buf) { int i; log::verbose("PORT_DataInd with data length {}, p_mcb:{},p_port:{},dlci:{}", p_buf->len, - fmt::ptr(p_mcb), fmt::ptr(p_port), dlci); + std::format_ptr(p_mcb), std::format_ptr(p_port), dlci); if (!p_port) { osi_free(p_buf); return; diff --git a/system/stack/rfcomm/port_utils.cc b/system/stack/rfcomm/port_utils.cc index 88276d0d26..25e1da9f4c 100644 --- a/system/stack/rfcomm/port_utils.cc +++ b/system/stack/rfcomm/port_utils.cc @@ -86,7 +86,7 @@ tPORT* port_allocate_port(uint8_t dlci, const RawAddress& bd_addr) { p_port->bd_addr = bd_addr; rfc_cb.rfc.last_port_index = port_index; log::verbose("rfc_cb.port.port[{}]:{} chosen, last_port_index:{}, bd_addr={}", port_index, - fmt::ptr(p_port), rfc_cb.rfc.last_port_index, bd_addr); + std::format_ptr(p_port), rfc_cb.rfc.last_port_index, bd_addr); return p_port; } } @@ -199,7 +199,7 @@ void port_select_mtu(tPORT* p_port) { * ******************************************************************************/ void port_release_port(tPORT* p_port) { - log::verbose("p_port: {} state: {} keep_handle: {}", fmt::ptr(p_port), p_port->rfc.state, + log::verbose("p_port: {} state: {} keep_handle: {}", std::format_ptr(p_port), p_port->rfc.state, p_port->keep_port_handle); mutex_global_lock(); @@ -280,7 +280,8 @@ tRFC_MCB* port_find_mcb(const RawAddress& bd_addr) { for (tRFC_MCB& mcb : rfc_cb.port.rfc_mcb) { if ((mcb.state != RFC_MX_STATE_IDLE) && (mcb.bd_addr == bd_addr)) { /* Multiplexer channel found do not change anything */ - log::verbose("found, bd_addr:{}, rfc_mcb:{}, lcid:0x{:x}", bd_addr, fmt::ptr(&mcb), mcb.lcid); + log::verbose("found, bd_addr:{}, rfc_mcb:{}, lcid:0x{:x}", bd_addr, std::format_ptr(&mcb), + mcb.lcid); return &mcb; } } @@ -307,14 +308,15 @@ tPORT* port_find_mcb_dlci_port(tRFC_MCB* p_mcb, uint8_t dlci) { } if (dlci > RFCOMM_MAX_DLCI) { - log::warn("DLCI {} is too large, bd_addr={}, p_mcb={}", dlci, p_mcb->bd_addr, fmt::ptr(p_mcb)); + log::warn("DLCI {} is too large, bd_addr={}, p_mcb={}", dlci, p_mcb->bd_addr, + std::format_ptr(p_mcb)); return nullptr; } uint8_t handle = p_mcb->port_handles[dlci]; if (handle == 0) { log::info("Cannot find allocated RFCOMM app port for DLCI {} on {}, p_mcb={}", dlci, - p_mcb->bd_addr, fmt::ptr(p_mcb)); + p_mcb->bd_addr, std::format_ptr(p_mcb)); return nullptr; } return &rfc_cb.port.port[handle - 1]; diff --git a/system/stack/rfcomm/rfc_event.h b/system/stack/rfcomm/rfc_event.h index 64c4e79d12..f8c766632e 100644 --- a/system/stack/rfcomm/rfc_event.h +++ b/system/stack/rfcomm/rfc_event.h @@ -124,11 +124,11 @@ inline std::string rfcomm_port_event_text(const tRFC_PORT_EVENT& event) { } } -namespace fmt { +namespace std { template <> struct formatter<tRFC_EVENT> : enum_formatter<tRFC_EVENT> {}; template <> struct formatter<tRFC_MX_EVENT> : enum_formatter<tRFC_MX_EVENT> {}; template <> struct formatter<tRFC_PORT_EVENT> : enum_formatter<tRFC_PORT_EVENT> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/rfcomm/rfc_l2cap_if.cc b/system/stack/rfcomm/rfc_l2cap_if.cc index 8b96d26301..5b7fc00185 100644 --- a/system/stack/rfcomm/rfc_l2cap_if.cc +++ b/system/stack/rfcomm/rfc_l2cap_if.cc @@ -268,13 +268,13 @@ void RFCOMM_BufDataInd(uint16_t lcid, BT_HDR* p_buf) { /* If the frame did not pass validation just ignore it */ if (event == RFC_EVENT_BAD_FRAME) { log::warn("Bad RFCOMM frame from lcid=0x{:x}, bd_addr={}, p_mcb={}", lcid, p_mcb->bd_addr, - fmt::ptr(p_mcb)); + std::format_ptr(p_mcb)); osi_free(p_buf); return; } if (rfc_cb.rfc.rx_frame.dlci == RFCOMM_MX_DLCI) { - log::verbose("handle multiplexer event {}, p_mcb={}", event, fmt::ptr(p_mcb)); + log::verbose("handle multiplexer event {}, p_mcb={}", event, std::format_ptr(p_mcb)); /* Take special care of the Multiplexer Control Messages */ if (event == RFC_EVENT_UIH) { rfc_process_mx_message(p_mcb, p_buf); @@ -293,11 +293,11 @@ void RFCOMM_BufDataInd(uint16_t lcid, BT_HDR* p_buf) { /* If this is a SABME on new port, check if any app is waiting for it */ if (event != RFC_EVENT_SABME) { log::warn("no for none-SABME event, lcid=0x{:x}, bd_addr={}, p_mcb={}", lcid, p_mcb->bd_addr, - fmt::ptr(p_mcb)); + std::format_ptr(p_mcb)); if ((p_mcb->is_initiator && !rfc_cb.rfc.rx_frame.cr) || (!p_mcb->is_initiator && rfc_cb.rfc.rx_frame.cr)) { log::error("Disconnecting RFCOMM, lcid=0x{:x}, bd_addr={}, p_mcb={}", lcid, p_mcb->bd_addr, - fmt::ptr(p_mcb)); + std::format_ptr(p_mcb)); rfc_send_dm(p_mcb, rfc_cb.rfc.rx_frame.dlci, rfc_cb.rfc.rx_frame.pf); } osi_free(p_buf); @@ -309,13 +309,14 @@ void RFCOMM_BufDataInd(uint16_t lcid, BT_HDR* p_buf) { log::error( "Disconnecting RFCOMM, no port for dlci {}, lcid=0x{:x}, bd_addr={}, " "p_mcb={}", - rfc_cb.rfc.rx_frame.dlci, lcid, p_mcb->bd_addr, fmt::ptr(p_mcb)); + rfc_cb.rfc.rx_frame.dlci, lcid, p_mcb->bd_addr, std::format_ptr(p_mcb)); rfc_send_dm(p_mcb, rfc_cb.rfc.rx_frame.dlci, true); osi_free(p_buf); return; } log::verbose("port_handles[dlci={}]:{}->{}, p_mcb={}", rfc_cb.rfc.rx_frame.dlci, - p_mcb->port_handles[rfc_cb.rfc.rx_frame.dlci], p_port->handle, fmt::ptr(p_mcb)); + p_mcb->port_handles[rfc_cb.rfc.rx_frame.dlci], p_port->handle, + std::format_ptr(p_mcb)); p_mcb->port_handles[rfc_cb.rfc.rx_frame.dlci] = p_port->handle; p_port->rfc.p_mcb = p_mcb; } diff --git a/system/stack/rfcomm/rfc_port_fsm.cc b/system/stack/rfcomm/rfc_port_fsm.cc index 6313abf073..0f3ec064ff 100644 --- a/system/stack/rfcomm/rfc_port_fsm.cc +++ b/system/stack/rfcomm/rfc_port_fsm.cc @@ -642,7 +642,8 @@ void rfc_process_pn(tRFC_MCB* p_mcb, bool is_command, MX_FRAME* p_frame) { if (p_mcb->state != RFC_MX_STATE_DISC_WAIT_UA) { PORT_ParNegInd(p_mcb, dlci, p_frame->u.pn.mtu, p_frame->u.pn.conv_layer, p_frame->u.pn.k); } else { - log::warn("MX PN while disconnecting, bd_addr={}, p_mcb={}", p_mcb->bd_addr, fmt::ptr(p_mcb)); + log::warn("MX PN while disconnecting, bd_addr={}, p_mcb={}", p_mcb->bd_addr, + std::format_ptr(p_mcb)); rfc_send_dm(p_mcb, dlci, false); } @@ -651,7 +652,7 @@ void rfc_process_pn(tRFC_MCB* p_mcb, bool is_command, MX_FRAME* p_frame) { /* If we are not awaiting response just ignore it */ tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); if ((p_port == nullptr) || !(p_port->rfc.expected_rsp & RFC_RSP_PN)) { - log::warn(": Ignore unwanted response, p_mcb={}, bd_addr={}, dlci={}", fmt::ptr(p_mcb), + log::warn(": Ignore unwanted response, p_mcb={}, bd_addr={}, dlci={}", std::format_ptr(p_mcb), p_mcb->bd_addr, dlci); return; } diff --git a/system/stack/rfcomm/rfc_state.h b/system/stack/rfcomm/rfc_state.h index 32afa29967..847c7d0878 100644 --- a/system/stack/rfcomm/rfc_state.h +++ b/system/stack/rfcomm/rfc_state.h @@ -68,10 +68,10 @@ inline std::string rfcomm_port_state_text(const tRFC_PORT_STATE& state) { } } -namespace fmt { +namespace std { template <> struct formatter<tRFC_MX_STATE> : enum_formatter<tRFC_MX_STATE> {}; template <> struct formatter<tRFC_PORT_STATE> : enum_formatter<tRFC_PORT_STATE> {}; -} // namespace fmt +} // namespace std diff --git a/system/stack/rfcomm/rfc_ts_frames.cc b/system/stack/rfcomm/rfc_ts_frames.cc index ea57abf6dc..e9df718116 100644 --- a/system/stack/rfcomm/rfc_ts_frames.cc +++ b/system/stack/rfcomm/rfc_ts_frames.cc @@ -683,7 +683,7 @@ void rfc_process_mx_message(tRFC_MCB* p_mcb, BT_HDR* p_buf) { } if (mx_len != length) { - log::error("Bad MX frame, p_mcb={}, bd_addr={}", fmt::ptr(p_mcb), p_mcb->bd_addr); + log::error("Bad MX frame, p_mcb={}, bd_addr={}", std::format_ptr(p_mcb), p_mcb->bd_addr); osi_free(p_buf); return; } @@ -692,7 +692,8 @@ void rfc_process_mx_message(tRFC_MCB* p_mcb, BT_HDR* p_buf) { switch (p_rx_frame->type) { case RFCOMM_MX_PN: if (length != RFCOMM_MX_PN_LEN) { - log::error("Invalid PN length, p_mcb={}, bd_addr={}", fmt::ptr(p_mcb), p_mcb->bd_addr); + log::error("Invalid PN length, p_mcb={}, bd_addr={}", std::format_ptr(p_mcb), + p_mcb->bd_addr); break; } @@ -708,7 +709,7 @@ void rfc_process_mx_message(tRFC_MCB* p_mcb, BT_HDR* p_buf) { if (!p_rx_frame->dlci || !RFCOMM_VALID_DLCI(p_rx_frame->dlci) || (p_rx_frame->u.pn.mtu < RFCOMM_MIN_MTU) || (p_rx_frame->u.pn.mtu > RFCOMM_MAX_MTU)) { - log::error("Bad PN frame, p_mcb={}, bd_addr={}", fmt::ptr(p_mcb), p_mcb->bd_addr); + log::error("Bad PN frame, p_mcb={}, bd_addr={}", std::format_ptr(p_mcb), p_mcb->bd_addr); break; } diff --git a/system/stack/rfcomm/rfc_utils.cc b/system/stack/rfcomm/rfc_utils.cc index 23420892cb..29b89258f7 100644 --- a/system/stack/rfcomm/rfc_utils.cc +++ b/system/stack/rfcomm/rfc_utils.cc @@ -145,7 +145,7 @@ tRFC_MCB* rfc_alloc_multiplexer_channel(const RawAddress& bd_addr, bool is_initi log::verbose( "rfc_alloc_multiplexer_channel:is_initiator:{}, found, state:{}, " "p_mcb:{}", - is_initiator, rfc_cb.port.rfc_mcb[i].state, fmt::ptr(&rfc_cb.port.rfc_mcb[i])); + is_initiator, rfc_cb.port.rfc_mcb[i].state, std::format_ptr(&rfc_cb.port.rfc_mcb[i])); return &rfc_cb.port.rfc_mcb[i]; } } @@ -166,7 +166,7 @@ tRFC_MCB* rfc_alloc_multiplexer_channel(const RawAddress& bd_addr, bool is_initi log::verbose( "rfc_alloc_multiplexer_channel:is_initiator:{}, create new p_mcb:{}, " "index:{}", - is_initiator, fmt::ptr(&rfc_cb.port.rfc_mcb[j]), j); + is_initiator, std::format_ptr(&rfc_cb.port.rfc_mcb[j]), j); p_mcb->mcb_timer = alarm_new("rfcomm_mcb.mcb_timer"); p_mcb->cmd_q = fixed_queue_new(SIZE_MAX); @@ -416,8 +416,9 @@ void rfc_check_send_cmd(tRFC_MCB* p_mcb, BT_HDR* p_buf) { /* if passed a buffer queue it */ if (p_buf != NULL) { if (p_mcb->cmd_q == NULL) { - log::error("empty queue: p_mcb = {} p_mcb->lcid = {} cached p_mcb = {}", fmt::ptr(p_mcb), - p_mcb->lcid, fmt::ptr(rfc_find_lcid_mcb(p_mcb->lcid))); + log::error("empty queue: p_mcb = {} p_mcb->lcid = {} cached p_mcb = {}", + std::format_ptr(p_mcb), p_mcb->lcid, + std::format_ptr(rfc_find_lcid_mcb(p_mcb->lcid))); } fixed_queue_enqueue(p_mcb->cmd_q, p_buf); } diff --git a/system/stack/sdp/sdp_api.cc b/system/stack/sdp/sdp_api.cc index 589a7eb42a..093dddde82 100644 --- a/system/stack/sdp/sdp_api.cc +++ b/system/stack/sdp/sdp_api.cc @@ -81,7 +81,7 @@ bool SDP_InitDiscoveryDb(tSDP_DISCOVERY_DB* p_db, uint32_t len, uint16_t num_uui if (p_db == NULL || (sizeof(tSDP_DISCOVERY_DB) > len) || num_attr > SDP_MAX_ATTR_FILTERS || num_uuid > SDP_MAX_UUID_FILTERS) { log::error("SDP_InitDiscoveryDb Illegal param: p_db {}, len {}, num_uuid {}, num_attr {}", - fmt::ptr(p_db), len, num_uuid, num_attr); + std::format_ptr(p_db), len, num_uuid, num_attr); return false; } @@ -1124,7 +1124,7 @@ void SDP_DumpConnectionControlBlock(int fd, const tCONN_CB& conn_cb) { if (conn_cb.device_address == RawAddress::kEmpty) { return; } - LOG_DUMPSYS(fd, "peer:%s discovery_state:%s", fmt::format("{}", conn_cb.device_address).c_str(), + LOG_DUMPSYS(fd, "peer:%s discovery_state:%s", std::format("{}", conn_cb.device_address).c_str(), sdp_disc_wait_text(conn_cb.disc_state).c_str()); LOG_DUMPSYS(fd, " connection_state:%s connection_flags:0x%02x mtu:%hu l2cap_cid:%hu", sdp_state_text(conn_cb.con_state).c_str(), conn_cb.con_flags, conn_cb.rem_mtu_size, diff --git a/system/stack/sdp/sdp_db.cc b/system/stack/sdp/sdp_db.cc index dbb8ba7f2b..8ecdf9ea9f 100644 --- a/system/stack/sdp/sdp_db.cc +++ b/system/stack/sdp/sdp_db.cc @@ -288,22 +288,22 @@ bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type, uint snprintf(&num_array[i * 2], sizeof(num_array) - i * 2, "%02X", (uint8_t)(p_val[i])); } log::verbose("SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, p_val:{}, *p_val:{}", - handle, attr_id, attr_type, attr_len, fmt::ptr(p_val), num_array); + handle, attr_id, attr_type, attr_len, std::format_ptr(p_val), num_array); } else if (attr_type == BOOLEAN_DESC_TYPE) { log::verbose("SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, p_val:{}, *p_val:{}", - handle, attr_id, attr_type, attr_len, fmt::ptr(p_val), *p_val); + handle, attr_id, attr_type, attr_len, std::format_ptr(p_val), *p_val); } else if ((attr_type == TEXT_STR_DESC_TYPE) || (attr_type == URL_DESC_TYPE)) { if (p_val[attr_len - 1] == '\0') { log::verbose( "SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, p_val:{}, *p_val:{}", - handle, attr_id, attr_type, attr_len, fmt::ptr(p_val), (char*)p_val); + handle, attr_id, attr_type, attr_len, std::format_ptr(p_val), (char*)p_val); } else { log::verbose("SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, p_val:{}", handle, - attr_id, attr_type, attr_len, fmt::ptr(p_val)); + attr_id, attr_type, attr_len, std::format_ptr(p_val)); } } else { log::verbose("SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, p_val:{}", handle, - attr_id, attr_type, attr_len, fmt::ptr(p_val)); + attr_id, attr_type, attr_len, std::format_ptr(p_val)); } } diff --git a/system/stack/smp/smp_int.h b/system/stack/smp/smp_int.h index dd51c0de4f..7725bd7e6d 100644 --- a/system/stack/smp/smp_int.h +++ b/system/stack/smp/smp_int.h @@ -502,13 +502,13 @@ void smp_save_local_oob_data(tSMP_CB* p_cb); void smp_clear_local_oob_data(); bool smp_has_local_oob_data(); -namespace fmt { +namespace std { template <> struct formatter<tSMP_EVENT> : enum_formatter<tSMP_EVENT> {}; template <> struct formatter<tSMP_OPCODE> : enum_formatter<tSMP_OPCODE> {}; template <> struct formatter<tSMP_ASSO_MODEL> : enum_formatter<tSMP_ASSO_MODEL> {}; -} // namespace fmt +} // namespace std #endif /* SMP_INT_H */ diff --git a/system/test/headless/headless.cc b/system/test/headless/headless.cc index 5f0d820c7a..f115ddd012 100644 --- a/system/test/headless/headless.cc +++ b/system/test/headless/headless.cc @@ -84,7 +84,7 @@ void adapter_properties(bt_status_t status, int num_properties, ::bt_property_t* } } log::info("num_callbacks:{} status:{} num_properties:{} properties:{}", num_callbacks, - bt_status_text(status), num_properties, fmt::ptr(properties)); + bt_status_text(status), num_properties, std::format_ptr(properties)); } void remote_device_properties(bt_status_t status, RawAddress* bd_addr, int num_properties, @@ -100,7 +100,7 @@ void remote_device_properties(bt_status_t status, RawAddress* bd_addr, int num_p } } log::info("num_callbacks:{} status:{} device:{} num_properties:{} properties:{}", num_callbacks, - bt_status_text(status), STR(*bd_addr), num_properties, fmt::ptr(properties)); + bt_status_text(status), STR(*bd_addr), num_properties, std::format_ptr(properties)); } // Aggregate disparate variables from callback API into unified single structure @@ -114,7 +114,7 @@ void device_found(int num_properties, ::bt_property_t* properties) { } } log::info("Device found callback: num_properties:{} properties:{}", num_properties, - fmt::ptr(properties)); + std::format_ptr(properties)); } void discovery_state_changed(bt_discovery_state_t state) { diff --git a/system/test/headless/interface.h b/system/test/headless/interface.h index 11c314c8b7..47e5484fdf 100644 --- a/system/test/headless/interface.h +++ b/system/test/headless/interface.h @@ -98,7 +98,8 @@ protected: : callback_params_t(name, callback_type) { for (int i = 0; i < num_properties; i++) { log::debug("Processing property {}/{} {} type:{} val:{}", i, num_properties, - fmt::ptr(&properties[i]), properties[i].type, fmt::ptr(properties[i].val)); + std::format_ptr(&properties[i]), properties[i].type, + std::format_ptr(properties[i].val)); property_queue_.push_back(bluetooth::test::headless::property_factory(properties[i])); } } @@ -132,7 +133,7 @@ struct acl_state_changed_params_t : public callback_params_t { uint16_t acl_handle; std::string ToString() const override { - return fmt::format( + return std::format( "status:{} remote_bd_addr:{} state:{} transport:{} reason:{}" " direction:{} handle:{}", bt_status_text(status), remote_bd_addr.ToString(), @@ -153,7 +154,7 @@ struct discovery_state_changed_params_t : public callback_params_t { bt_discovery_state_t state; std::string ToString() const override { - return fmt::format("state:{}", bt_discovery_state_text(state)); + return std::format("state:{}", bt_discovery_state_text(state)); } }; @@ -168,7 +169,7 @@ struct adapter_properties_params_t : public callback_params_with_properties_t { bt_status_t status; std::string ToString() const override { - return fmt::format("status:{} num_properties:{}", bt_status_text(status), num_properties()); + return std::format("status:{} num_properties:{}", bt_status_text(status), num_properties()); } }; @@ -187,7 +188,7 @@ struct remote_device_properties_params_t : public callback_params_with_propertie RawAddress bd_addr; std::string ToString() const override { - return fmt::format("status:{} bd_addr:{} num_properties:{}", bt_status_text(status), + return std::format("status:{} bd_addr:{} num_properties:{}", bt_status_text(status), bd_addr.ToString(), num_properties()); } }; @@ -201,7 +202,7 @@ struct device_found_params_t : public callback_params_with_properties_t { virtual ~device_found_params_t() {} std::string ToString() const override { - return fmt::format("num_properties:{}", num_properties()); + return std::format("num_properties:{}", num_properties()); } }; diff --git a/system/test/headless/property.h b/system/test/headless/property.h index 82279790fc..6af17a244f 100644 --- a/system/test/headless/property.h +++ b/system/test/headless/property.h @@ -99,7 +99,7 @@ struct void_t : public bt_property_t { public: virtual std::string ToString() const override { - return fmt::format("Unimplemented property type:{} name:{}", type, bt_property_type_text(type)); + return std::format("Unimplemented property type:{} name:{}", type, bt_property_type_text(type)); } }; @@ -119,7 +119,7 @@ public: } virtual std::string ToString() const override { - return fmt::format("Number of uuids:{}", get_uuids().size()); + return std::format("Number of uuids:{}", get_uuids().size()); } private: @@ -136,7 +136,7 @@ struct name_t : public bt_property_t { return std::string(s); } - virtual std::string ToString() const override { return fmt::format("Name:{}", get_name()); } + virtual std::string ToString() const override { return std::format("Name:{}", get_name()); } }; struct bdaddr_t : public bt_property_t { @@ -153,7 +153,7 @@ struct bdaddr_t : public bt_property_t { } virtual std::string ToString() const override { - return fmt::format("bd_addr:{}", get_addr().ToString()); + return std::format("bd_addr:{}", get_addr().ToString()); } }; @@ -168,7 +168,7 @@ struct class_of_device_t : public bt_property_t { } virtual std::string ToString() const override { - return fmt::format("cod:0x{:04x}", get_class_of_device()); + return std::format("cod:0x{:04x}", get_class_of_device()); } }; @@ -183,7 +183,7 @@ struct type_of_device_t : public bt_property_t { } virtual std::string ToString() const override { - return fmt::format("tod:0x{:04x}", get_type_of_device()); + return std::format("tod:0x{:04x}", get_type_of_device()); } }; diff --git a/system/test/headless/stopwatch.h b/system/test/headless/stopwatch.h index e2b549c45b..d7f5e3689b 100644 --- a/system/test/headless/stopwatch.h +++ b/system/test/headless/stopwatch.h @@ -40,7 +40,7 @@ public: std::string ToString() { return ToString(""); } std::string ToString(const std::string& comment) { - return fmt::format("{}: {} ms {}", name_, static_cast<unsigned long>(LapMs()), comment); + return std::format("{}: {} ms {}", name_, static_cast<unsigned long>(LapMs()), comment); } private: diff --git a/system/test/headless/utils/power_mode_client.h b/system/test/headless/utils/power_mode_client.h index 1f66c63419..d27c59e606 100644 --- a/system/test/headless/utils/power_mode_client.h +++ b/system/test/headless/utils/power_mode_client.h @@ -66,7 +66,7 @@ struct power_mode_callback_t { tHCI_STATUS hci_status; std::string ToString() const { - return fmt::format("bd_addr:{} pm_status:{} value:{} hci_status:{}", bd_addr.ToString(), + return std::format("bd_addr:{} pm_status:{} value:{} hci_status:{}", bd_addr.ToString(), power_mode_status_text(status), value, hci_status_code_text(hci_status)); } }; diff --git a/system/test/stub/osi.cc b/system/test/stub/osi.cc index 17accc1794..c087497528 100644 --- a/system/test/stub/osi.cc +++ b/system/test/stub/osi.cc @@ -346,18 +346,18 @@ static std::vector<struct fake_osi_alarm_set_on_mloop> previous_fake_osi_alarms_ bool alarm_is_scheduled(const alarm_t* alarm) { inc_func_call_count(__func__); - auto iter = - find_if(previous_fake_osi_alarms_.begin(), previous_fake_osi_alarms_.end(), - [alarm](auto const& a) { - bluetooth::log::debug("iter: {} == {} ?", fmt::ptr(a.alarm), fmt::ptr(alarm)); - return a.alarm == alarm; - }); + auto iter = find_if(previous_fake_osi_alarms_.begin(), previous_fake_osi_alarms_.end(), + [alarm](auto const& a) { + bluetooth::log::debug("iter: {} == {} ?", std::format_ptr(a.alarm), + std::format_ptr(alarm)); + return a.alarm == alarm; + }); if (iter != previous_fake_osi_alarms_.end()) { return true; } - bluetooth::log::debug(" {} == {} ?", fmt::ptr(fake_osi_alarm_set_on_mloop_.alarm), - fmt::ptr(alarm)); + bluetooth::log::debug(" {} == {} ?", std::format_ptr(fake_osi_alarm_set_on_mloop_.alarm), + std::format_ptr(alarm)); return fake_osi_alarm_set_on_mloop_.alarm == alarm; } @@ -371,14 +371,14 @@ static void fake_osi_alarm_clear(alarm_t* alarm) { auto iter = find_if(previous_fake_osi_alarms_.begin(), previous_fake_osi_alarms_.end(), [alarm](auto const& a) { return a.alarm == alarm; }); if (iter != previous_fake_osi_alarms_.end()) { - bluetooth::log::debug(" clearing alarm {} ", fmt::ptr(iter->alarm)); + bluetooth::log::debug(" clearing alarm {} ", std::format_ptr(iter->alarm)); previous_fake_osi_alarms_.erase(iter); return; } } if (fake_osi_alarm_set_on_mloop_.alarm == alarm || alarm == nullptr) { - bluetooth::log::debug(" clearing alarm {} ", fmt::ptr(alarm)); + bluetooth::log::debug(" clearing alarm {} ", std::format_ptr(alarm)); fake_osi_alarm_set_on_mloop_.alarm = nullptr; fake_osi_alarm_set_on_mloop_.interval_ms = 0; fake_osi_alarm_set_on_mloop_.cb = nullptr; @@ -412,11 +412,11 @@ void alarm_set_on_mloop(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t c inc_func_call_count(__func__); if (fake_osi_alarm_set_on_mloop_.alarm != nullptr) { - bluetooth::log::info("Queuing alarm {}", fmt::ptr(fake_osi_alarm_set_on_mloop_.alarm)); + bluetooth::log::info("Queuing alarm {}", std::format_ptr(fake_osi_alarm_set_on_mloop_.alarm)); previous_fake_osi_alarms_.push_back(fake_osi_alarm_set_on_mloop_); } - bluetooth::log::info("Adding alarm {}", fmt::ptr(alarm)); + bluetooth::log::info("Adding alarm {}", std::format_ptr(alarm)); fake_osi_alarm_set_on_mloop_.alarm = alarm; fake_osi_alarm_set_on_mloop_.interval_ms = interval_ms; fake_osi_alarm_set_on_mloop_.cb = cb; diff --git a/system/types/ble_address_with_type.h b/system/types/ble_address_with_type.h index 1c9869aec3..18f7cd0984 100644 --- a/system/types/ble_address_with_type.h +++ b/system/types/ble_address_with_type.h @@ -170,13 +170,13 @@ struct tAclLinkSpec { #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<tBLE_BD_ADDR> : formatter<std::string> { template <class Context> typename Context::iterator format(const tBLE_BD_ADDR& address, Context& ctx) const { std::string repr = address.ToRedactedStringForLogging(); - return fmt::formatter<std::string>::format(repr, ctx); + return std::formatter<std::string>::format(repr, ctx); } }; template <> @@ -184,10 +184,10 @@ struct formatter<tAclLinkSpec> : formatter<std::string> { template <class Context> typename Context::iterator format(const tAclLinkSpec& address, Context& ctx) const { std::string repr = address.ToRedactedStringForLogging(); - return fmt::formatter<std::string>::format(repr, ctx); + return std::formatter<std::string>::format(repr, ctx); } }; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h> diff --git a/system/types/bluetooth/uuid.h b/system/types/bluetooth/uuid.h index 9c09441544..eab8bb18fd 100644 --- a/system/types/bluetooth/uuid.h +++ b/system/types/bluetooth/uuid.h @@ -150,9 +150,9 @@ struct hash<bluetooth::Uuid> { #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<bluetooth::Uuid> : ostream_formatter {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/types/bt_transport.h b/system/types/bt_transport.h index 403e85d70b..a787a57af2 100644 --- a/system/types/bt_transport.h +++ b/system/types/bt_transport.h @@ -40,9 +40,9 @@ inline std::string bt_transport_text(const tBT_TRANSPORT& transport) { RETURN_UNKNOWN_TYPE_STRING(tBT_TRANSPORT, transport); } -namespace fmt { +namespace std { template <> struct formatter<tBT_TRANSPORT> : enum_formatter<tBT_TRANSPORT> {}; -} // namespace fmt +} // namespace std #endif diff --git a/system/types/hci_role.h b/system/types/hci_role.h index bbedb238ed..0a685825e4 100644 --- a/system/types/hci_role.h +++ b/system/types/hci_role.h @@ -53,9 +53,9 @@ const auto RoleText = hci_role_text; // LEGACY #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<tHCI_ROLE> : enum_formatter<tHCI_ROLE> {}; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) diff --git a/system/types/raw_address.h b/system/types/raw_address.h index 60ff23f697..2a8540bb34 100644 --- a/system/types/raw_address.h +++ b/system/types/raw_address.h @@ -113,15 +113,15 @@ inline void STREAM_TO_BDADDR(RawAddress& a, const uint8_t*& p) { #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> -namespace fmt { +namespace std { template <> struct formatter<RawAddress> : formatter<std::string> { template <class Context> typename Context::iterator format(const RawAddress& address, Context& ctx) const { std::string repr = address.ToRedactedStringForLogging(); - return fmt::formatter<std::string>::format(repr, ctx); + return std::formatter<std::string>::format(repr, ctx); } }; -} // namespace fmt +} // namespace std #endif // __has_include(<bluetooth/log.h>) |