From 90a1fc13b9b3254de9b0ce024a0595424fd7f43f Mon Sep 17 00:00:00 2001 From: zhuchaochao Date: Fri, 12 Jan 2024 03:54:53 +0000 Subject: [PATCH] fix telephony ring bug Signed-off-by: zhuchaochao Change-Id: I5df3793ef41dc398cd6294c0a6d99b67d2f25d09 --- frameworks/native/bluetoothclient/BUILD.gn | 1 + .../native/bluetoothclient/audio_bluetooth_manager.cpp | 9 +++++++++ .../native/bluetoothclient/audio_bluetooth_manager.h | 1 + 3 files changed, 11 insertions(+) diff --git a/frameworks/native/bluetoothclient/BUILD.gn b/frameworks/native/bluetoothclient/BUILD.gn index cdcd946a6b..5c1cc6aead 100644 --- a/frameworks/native/bluetoothclient/BUILD.gn +++ b/frameworks/native/bluetoothclient/BUILD.gn @@ -41,6 +41,7 @@ ohos_shared_library("audio_bluetooth_client") { "hdf_core:libhdi", "hdf_core:libpub_utils", "hilog:libhilog", + "ipc:ipc_single", ] part_name = "audio_framework" diff --git a/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp b/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp index e3dc6a2267..ecec21a244 100644 --- a/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp +++ b/frameworks/native/bluetoothclient/audio_bluetooth_manager.cpp @@ -15,6 +15,7 @@ #include "audio_bluetooth_manager.h" #include "bluetooth_def.h" +#include "ipc_skeleton.h" #include "audio_errors.h" #include "audio_log.h" #include "bluetooth_device_manager.h" @@ -284,6 +285,11 @@ int32_t AudioHfpManager::ConnectScoWithAudioScene(AudioScene scene) std::lock_guard sceneLock(g_audioSceneLock); int8_t lastScoCategory = GetScoCategoryFromScene(scene_); int8_t newScoCategory = GetScoCategoryFromScene(scene); + int32_t uid = IPCSkeleton::GetCallingUid(); + if (scene == AUDIO_SCENE_RINGING && uid == TELEPHONY_UID) { + AUDIO_INFO_LOG("Telephony call ring scene need set correct category."); + newScoCategory = ScoCategory::SCO_CALLULAR; + } if (lastScoCategory == newScoCategory) { AUDIO_DEBUG_LOG("AudioScene category is not changed, ignore ConnectScoWithAudioScene operation."); return SUCCESS; @@ -309,6 +315,9 @@ int32_t AudioHfpManager::ConnectScoWithAudioScene(AudioScene scene) CHECK_AND_RETURN_RET_LOG(ret == 0, ERROR, "ConnectScoWithAudioScene failed, result: %{public}d", ret); } scene_ = scene; + if (newScoCategory == ScoCategory::SCO_CALLULAR) { + scene_ = AUDIO_SCENE_PHONE_CALL; + } return SUCCESS; } diff --git a/frameworks/native/bluetoothclient/audio_bluetooth_manager.h b/frameworks/native/bluetoothclient/audio_bluetooth_manager.h index db59fd1d82..16bf2f2c47 100644 --- a/frameworks/native/bluetoothclient/audio_bluetooth_manager.h +++ b/frameworks/native/bluetoothclient/audio_bluetooth_manager.h @@ -114,6 +114,7 @@ private: static std::shared_ptr hfpListener_; static AudioStandard::AudioScene scene_; static BluetoothRemoteDevice activeHfpDevice_; + static const int32_t TELEPHONY_UID = 1013; }; } } -- Gitee