增加SOS功能
authorhcj <1224667075@qq.com>
Fri, 23 Aug 2024 08:03:39 +0000 (16:03 +0800)
committerhcj <1224667075@qq.com>
Fri, 23 Aug 2024 08:03:39 +0000 (16:03 +0800)
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
code/sdk/application/wearable/service/msg_center/include/notify/dial_sos_c.h [new file with mode: 0644]
code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c

index d5646ec..6bf8558 100644 (file)
@@ -19,6 +19,8 @@
 #include "graphic_service.h"
 #include "bleService.h"
 #include "ui_service.h"
+#include "dial_sos_c.h"
+
 extern "C" uint8_t uapi_dev_runtime_get_lock_status(void);
 namespace OHOS
 {
@@ -89,6 +91,12 @@ namespace OHOS
         GraphicService::GetInstance()->PostGraphicEvent(std::bind(PowerKeyLongPressCallBack));
     }
 
+    static void SOSKeyLongPress(void)
+    {
+        start_SOS_phone_dail();
+    }
+
+
     /*注册电源键的长按事件*/
     bool RebootAndShutdownModel::RegisterPowerKeyLongPressEvent(void)
     {
@@ -99,6 +107,12 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret);
             return false;
         }
+        ret = uapi_button_register_event_cb(SOSKeyLongPress, BUTTON1_LONGPRESS_8S);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret);
+            return false;
+        }
         return true;
     }
 
diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/dial_sos_c.h b/code/sdk/application/wearable/service/msg_center/include/notify/dial_sos_c.h
new file mode 100644 (file)
index 0000000..bb57d67
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.
+ * Description: makephone notification api
+ * Author: CompanyName
+ * Create: 2023-08-11
+ */
+
+#ifndef MAKEPHONE_SOS_NOTIFICATION_H
+#define MAKEPHONE_SOS_NOTIFICATION_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+
+void start_SOS_phone_dail(void);
+
+void sos_falg_add(void);
+
+void sos_falg_clean(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* MAKEPHONE_NOTIFICATION_H */
index 17c2487..e299778 100644 (file)
@@ -24,6 +24,7 @@
 #include "components/ui_view_group.h"
 #include "alarm_notification.h"
 #include "makephone_notification.h"
+#include "dial_sos_c.h"
 #include "charge_notification.h"
 #include "transmitting.h"
 #include "pairing_notification.h"
index 6aab98a..64b84fb 100644 (file)
@@ -840,6 +840,14 @@ void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req)
         //AlarmClockModel::GetInstance()->AlarmPlayerStart();
         int ret = PlayersModel::GetInstance()->PlayerStop();
 
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (display_api->get_screen_state() != SCREEN_ON)
+         {   
+               display_api->turn_on_screen();  
+         }  
+        display_api->set_screen_set_keepon_timeout(10000);
+
+
 
         cat1_call_dial(call_data);
         CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len);
index e4502fe..a1ef707 100755 (executable)
 #include "components/ui_label_button.h"
 #include "bletest.h"
 #include "NativeAbility.h"
+#include "dial_sos_c.h"
+#include <string>
+#include "string.h"
+#include "string/osal_string.h"
 // #define NOTIFY_THREE_SECONDS 3000
 // #define NOTIFY_ONE_SECOND 1000
 // #define NOTIFY_THIRTY_SECONDS 30000
 // #define NOTIFY_ONE_MINUTE 60000
 // #define NOTOFY_NO_OPERATE_TIME 35000
