From: hcj <1224667075@qq.com> Date: Fri, 23 Aug 2024 08:03:39 +0000 (+0800) Subject: 增加SOS功能 X-Git-Tag: release_V1.2.70_20241020_135402~599 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=16bdd41d3c69fe7acbc187694b7c51362ad4a150;p=mirrors%2FFD230.git 增加SOS功能 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp index d5646ec32..6bf855813 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -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 index 000000000..bb57d67a3 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/include/notify/dial_sos_c.h @@ -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 */ diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h index 17c24876c..e2997786c 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h @@ -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" diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 6aab98aa2..64b84fb9e 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -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); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp index e4502fea0..a1ef70707 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp @@ -27,11 +27,88 @@ #include "components/ui_label_button.h" #include "bletest.h" #include "NativeAbility.h" +#include "dial_sos_c.h" +#include +#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); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index 003f00b30..dfd0d2ecd 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -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; }