/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: broadcast feature implement
- * Author: CompanyName
- * Create: 2021-11-11
- */
-
- #include <cstdio>
- #include "securec.h"
- #include "adapter.h"
- #include "ohos_init.h"
- #include "samgr_lite.h"
- #include "memory_adapter.h"
- #include "wearable_log.h"
- #include "service_id_define.h"
- #include "broadcast_service.h"
- #include "alarm/include/AlarmClockModel.h"
- #include "AlarmPopUpPresenter.h"
- #include "CallerLogModel.h"
- #include "notification_manager.h"
- #include "NativeAbility.h"
- #include "abilityms_slite_client.h"
- #include "element_name.h"
- #include "want.h"
- #include "msg_center.h"
- #include "msg_center_msg.h"
- #include "msg_center_protocol.h"
- #include "xiaodu_navi_vector.h"
- #include "baidumap.h"
- #include "common_def.h"
- #include "keyinput.h"
- #include "KeyInputListener.h"
- #include "VolumeSettingView.h"
- #include "VolumeSettingPresenter.h"
- #include "VolumeSettingView.h"
-
- #define DIALDATASET 1
-
- #ifdef SUPPORT_BLE_SERVICE
- #include "bleInstruct.h"
- #endif
-
- #ifdef CUSTOM_ZHIHUI
-
- #ifdef SUPPORT_CAT1_HFP_AG_SERV
- #include "phoneservice/include/PhoneAGService.h"
- #endif
-
- #include "goal/include/goalmodel.h"
- #include "goal/include/goalview.h"
- #include "goal/include/goalother.h"
-
- #include "ConfigModel.h"
- #include "PlayersModelC.h"
- #include "PlayersModel.h"
-
- #include "main/include/PullUpDownView.h"
-
-
- #include "custom_save_runtime.h"
- #include "transmitting.h"
- #include "charge_notification.h"
- #include "motion_recognition_notification.h"
- #include "sedentaryReminder_notification.h"
- #include "findwatch_notification.h"
- #include "debug_output_notification/debug_output_notification.h"
- #include "pairing_notification.h"
- #include "phone_crt.h"
- #include "main/include/dial/DialModelChargeC.h"
- #include "saveele/include/SaveEleModel.h"
- #include "testchangingC.h"
- #include "custom_runtime.h"
- #include "message_notification.h"
- #include "goal_notification.h"
- #include "drinkReminder_notification.h"
- #include "sleep_notification.h"
- #include "sleep/include/SleepModel.h"
- #include "health/health_service/health_service.h"
- #include "player/include/PlayersModelC.h"
- #include "system/include/SystemLogModelC.h"
-
- #include "bloodoxygen/include/BloodOxygenModel.h"
- #include "heartrate/include/HeartModel.h"
- #include "saveele/include/SaveEleModel.h"
- #include "respiratorytraining/include/RespiratoryTrainingModel.h"
-
- #include "custom_utilscpp.h"
- #include "custom_utils.h"
- #ifdef SUPPORT_POWER_MANAGER
- #include "power_display_service.h"
- #endif
- #endif
-
- #ifdef SUPPORT_CYWEE_SERVICE
- #include "cywee_hal.h"
- #include "cywee_data.h"
- #include "cywee_service.h"
- #endif
-
- #ifdef SUPPORT_CAT1_SERVICE
- #include "cat1_pub_api.h"
- #endif
- #include "uiservice/include/ui_service.h"
-
- #include "goal_notification.h"
- namespace OHOS {
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /* 订阅事件设定优先级 */
- const PriorityMapper PRI_MAPPER[] = {
- {TOPIC_EVENT_ALARM_RING, PRIORITY_ONE},
- {TOPIC_EVENT_NEXTDAY_UPDATE, PRIORITY_TWO},
- {TOPIC_EVENT_HFP_INCOMMING, PRIORITY_ONE},
- {TOPIC_EVENT_HFP_FINISHED, PRIORITY_ONE},
- {TOPIC_EVENT_HFP_PHONE_ACTIVE, PRIORITY_ONE},
- {TOPIC_EVENT_HFP_WATCH_ACTIVE, PRIORITY_ONE},
- {TOPIC_EVENT_HFP_WATCH_TO_PHONE, PRIORITY_ONE},
- {TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE},
-
- #ifdef SUPPORT_CAT1_MODEM
- {TOPIC_EVENT_CAT1_INCOMMING, PRIORITY_ONE},
- {TOPIC_EVENT_CAT1_CALLCONNTED, PRIORITY_ONE},
- {TOPIC_EVENT_CAT1_CALLENDED, PRIORITY_ONE},
- {TOPIC_EVENT_CAT1_CALLDIAL,PRIORITY_ONE},
- {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, PRIORITY_ONE},
- {TOPIC_EVENT_CAT1_POWER_ON, PRIORITY_ONE},
- {TOPIC_EVENT_CAT1_POWER_OFF, PRIORITY_ONE},
- {TOPIC_EVENT_CAT1_CALL_FAIL,PRIORITY_ONE},
- {TOPIC_EVENT_HFP_HINT,PRIORITY_ONE},
- #endif
- {TOPIC_EVENT_ON_TIME,PRIORITY_TWO},
-
- #ifdef SUPPORT_CYWEE_SERVICE
- // {TOPIC_EVENT_ACTIVITY_UPDATE,PRIORITY_TWO},
- // {TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE,PRIORITY_TWO},
- {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE,PRIORITY_TWO},
- {TOPIC_EVENT_INACTIVITY_UPDATE,PRIORITY_TWO},
- // {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE,PRIORITY_TWO},
- #endif
- {TOPIC_EVENT_GOAL_SHOW_VIEW,PRIORITY_TWO},
- {TOPIC_EVENT_STEPDATA_UPDATE,PRIORITY_TWO},
-
-
- {TOPIC_EVENT_BLE_TRAINING,PRIORITY_TWO},
- {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE},
-
- {TOPIC_EVENT_CHARGE_PLUG, PRIORITY_TWO},
- {TOPIC_EVENT_CHARGE_UNPLUG, PRIORITY_TWO},
- {TOPIC_EVENT_LOWPOWER_ALARM,PRIORITY_TWO},
-
- {TOPIC_EVENT_DEVICE_BIND, PRIORITY_ONE},
- {TOPIC_EVENT_FIND_WATCH,PRIORITY_TWO},// 找手表 [2]
- {TOPIC_EVENT_DRINKREMINDER,PRIORITY_TWO},//喝水提醒 [2]
- {TOPIC_EVENT_MESSAGENOTE,PRIORITY_THREE},//消息提醒 [3]
- {TOPIC_EVENT_MESSAGE_UPDATA,PRIORITY_TWO},//消息更新提醒 [3]
- {TOPIC_EVENT_SLEEPNOTE,PRIORITY_THREE},//睡眠弹窗 [3]
- {TOPIC_EVENT_DEBUGOUTPUT,PRIORITY_ONE},//开发调试专用窗口
- {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,PRIORITY_ONE},//关机动画
- };
-
- bool g_pressFlag = false;
- bool g_longPressFlag = false;
-
- static bool CheckPriority(const Topic topic)
- {
- uint16_t mapperSize = sizeof(PRI_MAPPER) / sizeof(PRI_MAPPER[0]);
- for (uint16_t i = 0; i < mapperSize; i++) {
- if (topic == PRI_MAPPER[i].topicId) {
- if (PRI_MAPPER[i].prId <= OHOS::NativeAbility::GetInstance().GetCurSlicePriority() &&
- PRI_MAPPER[i].prId <= OHOS::NotificationManager::GetInstance()->GetNotifyPriority()) {
- return true;
- } else {
- return false;
- }
- }
- }
- return false;
- }
-
- /* 订阅事件可定制 */
- void MsgCenterSubscribe()
- {
- MsgCenterSubscribeTopic(TOPIC_EVENT_ALARM_RING);
- MsgCenterSubscribeTopic(TOPIC_EVENT_NEXTDAY_UPDATE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_ON_TIME);
- MsgCenterSubscribeTopic(TOPIC_EVENT_STEPDATA_UPDATE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_INCOMMING);
- MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_PHONE_ACTIVE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_ACTIVE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_FINISHED);
- MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_PHONE_TO_WATCH);
- MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_TO_PHONE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_HINT);
- // MsgCenterSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE);
- // MsgCenterSubscribeTopic(TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_AR_ALERT_TYPE_UPDATE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_INACTIVITY_UPDATE);
- // MsgCenterSubscribeTopic(TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
- MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRANSMIT);
- MsgCenterSubscribeTopic(TOPIC_EVENT_GOAL_SHOW_VIEW);
- MsgCenterSubscribeTopic(TOPIC_EVENT_CHARGE_PLUG);
- MsgCenterSubscribeTopic(TOPIC_EVENT_CHARGE_UNPLUG);
- MsgCenterSubscribeTopic(TOPIC_EVENT_LOWPOWER_ALARM);
- #ifdef SUPPORT_CAT1_MODEM
- MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_INCOMMING);
- MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLCONNTED);
- MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLENDED);
- MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLDIAL);
- // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_SIGNAL_UPDATE);
- // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_ON);
- // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_OFF);
- MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALL_FAIL);
+* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+* Description: broadcast feature implement
+* Author: CompanyName
+* Create: 2021-11-11
+*/
+
+#include <cstdio>
+#include "securec.h"
+#include "adapter.h"
+#include "ohos_init.h"
+#include "samgr_lite.h"
+#include "memory_adapter.h"
+#include "wearable_log.h"
+#include "service_id_define.h"
+#include "broadcast_service.h"
+#include "alarm/include/AlarmClockModel.h"
+#include "AlarmPopUpPresenter.h"
+#include "CallerLogModel.h"
+#include "notification_manager.h"
+#include "NativeAbility.h"
+#include "abilityms_slite_client.h"
+#include "element_name.h"
+#include "want.h"
+#include "msg_center.h"
+#include "msg_center_msg.h"
+#include "msg_center_protocol.h"
+#include "xiaodu_navi_vector.h"
+#include "baidumap.h"
+#include "common_def.h"
+#include "keyinput.h"
+#include "KeyInputListener.h"
+#include "VolumeSettingView.h"
+#include "VolumeSettingPresenter.h"
+#include "VolumeSettingView.h"
+
+#define DIALDATASET 1
+
+#ifdef SUPPORT_BLE_SERVICE
+#include "bleInstruct.h"
+#endif
+
+#ifdef CUSTOM_ZHIHUI
+
+#ifdef SUPPORT_CAT1_HFP_AG_SERV
+#include "phoneservice/include/PhoneAGService.h"
+#endif
+
+#include "goal/include/goalmodel.h"
+#include "goal/include/goalview.h"
+#include "goal/include/goalother.h"
+
+#include "ConfigModel.h"
+#include "PlayersModelC.h"
+#include "PlayersModel.h"
+
+#include "main/include/PullUpDownView.h"
+
+
+#include "custom_save_runtime.h"
+#include "transmitting.h"
+#include "charge_notification.h"
+#include "motion_recognition_notification.h"
+#include "sedentaryReminder_notification.h"
+#include "findwatch_notification.h"
+#include "debug_output_notification/debug_output_notification.h"
+#include "pairing_notification.h"
+#include "phone_crt.h"
+#include "main/include/dial/DialModelChargeC.h"
+#include "saveele/include/SaveEleModel.h"
+#include "testchangingC.h"
+#include "custom_runtime.h"
+#include "message_notification.h"
+#include "goal_notification.h"
+#include "drinkReminder_notification.h"
+#include "sleep_notification.h"
+#include "sleep/include/SleepModel.h"
+#include "health/health_service/health_service.h"
+#include "player/include/PlayersModelC.h"
+#include "system/include/SystemLogModelC.h"
+
+#include "bloodoxygen/include/BloodOxygenModel.h"
+#include "heartrate/include/HeartModel.h"
+#include "saveele/include/SaveEleModel.h"
+#include "respiratorytraining/include/RespiratoryTrainingModel.h"
+
+#include "custom_utilscpp.h"
+#include "custom_utils.h"
+#ifdef SUPPORT_POWER_MANAGER
+#include "power_display_service.h"
+#endif
+#endif
+
+#ifdef SUPPORT_CYWEE_SERVICE
+#include "cywee_hal.h"
+#include "cywee_data.h"
+#include "cywee_service.h"
+#endif
+
+#ifdef SUPPORT_CAT1_SERVICE
+#include "cat1_pub_api.h"
+#endif
+#include "uiservice/include/ui_service.h"
+
+#include "goal_notification.h"
+namespace OHOS {
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* 订阅事件设定优先级 */
+const PriorityMapper PRI_MAPPER[] = {
+ {TOPIC_EVENT_ALARM_RING, PRIORITY_ONE},
+ {TOPIC_EVENT_NEXTDAY_UPDATE, PRIORITY_TWO},
+ {TOPIC_EVENT_HFP_INCOMMING, PRIORITY_ONE},
+ {TOPIC_EVENT_HFP_FINISHED, PRIORITY_ONE},
+ {TOPIC_EVENT_HFP_PHONE_ACTIVE, PRIORITY_ONE},
+ {TOPIC_EVENT_HFP_WATCH_ACTIVE, PRIORITY_ONE},
+ {TOPIC_EVENT_HFP_WATCH_TO_PHONE, PRIORITY_ONE},
+ {TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE},
- #endif
- MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND);
- MsgCenterSubscribeTopic(TOPIC_EVENT_FIND_WATCH);
- MsgCenterSubscribeTopic(TOPIC_EVENT_DRINKREMINDER);
- MsgCenterSubscribeTopic(TOPIC_EVENT_MESSAGENOTE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_SLEEPNOTE);
- MsgCenterSubscribeTopic(TOPIC_EVENT_DEBUGOUTPUT);
- MsgCenterSubscribeTopic(TOPIC_EVENT_SHUTDOWN_ANIMATIOR);
- }
-
- static OHOS::UIViewGroup* ShowGoalNotify(void)
- {
- return OHOS::GoalviewShow();
- }
-
- static OHOS::UIViewGroup* ShowAlarmNotify(void)
- {
- return OHOS::CreateAlarmView();
- }
-
- static OHOS::UIViewGroup* ShowPhoneCallNotify(void)
- {
- return OHOS::CreatePhoneCallView();
- }
-
- static OHOS::UIViewGroup* ShowCallingNotify(void)
- {
- return OHOS::CreateCallingView();
- }
-
- static OHOS::UIViewGroup* ShowMultiPhoneCallNotify(void)
- {
- return OHOS::CreateMultiplePhoneView();
- }
-
-
- /*显示绑定通知*/
- static OHOS::UIViewGroup* showDeviceBindingNotify(void)
- {
- return OHOS::CreateDeviceBindingView();
- }
-
- /*显示解绑通知*/
- static OHOS::UIViewGroup* showDeviceUnBindingNotify(void)
- {
- return OHOS::CreateDeviceUnBindingView();
- }
-
- /*显示解除绑定请求(与新设备连接)通知*/
- static OHOS::UIViewGroup* showDeviceUnbindingRequestNotify(void)
- {
- return OHOS::CreateDeviceUnbindingRequestGroupView();
- }
-
- /*显示低电量通知*/
- static OHOS::UIViewGroup* showlowpowerNotify(void)
- {
- return OHOS::lowPowerShow();
- }
-
- static OHOS::UIViewGroup* ShowChargeingNotify(void)
- {
- return OHOS::ShowChargeingView();
- }
-
-
- static OHOS::UIViewGroup* showFindWatchNotify(void)
- {
- return OHOS::CreateFindWatchView();
- }
-
- /*显示喝水提醒视图*/
- static OHOS::UIViewGroup* showDrinkReminderNotify(void)
- {
- return OHOS::CreateDrinkReminderView();
- }
-
- /*显示久坐提醒视图*/
- static OHOS::UIViewGroup* showSedentaryReminderNotify(void)
- {
- return OHOS::CreateSedentaryReminderView();
- }
-
- /*显示运动识别视图*/
- static OHOS::UIViewGroup* showMotionRecognitionNotify(void)
- {
- return OHOS::CreateMotionRecognitionView();
- }
-
- /*显示传输中*/
- static OHOS::UIViewGroup* showtransmitNotify(void)
- {
- return OHOS::transmittingShow();
- }
-
- //关机动画
- static OHOS::UIViewGroup* showShutdownAnimatorNotify(void)
- {
- return OHOS::showShutDownAnimation();
- }
- //无法呼叫sos
- static OHOS::UIViewGroup* showSOSNotify(void)
- {
- return OHOS::SOS_cant_dial();
- }
-
- /*显示消息提醒*/
- static OHOS::UIViewGroup *showMessageNotify(void) {
- OHOS::UIViewGroup *view = OHOS::CreateMessageView();
- printf("showMessageNotify %p",view);
- return view;
- }
- /*显示睡眠提醒*/
- static OHOS::UIViewGroup* showSleepNotify(void)
- {
- return OHOS::CreateSleepNotifyView();
- }
-
- //显示新来电
- static OHOS::UIViewGroup* showcallhintNotify(void)
- {
- return OHOS::CALL_INCOMING_HINT();
- }
-
- static OHOS::UIViewGroup* showDebugOutputNotify(void)
- {
- return OHOS::CreateDebugOutputMainView();
- }
-
-
- static OHOS::UIViewGroup* showcallfailNotify(void)
- {
- return OHOS::CALL_FAIL_HINT();
- }
-
- static OHOS::UIViewGroup* showCat1UpdataNotify(void)
- {
- // return OHOS::Cat1PythonUpdataShow();
- }
-
-
- void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
- {
- unused(req);
- // The alarm notification is not displayed if the incoming call notification is already being processed
- if (CheckPriority(topic)) {
- // AlarmClockModel::GetInstance()->PopInterPlayMusic();
- // AlarmViewEventListener::GetInstance()->PopAlarmRing();
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
- NotificationManager::GetInstance()->ShowNotify(ShowAlarmNotify, static_cast<uint16_t>(topic), true);
- } else {
- // just delay the alarm
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "just delay the alarm");
- // AlarmClockModel::GetInstance()->AlarmGetClockNum();
- // AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
- AlarmViewEventListener::GetInstance()->DelayAlarmRing();
- }
- }
- /*NextDay*/
- void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
- {
- unused(topic);
- unused(req);
- AlarmClockModel::GetInstance()->NextDayNotify();
- // current_year = 0;
- printf("******nextday is begin******\r\n");
- // 存储nextday执行日志
- start_report_nextday_log_start();
- /* ----------------------------------- 睡眠相关 ----------------------------------- */
- if (!ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP))
- {
- // 未设置睡眠监控 nextday进行清除睡眠数据。
- SleepModel::GetInstance().DeleteSleepData();
- // 通知UI更新
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(&OHOS::SleepModel::UpdateSleepView, &OHOS::SleepModel::GetInstance()));
- }
- printf("sleep end\n");
- /* ---------------------------------- 健康数据相关 ---------------------------------- */
- // 清空当日的心率血氧数据
- HealthService::GetInstance()->CleanHealthData();
- // 通知UI更新
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(&OHOS::HeartModel::CleanAllData, OHOS::HeartModel::GetInstance()));
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(&OHOS::BloodOxygenModel::CleanAllData,
- OHOS::BloodOxygenModel::GetInstance()));
- printf("health end\n");
- /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
- RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
-
- // 存储nextday执行日志
- start_report_nextday_log_end();
- // 清除popup_windows日志
- nextday_clear_popup_windows_log();
-
- printf("******nextday is end******\r\n");
- #ifdef SUPPORT_CYWEE_SERVICE
- /* --------------------------------- 每日目标相关 --------------------------------- */
- cywee_reset_history_daily_data(); //清除运动相关数据
-
- // 午夜清除运动数据
- for(int i=1;i<6;i++)
- {
- set_Is_show_flag(1,i);
- }
+#ifdef SUPPORT_CAT1_MODEM
+ {TOPIC_EVENT_CAT1_INCOMMING, PRIORITY_ONE},
+ {TOPIC_EVENT_CAT1_CALLCONNTED, PRIORITY_ONE},
+ {TOPIC_EVENT_CAT1_CALLENDED, PRIORITY_ONE},
+ {TOPIC_EVENT_CAT1_CALLDIAL,PRIORITY_ONE},
+ {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, PRIORITY_ONE},
+ {TOPIC_EVENT_CAT1_POWER_ON, PRIORITY_ONE},
+ {TOPIC_EVENT_CAT1_POWER_OFF, PRIORITY_ONE},
+ {TOPIC_EVENT_CAT1_CALL_FAIL,PRIORITY_ONE},
+ {TOPIC_EVENT_HFP_HINT,PRIORITY_ONE},
+#endif
+ {TOPIC_EVENT_ON_TIME,PRIORITY_TWO},
+
+#ifdef SUPPORT_CYWEE_SERVICE
+ // {TOPIC_EVENT_ACTIVITY_UPDATE,PRIORITY_TWO},
+ // {TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE,PRIORITY_TWO},
+ {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE,PRIORITY_TWO},
+ {TOPIC_EVENT_INACTIVITY_UPDATE,PRIORITY_TWO},
+ // {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE,PRIORITY_TWO},
+#endif
+ {TOPIC_EVENT_GOAL_SHOW_VIEW,PRIORITY_TWO},
+ {TOPIC_EVENT_STEPDATA_UPDATE,PRIORITY_TWO},
+
+
+ {TOPIC_EVENT_BLE_TRAINING,PRIORITY_TWO},
+ {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE},
+
+ {TOPIC_EVENT_CHARGE_PLUG, PRIORITY_TWO},
+ {TOPIC_EVENT_CHARGE_UNPLUG, PRIORITY_TWO},
+ {TOPIC_EVENT_LOWPOWER_ALARM,PRIORITY_TWO},
+
+ {TOPIC_EVENT_DEVICE_BIND, PRIORITY_ONE},
+ {TOPIC_EVENT_FIND_WATCH,PRIORITY_TWO},// 找手表 [2]
+ {TOPIC_EVENT_DRINKREMINDER,PRIORITY_TWO},//喝水提醒 [2]
+ {TOPIC_EVENT_MESSAGENOTE,PRIORITY_THREE},//消息提醒 [3]
+ {TOPIC_EVENT_MESSAGE_UPDATA,PRIORITY_TWO},//消息更新提醒 [3]
+ {TOPIC_EVENT_SLEEPNOTE,PRIORITY_THREE},//睡眠弹窗 [3]
+ {TOPIC_EVENT_DEBUGOUTPUT,PRIORITY_ONE},//开发调试专用窗口
+ {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,PRIORITY_ONE},//关机动画
+};
+
+bool g_pressFlag = false;
+bool g_longPressFlag = false;
+
+static bool CheckPriority(const Topic topic)
+{
+ uint16_t mapperSize = sizeof(PRI_MAPPER) / sizeof(PRI_MAPPER[0]);
+ for (uint16_t i = 0; i < mapperSize; i++) {
+ if (topic == PRI_MAPPER[i].topicId) {
+ if (PRI_MAPPER[i].prId <= OHOS::NativeAbility::GetInstance().GetCurSlicePriority() &&
+ PRI_MAPPER[i].prId <= OHOS::NotificationManager::GetInstance()->GetNotifyPriority()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+ return false;
+}
+
+/* 订阅事件可定制 */
+void MsgCenterSubscribe()
+{
+ MsgCenterSubscribeTopic(TOPIC_EVENT_ALARM_RING);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_NEXTDAY_UPDATE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_ON_TIME);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_STEPDATA_UPDATE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_INCOMMING);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_PHONE_ACTIVE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_ACTIVE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_FINISHED);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_PHONE_TO_WATCH);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_TO_PHONE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_HINT);
+ // MsgCenterSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE);
+ // MsgCenterSubscribeTopic(TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_AR_ALERT_TYPE_UPDATE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_INACTIVITY_UPDATE);
+ // MsgCenterSubscribeTopic(TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRANSMIT);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_GOAL_SHOW_VIEW);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CHARGE_PLUG);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CHARGE_UNPLUG);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_LOWPOWER_ALARM);
+#ifdef SUPPORT_CAT1_MODEM
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_INCOMMING);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLCONNTED);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLENDED);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLDIAL);
+ // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_SIGNAL_UPDATE);
+ // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_ON);
+ // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_OFF);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALL_FAIL);
+
+#endif
+ MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_FIND_WATCH);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_DRINKREMINDER);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_MESSAGENOTE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_SLEEPNOTE);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_DEBUGOUTPUT);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_SHUTDOWN_ANIMATIOR);
+}
+
+static OHOS::UIViewGroup* ShowGoalNotify(void)
+{
+ return OHOS::GoalviewShow();
+}
+
+static OHOS::UIViewGroup* ShowAlarmNotify(void)
+{
+ return OHOS::CreateAlarmView();
+}
+
+static OHOS::UIViewGroup* ShowCallingNotify(void)
+{
+ // return OHOS::CreateCallingView();
+ return nullptr;
+}
+
+static OHOS::UIViewGroup* ShowMultiPhoneCallNotify(void)
+{
+ // return OHOS::CreateMultiplePhoneView();
+ return nullptr;
+}
+
+
+/*显示绑定通知*/
+static OHOS::UIViewGroup* showDeviceBindingNotify(void)
+{
+ return OHOS::CreateDeviceBindingView();
+}
+
+/*显示解绑通知*/
+static OHOS::UIViewGroup* showDeviceUnBindingNotify(void)
+{
+ return OHOS::CreateDeviceUnBindingView();
+}
+
+/*显示解除绑定请求(与新设备连接)通知*/
+static OHOS::UIViewGroup* showDeviceUnbindingRequestNotify(void)
+{
+ return OHOS::CreateDeviceUnbindingRequestGroupView();
+}
+
+/*显示低电量通知*/
+static OHOS::UIViewGroup* showlowpowerNotify(void)
+{
+ return OHOS::lowPowerShow();
+}
+
+static OHOS::UIViewGroup* ShowChargeingNotify(void)
+{
+ return OHOS::ShowChargeingView();
+}
+
+
+static OHOS::UIViewGroup* showFindWatchNotify(void)
+{
+ return OHOS::CreateFindWatchView();
+}
+
+/*显示喝水提醒视图*/
+static OHOS::UIViewGroup* showDrinkReminderNotify(void)
+{
+ return OHOS::CreateDrinkReminderView();
+}
+
+/*显示久坐提醒视图*/
+static OHOS::UIViewGroup* showSedentaryReminderNotify(void)
+{
+ return OHOS::CreateSedentaryReminderView();
+}
+
+/*显示运动识别视图*/
+static OHOS::UIViewGroup* showMotionRecognitionNotify(void)
+{
+ return OHOS::CreateMotionRecognitionView();
+}
+
+/*显示传输中*/
+static OHOS::UIViewGroup* showtransmitNotify(void)
+{
+ return OHOS::transmittingShow();
+}
+
+//关机动画
+static OHOS::UIViewGroup* showShutdownAnimatorNotify(void)
+{
+ return OHOS::showShutDownAnimation();
+}
+//无法呼叫sos
+static OHOS::UIViewGroup* showSOSNotify(void)
+{
+ return OHOS::SOS_cant_dial();
+}
+
+/*显示消息提醒*/
+static OHOS::UIViewGroup *showMessageNotify(void) {
+ OHOS::UIViewGroup *view = OHOS::CreateMessageView();
+ printf("showMessageNotify %p",view);
+ return view;
+}
+/*显示睡眠提醒*/
+static OHOS::UIViewGroup* showSleepNotify(void)
+{
+ return OHOS::CreateSleepNotifyView();
+}
+
+//显示新来电
+static OHOS::UIViewGroup* showcallhintNotify(void)
+{
+ return OHOS::CALL_INCOMING_HINT();
+}
+
+static OHOS::UIViewGroup* showDebugOutputNotify(void)
+{
+ return OHOS::CreateDebugOutputMainView();
+}
+
+
+static OHOS::UIViewGroup* showcallfailNotify(void)
+{
+ return OHOS::CALL_FAIL_HINT();
+}
+
+static OHOS::UIViewGroup* showCat1UpdataNotify(void)
+{
+ // return OHOS::Cat1PythonUpdataShow();
+}
+
+
+void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
+{
+ unused(req);
+ // The alarm notification is not displayed if the incoming call notification is already being processed
+ if (CheckPriority(topic)) {
+ // AlarmClockModel::GetInstance()->PopInterPlayMusic();
+ // AlarmViewEventListener::GetInstance()->PopAlarmRing();
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ NotificationManager::GetInstance()->ShowNotify(ShowAlarmNotify, static_cast<uint16_t>(topic), true);
+ } else {
+ // just delay the alarm
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "just delay the alarm");
+ // AlarmClockModel::GetInstance()->AlarmGetClockNum();
+ // AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+ AlarmViewEventListener::GetInstance()->DelayAlarmRing();
+ }
+}
+/*NextDay*/
+void MsgCenterNotifyNextDayProc(const Topic topic, Request *req)
+{
+ unused(topic);
+ unused(req);
+ AlarmClockModel::GetInstance()->NextDayNotify();
+ // current_year = 0;
+ printf("******nextday is begin******\r\n");
+ // 存储nextday执行日志
+ start_report_nextday_log_start();
+ /* ----------------------------------- 睡眠相关 ----------------------------------- */
+ if (!ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP))
+ {
+ // 未设置睡眠监控 nextday进行清除睡眠数据。
+ SleepModel::GetInstance().DeleteSleepData();
+ // 通知UI更新
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::SleepModel::UpdateSleepView, &OHOS::SleepModel::GetInstance()));
+ }
+ printf("sleep end\n");
+ /* ---------------------------------- 健康数据相关 ---------------------------------- */
+ // 清空当日的心率血氧数据
+ HealthService::GetInstance()->CleanHealthData();
+ // 通知UI更新
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::HeartModel::CleanAllData, OHOS::HeartModel::GetInstance()));
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::BloodOxygenModel::CleanAllData,
+ OHOS::BloodOxygenModel::GetInstance()));
+ printf("health end\n");
+ /* ---------------------------------- 呼吸训练相关 ---------------------------------- */
+ RespiratoryTrainingModel::GetInstance().ClearTotalRespiratoryTrainingTime();
+
+ // 存储nextday执行日志
+ start_report_nextday_log_end();
+ // 清除popup_windows日志
+ nextday_clear_popup_windows_log();
+
+ printf("******nextday is end******\r\n");
+#ifdef SUPPORT_CYWEE_SERVICE
+ /* --------------------------------- 每日目标相关 --------------------------------- */
+ cywee_reset_history_daily_data(); //清除运动相关数据
+
+ // 午夜清除运动数据
+ for(int i=1;i<6;i++)
+ {
+ set_Is_show_flag(1,i);
+ }
+
+ do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESET_DAILY_DATA, NULL);
+
+ SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
+ printf("sport end\n");
+#endif
+
+}
+void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
+{
+ unused(req);
+ AlarmClockEventData* time=(AlarmClockEventData*)req->data;
+ #ifdef SUPPORT_CYWEE_SERVICE
+
+ cywee_save_data(); //暂时没有这个函数
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时步数");
+ cywee_step_history_save(time->value);
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据");
+ if(cywee_get_stand_flag())
+ cywee_stand_history_save(time->value);
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据");
+ cywee_calories_history_save(time->value);
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据");
+ cywee_distances_history_save(time->value);
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时燃脂数据");
+ cywee_fat_history_save(time->value);
+ // 保存完增加一次读取数据
+ SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
+#endif
+ }
+//设备绑定通知
+void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
+{
+ #ifdef SUPPORT_BLE_SERVICE
+ //unused(req);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyBindProc Bind!");
+ // 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();
+ // }
+ uint8_t* data=(uint8_t*)req->data;
+ /* 安全:固定上限 + 显式终止 */
+ const size_t kMaxDevName = 64;
+ char devname[kMaxDevName + 1] = {0};
+ if (data != NULL && req->len >= 2)
+ {
+ switch(data[0])
+ {
+ case DEVICEBIND:
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ {
+ /* 设备名在 payload[2..],长度为 req->len-2,做边界裁剪并追加'\0' */
+ size_t name_len = (req->len > 2) ? (size_t)req->len - 2 : 0;
+ if (name_len > 0)
+ {
+ size_t copy_len = (name_len > kMaxDevName) ? kMaxDevName : name_len;
+ (void)memcpy_s(devname, sizeof(devname), (const char*)req->data + 2, copy_len);
+ devname[copy_len] = '\0';
+ PairingViewEventListener::GetInstance().SetDeviceName(devname);
+ }
+ else
+ {
+ PairingViewEventListener::GetInstance().SetDeviceName(NULL);
+ }
+ }
+ if(NotificationManager::GetInstance()->HasNotifyShowing())
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+ NotificationManager::GetInstance()->ShowNotify(showDeviceBindingNotify, (uint16_t)topic, true);
+ break;
+ case DEVICEUNBIND:
+
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ {
+ size_t name_len = (req->len > 2) ? (size_t)req->len - 2 : 0;
+ if (name_len > 0)
+ {
+ size_t copy_len = (name_len > kMaxDevName) ? kMaxDevName : name_len;
+ (void)memcpy_s(devname, sizeof(devname), (const char*)req->data + 2, copy_len);
+ devname[copy_len] = '\0';
+ PairingViewEventListener::GetInstance().SetDeviceName(devname);
+ }
+ else
+ {
+ PairingViewEventListener::GetInstance().SetDeviceName(NULL);
+ }
+ }
+ NotificationManager::GetInstance()->ShowNotify(showDeviceUnBindingNotify, (uint16_t)topic, true);
+ break;
+ case DeviceUnBindingRequest:
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showDeviceUnbindingRequestNotify, (uint16_t)topic, true);
+ break;
+ case SHUTDOWN:
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, " SHUTDOWN");
+ set_lowpower_falg(3);
+ if (NotificationManager::GetInstance()->HasNotifyShowing())
+ NotificationManager::GetInstance()->StopNotify();
+
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+
+ NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+ //low_power_play(true);
+ break;
+ case REBOOT:
+ set_lowpower_falg(4);
+ if (NotificationManager::GetInstance()->HasNotifyShowing())
+ NotificationManager::GetInstance()->StopNotify();
+
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+ //low_power_play(false);
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ #endif
+}
+
+
+
+void MsgCenterNotifybleTransmit(const Topic topic, Request* req)
+{
+#ifdef SUPPORT_BLE_SERVICE
+unused(topic);
+uint8_t* data=(uint8_t*)req->data;
+WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifybleTransmit:%d",data[0]);
+
+
+if(data[0]==TRANS_FREE)
+{
+ if(transmittingISShow())
+ NotificationManager::GetInstance()->StopNotify();
+}
+else if (data[0]==IS_NEED_CAT1_OTA)
+{
+
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+
+ // NotificationManager::GetInstance()->ShowNotify(showCat1UpdataNotify, (uint16_t)topic, true);
+}
+else if (data[0]==FILE_IS_DONE)
+{
+ set_transmittingShow_falg(data[0]);
+}
+else
+{
+ set_transmittingShow_falg(data[0]);
+
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+
+ NotificationManager::GetInstance()->ShowNotify(showtransmitNotify, (uint16_t)topic, true);
+}
+#endif
+}
+
+void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req)
+{
+ #ifdef SUPPORT_BATTERY_SERVICE
+ unused(req);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug !");
+#ifdef SYSTEM_LOG_SERVICE
+ uapi_save_runtime_log(RUNTIME_LOG_CHARGE_START);//充电开始事件
+#endif
+ 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();
+ }
+
+ if(PullUpDownView::GetInstance())
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
+ }
+#if DIALDATASET
+ // DialModelCharge::GetInstance()->UpdatechargeStatus(1);
+ setChargeStatus(1);
+#endif
+ SaveEleModel::GetInstance()->SetChargeStatus(true);
+
+ if (uapi_dev_runtime_get_train_status())
+ {
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug ! but train status is true");
+ return ;
+ }
+
+
+ if(IsTestCHANGINGViewCreated())
+ {
+ ChangeViewcolorC(1);
+ }
+ else
+ {
+ if (CheckPriority(topic) && !uapi_dev_runtime_get_factory_test_status_flag()) //产测模式不弹充电弹窗
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(ShowChargeingNotify, (uint16_t)topic, true);
+ }
+ }
+ #endif
+}
+
+/*充电器已拔掉*/
+void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req)
+{
+ #ifdef SUPPORT_BATTERY_SERVICE
+ unused(req);
+ unused(topic);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger UnPlug !");
+#ifdef SYSTEM_LOG_SERVICE
+ //充电停止事件
+ uapi_save_runtime_log(RUNTIME_LOG_CHARGE_STOP);//TOOD*
+#endif
+ if(PullUpDownView::GetInstance())
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
+ }
+#if DIALDATASET
+ // DialModelCharge::GetInstance()->UpdatechargeStatus(0);
+ setChargeStatus(0);
+#endif
+ SaveEleModel::GetInstance()->SetChargeStatus(false);
+
+
+ if(IsTestCHANGINGViewCreated())
+ {
+ ChangeViewcolorC(0);
+ }
+ else
+ {
+ if(is_UIViewGroup_charge())
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+ }
+#endif
+}
+
+/*低电量提醒*/
+void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
+{
+WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: LowPower Alarm !");
+uint8 *x= (uint8 *)(req->data);
+const power_display_svr_api_t *display_api = power_display_svr_get_api();
+// if(*x==3)
+// {
+// if (display_api->get_screen_state() != SCREEN_ON)
+// {
+// display_api->turn_on_screen();
+// }
+// display_api->set_screen_set_keepon_timeout(1000*5);
+// //倒计时结束后,直接执行关机动画
+// low_power_play();
+// }
+if(*x==0)
+{
+ //提醒低电充电
+ if (display_api->get_screen_state() != SCREEN_ON)
+ {
+ display_api->turn_on_screen();
+ }
+ display_api->set_screen_set_keepon_timeout(1000*5);
+
+ set_lowpower_falg(0);
+ if (CheckPriority(topic))
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+ }
+}
+else
+{
+ //电量过低,直接提醒关机
+ if (display_api->get_screen_state() != SCREEN_ON)
+ {
+ display_api->turn_on_screen();
+ }
+ display_api->set_screen_set_keepon_timeout(1000*10);
+ set_lowpower_falg(1);
+ if (NotificationManager::GetInstance()->HasNotifyShowing())
+ NotificationManager::GetInstance()->StopNotify();
+ if (CheckPriority(topic))
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+ }
+}
+}
+ //TODO: 亮屏弹窗倒计时5秒关机(不需要取消,强制关机)
+ // DialModelCharge::GetInstance()->UpdatechargeStatus(0);
+ // SaveEleModel::GetInstance()->SetChargeStatus(0);
+
+ // testCHANINGView *t=testCHANINGView::GetInstance();
+ // if(t!=NULL)
+ // {
+ // t->ChangeViewcolor(false);
+ // }
+
+#ifdef SUPPORT_CAT1_MODEM
+void MsgCenterNotifyHfpIncomingProc(const Topic topic, Request* req)
+{
+ hfp_hf_calls_info_t callData = {0};
+ int32 ret = memcpy_s(&callData, sizeof(hfp_hf_calls_info_t), req->data, req->len);
+ if (ret != EOK) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
+ } else {
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyHfpIncomingProc");
+ CallerLogModel::GetInstance()->SetoperateNumber(callData.number, callData.number_len);
+ CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone);
+ NotificationManager::GetInstance()->SetWatchCallStatus(true);
+ if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
+ {
+ // ui_api_vibrate_once_func();
+ }
+}
+void MsgCenterNotifyHfpPhoneProc(const Topic topic, Request* req)
+{
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "1201patch合并为编译过屏蔽下方代码");
+ #if 0 // 1201patch 为编译过屏蔽
+ unused(req);
+ // finish a single-channel call, or switch to phone, stop the notify
+ if (CallerLogModel::GetInstance()->GetNotifyFlag())
+ {
+ DisableWatingView();
+ if ((topic == TOPIC_EVENT_HFP_FINISHED && GetCurrCallNum() == 0) ||
+ topic == TOPIC_EVENT_HFP_PHONE_ACTIVE || topic == TOPIC_EVENT_HFP_WATCH_TO_PHONE)
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ NotificationManager::GetInstance()->SetWatchCallStatus(false);
+ }
+ }
+ #endif
+}
+
+void MsgCenterNotifyHfpWatchProc(const Topic topic, Request* req)
+{
+
+WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "1201patch合并为编译过屏蔽下方代码");
+#if 0 // 1201patch 为编译过屏蔽
+unused(req);
+if (CallerLogModel::GetInstance()->GetNotifyFlag())
+{
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ // default not mute
+ SetMicMute(false);
+ if (CallerLogModel::GetInstance()->IsMulitplePhoneStatus())
+ {
+ NotificationManager::GetInstance()->ShowNotify(ShowMultiPhoneCallNotify,
+ static_cast<uint16_t>(topic), true);
+ } else
+ {
+ NotificationManager::GetInstance()->ShowNotify(ShowCallingNotify, static_cast<uint16_t>(topic), true);
+}
+ NotificationManager::GetInstance()->SetWatchCallStatus(true);
+}
+#endif
+}
+
+void MsgCenterNotifyHfpWatchHintProc(const Topic topic, Request* req)
+{
+ unused(req);
+
+ phone_VibratorFunc();
+
+ if(NotificationManager::GetInstance()->HasNotifyShowing())
+ NotificationManager::GetInstance()->StopNotify();
+
+ NotificationManager::GetInstance()->ShowNotify(showcallhintNotify,
+ static_cast<uint16_t>(topic), true);
+}
+
+//来电处理函数
+void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req)
+{
+ unused(topic);
+ unused(topic);
+ if (req == NULL) return ;
+ char* call_data = (char*)malloc(req->len);
+ if(call_data==NULL)
+ {
+ return;
+ }
+ int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
+ if (ret != EOK) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
+ } else {
+ // Prevent this from happening:
+ // When the incoming call view is displayed, the calling number is not set in CallerLogModel.
+
+ if(NotificationManager::GetInstance()->GetWatchCallStatus() &&
+ (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_REJECT %s!=%s??",call_data,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+ CallerLogModel::GetInstance()->tempSetoperateNumberCAT1END(call_data,req->len);
+ cat1_phone_state_change_cb(OPERATE_WATCH_REJECT);
+ free(call_data);
+ return;
+ }
+
+ if((NotificationManager::GetInstance()->GetWatchCallStatus() &&
+ (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)) || uapi_dev_runtime_get_train_status() || transmittingISShow())
+ {
+
+ CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(call_data,req->len);
+ cat1_phone_state_change_cb(OPERATE_WAITING);
+ free(call_data);
+ return;
+ }
+
+ stopPlayingMusic();
+ PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐
+ uapi_set_screen_on_api();
+ phone_paly_ring();
+
+ CallerLogModel::GetInstance()->SetoperateNumber(call_data,strlen(call_data));
+
+ cat1_phone_state_change_cb(OPERATE_INCOMING);
+
+ }
+ free(call_data);
+
+}
+//开始通话处理函数
+void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req)
+{
+ unused(topic);
+ unused(req);
+
+ if (req == NULL) return ;
+ if(!NotificationManager::GetInstance()->GetWatchCallStatus())
+ {
+ return;
+ }
+ AlarmClockModel::GetInstance()->AlarmPlayerStop();
+ #ifdef SUPPORT_CAT1_HFP_AG_SERV
+ if(uapi_dev_runtime_get_earphone_connect_stat())
+ {
+
+ if(headset_Is_connect())
+ {
+ if(headset_SCO_Is_connect()==false)
+ {
+ cat1_ag_send_call_event(TOPIC_EVENT_CAT1_INCOMMING,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+ }
+ else
+ {
+ if(cat1_api_get_cat1_volte_voice_state()==0)
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "headset_Is_connect is false");
+ }
+
+ }
+ else
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);
+ }
+ cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLCONNTED,NULL);
+ }
+ else
+ #endif
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
+ }
+ SetMicMutecat1(false);
+ cat1_phone_state_change_cb(OPERATE_WATCH_ACTIVE);
+
+}
+#include "BluetoothModelC.h"
+#include "audio_manager_c_wrapper.h"
+#include "PhoneService.h"
+//拨号处理函数
+void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req)
+{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify MsgCenterNotifyCat1dialProc");
+ unused(topic);
+ unused(req);
+ if (req == NULL) return ;
+ char* call_data = (char*)malloc(req->len);
+ if(call_data==NULL) return;
+ int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
+ if (ret != EOK) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
+ } else {
+
+ // int ret = PlayersModel::GetInstance()->PlayerStop();
+ stopPlayingMusic();
+
+ if(strcmp(call_data,"SOS")==0)
+ {
+ free(call_data);
+ NotificationManager::GetInstance()->ShowNotify(showSOSNotify, (uint16_t)topic, true);
+ return;
+ }
- do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESET_DAILY_DATA, NULL);
-
- SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
- printf("sport end\n");
- #endif
-
- }
- void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
- {
- unused(req);
- AlarmClockEventData* time=(AlarmClockEventData*)req->data;
- #ifdef SUPPORT_CYWEE_SERVICE
-
- cywee_save_data(); //暂时没有这个函数
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时步数");
- cywee_step_history_save(time->value);
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据");
- if(cywee_get_stand_flag())
- cywee_stand_history_save(time->value);
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据");
- cywee_calories_history_save(time->value);
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据");
- cywee_distances_history_save(time->value);
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "保存每小时燃脂数据");
- cywee_fat_history_save(time->value);
- // 保存完增加一次读取数据
- SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
- #endif
- }
- //设备绑定通知
- void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
- {
- #ifdef SUPPORT_BLE_SERVICE
- //unused(req);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyBindProc Bind!");
- // 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();
- // }
- uint8_t* data=(uint8_t*)req->data;
- /* 安全:固定上限 + 显式终止 */
- const size_t kMaxDevName = 64;
- char devname[kMaxDevName + 1] = {0};
- if (data != NULL && req->len >= 2)
- {
- switch(data[0])
- {
- case DEVICEBIND:
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
- {
- /* 设备名在 payload[2..],长度为 req->len-2,做边界裁剪并追加'\0' */
- size_t name_len = (req->len > 2) ? (size_t)req->len - 2 : 0;
- if (name_len > 0)
- {
- size_t copy_len = (name_len > kMaxDevName) ? kMaxDevName : name_len;
- (void)memcpy_s(devname, sizeof(devname), (const char*)req->data + 2, copy_len);
- devname[copy_len] = '\0';
- PairingViewEventListener::GetInstance().SetDeviceName(devname);
- }
- else
- {
- PairingViewEventListener::GetInstance().SetDeviceName(NULL);
- }
- }
- if(NotificationManager::GetInstance()->HasNotifyShowing())
- {
- NotificationManager::GetInstance()->StopNotify();
- }
- NotificationManager::GetInstance()->ShowNotify(showDeviceBindingNotify, (uint16_t)topic, true);
- break;
- case DEVICEUNBIND:
-
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
- {
- size_t name_len = (req->len > 2) ? (size_t)req->len - 2 : 0;
- if (name_len > 0)
- {
- size_t copy_len = (name_len > kMaxDevName) ? kMaxDevName : name_len;
- (void)memcpy_s(devname, sizeof(devname), (const char*)req->data + 2, copy_len);
- devname[copy_len] = '\0';
- PairingViewEventListener::GetInstance().SetDeviceName(devname);
- }
- else
- {
- PairingViewEventListener::GetInstance().SetDeviceName(NULL);
- }
- }
- NotificationManager::GetInstance()->ShowNotify(showDeviceUnBindingNotify, (uint16_t)topic, true);
- break;
- case DeviceUnBindingRequest:
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(showDeviceUnbindingRequestNotify, (uint16_t)topic, true);
- break;
- case SHUTDOWN:
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, " SHUTDOWN");
- set_lowpower_falg(3);
- if (NotificationManager::GetInstance()->HasNotifyShowing())
- NotificationManager::GetInstance()->StopNotify();
-
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
-
- NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
- //low_power_play(true);
- break;
- case REBOOT:
- set_lowpower_falg(4);
- if (NotificationManager::GetInstance()->HasNotifyShowing())
- NotificationManager::GetInstance()->StopNotify();
-
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
- //low_power_play(false);
- break;
-
- default:
- break;
- }
+#ifdef SUPPORT_CAT1_SERVICE
+ cat1_cmd_send(CMD_4G_MAKE_CALL,call_data,strlen(call_data));
+#endif
+ CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len);
+
+#ifdef SUPPORT_CAT1_SERVICE
+ cat1_phone_state_change_cb(OPERATE_DIALING);
+#endif
+
+ #ifdef SUPPORT_CAT1_HFP_AG_SERV
+ if(uapi_dev_runtime_get_earphone_connect_stat())
+ {
+ if(headset_Is_connect())
+ {
+ cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLDIAL,NULL);
- }
- #endif
- }
-
-
-
- void MsgCenterNotifybleTransmit(const Topic topic, Request* req)
- {
- #ifdef SUPPORT_BLE_SERVICE
+ if(headset_SCO_Is_connect())
+ {
+ if(cat1_api_get_cat1_volte_voice_state()==0)
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
+ }
+ }
+ else
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);
+ }
+ }
+ else
+ #endif
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
+ }
+
+ }
+ free(call_data);
+}
+//电话结束处理函数
+void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req)
+{
unused(topic);
- uint8_t* data=(uint8_t*)req->data;
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifybleTransmit:%d",data[0]);
+ unused(req);
-
- if(data[0]==TRANS_FREE)
+ // just stop the notify
+ AlarmClockModel::GetInstance()->AlarmPlayerStop();
+
+
+ if(!NotificationManager::GetInstance()->GetWatchCallStatus())
{
- if(transmittingISShow())
- NotificationManager::GetInstance()->StopNotify();
+ return;
}
- else if (data[0]==IS_NEED_CAT1_OTA)
+
+ if (req == NULL) return ;
+ char* call_data = (char*)malloc(req->len);
+
+ if(call_data==NULL)
{
-
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ return;
+ }
+ int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
+
+ if(strcmp("callfail",call_data)==0)
+ {
+
+ // cat1_call_hungup();
+ cat1_phone_state_change_cb(OPERATE_WATCH_FINISH);
+ CustomEventPublish(TOPIC_EVENT_CAT1_CALL_FAIL,NULL,0);
- // NotificationManager::GetInstance()->ShowNotify(showCat1UpdataNotify, (uint16_t)topic, true);
+ free(call_data);
+ return;
}
- else if (data[0]==FILE_IS_DONE)
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s %s",call_data,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+ uint8_t offset_watch =0;
+ if(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()[0]=='+')
+ {
+ offset_watch++;
+ }
+
+ uint8_t offset_call =0;
+ if(call_data[0]=='+')
{
- set_transmittingShow_falg(data[0]);
+ offset_call++;
}
+
+ if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()+offset_watch,call_data+offset_call)!=0 &&
+ CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1)
+ {
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no OPERATE_WATCH_FINISH");
+ #ifdef SUPPORT_CAT1_HFP_AG_SERV
+ cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLENDED,NULL);
+ #endif
+ }
else
{
- set_transmittingShow_falg(data[0]);
-
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_FINISH");
+ cat1_phone_state_change_cb(OPERATE_WATCH_FINISH);
+ #ifdef SUPPORT_CAT1_HFP_AG_SERV
- NotificationManager::GetInstance()->ShowNotify(showtransmitNotify, (uint16_t)topic, true);
+ #endif
}
- #endif
- }
-
- void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req)
- {
- #ifdef SUPPORT_BATTERY_SERVICE
- unused(req);
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug !");
- #ifdef SYSTEM_LOG_SERVICE
- uapi_save_runtime_log(RUNTIME_LOG_CHARGE_START);//充电开始事件
- #endif
- 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();
- }
-
- if(PullUpDownView::GetInstance())
- {
- GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
- }
- #if DIALDATASET
- // DialModelCharge::GetInstance()->UpdatechargeStatus(1);
- setChargeStatus(1);
- #endif
- SaveEleModel::GetInstance()->SetChargeStatus(true);
-
- if (uapi_dev_runtime_get_train_status())
- {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug ! but train status is true");
- return ;
- }
-
-
- if(IsTestCHANGINGViewCreated())
- {
- ChangeViewcolorC(1);
- }
- else
- {
- if (CheckPriority(topic) && !uapi_dev_runtime_get_factory_test_status_flag()) //产测模式不弹充电弹窗
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(ShowChargeingNotify, (uint16_t)topic, true);
- }
- }
- #endif
- }
-
- /*充电器已拔掉*/
- void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req)
- {
- #ifdef SUPPORT_BATTERY_SERVICE
- unused(req);
- unused(topic);
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger UnPlug !");
- #ifdef SYSTEM_LOG_SERVICE
- //充电停止事件
- uapi_save_runtime_log(RUNTIME_LOG_CHARGE_STOP);//TOOD*
- #endif
- if(PullUpDownView::GetInstance())
- {
- GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
- }
- #if DIALDATASET
- // DialModelCharge::GetInstance()->UpdatechargeStatus(0);
- setChargeStatus(0);
- #endif
- SaveEleModel::GetInstance()->SetChargeStatus(false);
-
-
- if(IsTestCHANGINGViewCreated())
- {
- ChangeViewcolorC(0);
- }
- else
- {
- if(is_UIViewGroup_charge())
- {
- NotificationManager::GetInstance()->StopNotify();
- }
- }
- #endif
- }
-
- /*低电量提醒*/
-void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
+
+ free(call_data);
+
+}
+
+void MsgCenterNotifyCat1FailEProc(const Topic topic, Request* req)
{
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: LowPower Alarm !");
- uint8 *x= (uint8 *)(req->data);
- const power_display_svr_api_t *display_api = power_display_svr_get_api();
- // if(*x==3)
+ unused(req);
+
+ phone_VibratorFunc();
+
+ if(NotificationManager::GetInstance()->HasNotifyShowing())
+ NotificationManager::GetInstance()->StopNotify();
+
+ NotificationManager::GetInstance()->ShowNotify(showcallfailNotify,
+ static_cast<uint16_t>(topic), true);
+}
+#endif
+
+ static uint8_t goal_type=0;
+ void MsgCenterNotifystepProc(const Topic topic, Request* req)
+ {
+ //unused(req);
+ if (req->msgId == TOPIC_EVENT_STEPDATA_UPDATE)
+ {
+
+ #ifdef SUPPORT_CYWEE_SERVICE
+ if (req->data == nullptr) {
+ return;
+ }
+ // 计步数据累加
+
+ OHOS::GoalModel::GetInstance().show_data_step_refresh();
+ OHOS::GoalModel::GetInstance().show_data_calories_refresh();
+ OHOS::GoalModel::GetInstance().show_data_distance_refresh();
+
+ if(OHOS::GoalView::GetInstance())
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::GoalView::GoalViewrefresh, OHOS::GoalView::GetInstance() ));
+
+ // OHOS::GoalView::GetInstance()->GoalViewrefresh();
+ }
+ if(OHOS::GoalotherView::GetInstance())
+ {
+ //OHOS::GoalotherView::GetInstance()->GoalViewrefresh();
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::GoalotherView::GoalViewrefresh, OHOS::GoalotherView::GetInstance() ));
+ }
+
+ if(OHOS::GoalModel::GetInstance().getstepvalue()>=100)
+ {
+
+ goal_type=GOAL_STEP;
+ if(get_Is_show_flag(goal_type))
+ {
+ if(OHOS::GoalModel::GetInstance().get_step_goal_show())
+ {
+ CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+ }
+ }
+ }
+
+ if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done())
+ {
+ goal_type=GOAL_DISTANCE;
+ if(get_Is_show_flag(goal_type))
+ {
+ if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+ {
+ CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+ }
+
+ }
+ }
+
+ if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done())
+ {
+ goal_type=GOAL_FAT;
+ if(get_Is_show_flag(goal_type))
+ {
+ if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+ {
+ CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+ }
+ }
+ }
+
+ if(OHOS::GoalModel::GetInstance().is_goal_stand_done())
+ {
+ goal_type=GOAL_STAND;
+ if(get_Is_show_flag(goal_type))
+ {
+ if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+ {
+ CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+ }
+ }
+ }
+
+ if(OHOS::GoalModel::GetInstance().is_goal_calories_done())
+ {
+ goal_type=GOAL_CALOREIE;
+ if(get_Is_show_flag(goal_type))
+ {
+ if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+ {
+ CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+ }
+ }
+ }
+ #endif
+ }
+
+
+
+ }
+#ifdef SUPPORT_CYWEE_SERVICE
+ //每日训练数据刷新
+ // void MsgCenterNotifyActivityProc(const Topic topic, Request* req)
+ // {
+ // unused(topic);
+ // cywee_activity_result_t* c_activity_result_t = (cywee_activity_result_t *) malloc(req->len);
+ // if(c_activity_result_t==NULL)
+ // {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
+ // return;
+ // }
+
+ // int rets = memcpy_s(c_activity_result_t, req->len, (cywee_activity_result_t*)req->data, req->len);
+ // if (rets != EOK)
+ // {
+ // free(c_activity_result_t);
+ // c_activity_result_t = NULL;
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_t failed, ret = %d", rets);
+ // return;
+ // }
+ // if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_NORMAL)
+ // {
+ // /*更新卡路里数据*/
+ // //if(c_activity_result_t->calories!=0)
+ // {
+ // set_calories_data(c_activity_result_t->calories);
+ // #if DIALDATASET
+ // uint32_t calories= OHOS::GoalModel::GetInstance().show_data_calories_refresh();
+
+ // DialModelCalorie::GetInstance()->UpdateCalorie(calories);
+ // #endif
+ // }
+ // /*更新距离数据*/
+ // //if(c_activity_result_t->distance != 0)
+ // {
+ // set_distance_data(c_activity_result_t->distance);
+ // #if DIALDATASET
+ // float distance= OHOS::GoalModel::GetInstance().show_data_distance_refresh();
+ // DialModelDistance::GetInstance()->UpdateDistance(distance);
+ // #endif
+ // }
+ // }
+ // else if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_FREE_TRAINING && c_activity_result_t->MHR_zone >= 2)
+ // {
+ // /*更新燃脂时间数据*/
+ // set_fat_time_data(1);
+ // }
+
+ // free(c_activity_result_t);
+ // c_activity_result_t = NULL;
+ // }
+ // static int train_fat_time = 0;
+ // void MsgCenterNotifyActivityExtraInfoProc(const Topic topic, Request* req)
// {
- // if (display_api->get_screen_state() != SCREEN_ON)
- // {
- // display_api->turn_on_screen();
+ // unused(topic);
+ // cywee_activity_result_extre_info_t* c_activity_result_extre_info_t = (cywee_activity_result_extre_info_t *) malloc(req->len);
+ // if(c_activity_result_extre_info_t==NULL)
+ // {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
+ // return;
+ // }
+
+ // int rets = memcpy_s(c_activity_result_extre_info_t, req->len, (cywee_activity_result_extre_info_t*)req->data, req->len);
+ // if (rets != EOK)
+ // {
+ // free(c_activity_result_extre_info_t);
+ // c_activity_result_extre_info_t = NULL;
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_extre_info_t failed, ret = %d", rets);
+ // return;
+ // }
+
+ // if(uapi_dev_runtime_get_train_status() && c_activity_result_extre_info_t->ativity_zone_high_duration)
+ // {
+ // train_fat_time = c_activity_result_extre_info_t->ativity_zone_high_duration;
+ // }
+ // /*更新燃脂时间数据*/
+ // else if(uapi_dev_runtime_get_train_status() == 0 && train_fat_time)
+ // {
+ // set_fat_time_data(train_fat_time);
+ // train_fat_time = 0;
// }
- // display_api->set_screen_set_keepon_timeout(1000*5);
- // //倒计时结束后,直接执行关机动画
- // low_power_play();
+
+ // free(c_activity_result_extre_info_t);
+ // c_activity_result_extre_info_t = NULL;
// }
- if(*x==0)
+
+/*运动识别*/
+void MsgCenterNotifyArAlertProc(const Topic topic, Request* req)
+{
+ uint8_t* motionType=(uint8_t*)req->data;
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyArAlertProc,motionType = %d !",*motionType);
+ MotionRecognitionViewEventListener::GetInstance().record_motion_recognition_log();
+ if(*motionType > 5 || *motionType <1) //未知运动不弹窗
{
- //提醒低电充电
- if (display_api->get_screen_state() != SCREEN_ON)
- {
- display_api->turn_on_screen();
- }
- display_api->set_screen_set_keepon_timeout(1000*5);
+ return;
+ }
+ if (CheckPriority(topic))
+ {
+ MotionRecognitionViewEventListener::GetInstance().SetMotionTypeId(*motionType);
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showMotionRecognitionNotify, (uint16_t)topic, true);
+ }
- set_lowpower_falg(0);
- if (CheckPriority(topic))
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+}
+
+void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
+{
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyInactivityProc !");
+ inact_result_t *cywee_Inactivity_Info = (inact_result_t *)malloc(req->len);
+ if (!cywee_Inactivity_Info)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
+ return;
+ }
+
+ int rets = memcpy_s(cywee_Inactivity_Info, req->len, (inact_result_t*)req->data, req->len);
+ if (rets != EOK)
+ {
+ free(cywee_Inactivity_Info);
+ cywee_Inactivity_Info = NULL;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s cywee_inactivity_result_t failed, ret = %d", rets);
+ return;
+ }
+
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "cywee_Inactivity_Info->output_number = %d", cywee_Inactivity_Info->output_number);
+
+ switch (cywee_Inactivity_Info->output_number)
+ {
+ case INACTIVITY_MODE_SEDENTARY_OUTPUT:
+ if(cywee_Inactivity_Info->status == 1)
+ {
+ SedentaryReminderViewEventListener::GetInstance().record_sedentary_reminder_log();
+ if (CheckPriority(topic))
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true);
+ }
+ }
+ else if(cywee_Inactivity_Info->status==9)
+ {
+ cywee_set_stand_flag();
+ }
+ break;
+ default:
+ break;
+ }
+
+ free(cywee_Inactivity_Info);
+ cywee_Inactivity_Info = NULL;
+}
+
+#endif
+
+//查找手表通知
+void MsgCenterNotifyFindWatchProc(const Topic topic, Request* req)
+{
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyFindWatchProc !");
+ if (CheckPriority(topic))
+ {
+ uint8_t* type=(uint8_t*)req->data;
+ if(*type == 1)
+ {
+ FindWatchViewEventListener::GetInstance().SetFindWatchNotifyFlag(true);
+ FindWatchViewEventListener::GetInstance().PopInterPlayMusic(nullptr);//播放铃声
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showFindWatchNotify, (uint16_t)topic, true);
+ //如果查找手表铃声播放成功,记录该事件
+ uapi_save_runtime_log(RUNTIME_LOG_RING_PLAY_START_FINDWATCH);//TOOD*
+ } else {
+ if (FindWatchViewEventListener::GetInstance().GetFindWatchNotifyFlag() == true) {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+ FindWatchViewEventListener::GetInstance().SetFindWatchNotifyFlag(false);
}
+ } else {
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyPriority = %d ",NotificationManager::GetInstance()->GetNotifyPriority());
}
- else
+}
+
+void MsgCenterNotifyDebugOutProc(const Topic topic, Request *req)
+{
+ unused(req);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyDebugOutProc !");
+ if (CheckPriority(topic))
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ NotificationManager::GetInstance()->ShowNotify(showDebugOutputNotify, (uint16_t)topic, true);
+ }
+}
+//运动目标通知
+void MsgCenterNotifyGoalShowViewProc(const Topic topic, Request* req)
+{
+ unused(req);
+ if (CheckPriority(topic))
{
- //电量过低,直接提醒关机
- if (display_api->get_screen_state() != SCREEN_ON)
+ uint8_t* data=(uint8_t*)req->data;
+ if(get_Is_show_flag(data[0]))
{
- display_api->turn_on_screen();
- }
- display_api->set_screen_set_keepon_timeout(1000*10);
- set_lowpower_falg(1);
- if (NotificationManager::GetInstance()->HasNotifyShowing())
- NotificationManager::GetInstance()->StopNotify();
- if (CheckPriority(topic))
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
- NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+ set_goal_flag_view(data[0]);
+ set_Is_show_flag(0,data[0]);
+
+ const power_display_svr_api_t *display_api = power_display_svr_get_api();
+
+ uapi_set_screen_on_api();
+
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(ShowGoalNotify, static_cast<uint16_t>(topic), true);
}
}
}
- //TODO: 亮屏弹窗倒计时5秒关机(不需要取消,强制关机)
- // DialModelCharge::GetInstance()->UpdatechargeStatus(0);
- // SaveEleModel::GetInstance()->SetChargeStatus(0);
-
- // testCHANINGView *t=testCHANINGView::GetInstance();
- // if(t!=NULL)
- // {
- // t->ChangeViewcolor(false);
- // }
-
- #ifdef SUPPORT_CAT1_MODEM
- void MsgCenterNotifyHfpIncomingProc(const Topic topic, Request* req)
- {
- hfp_hf_calls_info_t callData = {0};
- int32 ret = memcpy_s(&callData, sizeof(hfp_hf_calls_info_t), req->data, req->len);
- if (ret != EOK) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
- } else {
- }
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyHfpIncomingProc");
- CallerLogModel::GetInstance()->SetoperateNumber(callData.number, callData.number_len);
- CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone);
- NotificationManager::GetInstance()->SetWatchCallStatus(true);
- if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
- {
- // ui_api_vibrate_once_func();
- }
- }
- void MsgCenterNotifyHfpPhoneProc(const Topic topic, Request* req)
- {
- unused(req);
- // finish a single-channel call, or switch to phone, stop the notify
- if (CallerLogModel::GetInstance()->GetNotifyFlag()) {
- DisableWatingView();
- if ((topic == TOPIC_EVENT_HFP_FINISHED && GetCurrCallNum() == 0) ||
- topic == TOPIC_EVENT_HFP_PHONE_ACTIVE || topic == TOPIC_EVENT_HFP_WATCH_TO_PHONE) {
- NotificationManager::GetInstance()->StopNotify();
- NotificationManager::GetInstance()->SetWatchCallStatus(false);
- }
- }
- }
-
- void MsgCenterNotifyHfpWatchProc(const Topic topic, Request* req)
- {
- unused(req);
- if (CallerLogModel::GetInstance()->GetNotifyFlag()) {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
- // default not mute
- SetMicMute(false);
- if (CallerLogModel::GetInstance()->IsMulitplePhoneStatus()) {
- NotificationManager::GetInstance()->ShowNotify(ShowMultiPhoneCallNotify,
- static_cast<uint16_t>(topic), true);
- } else {
- NotificationManager::GetInstance()->ShowNotify(ShowCallingNotify, static_cast<uint16_t>(topic), true);
- }
- NotificationManager::GetInstance()->SetWatchCallStatus(true);
- }
- }
-
- void MsgCenterNotifyHfpWatchHintProc(const Topic topic, Request* req)
- {
- unused(req);
-
- phone_VibratorFunc();
-
- if(NotificationManager::GetInstance()->HasNotifyShowing())
- NotificationManager::GetInstance()->StopNotify();
-
- NotificationManager::GetInstance()->ShowNotify(showcallhintNotify,
- static_cast<uint16_t>(topic), true);
- }
-
- //来电处理函数
- void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req)
- {
- unused(topic);
- unused(topic);
- if (req == NULL) return ;
- char* call_data = (char*)malloc(req->len);
- if(call_data==NULL)
- {
- return;
- }
- int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
- if (ret != EOK) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
- } else {
- // Prevent this from happening:
- // When the incoming call view is displayed, the calling number is not set in CallerLogModel.
-
- if(NotificationManager::GetInstance()->GetWatchCallStatus() &&
- (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1))
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_REJECT %s!=%s??",call_data,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
- CallerLogModel::GetInstance()->tempSetoperateNumberCAT1END(call_data,req->len);
- cat1_phone_state_change_cb(OPERATE_WATCH_REJECT);
- free(call_data);
- return;
- }
-
- if((NotificationManager::GetInstance()->GetWatchCallStatus() &&
- (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)) || uapi_dev_runtime_get_train_status() || transmittingISShow())
- {
-
- CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(call_data,req->len);
- cat1_phone_state_change_cb(OPERATE_WAITING);
- free(call_data);
- return;
- }
-
- stopPlayingMusic();
- PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐
- uapi_set_screen_on_api();
- phone_paly_ring();
-
- CallerLogModel::GetInstance()->SetoperateNumber(call_data,strlen(call_data));
-
- cat1_phone_state_change_cb(OPERATE_INCOMING);
+//喝水提醒通知
+void MsgCenterNotifyDrinkReminderProc(const Topic topic, Request *req)
+{
+// unused(topic);
+ unused(req);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyDrinkReminderProc !");
+ // DrinkReminderViewEventListener::GetInstance().set_screen_on_and_vibration();
+ DrinkReminderViewEventListener::GetInstance().record_drink_reminder_log();
+ if (CheckPriority(topic))
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showDrinkReminderNotify, (uint16_t)topic, true);
+ }
+}
+//关机动画
+void MsgCenterNotifyShutDownAnimatorProc(const Topic topic, Request* req)
+{
+ unused(topic);
+ uint8_t* data=(uint8_t*)req->data;
+ set_shutDownAnimation_falg(data[0]);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyShutDownAnimatorProc,shutdown_flag = %d",*data);
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ NotificationManager::GetInstance()->ShowNotify(showShutdownAnimatorNotify, (uint16_t)topic, true);
+}
+//消息通知
+void MsgCenterNotifyMessageProc(const Topic topic, Request* req)
+{
+ // unused(topic);
+ unused(req);
+ // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyMessageProc !");
+ if (CheckPriority(topic)) {
+ // do_custom_fileoperate_service_check_msg(CUSTOM_FILEOPERATE_MSG_TYPE_MESSAGE_DATA_NOTIFY,
+ // nullptr, 0);
+ OHOS::NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_THREE);
+ OHOS::NotificationManager::GetInstance()->ShowNotify(OHOS::CreateMessageView, TOPIC_EVENT_MESSAGENOTE, true);
+ //进行消息显示记录
+ uapi_save_runtime_log(RUNTIME_LOG_MSG_SHOW);
+ }
+}
+
+//睡眠提醒通知
+void MsgCenterNotifySleepProc(const Topic topic, Request* req)
+{
+ unused(req);
+// unused(topic);
+ if (CheckPriority(topic))
+ {
- }
- free(call_data);
-
- }
- //开始通话处理函数
- void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req)
- {
- unused(topic);
- unused(req);
-
- if (req == NULL) return ;
- if(!NotificationManager::GetInstance()->GetWatchCallStatus())
- {
- return;
- }
- AlarmClockModel::GetInstance()->AlarmPlayerStop();
- #ifdef SUPPORT_CAT1_HFP_AG_SERV
- if(uapi_dev_runtime_get_earphone_connect_stat())
- {
-
- if(headset_Is_connect())
- {
- if(headset_SCO_Is_connect()==false)
- {
- cat1_ag_send_call_event(TOPIC_EVENT_CAT1_INCOMMING,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
- }
- else
- {
- if(cat1_api_get_cat1_volte_voice_state()==0)
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "headset_Is_connect is false");
- }
-
- }
- else
- {
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);
- }
- cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLCONNTED,NULL);
- }
- else
- #endif
- {
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
- }
- SetMicMutecat1(false);
- cat1_phone_state_change_cb(OPERATE_WATCH_ACTIVE);
-
- }
- #include "BluetoothModelC.h"
- #include "audio_manager_c_wrapper.h"
- #include "PhoneService.h"
- //拨号处理函数
- void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify MsgCenterNotifyCat1dialProc");
- unused(topic);
- unused(req);
- if (req == NULL) return ;
- char* call_data = (char*)malloc(req->len);
- if(call_data==NULL) return;
- int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
- if (ret != EOK) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
- } else {
-
- // int ret = PlayersModel::GetInstance()->PlayerStop();
- stopPlayingMusic();
-
- if(strcmp(call_data,"SOS")==0)
- {
- free(call_data);
- NotificationManager::GetInstance()->ShowNotify(showSOSNotify, (uint16_t)topic, true);
- return;
- }
-
- #ifdef SUPPORT_CAT1_SERVICE
- cat1_cmd_send(CMD_4G_MAKE_CALL,call_data,strlen(call_data));
- #endif
- CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifySleepProc %d!",SleepModel::GetInstance().get_sleep_state());
- #ifdef SUPPORT_CAT1_SERVICE
- cat1_phone_state_change_cb(OPERATE_DIALING);
- #endif
-
- #ifdef SUPPORT_CAT1_HFP_AG_SERV
- if(uapi_dev_runtime_get_earphone_connect_stat())
- {
- if(headset_Is_connect())
- {
- cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLDIAL,NULL);
-
- if(headset_SCO_Is_connect())
- {
- if(cat1_api_get_cat1_volte_voice_state()==0)
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
- }
- }
- else
- {
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);
- }
- }
- else
- #endif
- {
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
- }
+ /*早安闹钟*/
+ if(SleepModel::GetInstance().get_sleep_state()==SLEEPSTATE::WAKE)
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ SleepViewEventListener::GetInstance().PopInterPlayMusic();
+ }
+ else
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_THREE);
+ }
+
+ NotificationManager::GetInstance()->ShowNotify(showSleepNotify, (uint16_t)topic, true);
+ }
- }
- free(call_data);
- }
- //电话结束处理函数
- void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req)
- {
- unused(topic);
- unused(req);
+}
+
+void MsgCenterNotifyInactivityAccumulateTimeProc(const Topic topic, Request* req)
+{
+ unused(topic);
+#if 0
+ if(uapi_dev_runtime_get_absolute_static_status())
+ {
+ memset(&sleep_data,0,sizeof(SLEEP_T));
+ state_num = 0;
+ //fall_asleep_state_num = 0;
+ uapi_dev_runtime_set_absolute_static_status(0);
+ return;
+ }
+
+ cywee_inactivity_accumulate_time_t *cywee_Inactivity_Accumulate_Time_Info = (cywee_inactivity_accumulate_time_t *)malloc(req->len);
+ if (!cywee_Inactivity_Accumulate_Time_Info)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
+ return;
+ }
- // just stop the notify
- AlarmClockModel::GetInstance()->AlarmPlayerStop();
-
-
- if(!NotificationManager::GetInstance()->GetWatchCallStatus())
- {
- return;
- }
-
- if (req == NULL) return ;
- char* call_data = (char*)malloc(req->len);
-
- if(call_data==NULL)
- {
- return;
- }
- int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
-
- if(strcmp("callfail",call_data)==0)
- {
-
- // cat1_call_hungup();
- cat1_phone_state_change_cb(OPERATE_WATCH_FINISH);
- CustomEventPublish(TOPIC_EVENT_CAT1_CALL_FAIL,NULL,0);
-
- free(call_data);
- return;
- }
-
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s %s",call_data,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
- uint8_t offset_watch =0;
- if(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()[0]=='+')
- {
- offset_watch++;
- }
-
- uint8_t offset_call =0;
- if(call_data[0]=='+')
- {
- offset_call++;
- }
-
- if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()+offset_watch,call_data+offset_call)!=0 &&
- CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1)
- {
-
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no OPERATE_WATCH_FINISH");
- #ifdef SUPPORT_CAT1_HFP_AG_SERV
- cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLENDED,NULL);
- #endif
- }
- else
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_FINISH");
- cat1_phone_state_change_cb(OPERATE_WATCH_FINISH);
- #ifdef SUPPORT_CAT1_HFP_AG_SERV
-
- #endif
- }
-
- free(call_data);
-
- }
-
- void MsgCenterNotifyCat1FailEProc(const Topic topic, Request* req)
- {
- unused(req);
-
- phone_VibratorFunc();
-
- if(NotificationManager::GetInstance()->HasNotifyShowing())
- NotificationManager::GetInstance()->StopNotify();
-
- NotificationManager::GetInstance()->ShowNotify(showcallfailNotify,
- static_cast<uint16_t>(topic), true);
- }
- #endif
-
- static uint8_t goal_type=0;
- void MsgCenterNotifystepProc(const Topic topic, Request* req)
- {
- //unused(req);
- if (req->msgId == TOPIC_EVENT_STEPDATA_UPDATE)
- {
-
- #ifdef SUPPORT_CYWEE_SERVICE
- if (req->data == nullptr) {
- return;
- }
- // 计步数据累加
-
- OHOS::GoalModel::GetInstance().show_data_step_refresh();
- OHOS::GoalModel::GetInstance().show_data_calories_refresh();
- OHOS::GoalModel::GetInstance().show_data_distance_refresh();
-
- if(OHOS::GoalView::GetInstance())
- {
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(&OHOS::GoalView::GoalViewrefresh, OHOS::GoalView::GetInstance() ));
-
- // OHOS::GoalView::GetInstance()->GoalViewrefresh();
- }
- if(OHOS::GoalotherView::GetInstance())
- {
- //OHOS::GoalotherView::GetInstance()->GoalViewrefresh();
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(&OHOS::GoalotherView::GoalViewrefresh, OHOS::GoalotherView::GetInstance() ));
- }
-
- if(OHOS::GoalModel::GetInstance().getstepvalue()>=100)
- {
-
- goal_type=GOAL_STEP;
- if(get_Is_show_flag(goal_type))
- {
- if(OHOS::GoalModel::GetInstance().get_step_goal_show())
- {
- CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
- }
- }
- }
-
- if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done())
- {
- goal_type=GOAL_DISTANCE;
- if(get_Is_show_flag(goal_type))
- {
- if(OHOS::GoalModel::GetInstance().get_other_goal_show())
- {
- CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
- }
-
- }
- }
-
- if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done())
- {
- goal_type=GOAL_FAT;
- if(get_Is_show_flag(goal_type))
- {
- if(OHOS::GoalModel::GetInstance().get_other_goal_show())
- {
- CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
- }
- }
- }
-
- if(OHOS::GoalModel::GetInstance().is_goal_stand_done())
- {
- goal_type=GOAL_STAND;
- if(get_Is_show_flag(goal_type))
- {
- if(OHOS::GoalModel::GetInstance().get_other_goal_show())
- {
- CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
- }
- }
- }
-
- if(OHOS::GoalModel::GetInstance().is_goal_calories_done())
- {
- goal_type=GOAL_CALOREIE;
- if(get_Is_show_flag(goal_type))
- {
- if(OHOS::GoalModel::GetInstance().get_other_goal_show())
- {
- CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
- }
- }
- }
- #endif
- }
-
-
-
- }
- #ifdef SUPPORT_CYWEE_SERVICE
- //每日训练数据刷新
- // void MsgCenterNotifyActivityProc(const Topic topic, Request* req)
- // {
- // unused(topic);
- // cywee_activity_result_t* c_activity_result_t = (cywee_activity_result_t *) malloc(req->len);
- // if(c_activity_result_t==NULL)
- // {
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
- // return;
- // }
-
- // int rets = memcpy_s(c_activity_result_t, req->len, (cywee_activity_result_t*)req->data, req->len);
- // if (rets != EOK)
- // {
- // free(c_activity_result_t);
- // c_activity_result_t = NULL;
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_t failed, ret = %d", rets);
- // return;
- // }
- // if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_NORMAL)
- // {
- // /*更新卡路里数据*/
- // //if(c_activity_result_t->calories!=0)
- // {
- // set_calories_data(c_activity_result_t->calories);
- // #if DIALDATASET
- // uint32_t calories= OHOS::GoalModel::GetInstance().show_data_calories_refresh();
-
- // DialModelCalorie::GetInstance()->UpdateCalorie(calories);
- // #endif
- // }
- // /*更新距离数据*/
- // //if(c_activity_result_t->distance != 0)
- // {
- // set_distance_data(c_activity_result_t->distance);
- // #if DIALDATASET
- // float distance= OHOS::GoalModel::GetInstance().show_data_distance_refresh();
- // DialModelDistance::GetInstance()->UpdateDistance(distance);
- // #endif
- // }
- // }
- // else if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_FREE_TRAINING && c_activity_result_t->MHR_zone >= 2)
- // {
- // /*更新燃脂时间数据*/
- // set_fat_time_data(1);
- // }
-
- // free(c_activity_result_t);
- // c_activity_result_t = NULL;
- // }
- // static int train_fat_time = 0;
- // void MsgCenterNotifyActivityExtraInfoProc(const Topic topic, Request* req)
- // {
- // unused(topic);
- // cywee_activity_result_extre_info_t* c_activity_result_extre_info_t = (cywee_activity_result_extre_info_t *) malloc(req->len);
- // if(c_activity_result_extre_info_t==NULL)
- // {
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
- // return;
- // }
-
- // int rets = memcpy_s(c_activity_result_extre_info_t, req->len, (cywee_activity_result_extre_info_t*)req->data, req->len);
- // if (rets != EOK)
- // {
- // free(c_activity_result_extre_info_t);
- // c_activity_result_extre_info_t = NULL;
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_extre_info_t failed, ret = %d", rets);
- // return;
- // }
-
- // if(uapi_dev_runtime_get_train_status() && c_activity_result_extre_info_t->ativity_zone_high_duration)
- // {
- // train_fat_time = c_activity_result_extre_info_t->ativity_zone_high_duration;
- // }
- // /*更新燃脂时间数据*/
- // else if(uapi_dev_runtime_get_train_status() == 0 && train_fat_time)
- // {
- // set_fat_time_data(train_fat_time);
- // train_fat_time = 0;
- // }
-
- // free(c_activity_result_extre_info_t);
- // c_activity_result_extre_info_t = NULL;
- // }
-
- /*运动识别*/
- void MsgCenterNotifyArAlertProc(const Topic topic, Request* req)
- {
- uint8_t* motionType=(uint8_t*)req->data;
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyArAlertProc,motionType = %d !",*motionType);
- MotionRecognitionViewEventListener::GetInstance().record_motion_recognition_log();
- if(*motionType > 5 || *motionType <1) //未知运动不弹窗
- {
- return;
- }
- if (CheckPriority(topic))
- {
- MotionRecognitionViewEventListener::GetInstance().SetMotionTypeId(*motionType);
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(showMotionRecognitionNotify, (uint16_t)topic, true);
- }
+ int rets = memcpy_s(cywee_Inactivity_Accumulate_Time_Info, req->len, (cywee_inactivity_accumulate_time_t*)req->data, req->len);
+ if (rets != EOK)
+ {
+ free(cywee_Inactivity_Accumulate_Time_Info);
+ cywee_Inactivity_Accumulate_Time_Info = NULL;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s cywee_Inactivity_Accumulate_Time_Info failed, ret = %d", rets);
+ return;
+ }
+#ifdef CUSTOM_ZHIHUI
+ if(cywee_Inactivity_Accumulate_Time_Info->output_number == INACTIVITY_MODE_NAP_ACCUMULATE_TIME_OUTPUT)
+ {
+ nap_data.total_time = cywee_Inactivity_Accumulate_Time_Info->total_time;
+ set_nap_data(&nap_data);
+ do_custom_fileoperate_service_check_msg(
+ CUSTOM_FILEOPERATE_MSG_TYPE_NAPDATA_SAVE, nullptr, 0);
+ memset(&nap_data,0,sizeof(NAP_T));
+ }
+ else if(cywee_Inactivity_Accumulate_Time_Info->output_number == INACTIVITY_MODE_SLEEPING_ACCUMULATE_TIME_OUTPUT)
+ {
+ // if(sleep_data.fall_asleep_timestamp > sleep_data.wake_up_timestamp && sleep_data.wake_up_timestamp != 0)
+ // {
+ // sleep_data.fall_asleep_timestamp -= 24 * 60 * 60;
+ // sleep_data.sleep_status[fall_asleep_state_num].timestamp = sleep_data.fall_asleep_timestamp;
+ // }
+
+ sleep_data.total_time = cywee_Inactivity_Accumulate_Time_Info->total_time;
+ sleep_data.total_deep_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_deep_sleep_time;
+ sleep_data.total_mild_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_mild_sleep_time;
+ sleep_data.total_wake_time = cywee_Inactivity_Accumulate_Time_Info->total_wake_time;
+ sleep_data.total_rem_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_rem_sleep_time;
+ sleep_data.status_num = state_num;
+
+ set_sleep_data(&sleep_data);
+ do_custom_fileoperate_service_check_msg(
+ CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_SAVE, nullptr, 0);
+ memset(&sleep_data,0,sizeof(SLEEP_T));
+ state_num = 0;
+ //fall_asleep_state_num = 0;
+ }
+#endif
+ free(cywee_Inactivity_Accumulate_Time_Info);
+ cywee_Inactivity_Accumulate_Time_Info = NULL;
+ //uapi_dev_runtime_set_sleep_status(0);
+#endif
+}
+
+//APP运动相关
+void MsgCenterNotifybleAPPtraining(const Topic topic, Request* req)
+{
+ unused(topic);
+ uint8_t* data=(uint8_t*)req->data;
+ if(data!=NULL && req->len>=2)
+ {
+ switch (data[1])
+ {
+ case START://运动开始
+
+ break;
+ case STOP://运动暂停
+
+ break;
+ case RECOVER://运动恢复
+
+ break;
+
+ case END://运动结束
+ break;
+ }
+ }
+
+ // unused(req);
+
+}
+
+
+/* 订阅事件通知逻辑可定制 */
+static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
+ {TOPIC_EVENT_ALARM_RING, MsgCenterNotifyAlarmProc},
+ {TOPIC_EVENT_ON_TIME, MsgCenterNotifyONtimeProc},//增加整点保存数据
+ {TOPIC_EVENT_NEXTDAY_UPDATE, MsgCenterNotifyNextDayProc},
+ {TOPIC_EVENT_STEPDATA_UPDATE, MsgCenterNotifystepProc},
+
+ {TOPIC_EVENT_HFP_INCOMMING, MsgCenterNotifyHfpIncomingProc},
+ {TOPIC_EVENT_HFP_PHONE_ACTIVE, MsgCenterNotifyHfpPhoneProc},
+ {TOPIC_EVENT_HFP_FINISHED, MsgCenterNotifyHfpPhoneProc},
+ {TOPIC_EVENT_HFP_WATCH_TO_PHONE, MsgCenterNotifyHfpPhoneProc},
+ {TOPIC_EVENT_HFP_WATCH_ACTIVE, MsgCenterNotifyHfpWatchProc},
+ {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc},
+ {TOPIC_EVENT_HFP_HINT, MsgCenterNotifyHfpWatchHintProc},
- }
-
- void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
- {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyInactivityProc !");
- inact_result_t *cywee_Inactivity_Info = (inact_result_t *)malloc(req->len);
- if (!cywee_Inactivity_Info)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
- return;
- }
-
- int rets = memcpy_s(cywee_Inactivity_Info, req->len, (inact_result_t*)req->data, req->len);
- if (rets != EOK)
- {
- free(cywee_Inactivity_Info);
- cywee_Inactivity_Info = NULL;
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s cywee_inactivity_result_t failed, ret = %d", rets);
- return;
- }
-
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "cywee_Inactivity_Info->output_number = %d", cywee_Inactivity_Info->output_number);
-
- switch (cywee_Inactivity_Info->output_number)
- {
- case INACTIVITY_MODE_SEDENTARY_OUTPUT:
- if(cywee_Inactivity_Info->status == 1)
- {
- SedentaryReminderViewEventListener::GetInstance().record_sedentary_reminder_log();
- if (CheckPriority(topic))
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true);
- }
- }
- else if(cywee_Inactivity_Info->status==9)
- {
- cywee_set_stand_flag();
- }
- break;
- default:
- break;
- }
-
- free(cywee_Inactivity_Info);
- cywee_Inactivity_Info = NULL;
- }
-
- #endif
-
- //查找手表通知
- void MsgCenterNotifyFindWatchProc(const Topic topic, Request* req)
- {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyFindWatchProc !");
- if (CheckPriority(topic))
- {
- uint8_t* type=(uint8_t*)req->data;
- if(*type == 1)
- {
- FindWatchViewEventListener::GetInstance().SetFindWatchNotifyFlag(true);
- FindWatchViewEventListener::GetInstance().PopInterPlayMusic(nullptr);//播放铃声
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(showFindWatchNotify, (uint16_t)topic, true);
- //如果查找手表铃声播放成功,记录该事件
- uapi_save_runtime_log(RUNTIME_LOG_RING_PLAY_START_FINDWATCH);//TOOD*
- } else {
- if (FindWatchViewEventListener::GetInstance().GetFindWatchNotifyFlag() == true) {
- NotificationManager::GetInstance()->StopNotify();
- }
- FindWatchViewEventListener::GetInstance().SetFindWatchNotifyFlag(false);
- }
- } else {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyPriority = %d ",NotificationManager::GetInstance()->GetNotifyPriority());
- }
- }
-
- void MsgCenterNotifyDebugOutProc(const Topic topic, Request *req)
- {
- unused(req);
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyDebugOutProc !");
- if (CheckPriority(topic))
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
- NotificationManager::GetInstance()->ShowNotify(showDebugOutputNotify, (uint16_t)topic, true);
- }
- }
- //运动目标通知
- void MsgCenterNotifyGoalShowViewProc(const Topic topic, Request* req)
- {
- unused(req);
- if (CheckPriority(topic))
- {
- uint8_t* data=(uint8_t*)req->data;
- if(get_Is_show_flag(data[0]))
- {
- set_goal_flag_view(data[0]);
- set_Is_show_flag(0,data[0]);
-
- const power_display_svr_api_t *display_api = power_display_svr_get_api();
-
- uapi_set_screen_on_api();
-
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(ShowGoalNotify, static_cast<uint16_t>(topic), true);
- }
- }
- }
- //喝水提醒通知
- void MsgCenterNotifyDrinkReminderProc(const Topic topic, Request *req)
- {
- // unused(topic);
- unused(req);
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyDrinkReminderProc !");
- // DrinkReminderViewEventListener::GetInstance().set_screen_on_and_vibration();
- DrinkReminderViewEventListener::GetInstance().record_drink_reminder_log();
- if (CheckPriority(topic))
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- NotificationManager::GetInstance()->ShowNotify(showDrinkReminderNotify, (uint16_t)topic, true);
- }
- }
- //关机动画
- void MsgCenterNotifyShutDownAnimatorProc(const Topic topic, Request* req)
- {
- unused(topic);
- uint8_t* data=(uint8_t*)req->data;
- set_shutDownAnimation_falg(data[0]);
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyShutDownAnimatorProc,shutdown_flag = %d",*data);
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
- NotificationManager::GetInstance()->ShowNotify(showShutdownAnimatorNotify, (uint16_t)topic, true);
- }
- //消息通知
- void MsgCenterNotifyMessageProc(const Topic topic, Request* req)
- {
- // unused(topic);
- unused(req);
- // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyMessageProc !");
- if (CheckPriority(topic)) {
- // do_custom_fileoperate_service_check_msg(CUSTOM_FILEOPERATE_MSG_TYPE_MESSAGE_DATA_NOTIFY,
- // nullptr, 0);
- OHOS::NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_THREE);
- OHOS::NotificationManager::GetInstance()->ShowNotify(OHOS::CreateMessageView, TOPIC_EVENT_MESSAGENOTE, true);
- //进行消息显示记录
- uapi_save_runtime_log(RUNTIME_LOG_MSG_SHOW);
- }
- }
-
- //睡眠提醒通知
- void MsgCenterNotifySleepProc(const Topic topic, Request* req)
- {
- unused(req);
- // unused(topic);
- if (CheckPriority(topic))
- {
-
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifySleepProc %d!",SleepModel::GetInstance().get_sleep_state());
-
- /*早安闹钟*/
- if(SleepModel::GetInstance().get_sleep_state()==SLEEPSTATE::WAKE)
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
- SleepViewEventListener::GetInstance().PopInterPlayMusic();
- }
- else
- {
- NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_THREE);
- }
+#ifdef SUPPORT_CYWEE_SERVICE
+ // {TOPIC_EVENT_ACTIVITY_UPDATE, MsgCenterNotifyActivityProc},
+ // {TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE, MsgCenterNotifyActivityExtraInfoProc},
+ {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE, MsgCenterNotifyArAlertProc},
+ {TOPIC_EVENT_INACTIVITY_UPDATE, MsgCenterNotifyInactivityProc},
+ // {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE, MsgCenterNotifyInactivityAccumulateTimeProc},
+#endif
+ {TOPIC_EVENT_GOAL_SHOW_VIEW, MsgCenterNotifyGoalShowViewProc},
+ {TOPIC_EVENT_BLE_TRANSMIT, MsgCenterNotifybleTransmit},
+
+ {TOPIC_EVENT_CHARGE_PLUG, MsgCenterNotifyChargePlugProc},
+ {TOPIC_EVENT_CHARGE_UNPLUG, MsgCenterNotifyChargeUnPlugProc},
+ {TOPIC_EVENT_LOWPOWER_ALARM, MsgCenterNotifyLowPowerAlarmProc},
- NotificationManager::GetInstance()->ShowNotify(showSleepNotify, (uint16_t)topic, true);
- }
-
- }
-
- void MsgCenterNotifyInactivityAccumulateTimeProc(const Topic topic, Request* req)
- {
- unused(topic);
- #if 0
- if(uapi_dev_runtime_get_absolute_static_status())
- {
- memset(&sleep_data,0,sizeof(SLEEP_T));
- state_num = 0;
- //fall_asleep_state_num = 0;
- uapi_dev_runtime_set_absolute_static_status(0);
- return;
- }
-
- cywee_inactivity_accumulate_time_t *cywee_Inactivity_Accumulate_Time_Info = (cywee_inactivity_accumulate_time_t *)malloc(req->len);
- if (!cywee_Inactivity_Accumulate_Time_Info)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
- return;
- }
-
- int rets = memcpy_s(cywee_Inactivity_Accumulate_Time_Info, req->len, (cywee_inactivity_accumulate_time_t*)req->data, req->len);
- if (rets != EOK)
- {
- free(cywee_Inactivity_Accumulate_Time_Info);
- cywee_Inactivity_Accumulate_Time_Info = NULL;
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s cywee_Inactivity_Accumulate_Time_Info failed, ret = %d", rets);
- return;
- }
- #ifdef CUSTOM_ZHIHUI
- if(cywee_Inactivity_Accumulate_Time_Info->output_number == INACTIVITY_MODE_NAP_ACCUMULATE_TIME_OUTPUT)
- {
- nap_data.total_time = cywee_Inactivity_Accumulate_Time_Info->total_time;
- set_nap_data(&nap_data);
- do_custom_fileoperate_service_check_msg(
- CUSTOM_FILEOPERATE_MSG_TYPE_NAPDATA_SAVE, nullptr, 0);
- memset(&nap_data,0,sizeof(NAP_T));
- }
- else if(cywee_Inactivity_Accumulate_Time_Info->output_number == INACTIVITY_MODE_SLEEPING_ACCUMULATE_TIME_OUTPUT)
- {
- // if(sleep_data.fall_asleep_timestamp > sleep_data.wake_up_timestamp && sleep_data.wake_up_timestamp != 0)
- // {
- // sleep_data.fall_asleep_timestamp -= 24 * 60 * 60;
- // sleep_data.sleep_status[fall_asleep_state_num].timestamp = sleep_data.fall_asleep_timestamp;
- // }
-
- sleep_data.total_time = cywee_Inactivity_Accumulate_Time_Info->total_time;
- sleep_data.total_deep_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_deep_sleep_time;
- sleep_data.total_mild_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_mild_sleep_time;
- sleep_data.total_wake_time = cywee_Inactivity_Accumulate_Time_Info->total_wake_time;
- sleep_data.total_rem_sleep_time = cywee_Inactivity_Accumulate_Time_Info->total_rem_sleep_time;
- sleep_data.status_num = state_num;
-
- set_sleep_data(&sleep_data);
- do_custom_fileoperate_service_check_msg(
- CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_SAVE, nullptr, 0);
- memset(&sleep_data,0,sizeof(SLEEP_T));
- state_num = 0;
- //fall_asleep_state_num = 0;
- }
- #endif
- free(cywee_Inactivity_Accumulate_Time_Info);
- cywee_Inactivity_Accumulate_Time_Info = NULL;
- //uapi_dev_runtime_set_sleep_status(0);
- #endif
- }
-
- //APP运动相关
- void MsgCenterNotifybleAPPtraining(const Topic topic, Request* req)
- {
- unused(topic);
- uint8_t* data=(uint8_t*)req->data;
- if(data!=NULL && req->len>=2)
- {
- switch (data[1])
- {
- case START://运动开始
-
- break;
- case STOP://运动暂停
-
- break;
- case RECOVER://运动恢复
-
- break;
-
- case END://运动结束
- break;
- }
- }
-
- // unused(req);
-
- }
-
-
- /* 订阅事件通知逻辑可定制 */
- static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
- {TOPIC_EVENT_ALARM_RING, MsgCenterNotifyAlarmProc},
- {TOPIC_EVENT_ON_TIME, MsgCenterNotifyONtimeProc},//增加整点保存数据
- {TOPIC_EVENT_NEXTDAY_UPDATE, MsgCenterNotifyNextDayProc},
- {TOPIC_EVENT_STEPDATA_UPDATE, MsgCenterNotifystepProc},
-
- {TOPIC_EVENT_HFP_INCOMMING, MsgCenterNotifyHfpIncomingProc},
- {TOPIC_EVENT_HFP_PHONE_ACTIVE, MsgCenterNotifyHfpPhoneProc},
- {TOPIC_EVENT_HFP_FINISHED, MsgCenterNotifyHfpPhoneProc},
- {TOPIC_EVENT_HFP_WATCH_TO_PHONE, MsgCenterNotifyHfpPhoneProc},
- {TOPIC_EVENT_HFP_WATCH_ACTIVE, MsgCenterNotifyHfpWatchProc},
- {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc},
- {TOPIC_EVENT_HFP_HINT, MsgCenterNotifyHfpWatchHintProc},
-
- #ifdef SUPPORT_CYWEE_SERVICE
- // {TOPIC_EVENT_ACTIVITY_UPDATE, MsgCenterNotifyActivityProc},
- // {TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE, MsgCenterNotifyActivityExtraInfoProc},
- {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE, MsgCenterNotifyArAlertProc},
- {TOPIC_EVENT_INACTIVITY_UPDATE, MsgCenterNotifyInactivityProc},
- // {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE, MsgCenterNotifyInactivityAccumulateTimeProc},
- #endif
- {TOPIC_EVENT_GOAL_SHOW_VIEW, MsgCenterNotifyGoalShowViewProc},
- {TOPIC_EVENT_BLE_TRANSMIT, MsgCenterNotifybleTransmit},
-
- {TOPIC_EVENT_CHARGE_PLUG, MsgCenterNotifyChargePlugProc},
- {TOPIC_EVENT_CHARGE_UNPLUG, MsgCenterNotifyChargeUnPlugProc},
- {TOPIC_EVENT_LOWPOWER_ALARM, MsgCenterNotifyLowPowerAlarmProc},
-
- #ifdef SUPPORT_CAT1_MODEM
- {TOPIC_EVENT_CAT1_INCOMMING, MsgCenterNotifyCatIncomingCallProc},
- {TOPIC_EVENT_CAT1_CALLCONNTED, MsgCenterNotifyCat1CallConnectedProc},
- {TOPIC_EVENT_CAT1_CALLENDED, MsgCenterNotifyCat1CallEndedProc},
- {TOPIC_EVENT_CAT1_CALLDIAL, MsgCenterNotifyCat1dialProc},
-
- // {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, MsgCenterNotifyCat1SignalUpdateProc},
- // {TOPIC_EVENT_CAT1_POWER_ON, MsgCenterNotifyCat1PowerOnProc},
- // {TOPIC_EVENT_CAT1_POWER_OFF, MsgCenterNotifyCat1PowerOffProc},
- {TOPIC_EVENT_CAT1_CALL_FAIL, MsgCenterNotifyCat1FailEProc},
- #endif
- {TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc},
- {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
- {TOPIC_EVENT_DRINKREMINDER,MsgCenterNotifyDrinkReminderProc},
- {TOPIC_EVENT_MESSAGENOTE,MsgCenterNotifyMessageProc},
- {TOPIC_EVENT_SLEEPNOTE,MsgCenterNotifySleepProc},
- {TOPIC_EVENT_DEBUGOUTPUT,MsgCenterNotifyDebugOutProc},
- {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,MsgCenterNotifyShutDownAnimatorProc},
- };
-
- static MsgCenterNotifyTable *MsgCenterGetNotifyTblCb(uint8_t idx)
- {
- return &g_msgCenterNotifyTable[idx];
- }
-
- static uint8_t MsgCenterGetNotifyTblSize(void)
- {
- return sizeof(g_msgCenterNotifyTable) / sizeof(g_msgCenterNotifyTable[0]);
- }
-
- static void CallVolumeDipSwitchControl(uint16_t notifyId, uint8_t states)
- {
- VolumeSliderEventListener *volumeSliderEventListener = nullptr;
- if (notifyId == TOPIC_EVENT_HFP_WATCH_ACTIVE ||
- notifyId == TOPIC_EVENT_HFP_PHONE_TO_WATCH) {
- if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) {
- VolumeSettingView *settingView = GetvolumeSetting();
- if (settingView == nullptr) {
- return;
- }
- volumeSliderEventListener = settingView->GetVolumeEventListener();
- if (volumeSliderEventListener == nullptr) {
- return;
- }
- volumeSliderEventListener->ChangeVolume(static_cast<VolumeChangeStatus>(states));
- } else {
- HonrsViewChange();
- NotificationManager::GetInstance()->SetVolumeScreenStatus(true);
- }
- }
- return;
- }
-
- static void OnKeyLongPress(uint16_t keyID)
- {
- g_longPressFlag = true; // Long press the logo
- if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button
- // After StopNotify, a restart card will pop up first
- uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId();
- if(notifyId == TOPIC_EVENT_ALARM_RING) {
- NativeAbility::GetInstance().ChangeSlice(VIEW_REBOOT);
- NotificationManager::GetInstance()->SetNativeUIRunning(true);
- NotificationManager::GetInstance()->StopNotify();
- }
- } else if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons
- // Switch to user configured shortcut card
- }
- return;
- }
-
- static void HandleKeyPress(uint16_t notifyId)
- {
- if (notifyId == TOPIC_EVENT_ALARM_RING) {
- AlarmClockModel::GetInstance()->AlarmGetClockNum();
- AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
- NotificationManager::GetInstance()->StopNotify();
- }
- }
-
- static bool PressKeyEvent(uint16_t keyID, uint8_t state)
- {
- switch (state) {
- case InputDevice::STATE_PRESS:
- g_pressFlag = true;
- return true;
- case InputDevice::STATE_LONG_PRESS:
- OnKeyLongPress(keyID);
- return true;
- case InputDevice::STATE_RELEASE:
- if (g_longPressFlag) {
- g_pressFlag = false;
- g_longPressFlag = false;
- return true;
- }
- break;
- default:
- break;
- }
- return false;
- }
-
- static bool KeyNotifyCallback(uint16_t keyID, uint8_t state)
- {
- if (!OHOS::NotificationManager::GetInstance()->HasNotifyShowing()) {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Notify does not exist!");
- OHOS::ACELite::KeyInputModule::SetNotifyKeyListener(nullptr);
- g_pressFlag = false;
- g_longPressFlag = false;
- return false;
- }
- if (PressKeyEvent(keyID, state)) {
- return true;
- }
- uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId();
- if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button
- if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Volume card
- // volume+
- CallVolumeDipSwitchControl(notifyId, VOLUMEUP);
- } else {
- HandleKeyPress(notifyId);
- }
- }
- else if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons
- if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Volume card
- // volume-
- CallVolumeDipSwitchControl(notifyId, VOLUMEDOWN);
- } else {
- // Switch to user configured shortcut card
- }
- }
- g_pressFlag = false;
- g_longPressFlag = false;
- return true;
- }
-
- bool MsgCenterNotifyProc(const Topic topic, Request* req)
- {
- uint8_t i;
- uint8_t tblSize = MsgCenterGetNotifyTblSize();
- OHOS::ACELite::KeyInputModule::SetNotifyKeyListener(KeyNotifyCallback);
- for (i = 0; i < tblSize; i++) {
- MsgCenterNotifyTable *item = MsgCenterGetNotifyTblCb(i);
- if (item != nullptr && item->topic == topic && item->cb != nullptr) {
- item->cb(topic, req);
- return true;
- }
- }
-
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: Can not find the cb!");
- return false;
- }
-
- #ifdef JS_ENABLE
- void StartJsApp(char *bundleName)
- {
- ElementName* topAbility = OHOS::AbilityMsClient::GetInstance().GetTopAbility();
- if (topAbility == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "topAbility is null");
- return;
- }
-
- if (strcmp(topAbility->bundleName, bundleName) == 0) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is active", bundleName);
- FreeElement(topAbility);
- return;
- }
- FreeElement(topAbility);
- // If the alarm notification is being processed, we need to disable the alarm notification first.
- if (OHOS::NotificationManager::GetInstance()->GetNotifyPriority() == PRIORITY_TWO &&
- OHOS::NotificationManager::GetInstance()->HasNotifyShowing()) {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Alarm notification needs to be disabled first.");
- AlarmClockModel::GetInstance()->AlarmGetClockNum();
- OHOS::AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
- OHOS::NotificationManager::GetInstance()->StopNotify();
- }
- Want *want = new Want();
- memset_s(want, sizeof(Want), 0, sizeof(Want));
-
- ElementName startElement = {};
- startElement.abilityName = (char *)"default";
- startElement.bundleName = bundleName;
- startElement.deviceId = nullptr;
- SetWantElement(want, startElement);
-
- StartAbility(want);
- ClearWant(want);
- delete want;
- }
-
- void StopJsApp(char *bundleName)
- {
- ElementName* topAbility = OHOS::AbilityMsClient::GetInstance().GetTopAbility();
- if (topAbility == nullptr) {
- WEARABLE_LOGE(HILOG_MODULE_AAFWK, "topAbility is null");
- return;
- }
-
- if (strcmp(topAbility->bundleName, bundleName) != 0) {
- WEARABLE_LOGE(HILOG_MODULE_AAFWK, "%s is not top active", bundleName);
- FreeElement(topAbility);
- return;
- }
- FreeElement(topAbility);
- int token = 0;
- OHOS::AbilityMsClient::GetInstance().TerminateAbility(token);
- }
-
- void MsgCenterReportBtStatusToJS(uint16_t msgId)
- {
- ElementName *elementName = OHOS::AbilityMsClient::GetInstance().GetTopAbility();
- if (!(elementName != nullptr && strcmp(elementName->bundleName, "com.huawei.launcher") != 0)) {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "JS is not on top, ignore report");
- FreeElement(elementName);
- return;
- }
- FreeElement(elementName);
- if (msgId == BT_DISCONNECTED_TO_MSGCENTER) {
- BaidumapSendMsgToJS("0", MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_DISCONNECTED);
- } else if (msgId == BT_CONNECTED_TO_MSGCENTER) {
- BaidumapSendMsgToJS("1", MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED);
- } else {
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "unexpected msgId %d", msgId);
- }
- }
- #endif
-
- #ifdef __cplusplus
- }
- #endif
- }
\ No newline at end of file
+#ifdef SUPPORT_CAT1_MODEM
+ {TOPIC_EVENT_CAT1_INCOMMING, MsgCenterNotifyCatIncomingCallProc},
+ {TOPIC_EVENT_CAT1_CALLCONNTED, MsgCenterNotifyCat1CallConnectedProc},
+ {TOPIC_EVENT_CAT1_CALLENDED, MsgCenterNotifyCat1CallEndedProc},
+ {TOPIC_EVENT_CAT1_CALLDIAL, MsgCenterNotifyCat1dialProc},
+
+ // {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, MsgCenterNotifyCat1SignalUpdateProc},
+ // {TOPIC_EVENT_CAT1_POWER_ON, MsgCenterNotifyCat1PowerOnProc},
+ // {TOPIC_EVENT_CAT1_POWER_OFF, MsgCenterNotifyCat1PowerOffProc},
+ {TOPIC_EVENT_CAT1_CALL_FAIL, MsgCenterNotifyCat1FailEProc},
+#endif
+ {TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc},
+ {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
+ {TOPIC_EVENT_DRINKREMINDER,MsgCenterNotifyDrinkReminderProc},
+ {TOPIC_EVENT_MESSAGENOTE,MsgCenterNotifyMessageProc},
+ {TOPIC_EVENT_SLEEPNOTE,MsgCenterNotifySleepProc},
+ {TOPIC_EVENT_DEBUGOUTPUT,MsgCenterNotifyDebugOutProc},
+ {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,MsgCenterNotifyShutDownAnimatorProc},
+};
+
+static MsgCenterNotifyTable *MsgCenterGetNotifyTblCb(uint8_t idx)
+{
+ return &g_msgCenterNotifyTable[idx];
+}
+
+static uint8_t MsgCenterGetNotifyTblSize(void)
+{
+ return sizeof(g_msgCenterNotifyTable) / sizeof(g_msgCenterNotifyTable[0]);
+}
+
+static void CallVolumeDipSwitchControl(uint16_t notifyId, uint8_t states)
+{
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "1201patch合并为编译过屏蔽下方代码");
+ #if 0 // 1201patch 为编译过屏蔽
+ VolumeSliderEventListener *volumeSliderEventListener = nullptr;
+ if (notifyId == TOPIC_EVENT_HFP_WATCH_ACTIVE ||
+ notifyId == TOPIC_EVENT_HFP_PHONE_TO_WATCH) {
+ if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) {
+ VolumeSettingView *settingView = GetvolumeSetting();
+ if (settingView == nullptr) {
+ return;
+ }
+ volumeSliderEventListener = settingView->GetVolumeEventListener();
+ if (volumeSliderEventListener == nullptr) {
+ return;
+ }
+ volumeSliderEventListener->ChangeVolume(static_cast<VolumeChangeStatus>(states));
+ } else {
+ HonrsViewChange();
+ NotificationManager::GetInstance()->SetVolumeScreenStatus(true);
+ }
+ }
+ return;
+ #endif
+}
+
+static void OnKeyLongPress(uint16_t keyID)
+{
+ g_longPressFlag = true; // Long press the logo
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button
+ // After StopNotify, a restart card will pop up first
+ uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId();
+ if(notifyId == TOPIC_EVENT_ALARM_RING) {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_REBOOT);
+ NotificationManager::GetInstance()->SetNativeUIRunning(true);
+ NotificationManager::GetInstance()->StopNotify();
+ }
+ } else if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons
+ // Switch to user configured shortcut card
+ }
+ return;
+}
+
+static void HandleKeyPress(uint16_t notifyId)
+{
+ if (notifyId == TOPIC_EVENT_ALARM_RING) {
+ AlarmClockModel::GetInstance()->AlarmGetClockNum();
+ AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+ NotificationManager::GetInstance()->StopNotify();
+ }
+}
+
+static bool PressKeyEvent(uint16_t keyID, uint8_t state)
+{
+ switch (state) {
+ case InputDevice::STATE_PRESS:
+ g_pressFlag = true;
+ return true;
+ case InputDevice::STATE_LONG_PRESS:
+ OnKeyLongPress(keyID);
+ return true;
+ case InputDevice::STATE_RELEASE:
+ if (g_longPressFlag) {
+ g_pressFlag = false;
+ g_longPressFlag = false;
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+static bool KeyNotifyCallback(uint16_t keyID, uint8_t state)
+{
+ if (!OHOS::NotificationManager::GetInstance()->HasNotifyShowing()) {
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Notify does not exist!");
+ OHOS::ACELite::KeyInputModule::SetNotifyKeyListener(nullptr);
+ g_pressFlag = false;
+ g_longPressFlag = false;
+ return false;
+ }
+ if (PressKeyEvent(keyID, state)) {
+ return true;
+ }
+ uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId();
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER)) { // Power button
+ if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Volume card
+ // volume+
+ CallVolumeDipSwitchControl(notifyId, VOLUMEUP);
+ } else {
+ HandleKeyPress(notifyId);
+ }
+ }
+ else if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC)) { // Function buttons
+ if (NotificationManager::GetInstance()->GetWatchCallStatus()) { // Volume card
+ // volume-
+ CallVolumeDipSwitchControl(notifyId, VOLUMEDOWN);
+ } else {
+ // Switch to user configured shortcut card
+ }
+ }
+ g_pressFlag = false;
+ g_longPressFlag = false;
+ return true;
+}
+
+bool MsgCenterNotifyProc(const Topic topic, Request* req)
+{
+ uint8_t i;
+ uint8_t tblSize = MsgCenterGetNotifyTblSize();
+ OHOS::ACELite::KeyInputModule::SetNotifyKeyListener(KeyNotifyCallback);
+ for (i = 0; i < tblSize; i++) {
+ MsgCenterNotifyTable *item = MsgCenterGetNotifyTblCb(i);
+ if (item != nullptr && item->topic == topic && item->cb != nullptr) {
+ item->cb(topic, req);
+ return true;
+ }
+ }
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: Can not find the cb!");
+ return false;
+}
+
+#ifdef JS_ENABLE
+void StartJsApp(char *bundleName)
+{
+ ElementName* topAbility = OHOS::AbilityMsClient::GetInstance().GetTopAbility();
+ if (topAbility == nullptr) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "topAbility is null");
+ return;
+ }
+
+ if (strcmp(topAbility->bundleName, bundleName) == 0) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is active", bundleName);
+ FreeElement(topAbility);
+ return;
+ }
+ FreeElement(topAbility);
+ // If the alarm notification is being processed, we need to disable the alarm notification first.
+ if (OHOS::NotificationManager::GetInstance()->GetNotifyPriority() == PRIORITY_TWO &&
+ OHOS::NotificationManager::GetInstance()->HasNotifyShowing()) {
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Alarm notification needs to be disabled first.");
+ AlarmClockModel::GetInstance()->AlarmGetClockNum();
+ OHOS::AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+ OHOS::NotificationManager::GetInstance()->StopNotify();
+ }
+ Want *want = new Want();
+ memset_s(want, sizeof(Want), 0, sizeof(Want));
+
+ ElementName startElement = {};
+ startElement.abilityName = (char *)"default";
+ startElement.bundleName = bundleName;
+ startElement.deviceId = nullptr;
+ SetWantElement(want, startElement);
+
+ StartAbility(want);
+ ClearWant(want);
+ delete want;
+}
+
+void StopJsApp(char *bundleName)
+{
+ ElementName* topAbility = OHOS::AbilityMsClient::GetInstance().GetTopAbility();
+ if (topAbility == nullptr) {
+ WEARABLE_LOGE(HILOG_MODULE_AAFWK, "topAbility is null");
+ return;
+ }
+
+ if (strcmp(topAbility->bundleName, bundleName) != 0) {
+ WEARABLE_LOGE(HILOG_MODULE_AAFWK, "%s is not top active", bundleName);
+ FreeElement(topAbility);
+ return;
+ }
+ FreeElement(topAbility);
+ int token = 0;
+ OHOS::AbilityMsClient::GetInstance().TerminateAbility(token);
+}
+
+void MsgCenterReportBtStatusToJS(uint16_t msgId)
+{
+ ElementName *elementName = OHOS::AbilityMsClient::GetInstance().GetTopAbility();
+ if (!(elementName != nullptr && strcmp(elementName->bundleName, "com.huawei.launcher") != 0)) {
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "JS is not on top, ignore report");
+ FreeElement(elementName);
+ return;
+ }
+ FreeElement(elementName);
+ if (msgId == BT_DISCONNECTED_TO_MSGCENTER) {
+ BaidumapSendMsgToJS("0", MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_DISCONNECTED);
+ } else if (msgId == BT_CONNECTED_TO_MSGCENTER) {
+ BaidumapSendMsgToJS("1", MSGCENTER_TYPE_ID_VECTOR_NAVI_BT_CONNECTED);
+ } else {
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "unexpected msgId %d", msgId);
+ }
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+}
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.\r
- * Description: makephone notification implement\r
- * Author: CompanyName\r
- * Create: 2023-08-11\r
- */\r
-\r
-#include "notification_manager.h"\r
-#include "wearable_log.h"\r
-#include "CallerLogModel.h"\r
-#include "PhoneService.h"\r
-#include "cmsis_os.h"\r
-#include "UiConfig.h"\r
-#include "components/ui_image_view.h"\r
-#include "components/ui_label.h"\r
-#include "common/image_cache_manager.h"\r
-#include "VolumeSettingView.h"\r
-#include "VolumeSettingPresenter.h"\r
-#include "ui_resource_image.h"\r
-#include "audio_manager.h"\r
-\r
-namespace OHOS {\r
-\r
-using namespace Audio;\r
-using Audio::AudioManager;\r
-\r
-constexpr int32_t NOTIFY_THREE_SECONDS = 3000;\r
-constexpr int32_t NOTIFY_ONE_SECOND = 1000;\r
-constexpr int32_t NOTIFY_THIRTY_SECONDS = 30000;\r
-constexpr int32_t NOTIFY_ONE_MINUTE = 60000;\r
-constexpr int32_t NOTOFY_NO_OPERATE_TIME = 35000;\r
-int g_changeImage = 0;\r
-osTimerId_t g_callDurationTimer = nullptr; // timer of call duration\r
-osTimerId_t g_callCurrentTime = nullptr; // timer of current time\r
-\r
-static constexpr uint16 MATH_ZERO = 0;\r
-\r
-// 来电显示\r
-static constexpr uint16 LABEL_PERCENT_POSITION_X = 0;\r
-static constexpr uint16 LABEL_PERCENT_POSITION_Y = 100;\r
-static constexpr uint16 LABEL_COMINGVIEW_POSITION_X = 0;\r
-static constexpr uint16 LABEL_COMINGVIEW_POSITION_Y = 80;\r
-static constexpr uint16 TITLE_LABEL_DEFAULT_HEIGHT = 80;\r
-\r
-// 当前时间\r
-static constexpr uint16 LABEL_CURREMTTIME_POSITION_X = 0;\r
-static constexpr uint16 LABEL_CURREMTTIME_POSITION_Y = 360;\r
-static constexpr uint16 LABEL_COMINGTIME_POSITION_X = 0;\r
-static constexpr uint16 LABEL_COMINGTIME_POSITION_Y = 340;\r
-\r
-// 图片坐标\r
-static constexpr uint16 LABEL_CALLERD_POSITION_X = 0;\r
-static constexpr uint16 LABEL_CALLERD_POSITION_Y = 160;\r
-static constexpr uint16 LABEL_NEWCALLERD_POSITION_X = 0;\r
-static constexpr uint16 LABEL_NEWCALLERD_POSITION_Y = 160;\r
-static constexpr uint16 IMAGE_HONRS_POSITION_X = 185;\r
-static constexpr uint16 IMAGE_HONRS_POSITION_Y = 10;\r
-static constexpr uint16 IMAGE_HANDUP_POSITION_X = 70;\r
-static constexpr uint16 IMAGE_MIC_POSITION_X = 280;\r
-static constexpr uint16 IMAGE_DISSGREE_POSITION_X = 80;\r
-static constexpr uint16 IMAGE_AGREEING_POSITION_X = 270;\r
-static constexpr uint16 IMAGE_ALL_POSITION_Y = 240;\r
-static constexpr uint16 IMAGE_HANDUP2_POSITION_X = 177;\r
-static constexpr uint16 IMAGE_HANDUP2_POSITION_Y = 270;\r
-\r
-// 字体大小\r
-static constexpr uint16 FONT_CURRENT_SIZE = 25;\r
-static constexpr uint16 FONT_CALLER_SIZE = 40;\r
-UIViewGroup* g_phoneView = nullptr;\r
-UIViewGroup* g_multiPhoneView = nullptr;\r
-UIViewGroup* g_callingView = nullptr;\r
-UIViewGroup* g_waitingHintsView = nullptr;\r
-VolumeSettingView *g_volumeSetting = nullptr;\r
-UIImageView* g_imageAgree = nullptr;\r
-UIImageView* g_imageDissgree = nullptr;\r
-UIImageView* g_imageMicrophone = nullptr;\r
-UIImageView* g_imageHandUp = nullptr;\r
-UIImageView* g_imageHorns = nullptr;\r
-UIImageView* g_imageDissgreeNew = nullptr;\r
-UILabel* g_callerNum = nullptr;\r
-UILabel* g_callerDisplay = nullptr;\r
-UILabel* g_callDuration = nullptr;\r
-UILabel* g_currentTimes = nullptr;\r
-UILabel* g_comingTimes = nullptr;\r
-UILabel* g_newCallHints = nullptr;\r
-UILabel* g_newCallNum = nullptr;\r
-\r
-void CallTimerCallBack(int data)\r
-{\r
- GraphicService::GetInstance()->PostGraphicEvent(std::bind(CallTimerCallBackProc, data));\r
-}\r
-\r
-void CallTimerCallBackProc(int data)\r
-{\r
- if (g_callDuration != nullptr) {\r
- g_callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str());\r
- }\r
-}\r
-\r
-void CallCurTimerCallBack(int data)\r
-{\r
- if (g_currentTimes != nullptr) {\r
- g_currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str());\r
- }\r
-}\r
-\r
-void StartCallTimer(CallTimerType type, int32_t interval)\r
-{\r
- uint32_t tick;\r
- osStatus_t retTimer;\r
- if (type >= CallTimerType::NOTIFY_PHONE_UNKNOWN) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCallTimer type:%d invalid!!", type);\r
- return;\r
- }\r
- switch (type) {\r
- case CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY:\r
- g_callDurationTimer = osTimerNew((osTimerFunc_t)CallTimerCallBack, osTimerPeriodic, nullptr, nullptr);\r
- tick = osMs2Tick(interval);\r
- retTimer = osTimerStart(g_callDurationTimer, tick);\r
- if (retTimer != osOK && g_callDurationTimer != nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
- "StartCallTimer osTimerStart failed, type = %d ret = %lx!!", type, retTimer);\r
- osTimerDelete(g_callDurationTimer);\r
- g_callDurationTimer = nullptr;\r
- return;\r
- }\r
- break;\r
- case CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY:\r
- g_callCurrentTime = osTimerNew((osTimerFunc_t)CallCurTimerCallBack, osTimerPeriodic, nullptr, nullptr);\r
- tick = osMs2Tick(interval);\r
- retTimer = osTimerStart(g_callCurrentTime, tick);\r
- if (retTimer != osOK && g_callCurrentTime != nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
- "StartCallTimer osTimerStart failed, type = %d ret = %lx!!", type, retTimer);\r
- osTimerDelete(g_callCurrentTime);\r
- g_callCurrentTime = nullptr;\r
- return;\r
- }\r
- break;\r
- default:\r
- break;\r
- }\r
-}\r
-\r
-void DisableCallTimer(CallTimerType type)\r
-{\r
- if (type >= CallTimerType::NOTIFY_PHONE_UNKNOWN) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer type:%d invalid!!", type);\r
- return;\r
- }\r
- osStatus_t ret;\r
- switch (type) {\r
- case CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY:\r
- if (g_callDurationTimer != nullptr) {\r
- ret = osTimerDelete(g_callDurationTimer);\r
- if (ret != osOK) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer failed, type= %d ret = %lx!", type, ret);\r
- return;\r
- }\r
- g_callDurationTimer = nullptr;\r
- }\r
- break;\r
- case CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY:\r
- if (g_callCurrentTime != nullptr) {\r
- ret = osTimerDelete(g_callCurrentTime);\r
- if (ret != osOK) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableCallTimer failed, type= %d ret = %lx!", type, ret);\r
- return;\r
- }\r
- g_callCurrentTime = nullptr;\r
- }\r
- break;\r
- default:\r
- break;\r
- }\r
-}\r
-\r
-void HonrsViewChange(void)\r
-{\r
- if (g_volumeSetting == nullptr) {\r
- g_volumeSetting = new VolumeSettingView();\r
- if (g_volumeSetting == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::g_volumeSetting nullptr err");\r
- return;\r
- }\r
- if (!g_volumeSetting->SetUpVolume()) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::g_volumeSetting SetUpVolume fail");\r
- return;\r
- }\r
- g_volumeSetting->GetProgress()->SetValue(\r
- AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO));\r
- if (AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO) == 0) {\r
- ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_MUTE_BUTTON, PLAYER_IAMGES);\r
- g_volumeSetting->GetDecreaseButton()->SetImageSrc(image, image);\r
- }\r
- NotificationManager::GetInstance()->screenContainer_->Add(g_volumeSetting);\r
- }\r
- VolumeSliderEventListener *volumeSliderEventListener = g_volumeSetting->GetVolumeEventListener();\r
- if (volumeSliderEventListener == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makephone_notification::volumeSliderEventListener nullptr err");\r
- return;\r
- }\r
-\r
- volumeSliderEventListener->SetPlayerCoefficients(VOLUMEPHONENOTIFY); // 进度条系数\r
- g_volumeSetting->SetVisible(true);\r
- // 刷新UI\r
- RootView::GetInstance()->Invalidate();\r
-}\r
-VolumeSettingView *GetvolumeSetting(void)\r
-{\r
- return g_volumeSetting;\r
-}\r
-\r
-static void FreeCallingViewImage(void)\r
-{\r
- if (g_imageMicrophone != nullptr) {\r
- delete g_imageMicrophone;\r
- g_imageMicrophone = nullptr;\r
- }\r
- if (g_imageHandUp != nullptr) {\r
- delete g_imageHandUp;\r
- g_imageHandUp = nullptr;\r
- }\r
- if (g_imageHorns != nullptr) {\r
- delete g_imageHorns;\r
- g_imageHorns = nullptr;\r
- }\r
-}\r
-\r
-static bool DrawCallingViewImage(void)\r
-{\r
- g_imageMicrophone = new UIImageView();\r
- if (g_imageMicrophone == nullptr) {\r
- return false;\r
- }\r
- g_imageMicrophone->SetPosition(IMAGE_MIC_POSITION_X, IMAGE_ALL_POSITION_Y);\r
- g_imageMicrophone->SetSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH);\r
- g_imageMicrophone->SetTouchable(true);\r
- g_imageMicrophone->SetViewId("microphoneChange");\r
-\r
- g_imageHandUp = new UIImageView();\r
- if (g_imageHandUp == nullptr) {\r
- FreeCallingViewImage();\r
- return false;\r
- }\r
- g_imageHandUp->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_ALL_POSITION_Y);\r
- g_imageHandUp->SetSrc(PNG_DISSGREE_IMAGE_PATH);\r
- g_imageHandUp->SetTouchable(true);\r
- g_imageHandUp->SetViewId("callingHandUp");\r
-\r
- g_imageHorns = new UIImageView();\r
- if (g_imageHorns == nullptr) {\r
- FreeCallingViewImage();\r
- return false;\r
- }\r
- g_imageHorns->SetPosition(IMAGE_HONRS_POSITION_X, IMAGE_HONRS_POSITION_Y);\r
- g_imageHorns->SetSrc(PNG_SOUNDBUTTON2);\r
- g_imageHorns->SetTouchable(true);\r
- g_imageHorns->SetViewId("volumeSwitch");\r
-\r
- return true;\r
-}\r
-\r
-static void FreeCallingViewUILabel(void)\r
-{\r
- if (g_callerDisplay != nullptr) {\r
- delete g_callerDisplay;\r
- g_callerDisplay = nullptr;\r
- }\r
- if (g_callDuration != nullptr) {\r
- delete g_callDuration;\r
- g_callDuration = nullptr;\r
- }\r
- if (g_currentTimes != nullptr) {\r
- delete g_currentTimes;\r
- g_currentTimes = nullptr;\r
- }\r
-}\r
-\r
-static bool DrawCallingViewUILabel(void)\r
-{\r
- g_callerDisplay = new UILabel();\r
- if (g_callerDisplay == nullptr) {\r
- return false;\r
- }\r
- g_callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y,\r
- Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);\r
- g_callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r
- g_callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());\r
- g_callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER);\r
- g_callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE);\r
- g_callerDisplay->SetTextColor(Color::White());\r
-\r
- g_callDuration = new UILabel();\r
- if (g_callDuration == nullptr) {\r
- FreeCallingViewUILabel();\r
- return false;\r
- }\r
- g_callDuration->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y,\r
- Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);\r
- g_callDuration->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r
- g_callDuration->SetAlign(TEXT_ALIGNMENT_CENTER);\r
- g_callDuration->SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str());\r
- g_callDuration->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE);\r
- g_callDuration->SetTextColor(Color::White());\r
-\r
- g_currentTimes = new UILabel();\r
- if (g_currentTimes == nullptr) {\r
- FreeCallingViewUILabel();\r
- return false;\r
- }\r
- g_currentTimes->SetPosition(LABEL_CURREMTTIME_POSITION_X, LABEL_CURREMTTIME_POSITION_Y,\r
- Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);\r
- g_currentTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r
- g_currentTimes->SetAlign(TEXT_ALIGNMENT_CENTER);\r
- g_currentTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str());\r
- g_currentTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE);\r
- g_currentTimes->SetTextColor(Color::White());\r
-\r
- return true;\r
-}\r
-\r
-static bool DrawWaitingHintsViewImage(void)\r
-{\r
- g_imageDissgreeNew = new UIImageView();\r
- if (g_imageDissgreeNew == nullptr) {\r
- FreeCallingViewImage();\r
- return false;\r
- }\r
- g_imageDissgreeNew->SetPosition(IMAGE_HANDUP2_POSITION_X, IMAGE_HANDUP2_POSITION_Y);\r
- g_imageDissgreeNew->SetSrc(PNG_DISSGREE_IMAGE_PATH);\r
- g_imageDissgreeNew->SetTouchable(true);\r
- g_imageDissgreeNew->SetViewId("newCallHandUp");\r
- return true;\r
-}\r
-\r
-static void FreeWaitingHintsViewImage(void)\r
-{\r
- if (g_imageDissgreeNew != nullptr) {\r
- delete g_imageDissgreeNew;\r
- g_imageDissgreeNew = nullptr;\r
- }\r
-}\r
-\r
-static void FreeWaitingHintsViewLabel(void)\r
-{\r
- if (g_newCallNum != nullptr) {\r
- delete g_newCallNum;\r
- g_newCallNum = nullptr;\r
- }\r
- if (g_newCallHints != nullptr) {\r
- delete g_newCallHints;\r
- g_newCallHints = nullptr;\r
- }\r
-}\r
-\r
-static bool DrawWaitingHintsViewLabel(void)\r
-{\r
- g_newCallNum = new UILabel();\r
- if (g_newCallNum == nullptr) {\r
- return false;\r
- }\r
- g_newCallNum->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y,\r
- Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);\r
- g_newCallNum->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r
- g_newCallNum->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());\r
- g_newCallNum->SetAlign(TEXT_ALIGNMENT_CENTER);\r
- g_newCallNum->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE);\r
- g_newCallNum->SetTextColor(Color::White());\r
-\r
- g_newCallHints = new UILabel();\r
- if (g_newCallHints == nullptr) {\r
- FreeWaitingHintsViewLabel();\r
- return false;\r
- }\r
- g_newCallHints->SetPosition(LABEL_NEWCALLERD_POSITION_X, LABEL_NEWCALLERD_POSITION_Y,\r
- Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);\r
- g_newCallHints->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r
- g_newCallHints->SetText("新来电");\r
- g_newCallHints->SetAlign(TEXT_ALIGNMENT_CENTER);\r
- g_newCallHints->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE);\r
- g_newCallHints->SetTextColor(Color::White());\r
- return true;\r
-}\r
-\r
-static void FreePhoneCallViewImage(void)\r
-{\r
- if (g_imageAgree != nullptr) {\r
- delete g_imageAgree;\r
- g_imageAgree = nullptr;\r
- }\r
- if (g_imageDissgree != nullptr) {\r
- delete g_imageDissgree;\r
- g_imageDissgree = nullptr;\r
- }\r
-}\r
-\r
-static bool DrawPhoneCallViewImage(void)\r
-{\r
- g_imageAgree = new UIImageView();\r
- if (g_imageAgree == nullptr) {\r
- return false;\r
- }\r
- g_imageAgree->SetPosition(IMAGE_AGREEING_POSITION_X, IMAGE_ALL_POSITION_Y);\r
- g_imageAgree->SetSrc(PNG_AGREEING_IMAGE_PATH);\r
- g_imageAgree->SetTouchable(true);\r
- g_imageAgree->SetViewId("answer");\r
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>\\r
- (OHOS::CallViewEventListener::GetInstance());\r
- g_imageAgree->SetOnClickListener(clickListener);\r
- g_imageDissgree = new UIImageView();\r
- if (g_imageDissgree == nullptr) {\r
- FreePhoneCallViewImage();\r
- return false;\r
- }\r
- g_imageDissgree->SetPosition(IMAGE_DISSGREE_POSITION_X, IMAGE_ALL_POSITION_Y);\r
- g_imageDissgree->SetSrc(PNG_DISSGREE_IMAGE_PATH);\r
- g_imageDissgree->SetTouchable(true);\r
- g_imageDissgree->SetViewId("displayHandUp");\r
- g_imageDissgree->SetOnClickListener(clickListener);\r
- return true;\r
-}\r
-\r
-static void FreePhoneCallViewLabel(void)\r
-{\r
- if (g_callerNum != nullptr) {\r
- delete g_callerNum;\r
- g_callerNum = nullptr;\r
- }\r
- if (g_comingTimes != nullptr) {\r
- delete g_comingTimes;\r
- g_comingTimes = nullptr;\r
- }\r
-}\r
-\r
-static bool DrawPhoneCallViewLabel(void)\r
-{\r
- g_callerNum = new UILabel();\r
- if (g_callerNum == nullptr) {\r
- return false;\r
- }\r
- g_callerNum->SetPosition(LABEL_COMINGVIEW_POSITION_X, LABEL_COMINGVIEW_POSITION_Y,\r
- Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);\r
- g_callerNum->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "CreatePhoneCallView phonenum:%s!",\r
- CallerLogModel::GetInstance()->GetPhoneNumber().c_str());\r
- g_callerNum->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());\r
- g_callerNum->SetAlign(TEXT_ALIGNMENT_CENTER);\r
- g_callerNum->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CALLER_SIZE);\r
- g_callerNum->SetTextColor(Color::White());\r
-\r
- g_comingTimes = new UILabel();\r
- if (g_comingTimes == nullptr) {\r
- FreePhoneCallViewLabel();\r
- return false;\r
- }\r
- g_comingTimes->SetPosition(LABEL_COMINGTIME_POSITION_X, LABEL_COMINGTIME_POSITION_Y,\r
- Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);\r
- g_comingTimes->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r
- g_comingTimes->SetAlign(TEXT_ALIGNMENT_CENTER);\r
- g_comingTimes->SetText(CallerLogModel::GetInstance()->InitDateHourTime().c_str());\r
- g_comingTimes->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_CURRENT_SIZE);\r
- g_comingTimes->SetTextColor(Color::White());\r
- return true;\r
-}\r
-\r
-UIViewGroup* CreatePhoneCallView(void)\r
-{\r
- g_phoneView = new UIViewGroup();\r
- if (g_phoneView == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePhoneCallView g_phoneView null!");\r
- return nullptr;\r
- }\r
- g_phoneView->SetPosition(MATH_ZERO, MATH_ZERO);\r
- g_phoneView->SetWidth(Screen::GetInstance().GetWidth());\r
- g_phoneView->SetHeight(Screen::GetInstance().GetHeight());\r
- if (!DrawPhoneCallViewImage()) {\r
- delete g_phoneView;\r
- g_phoneView = nullptr;\r
- return nullptr;\r
- }\r
- if (!DrawPhoneCallViewLabel()) {\r
- FreePhoneCallViewImage();\r
- delete g_phoneView;\r
- g_phoneView = nullptr;\r
- return nullptr;\r
- }\r
- g_phoneView->Add(g_imageAgree);\r
- g_phoneView->Add(g_imageDissgree);\r
- g_phoneView->Add(g_callerNum);\r
- g_phoneView->Add(g_comingTimes);\r
- g_phoneView->SetDraggable(true);\r
- g_phoneView->SetTouchable(true);\r
- NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreePhoneCallView);\r
- return g_phoneView;\r
-}\r
-\r
-void FreePhoneCallView(void)\r
-{\r
- if (g_phoneView != nullptr) {\r
- g_phoneView->RemoveAll();\r
- FreePhoneCallViewImage();\r
- FreePhoneCallViewLabel();\r
- RootView::GetInstance()->Remove(g_phoneView);\r
- delete g_phoneView;\r
- g_phoneView = nullptr;\r
- }\r
-}\r
-\r
-UIViewGroup* CreateMultiplePhoneView(void)\r
-{\r
- g_multiPhoneView = new UIViewGroup();\r
- if (g_multiPhoneView == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateMultiplePhoneView g_multiPhoneView null!");\r
- return nullptr;\r
- }\r
- g_multiPhoneView->SetPosition(MATH_ZERO, MATH_ZERO);\r
- g_multiPhoneView->SetWidth(Screen::GetInstance().GetWidth());\r
- g_multiPhoneView->SetHeight(Screen::GetInstance().GetHeight());\r
- if (!DrawCallingViewImage()) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateMultiplePhoneView create image error!");\r
- delete g_multiPhoneView;\r
- g_multiPhoneView = nullptr;\r
- return nullptr;\r
- }\r
- if (!DrawCallingViewUILabel()) {\r
- FreeCallingViewImage();\r
- delete g_multiPhoneView;\r
- g_multiPhoneView = nullptr;\r
- return nullptr;\r
- }\r
- g_callerDisplay->SetText("正在通话");\r
- g_callDuration->SetText("");\r
- g_multiPhoneView->Add(g_imageMicrophone);\r
- g_multiPhoneView->Add(g_imageHandUp);\r
- g_multiPhoneView->Add(g_imageHorns);\r
- g_multiPhoneView->Add(g_callerDisplay);\r
- g_multiPhoneView->Add(g_callDuration);\r
- g_multiPhoneView->Add(g_currentTimes);\r
- g_multiPhoneView->SetDraggable(true);\r
- g_multiPhoneView->SetTouchable(true);\r
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>\\r
- (OHOS::CallViewEventListener::GetInstance());\r
- g_imageMicrophone->SetOnClickListener(clickListener);\r
- g_imageHandUp->SetOnClickListener(clickListener);\r
- g_imageHorns->SetOnClickListener(clickListener);\r
- StartCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY, NOTIFY_THIRTY_SECONDS);\r
- NotificationManager::GetInstance()->SetVolumeScreenStatus(false);\r
- NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeMultiplePhoneCallView);\r
- return g_multiPhoneView;\r
-}\r
-\r
-void FreeMultiplePhoneCallView(void)\r
-{\r
- if (g_multiPhoneView != nullptr) {\r
- DisableCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY);\r
- g_multiPhoneView->RemoveAll();\r
- FreeCallingViewImage();\r
- FreeCallingViewUILabel();\r
- RootView::GetInstance()->Remove(g_multiPhoneView);\r
- delete g_multiPhoneView;\r
- g_multiPhoneView = nullptr;\r
- }\r
- if (g_volumeSetting != nullptr) {\r
- delete g_volumeSetting;\r
- g_volumeSetting = nullptr;\r
- }\r
-}\r
-\r
-UIViewGroup* CreateCallingView(void)\r
-{\r
- g_callingView = new UIViewGroup();\r
- if (g_callingView == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView g_callingView null!");\r
- return nullptr;\r
- }\r
- g_callingView->SetPosition(MATH_ZERO, MATH_ZERO);\r
- g_callingView->SetWidth(Screen::GetInstance().GetWidth());\r
- g_callingView->SetHeight(Screen::GetInstance().GetHeight());\r
- if (!DrawCallingViewImage()) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView create image error!");\r
- delete g_callingView;\r
- g_callingView = nullptr;\r
- return nullptr;\r
- }\r
- if (!DrawCallingViewUILabel()) {\r
- FreeCallingViewImage();\r
- delete g_callingView;\r
- g_callingView = nullptr;\r
- return nullptr;\r
- }\r
- g_callingView->Add(g_imageMicrophone);\r
- g_callingView->Add(g_imageHandUp);\r
- g_callingView->Add(g_imageHorns);\r
- g_callingView->Add(g_callerDisplay);\r
- g_callingView->Add(g_callDuration);\r
- g_callingView->Add(g_currentTimes);\r
- g_callingView->SetDraggable(true);\r
- g_callingView->SetTouchable(true);\r
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>\\r
- (OHOS::CallViewEventListener::GetInstance());\r
- g_imageMicrophone->SetOnClickListener(clickListener);\r
- g_imageHandUp->SetOnClickListener(clickListener);\r
- g_imageHorns->SetOnClickListener(clickListener);\r
- StartCallTimer(CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY, NOTIFY_ONE_SECOND);\r
- StartCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY, NOTIFY_THIRTY_SECONDS);\r
- NotificationManager::GetInstance()->SetVolumeScreenStatus(false);\r
- NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeCallingView);\r
- return g_callingView;\r
-}\r
-\r
-void FreeCallingView(void)\r
-{\r
- if (g_callingView != nullptr) {\r
- DisableCallTimer(CallTimerType::NOTIFY_PHONE_CALLING_DISPLAY);\r
- DisableCallTimer(CallTimerType::NOTIFY_PHONE_CURTIME_DISPLAY);\r
- g_callingView->RemoveAll();\r
- FreeCallingViewImage();\r
- FreeCallingViewUILabel();\r
- RootView::GetInstance()->Remove(g_callingView);\r
- delete g_callingView;\r
- g_callingView = nullptr;\r
- }\r
- if (g_volumeSetting != nullptr) {\r
- delete g_volumeSetting;\r
- g_volumeSetting = nullptr;\r
- }\r
-}\r
-\r
-UIViewGroup* CreateWaitingHintsView(void)\r
-{\r
- g_waitingHintsView = new UIViewGroup();\r
- if (g_waitingHintsView == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateWaitingHintsView g_waitingHintsView null!");\r
- return nullptr;\r
- }\r
- g_waitingHintsView->SetPosition(MATH_ZERO, MATH_ZERO);\r
- g_waitingHintsView->SetWidth(Screen::GetInstance().GetWidth());\r
- g_waitingHintsView->SetHeight(Screen::GetInstance().GetHeight());\r
- if (!DrawWaitingHintsViewImage()) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateWaitingHintsView create image error!");\r
- delete g_waitingHintsView;\r
- g_waitingHintsView = nullptr;\r
- return nullptr;\r
- }\r
- if (!DrawWaitingHintsViewLabel()) {\r
- FreeWaitingHintsViewImage();\r
- delete g_waitingHintsView;\r
- g_waitingHintsView = nullptr;\r
- return nullptr;\r
- }\r
- g_waitingHintsView->Add(g_imageDissgreeNew);\r
- g_waitingHintsView->Add(g_newCallNum);\r
- g_waitingHintsView->Add(g_newCallHints);\r
- g_waitingHintsView->SetDraggable(true);\r
- g_waitingHintsView->SetTouchable(true);\r
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>\\r
- (OHOS::CallViewEventListener::GetInstance());\r
- g_imageDissgreeNew->SetOnClickListener(clickListener);\r
- NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeWaitingHintsView);\r
- return g_waitingHintsView;\r
-}\r
-\r
-void FreeWaitingHintsView(void)\r
-{\r
- if (g_waitingHintsView != nullptr) {\r
- g_waitingHintsView->RemoveAll();\r
- FreeWaitingHintsViewImage();\r
- FreeWaitingHintsViewLabel();\r
- RootView::GetInstance()->Remove(g_waitingHintsView);\r
- delete g_waitingHintsView;\r
- g_waitingHintsView = nullptr;\r
- }\r
-}\r
-\r
-void RefreshMicrophoneImageSrc(const char* src)\r
-{\r
- g_imageMicrophone->SetSrc(src);\r
-}\r
-\r
-void EnableWaitingView(void)\r
-{\r
- if (g_waitingHintsView == nullptr) {\r
- CreateWaitingHintsView();\r
- }\r
- if (NotificationManager::GetInstance()->screenContainer_ != nullptr) {\r
- NotificationManager::GetInstance()->screenContainer_->SetVisible(false);\r
- }\r
- RootView::GetInstance()->Add(g_waitingHintsView);\r
- g_waitingHintsView->SetVisible(true);\r
- RootView::GetInstance()->Invalidate();\r
-}\r
-\r
-void DisableWatingView(void)\r
-{\r
- if (g_waitingHintsView != nullptr) {\r
- g_waitingHintsView->SetVisible(false);\r
- FreeWaitingHintsView();\r
- if (NotificationManager::GetInstance()->screenContainer_ != nullptr) {\r
- NotificationManager::GetInstance()->screenContainer_->SetVisible(true);\r
- }\r
- RootView::GetInstance()->Invalidate();\r
- }\r
-}\r
-\r
-bool HintsHandupClick(void)\r
-{\r
- if (RejectIncomingCall() != 0) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[HintsHandupClick] RejectIncomingCall error");\r
- return false;\r
- }\r
- CallerLogModel::GetInstance()->SetWaitingStatus(false);\r
- CallerLogModel::GetInstance()->SetCallStatus(true);\r
-\r
- return true;\r
-}\r
-\r
-CallViewEventListener::CallViewEventListener()\r
-{\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallViewEventListener :%p", this);\r
-}\r
-\r
-CallViewEventListener::~CallViewEventListener()\r
-{\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~CallViewEventListener");\r
-}\r
-\r
-CallViewEventListener *CallViewEventListener::GetInstance(void)\r
-{\r
- static CallViewEventListener callViewEventListener;\r
- return &callViewEventListener;\r
-}\r
-\r
-bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event)\r
-{\r
- UNUSED(event);\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MakephoneNotify ClickListener %s", view.GetViewId());\r
- if (strcmp(view.GetViewId(), "answer") == 0) {\r
- // watch answer the call\r
- if (AcceptIncomingCall() != 0) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AcceptIncomingCall() fail");\r
- return false;\r
- }\r
- return true;\r
- } else if (strcmp(view.GetViewId(), "displayHandUp") == 0 ||\r
- strcmp(view.GetViewId(), "callingHandUp") == 0) {\r
- if (strcmp(view.GetViewId(), "displayHandUp") == 0) {\r
- // The watch rejects the call\r
- if (RejectIncomingCall() != 0) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RejectIncomingCall() fail");\r
- return false;\r
- }\r
- }\r
- if (FinishCall() != 0) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FinishCall() fail");\r
- return false;\r
- }\r
- return true;\r
- } else if (strcmp(view.GetViewId(), "microphoneChange") == 0) {\r
- if (g_changeImage == 0) {\r
- g_changeImage = 1;\r
- RefreshMicrophoneImageSrc(PNG_MICROPHONE_CLOSE_IMAGE_PATH);\r
- SetMicMute(true);\r
- } else {\r
- g_changeImage = 0;\r
- RefreshMicrophoneImageSrc(PNG_MICROPHONE_OPEN_IMAGE_PATH);\r
- SetMicMute(false);\r
- }\r
- return true;\r
- } else if (strcmp(view.GetViewId(), "volumeSwitch") == 0) {\r
- HonrsViewChange();\r
- } else if (strcmp(view.GetViewId(), "newCallHandUp") == 0) {\r
- if (!HintsHandupClick()) {\r
- return false;\r
- }\r
- }\r
- if (strcmp(view.GetViewId(), "SOS_FAIL") == 0) {\r
- NotificationManager::GetInstance()->StopNotify();\r
- }\r
- return true;\r
-}\r
-} // namespace OHOS\r