+static uint8_t sos_dail_falg=0;
+static char*sos_dail_buf[]={"10085","10086","10084"};
+
+#define SOS_TEST_FLAG 0
+
+#define SOS_HFP_FALG 0
+
+#define DIAL_TIME 30
+
+//结束通话运行
+void sos_falg_add(void)
+{
+    if(sos_dail_falg)
+    {
+
+        #if SOS_TEST_FLAG
+        if(1)
+        #else
+        if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0)
+        #endif
+        {
+            calldial_event_sendmsg_toUI(sos_dail_buf[(sos_dail_falg)%3]);
+        }
+        #if SOS_HFP_FALG
+        else if(uapi_hfp_connect_state()==0)
+        {
+            DialCall((unsigned char *)sos_dail_buf[sos_dail_falg],osal_strlen((const char*)sos_dail_buf[sos_dail_falg]));
+        }
+        #endif
+        else
+        {
+            //show 没连接也没卡UI
+        }
+        sos_dail_falg++;
+        if(sos_dail_falg>=9)
+        {
+            sos_dail_falg=0;
+        }
+    }
+}
+
+void sos_falg_clean(void)
+{
+    sos_dail_falg=0;
+}
+
+void start_SOS_phone_dail(void)
+{
+    #if SOS_TEST_FLAG
+    if(1)
+    #else
+    if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0)
+    #endif
+    {
+        calldial_event_sendmsg_toUI(sos_dail_buf[(0)%3]);
+         sos_dail_falg=1;
+    }
+    #if SOS_HFP_FALG
+    else if(uapi_hfp_connect_state()==0)
+    {
+        DialCall((unsigned char *)sos_dail_buf,osal_strlen((const char*)sos_dail_buf));
+        sos_dail_falg=1;
+    }
+    #endif
+    else
+    {
+        //show 没连接也没卡UI
+    }
+    
+   
+}
+
+
 
 namespace OHOS {
 constexpr int32_t NOTIFY_THREE_SECONDS = 3000;
@@ -164,6 +241,9 @@ static void DialingHandle(void)
     CallerLogModel::GetInstance()->SetDialingStatus("正在拨号");
     CallerLogModel::GetInstance()->SetMakePhoneStatus(true);
 
+    StartCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY, (int32_t)NOTIFY_ONE_SECOND);
+
+
 }
 
 static void AlertingHandle(void)
@@ -175,6 +255,8 @@ static void AlertingHandle(void)
 static void IncomingHandle(void)
 {
     CallerLogModel::GetInstance()->SetMakePhoneStatus(false);
+    DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY);
+
 }
 
 static void WaitingOpreate()
@@ -190,16 +272,14 @@ static void WaitingOpreate()
 
 static void WatchActiveHandle()
 {
+    DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY);
     CallerLogModel::GetInstance()->SetCallStatus(true);
     CallerLogModel::GetInstance()->SetWaitingStatus(false);
-   
-}
 
-static void PhoneActiveHandle(void)
-{
-   
 }
 
+
+
 static void WatchFinishHandle(void)
 {
     if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL ||
@@ -207,6 +287,8 @@ static void WatchFinishHandle(void)
     {
         StatusReset();
     }
+    sos_falg_add();
+    DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY);
 }
 
 void cat1_phone_state_change_cb(uint8_t state)
@@ -217,6 +299,7 @@ void cat1_phone_state_change_cb(uint8_t state)
         case OPERATE_DIALING:
             // 显示正在呼出界面
             DialingHandle();
+            
             call_stat=0;
             calllog_info_init();
             break;
@@ -239,6 +322,7 @@ void cat1_phone_state_change_cb(uint8_t state)
             // 手表接听,显示界面
             if(call_stat==2)
             call_stat=1;
+            sos_falg_clean();
             WatchActiveHandle();
             break;
         case OPERATE_PHONE_HOLD:
@@ -310,12 +394,12 @@ void CallTimerCallBackProc(int data)
 uint16_t dail_falg=0;
 void CalldialTimerCallBackProc(int data)
 {
-    if(dail_falg<=70)
+    if(dail_falg<=DIAL_TIME)
     dail_falg++;
-    if(dail_falg>=70)
+    if(dail_falg>=DIAL_TIME)
     {
-        NotificationManager::GetInstance()->StopNotify();
-        addcalllog();
+        cat1_call_hungup();
+        cat1_handle_call_disconnected();
     }
    
 }
@@ -362,6 +446,7 @@ void StartCallTimer(CallTimerType type, int32_t interval)
             }
             break;
          case CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY:
+            dail_falg=0;
             g_calldialTime = osTimerNew((osTimerFunc_t)CalldialTimerCallBackProc, osTimerPeriodic, NULL, NULL);
             tick = osMs2Tick(interval);
             retTimer = osTimerStart(g_calldialTime, tick);
index 003f00b..dfd0d2e 100644 (file)
@@ -1043,6 +1043,8 @@ static uint32_t PBAP_LS(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 }
 
 #include "bletest.h"
+#include "dial_sos_c.h"
+
 static uint32_t BLE_TEST(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 {
      UNUSED(strCommonCmd);
@@ -1089,6 +1091,9 @@ static uint32_t BLE_TEST(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
     case 9:
         br_adv_stop();
         break;
+    case 10:
+        start_SOS_phone_dail();
+        break;
     default:
         break;
     }