Merge #1316 into sdk602patch0911 from refs/changes/1316/head
author袁清梦 <3449750381@qq.com>
Fri, 1 Nov 2024 08:53:18 +0000 (08:53 +0000)
committer袁清梦 <3449750381@qq.com>
Fri, 1 Nov 2024 08:53:18 +0000 (08:53 +0000)
Code review from 袁清梦

* refs/changes/1316/head: (3 commits squashed)

  - 遥控拍照:修复遥控拍照退出异常

  - 睡眠:优化睡眠弹窗topic发送

  - Merge branch &#39;sdk602patch0911&#39; 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 <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Reviewed-by: aliyun6865282430 <1624952103@qq.com>
Merged-by: Caisking <3449750381@qq.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1316
code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp
code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosModel.h
code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp

index 3703e8a..bc995c2 100644 (file)
@@ -485,7 +485,7 @@ extern "C"
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "20分钟后要睡觉啦!");\r
                     // 设置状态为睡眠提醒\r
                     OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::SLEEPNOTIFY);\r
-                    AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4);\r
+                    AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE,  NULL, 0);  \r
                 }\r
             }\r
             // 退出睡眠检测模式并进入小睡检测模式\r
@@ -532,7 +532,7 @@ extern "C"
                     //进入睡眠模式\r
                     OHOS::SleepModeModel::GetInstance().SetSleepModeEnabled();\r
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "要睡觉啦!!!! 开始");\r
-                    AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE,  NULL, 0);  \r
+                    AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, NULL, 0);  \r
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "要睡觉啦!!!! 结束");\r
                 }\r
 \r
index 7af14d4..c89e73b 100644 (file)
  * @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 <cmsis_os2.h>
 #include <service/graphic_service.h>
-#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