From 5424320a9be31ec93239c1050945152e208bfca7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Fri, 1 Nov 2024 08:53:18 +0000 Subject: [PATCH] Merge #1316 into sdk602patch0911 from refs/changes/1316/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/1316/head: (3 commits squashed) - 遥控拍照:修复遥控拍照退出异常 - 睡眠:优化睡眠弹窗topic发送 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: Caisking <3449750381@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1316 --- .../src/AlarmClockTimerConfig.cpp | 4 +- .../takephotos/include/TakephotosModel.h | 2 +- .../takephotos/src/TakephotosModel.cpp | 240 +++++++++--------- 3 files changed, 121 insertions(+), 125 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 3703e8ace..bc995c298 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -485,7 +485,7 @@ extern "C" WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "20分钟后要睡觉啦!"); // 设置状态为睡眠提醒 OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::SLEEPNOTIFY); - AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); + AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, NULL, 0); } } // 退出睡眠检测模式并进入小睡检测模式 @@ -532,7 +532,7 @@ extern "C" //进入睡眠模式 OHOS::SleepModeModel::GetInstance().SetSleepModeEnabled(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "要睡觉啦!!!! 开始"); - AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, NULL, 0); + AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, NULL, 0); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "要睡觉啦!!!! 结束"); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosModel.h b/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosModel.h index 1c82f4195..6fc9522c5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosModel.h @@ -8,7 +8,7 @@ #ifndef Takephotos_MODEL_H #define Takephotos_MODEL_H - +#include "TakephotosView.h" namespace OHOS { class TakephotosModel diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp index 7af14d404..c89e73b1d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp @@ -2,153 +2,149 @@ * @Date: 2024-07-06 16:27:31 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-07-15 20:30:24 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp */ /*** * @Date: 2024-05-09 17:46:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-05-09 18:05:27 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp + * @FilePath: + * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp */ +#include "takephotos/include/TakephotosModel.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "bleEvent.h" #include "broadcast_feature.h" #include "broadcast_service.h" +#include "custom_utils.h" #include "samgr_lite.h" +#include "takephotos/include/TakephotosView.h" +#include "thread_adapter.h" #include "vibrator_service.h" -#include "custom_utils.h" +#include "wearable_log.h" #include #include -#include "thread_adapter.h" -#include "wearable_log.h" -#include "takephotos/include/TakephotosView.h" -#include "takephotos/include/TakephotosModel.h" -#include "NativeAbility.h" -#include "AppViewIDs.h" -#include "bleEvent.h" #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - static void Notify(void *args, const Topic topic, Request *request); +static void Notify(void *args, const Topic topic, Request *request); - using namespace OHOS; +using namespace OHOS; - Subscriber TakephotosSubscirber = { - .identity = NULL, - .args = NULL, - .Notify = Notify, - }; - void TakephotosSubscribeTopic(Topic topic) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "stepsubscribeTopic, topic=%u", topic); - BroadcastApi *broadcastApi = NULL; - IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, BROADCAST_FEATURE_NAME); - if (api == NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stepsubscribeTopic, GetFeatureApi failed"); - return; - } - int result = api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); - if (result != 0 || broadcastApi == NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stepsubscribeTopic, QueryInterface failed"); - return; - } - broadcastApi->SubscribeTopic((IUnknown *)broadcastApi, topic, &TakephotosSubscirber); - broadcastApi->Release((IUnknown *)broadcastApi); - } +Subscriber TakephotosSubscirber = { + .identity = NULL, + .args = NULL, + .Notify = Notify, +}; +void TakephotosSubscribeTopic(Topic topic) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "stepsubscribeTopic, topic=%u", topic); + BroadcastApi *broadcastApi = NULL; + IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, + BROADCAST_FEATURE_NAME); + if (api == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "stepsubscribeTopic, GetFeatureApi failed"); + return; + } + int result = + api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); + if (result != 0 || broadcastApi == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "stepsubscribeTopic, QueryInterface failed"); + return; + } + broadcastApi->SubscribeTopic((IUnknown *)broadcastApi, topic, + &TakephotosSubscirber); + broadcastApi->Release((IUnknown *)broadcastApi); +} - void TakephotosUnsubscribeTopic(Topic topic) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TakephotosUnsubscribeTopic, topic=%u", topic); - BroadcastApi *broadcastApi = NULL; - IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, BROADCAST_FEATURE_NAME); - if (api == NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosUnsubscribeTopic, GetFeatureApi failed"); - return; - } - int result = api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); - if (result != 0 || broadcastApi == NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosUnsubscribeTopic, QueryInterface failed"); - return; - } - broadcastApi->UnsubscribeTopic((IUnknown *)broadcastApi, topic, &TakephotosSubscirber); - broadcastApi->Release((IUnknown *)broadcastApi); - } +void TakephotosUnsubscribeTopic(Topic topic) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TakephotosUnsubscribeTopic, topic=%u", + topic); + BroadcastApi *broadcastApi = NULL; + IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, + BROADCAST_FEATURE_NAME); + if (api == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "TakephotosUnsubscribeTopic, GetFeatureApi failed"); + return; + } + int result = + api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); + if (result != 0 || broadcastApi == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "TakephotosUnsubscribeTopic, QueryInterface failed"); + return; + } + broadcastApi->UnsubscribeTopic((IUnknown *)broadcastApi, topic, + &TakephotosSubscirber); + broadcastApi->Release((IUnknown *)broadcastApi); +} - static void Notify(void *args, const Topic topic, Request *request) - { - UNUSED(args); - UNUSED(topic); - if (request == NULL) - { - return; - } - // 进入拍照界面 - if (request->msgId == TOPIC_EVENT_ENTER_CMAERA) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 遥控拍照 \r\n"); - uapi_set_screen_on_api(); // 亮屏 - TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::TakePopup); - //获取当前界面Id - int16_t curviewid = OHOS::NativeAbility::GetInstance().GetCurSliceId(); - //已经处于遥控拍照界面 - if (curviewid == VIEW_TAKEPHOTOS) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TAKEPHOTOS); - } - else { - NativeAbility::GetInstance().EnterSlice(VIEW_TAKEPHOTOS); - } - } - // 退出拍照 - if (request->msgId == TOPIC_EVENT_CANCEL_CMAERA) - { - NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); - cameraSend(3); - TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::CreamPopup); - } +static void Notify(void *args, const Topic topic, Request *request) { + UNUSED(args); + UNUSED(topic); + if (request == NULL) { + return; + } + // 进入拍照界面 + if (request->msgId == TOPIC_EVENT_ENTER_CMAERA) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 遥控拍照 \r\n"); + uapi_set_screen_on_api(); // 亮屏 + TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::TakePopup); + //获取当前界面Id + int16_t curviewid = OHOS::NativeAbility::GetInstance().GetCurSliceId(); + //已经处于遥控拍照界面 + if (curviewid == VIEW_TAKEPHOTOS) { + NativeAbility::GetInstance().ChangeSlice(VIEW_TAKEPHOTOS); + } else { + NativeAbility::GetInstance().EnterSlice(VIEW_TAKEPHOTOS); } + } + // 退出拍照 + if (request->msgId == TOPIC_EVENT_CANCEL_CMAERA) { + //获取当前界面Id + int16_t curviewid = OHOS::NativeAbility::GetInstance().GetCurSliceId(); + //已经处于遥控拍照界面 + if (curviewid == VIEW_TAKEPHOTOS) { + NativeAbility::GetInstance().Back( + TransitionType::TRANSITION_BACK_TO_HEXAGONS); + cameraSend(3); + TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::CreamPopup); + } + } +} #ifdef __cplusplus } #endif -namespace OHOS -{ - TakephotosModel ::TakephotosModel() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosModel::TakephotosModel()"); - // sportdata->Initialize(); // 初始化结构体 - } - TakephotosModel ::~TakephotosModel() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosModel::~TakephotosModel()"); - TakephotosUnsubscribeTopic(TOPIC_EVENT_ENTER_CMAERA); // 取消订阅 - TakephotosUnsubscribeTopic(TOPIC_EVENT_CANCEL_CMAERA); - } - TakephotosModel *TakephotosModel::GetInstance(void) - { - static TakephotosModel instance; - return &instance; - } +namespace OHOS { +TakephotosModel ::TakephotosModel() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosModel::TakephotosModel()"); + // sportdata->Initialize(); // 初始化结构体 +} +TakephotosModel ::~TakephotosModel() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosModel::~TakephotosModel()"); + TakephotosUnsubscribeTopic(TOPIC_EVENT_ENTER_CMAERA); // 取消订阅 + TakephotosUnsubscribeTopic(TOPIC_EVENT_CANCEL_CMAERA); +} +TakephotosModel *TakephotosModel::GetInstance(void) { + static TakephotosModel instance; + return &instance; +} - void TakephotosModel ::Init() - { - TakephotosSubscribeTopic(TOPIC_EVENT_ENTER_CMAERA); // 进行消息订阅 - TakephotosSubscribeTopic(TOPIC_EVENT_CANCEL_CMAERA); - } +void TakephotosModel ::Init() { + TakephotosSubscribeTopic(TOPIC_EVENT_ENTER_CMAERA); // 进行消息订阅 + TakephotosSubscribeTopic(TOPIC_EVENT_CANCEL_CMAERA); +} - // 设置弹窗状态 - void TakephotosModel ::SetPopStaust(PopupPhoto status) - { - popupStatus = status; - } +// 设置弹窗状态 +void TakephotosModel ::SetPopStaust(PopupPhoto status) { popupStatus = status; } - // 获取弹窗状态 - PopupPhoto TakephotosModel ::GetPopStaust() - { - return popupStatus; - } -} \ No newline at end of file +// 获取弹窗状态 +PopupPhoto TakephotosModel ::GetPopStaust() { return popupStatus; } +} // namespace OHOS \ No newline at end of file -- 2.17.1