From e2ca2510fcdbcacb76876bd569fe1d3d69922e0c Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Wed, 6 Nov 2024 14:11:05 +0800 Subject: [PATCH] =?utf8?q?=E8=93=9D=E7=89=99=E9=93=83=E5=A3=B0=E6=94=B9?= =?utf8?q?=E4=B8=BA=E6=9C=AC=E5=9C=B0=E9=93=83=E5=A3=B0=EF=BC=8C=E4=BB=8D?= =?utf8?q?=E9=9C=80=E5=A4=9A=E6=89=8B=E6=9C=BA=EF=BC=8C=E5=A4=9A=E5=9C=BA?= =?utf8?q?=E6=99=AF=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/alarm/src/AlarmClockModel.cpp | 4 +- .../nativeui/callerlog/src/CallerLogModel.cpp | 20 +++++++--- .../phoneservice/src/PhoneService.cpp | 38 +++++++++++++++---- .../peripheral/config/src/ConfigModel.cpp | 6 +-- 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp index 5f66a125f..d884f8119 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp @@ -858,7 +858,7 @@ int AlarmClockModel::AlarmPlayerStat() } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmPlayer uri %s.", uri.c_str()); playerCtr->SetSource(*source); - playerCtr->SetAudioStreamType(AUDIO_STREAM_ALARM_CLOCK); + playerCtr->SetAudioStreamType(AUDIO_STREAM_RING); playerCtr->Prepare(); // 申请焦点 @@ -874,7 +874,7 @@ int AlarmClockModel::AlarmPlayerStat() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playerInterruptListener new fail"); return OHOS_FAILURE; } - interrupt = { AUDIO_STREAM_ALARM_CLOCK, sessionId, playerInterruptListener }; + interrupt = { AUDIO_STREAM_RING, sessionId, playerInterruptListener }; // 激活音频中断 5s超时 if (amIntance.ActivateAudioInterrupt(interrupt) == INTERRUPT_FAILED) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ActivateAudioInterrupt faild"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp index 811271c5e..95c024e08 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -25,7 +25,7 @@ #include "dial_sos_c.h" #include "cat1_ctl.h" #include "cat1_server.h" - +#include "AlarmClockModel.h" #ifdef __cplusplus extern "C" { #endif @@ -146,9 +146,12 @@ void StatusReset(void) set_call_hungup_flag(0); set_TransCallToMobilePhone_falg(0); + OHOS::AlarmClockModel::GetInstance()->AlarmPlayerStop(); + // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) + //if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxx"); PhoneServiceScreenCtr(false); if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL) { @@ -156,10 +159,10 @@ void StatusReset(void) NativeAbility::GetInstance().Back_CountSlice_make_phone(); } - - } else { - g_isWatchCallView = false; } + // } else { + // g_isWatchCallView = false; + // } return; } @@ -473,7 +476,8 @@ static void PhoneActiveHandle(void) TransCallToMobilePhone(); // If the call is handling in the notification, the slice is not switched if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); // 退出通话界面,回到主表盘应用 + //NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); // 退出通话界面,回到主表盘应用 + StatusReset(); } else { g_isWatchCallView = false; } @@ -686,6 +690,7 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall) else { uapi_SetSpeaker_Mute(false); + //OHOS::AlarmClockModel::GetInstance()->AlarmPlayerStop(); } if (phoneCall->operate == OPERATE_WATCH_FINISH && GetCurrCallNum() == 0) { @@ -775,7 +780,10 @@ static void ScoConnectHandle(void) else { uapi_SetSpeaker_Mute(false); + OHOS::AlarmClockModel::GetInstance()->AlarmPlayerStop(); } + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoConnectHandle] g_isCall = %d", g_isCall); switch (g_isCall) { case HFP_HF_CALL_STATE_ACTIVE: diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp index cff8d2667..eef946517 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -790,6 +790,8 @@ static void ScoStateChanged(const bd_addr_t *bdAddr, hfp_sco_connect_state_t sta { TransCallToMobilePhone(); } + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoStateChanged] SCO connected!"); break; // SCO断连中 @@ -1490,11 +1492,17 @@ static void CallChangeHeldPro(const hfp_hf_calls_info_t *call) static void PlayWatchRing(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PlayWatchRing] start"); - // if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()) && true != OHOS::ConfigModel::GetInstance()->GetSilentMode()) - // { - // OHOS::AlarmClockModel::GetInstance()->testPlayerStart("/music/ring/ring.mp3"); - // } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PlayWatchRing] start"); + if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()) && true != OHOS::ConfigModel::GetInstance()->GetSilentMode()) + { + #ifdef SINGLE_USER_PARTITION + OHOS::AlarmClockModel::GetInstance()->testPlayerStart("/user/music/ring/ring.mp3"); + #else + OHOS::AlarmClockModel::GetInstance()->testPlayerStart("/music/ring/ring.mp3"); + g_audioState = AUDIO_ACT_INTERRUPT_WATCH_RING; + #endif + + } } static void CallAudioHandle(const hfp_hf_calls_info_t *call) @@ -1513,8 +1521,10 @@ static void CallAudioHandle(const hfp_hf_calls_info_t *call) PostGraphicEvent(AudioDn); } } else { - if (g_scoFlag != HFP_SCO_STATE_CONNECTED) { + //if (g_scoFlag != HFP_SCO_STATE_CONNECTED && + if(state == HFP_HF_CALL_STATE_INCOMING) { // 播放手表铃声 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"xxxxxxxxxxx"); PostGraphicEvent(PlayWatchRing); } } @@ -1561,6 +1571,11 @@ bool IsCompleteCallFlow(void) return g_completeCallFlag; } +static void stop_ring(void) +{ + OHOS::AlarmClockModel::GetInstance()->AlarmPlayerStop(); +} + // 通话状态变化上报回调 static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t *call) { @@ -1599,6 +1614,12 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t CallAudioHandle(call); uapi_pbap_cmd_pull_vcard_listing((unsigned char *)call->number); + if(HFP_HF_CALL_STATE_INCOMING!=call->state) + { + PostGraphicEvent(stop_ring); + // + } + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "CallStateChanged state:%d", call->state); switch (call->state) { @@ -2111,8 +2132,9 @@ void uapi_SetSpeaker_Mute(bool isMute) //return; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerMute] start!"); - if(isMute==true && (true == OHOS::ConfigModel::GetInstance()->GetDnotdisturb() || - (uapi_sleep_mode_flag_get()) || true == OHOS::ConfigModel::GetInstance()->GetSilentMode())) + if(isMute==true ) + // && (true == OHOS::ConfigModel::GetInstance()->GetDnotdisturb() || + // (uapi_sleep_mode_flag_get()) || true == OHOS::ConfigModel::GetInstance()->GetSilentMode())) { if(isMute!=SetSpeaker) { diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 6732f9ff0..04da1a3a5 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1403,21 +1403,21 @@ void cm_initializeMotionRecognition(void) bool cm_get_SPP_switch(void) { bool isopen = OHOS::ConfigModel::GetInstance()->get_configData_bool(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPP); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "getSPPSwitch %d",isopen); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "getSPPSwitch %d",isopen); return isopen; } bool cm_get_HFP_switch(void) { bool isopen = OHOS::ConfigModel::GetInstance()->GetHFPState(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "getHFPSwitch %d",isopen); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "getHFPSwitch %d",isopen); return isopen; } bool cm_get_A2DP_switch(void) { bool isopen = OHOS::ConfigModel::GetInstance()->GetA2DPState(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "getA2DPSwitch %d",isopen); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "getA2DPSwitch %d",isopen); return isopen; } void cm_set_timezone_quarters(int16_t timezone_quarters) -- 2.17.1