蓝牙铃声改为本地铃声,仍需多手机,多场景验证 1352/2
authorhcj <1224667075@qq.com>
Wed, 6 Nov 2024 06:11:05 +0000 (14:11 +0800)
committerhcj <1224667075@qq.com>
Wed, 6 Nov 2024 06:11:05 +0000 (14:11 +0800)
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/drivers/peripheral/config/src/ConfigModel.cpp

index 5f66a12..d884f81 100644 (file)
@@ -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");
index 811271c..95c024e 100644 (file)
@@ -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:
index cff8d26..eef9465 100644 (file)
@@ -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)
         {
index 6732f9f..04da1a3 100644 (file)
@@ -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)