蓝牙来电静音
authorhcj <1224667075@qq.com>
Mon, 28 Oct 2024 12:51:15 +0000 (20:51 +0800)
committerhcj <1224667075@qq.com>
Mon, 28 Oct 2024 12:51:15 +0000 (20:51 +0800)
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h
code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp

index 74af04e..3ff0c24 100644 (file)
@@ -171,6 +171,8 @@ static void CallTimerCallbackProc(int data)
         return;
    }
 
+
+
    if(MainCallingView::GetInstance()->GetCallingView())
    {
         if (MainCallingView::GetInstance()->GetCallingView()->GetCallingDurationLabel()) 
@@ -183,7 +185,6 @@ static void CallTimerCallbackProc(int data)
         }
    }
 
-
     if( CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1
     && NotificationManager::GetInstance()->GetWatchCallStatus()==true)
    {    
@@ -676,6 +677,15 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall)
 
     DisshakeTimer();
 
+     if(phoneCall->operate==OPERATE_INCOMING)
+    {
+        uapi_SetSpeaker_Mute(true);
+    }
+    else
+    {
+        uapi_SetSpeaker_Mute(false);
+    }
+    
     if (phoneCall->operate == OPERATE_WATCH_FINISH && GetCurrCallNum() == 0) {
         g_callOperate = OPERATE_WATCH_FINISH;
         WatchFinishHandle();
@@ -756,6 +766,14 @@ static void ScoConnectHandle(void)
         return;
     }
 
+    if(g_isCall==HFP_HF_CALL_STATE_INCOMING)
+    {
+        uapi_SetSpeaker_Mute(true);
+    }
+    else
+    {
+        uapi_SetSpeaker_Mute(false);
+    }
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoConnectHandle] g_isCall = %d", g_isCall);
     switch (g_isCall) {
         case HFP_HF_CALL_STATE_ACTIVE:
@@ -785,6 +803,7 @@ static void ScoConnectHandle(void)
             break;
         case HFP_HF_CALL_STATE_INCOMING:
             CallerLogModel::GetInstance()->SetMakePhoneStatus(false);
+
             break;
         case HFP_HF_CALL_STATE_HELD:
             CallerLogModel::GetInstance()->SetCallStatus(true);
index 4e7b099..1c9210e 100644 (file)
@@ -1465,7 +1465,6 @@ static void CallAudioHandle(const hfp_hf_calls_info_t *call)
     if (state == HFP_HF_CALL_STATE_INCOMING || state == HFP_HF_CALL_STATE_DIALING ||
         state == HFP_HF_CALL_STATE_ALERTING) { // 电话呼入,支持播放手机铃声
         if (call->in_band_ring) {
-            if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()) && true != OHOS::ConfigModel::GetInstance()->GetSilentMode())
             {
                 // 播放手机端铃声
                 PostGraphicEvent(AudioDn);
@@ -2061,6 +2060,41 @@ void set_speaker_volume(unsigned char hfpVolume,int type)
 
 
     return;
+}
+static uint8_t SetSpeaker=false;
+
+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!=SetSpeaker)
+        {
+            if(true== SetSpeakerMute(isMute))
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerMute] true!");
+                SetSpeaker=isMute;
+            }
+        }
+
+    }
+    else if(isMute==false)
+    {
+        if(isMute!=SetSpeaker)
+        {
+            if(true== SetSpeakerMute(isMute))
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerMute] false!");
+                SetSpeaker=isMute;
+            }
+        }
+    }
+    
+
+   
 }
 
 // 设置通话speaker静音