From: luozheng <1732036298@qq.com> Date: Mon, 20 Apr 2026 09:12:15 +0000 (+0800) Subject: application/wearable/ohos_deps 和application/wearable/service 文件夹1201patch合并提交 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=d9199203eecb1d425ec64c19edac218b27ca14f1;p=mirrors%2FFD230.git application/wearable/ohos_deps 和application/wearable/service 文件夹1201patch合并提交 --- diff --git a/code/sdk/application/wearable/n9/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/n9/service/broadcast/include/broadcast_feature.h index 42f1f9241..5872c1652 100644 --- a/code/sdk/application/wearable/n9/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/n9/service/broadcast/include/broadcast_feature.h @@ -49,7 +49,7 @@ typedef enum { TOPIC_EVENT_HFP_WATCH_TO_PHONE, TOPIC_EVENT_BLOODOXYGEN_UPDATA, TOPIC_EVENT_SPORT_DISTANCE, - TOPIC_EVENT_LOCATION, + TOPIC_EVENT_CALENDAR_NOTIFY, TOPIC_EVENT_HFP_HINT, #ifdef SUPPORT_CYWEE_SERVICE // TOPIC_EVENT_ACTIVITY_UPDATE, diff --git a/code/sdk/application/wearable/n9/service/device_msg/CMakeLists.txt b/code/sdk/application/wearable/n9/service/device_msg/CMakeLists.txt index 972f58f50..c3de1d51d 100644 --- a/code/sdk/application/wearable/n9/service/device_msg/CMakeLists.txt +++ b/code/sdk/application/wearable/n9/service/device_msg/CMakeLists.txt @@ -9,22 +9,26 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/innerkits + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/frameworks ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits ${ROOT_DIR}/middleware/services/media/foundation/audiomanager/interfaces/kits/audiomanager ${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks ${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits ${ROOT_DIR}/middleware/chips/brandy/nv/include ${ROOT_DIR}/middleware/chips/brandy/nv/nv_config + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/include ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include ${ROOT_DIR}/open_source/openharmony/base/sensors/location/interfaces/kits/include ${ROOT_DIR}/middleware/utils/dfx/diag/ + ${ROOT_DIR}/open_source/openharmony/third_party/cJSON + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits + ${ROOT_DIR}/application/wearable/nativeapp/nativeui/ ) set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/device_msg.cpp ${CMAKE_CURRENT_SOURCE_DIR}/device_proxy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/msg_center_device.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/device_location.cpp ) set(COMPONENT_PUBLIC_CCFLAGS diff --git a/code/sdk/application/wearable/n9/service/device_msg/device_msg.cpp b/code/sdk/application/wearable/n9/service/device_msg/device_msg.cpp index 3f54b45ab..79f0fc25a 100644 --- a/code/sdk/application/wearable/n9/service/device_msg/device_msg.cpp +++ b/code/sdk/application/wearable/n9/service/device_msg/device_msg.cpp @@ -1,9 +1,9 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: Breath Ease - * Author: wangle - * Create: 2025-4-23 + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. + * Description: Device Msg + * Create: 2025-06-06 */ + #include "msg_center_protocol.h" #include "msg_center_cmd.h" #include "ohos_init.h" @@ -14,8 +14,6 @@ #include "graphic_timer.h" #include "broadcast_feature.h" #include "ohos_timer.h" -#include "heartrate/HeartModel.h" -#include "device_location.h" #endif namespace OHOS { @@ -31,14 +29,7 @@ extern "C" { #define HEARTRATE_RANGE 60 static uint8_t g_rotation_publish = 0; static GraphicTimer *g_publishTestDataHandle = nullptr; -enum publishDataType { - PUBLISH_SETP = 0, - PUBLISH_DISTANCE, - PUBLISH_HEARTRATE, - PUBLISH_BLOODOXYGEN, - PUBLISH_TYPE_MAX -}; - +enum publishDataType { PUBLISH_SETP = 0, PUBLISH_DISTANCE, PUBLISH_HEARTRATE, PUBLISH_BLOODOXYGEN, PUBLISH_TYPE_MAX }; static void PublishTopicTestDataEvent(uint16_t topic, const void *data, size_t len) { int32_t ret; @@ -115,7 +106,7 @@ static void PublishTestDataCallback(void *) } } -void PublishTestData() +static void PublishTestData() { uint32 tick = GetOSTick(5000); // 5秒发布一次测试数据 if (g_publishTestDataHandle == nullptr) { @@ -141,28 +132,24 @@ static const msg_center_cmd_map_t g_msg_center_device_tbl[] = { {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_GET_STORAGE_INFO, msg_center_get_storage_info}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_GET_PRODUCT_INFO, msg_center_get_product_info}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_GET_LANGUAGE_ID, msg_center_get_language_id}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_GET_VOLUME_INFO, msg_center_get_volume_info}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SET_LANGUAGE_ID, msg_center_set_language_id}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SET_VOLUME_INFO, msg_center_set_volume_info}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_DEVICE_HEARTRATE, msg_center_device_heartrate}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_DEVICE_STEPDATA, msg_center_device_stepdata}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_DEVICE_BLOODOXYGEN, msg_center_device_bloodoxygen}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_OFFLINE_LOG_SWITCH, msg_center_offline_log_switch}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_LOCATION_GET_INFO, msg_center_location_get_info}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_LOCATION_START, msg_center_location_start}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_LOCATION_STOP, msg_center_location_stop}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SPORT_ACTION, msg_center_sport_action}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SPORT_GET_DATA, msg_center_sport_get_data}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SPORT_REPORT_DATA, msg_center_sport_report_data}, + {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SPORT_GET_RECORD, msg_center_sport_get_record}, #if (CONFIG_ONLINE_LOG == 1) {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SET_ONLINELOG_CHANNEL, msg_center_set_online_log_channel}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SET_ONLINELOG_LEVEL, msg_center_set_online_log_level}, #endif {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_OTA_INIT, msg_center_ota_init}, {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_OTA_UPDATE, msg_center_ota_update}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_OFF_FIND_PHONE, msg_center_device_findphone}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_CAMERA_WATCH_EXIT, msg_center_camera_exit}, - {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_CAMERA_CONNECT_PHONE_SUCCESS, msg_center_camera_online}, + {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_STOP_FIND_PHONE, msg_center_device_findphone}, + {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_WATCH_EXIT_CAMERA, msg_center_camera_exit}, + {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_CAMERA_CONNECTED_PHONE, msg_center_camera_online}, + {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SYNC_WEATHER_REC, msg_center_device_sync_weather_rec}, + {MSGCENTER_CMD_DEVICE, MSGCENTER_TYPE_ID_SYNC_DATE_REC, msg_center_device_sync_date_rec}, }; errcode_t msg_center_device_type_dispatch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) @@ -182,6 +169,9 @@ errcode_t msg_center_device_type_dispatch(uint8_t cmd_id, uint8_t type, void *us void device_init(void) { msg_center_register_cmd(MSGCENTER_CMD_DEVICE, msg_center_device_type_dispatch); +#ifdef PUBLISH_TEST_DATA + PublishTestData(); +#endif } APP_FEATURE_INIT_PRI(device_init, LAYER_INIT_LEVEL_4); diff --git a/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.cpp b/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.cpp index 5ef6fe6c3..80255a34d 100644 --- a/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.cpp +++ b/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.cpp @@ -1,19 +1,21 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: Breath Ease - * Author: wangle - * Create: 2025-4-23 + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. + * Description: MsgCenter Device + * Create: 2025-06-06 */ -#include "msg_center_protocol.h" + #include "msg_center_device.h" +#include "msg_center_protocol.h" #include "device_proxy.h" #include "wearable_log.h" -#include "device_location.h" #include "AppViewIDs.h" #include "NativeAbility.h" -// #include "sports/SportsModel.h" -// #include "findphone/FindPhoneMainPage.h" -// #include "camera/CameraMainPage.h" +#include "sport/SportView.h" +#include "sport/SportModel.h" +#include "findphone/FindPhoneMainPage.h" +#include "camera/CameraMainPage.h" +#include "weather/WeatherMainPage.h" +#include "date/DateMainPage.h" #ifdef __cplusplus extern "C" { @@ -22,10 +24,9 @@ extern "C" { #include "diag_ind_src.h" uint8_t g_bloodoxygen = 0; -uint16_t g_heartrate = 0; +uint8_t g_heartrate = 0; uint32_t g_stepdata = 0; uint32_t g_distance = 0; -extern LocationInfo_t g_locationInfo; // 获取电量 errcode_t msg_center_get_battery_level(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { @@ -100,29 +101,6 @@ errcode_t msg_center_get_language_id(uint8_t cmd_id, uint8_t type, void *usr_dat } return ERRCODE_SUCC; } -// 获取音量 -errcode_t msg_center_get_volume_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get_volume_info"); - uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); - void *v_data = msg_center_get_tlv_payload(usr_data); - uint8_t v_len = usr_len - tl_len; - - uint8_t vol_type = 0; - if (v_len == sizeof(uint8_t)) { - vol_type = *(uint8_t *)v_data; - } - - std::vector vol_info; - OHOS::device_proxy::get_volume_info(vol_type, vol_info); - - errcode_t ret = msg_center_send_data(cmd_id, type, &vol_info[0], vol_info.size() * sizeof(OHOS::volume_info)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "send get_volume_info_ack fail, ret = %d", ret); - return ERRCODE_FAIL; - } - return ERRCODE_SUCC; -} // 设置语言 errcode_t msg_center_set_language_id(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { @@ -147,30 +125,6 @@ errcode_t msg_center_set_language_id(uint8_t cmd_id, uint8_t type, void *usr_dat } return ERRCODE_SUCC; } -// 设置音量 -errcode_t msg_center_set_volume_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) -{ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "set_volume_info"); - uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); - void *v_data = msg_center_get_tlv_payload(usr_data); - uint8_t v_len = usr_len - tl_len; - - OHOS::volume_info info; - if (v_len != sizeof(OHOS::volume_info)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "v_len check error, v_len=%u, need=%u", v_len, sizeof(uint8_t)); - return ERRCODE_FAIL; - } - - memcpy_s(&info, sizeof(OHOS::volume_info), v_data, v_len); - OHOS::device_proxy::set_volume_info(info); - - errcode_t ret = msg_center_send_data(cmd_id, type, &info, sizeof(OHOS::volume_info)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "send set_volume_info_ack fail, ret = %d", ret); - return ERRCODE_FAIL; - } - return ERRCODE_SUCC; -} // ota初始化 errcode_t msg_center_ota_init(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { @@ -218,7 +172,7 @@ errcode_t msg_center_ota_update(uint8_t cmd_id, uint8_t type, void *usr_data, ui return ERRCODE_FAIL; } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "send ret = %d", ret); - OHOS::device_proxy::call_ui_ota_update(); + OHOS::device_proxy::call_ui_ota_update(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "send ui over"); return ERRCODE_SUCC; @@ -274,89 +228,6 @@ errcode_t msg_center_device_bloodoxygen(uint8_t cmd_id, uint8_t type, void *usr_ return ERRCODE_SUCC; } - -/* LOCATION */ -errcode_t msg_center_location_get_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) -{ - uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); - uint16_t payload_len = usr_len - tl_len; - uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); - errcode_t ret = ERRCODE_SUCC; - - ret = msg_center_send_data(cmd_id, type, &g_locationInfo, sizeof(g_locationInfo)); - if (ret != ERRCODE_SUCC) { - return ERRCODE_FAIL; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_get_info latitude_:%d,longitude_:%d\n", - g_locationInfo.latitude_, g_locationInfo.longitude_); - /* notify UI or call UI load */ - - return ERRCODE_SUCC; -} - -errcode_t msg_center_location_start(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) -{ - uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); - uint16_t payload_len = usr_len - tl_len; - uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); - errcode_t ret = ERRCODE_SUCC; - uint8_t ack = 1; - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_start finish\r\n"); - ret = deviceLocationStartLocating(); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_start fail\r\n"); - ret = msg_center_send_data(cmd_id, type, &ack, sizeof(ack)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_start send msg fail\r\n"); - return ERRCODE_FAIL; - } - } else { - ret = msg_center_send_data(cmd_id, type, &ack, sizeof(ack)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_start send msg fail\r\n"); - return ERRCODE_FAIL; - } - } - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_start finish\r\n"); - /* notify UI or call UI load */ - - return ERRCODE_SUCC; -} - -errcode_t msg_center_location_stop(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) -{ - uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); - uint16_t payload_len = usr_len - tl_len; - uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); - errcode_t ret = ERRCODE_SUCC; - uint8_t ack = 1; - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_stop\r\n"); - ret = deviceLocationStopLocating(); - ret = msg_center_send_data(cmd_id, type, &ack, sizeof(ack)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_stop fail\r\n"); - ret = msg_center_send_data(cmd_id, type, &ack, sizeof(ack)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_stop send msg fail\r\n"); - return ERRCODE_FAIL; - } - } else { - ret = msg_center_send_data(cmd_id, type, &ack, sizeof(ack)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_stop send msg fail\r\n"); - return ERRCODE_FAIL; - } - } - - WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_location_stop\r\n"); - /* notify UI or call UI load */ - - return ERRCODE_SUCC; -} - /* SPORT */ errcode_t msg_center_sport_action(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { @@ -365,82 +236,100 @@ errcode_t msg_center_sport_action(uint8_t cmd_id, uint8_t type, void *usr_data, uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); errcode_t ret = ERRCODE_SUCC; uint8_t ack = 1; - sport_action_t action = (sport_action_t)*tlv_payload; - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_action : %d\r\n", action); - - #ifdef FD230_650_0723 - switch (action) { - case SPORT_ACTION_START: - OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_SPORTS); - OHOS::SportsModel::GetInstance()->ResetSportsData(); - if (!OHOS::SportsModel::GetInstance()->StartSportsTimer()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_start StartSportsTimer failed\r\n"); - ret = ERRCODE_FAIL; - } + OHOS::sport_control_t *sport = (OHOS::sport_control_t *)tlv_payload; + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_action=%d, type=%d", sport->action, sport->type); + + switch (sport->action) { + case OHOS::SPORT_ACTION_START: + OHOS::SportModel::GetInstance().SetSportType(static_cast(sport->type)); + OHOS::SportModel::GetInstance().StartSport(false); + OHOS::NativeAbility::GetInstance().SwitchSlice(VIEW_SPORT, OHOS::SportPages::SPORT_PAGE_DATA); break; - case SPORT_ACTION_PAUSE: - OHOS::SportsModel::GetInstance()->StopSportsTimer(false); + case OHOS::SPORT_ACTION_PAUSE: + OHOS::SportModel::GetInstance().PauseAndReport(false); + OHOS::NativeAbility::GetInstance().SwitchSlice(VIEW_SPORT, OHOS::SportPages::SPORT_PAGE_PAUSE); break; - case SPORT_ACTION_RESUME: - if (!OHOS::SportsModel::GetInstance()->StartSportsTimer()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_resume StartSportsTimer failed\r\n"); - ret = ERRCODE_FAIL; - } + case OHOS::SPORT_ACTION_RESUME: + OHOS::SportModel::GetInstance().ResumeAndReport(false); + OHOS::NativeAbility::GetInstance().SwitchSlice(VIEW_SPORT, OHOS::SportPages::SPORT_PAGE_DATA); break; - case SPORT_ACTION_STOP: - OHOS::SportsModel::GetInstance()->StopSportsTimer(false); - OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + case OHOS::SPORT_ACTION_STOP: + OHOS::SportModel::GetInstance().StopAndReport(false); + OHOS::NativeAbility::GetInstance().SwitchSlice(VIEW_SPORT, OHOS::SportPages::SPORT_PAGE_MENU); break; default: ret = ERRCODE_FAIL; break; } - #endif ret = msg_center_send_data(cmd_id, type, &ack, sizeof(ack)); if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_resume send data failed\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_action send data failed\r\n"); return ERRCODE_FAIL; } return ERRCODE_SUCC; } -errcode_t msg_center_sport_get_data(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) +errcode_t msg_center_sport_get_record(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); uint16_t payload_len = usr_len - tl_len; uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); errcode_t ret = ERRCODE_SUCC; - WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_get_data\r\n"); - #ifdef FD230_650_0723 - OHOS::sport_data_t *sportData = OHOS::SportsModel::GetInstance()->GetSportsData(); - ret = msg_center_send_data(cmd_id, type, sportData, sizeof(OHOS::sport_data_t)); - if (ret != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_get_data end data failed\r\n"); + auto record = OHOS::SportModel::GetInstance().GetRecord(); + uint16_t num = record.size(); + uint16_t size = sizeof(uint16_t) + num * sizeof(OHOS::sport_data_t); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_get_record record num=%d, malloc szie=%d\r\n", num, + size); + uint8_t *data = (uint8_t *)malloc(size); + if (data == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_get_record malloc data failed\r\n"); return ERRCODE_FAIL; } - #endif - return ERRCODE_SUCC; -} + uint8_t *data_addr = data; + + memcpy_s(data, sizeof(uint16_t), &num, sizeof(uint16_t)); + data += sizeof(uint16_t); + + for (int i = 0; i < num; i++) { + memcpy_s(data, sizeof(OHOS::sport_data_t), &record[i], sizeof(OHOS::sport_data_t)); + data += sizeof(OHOS::sport_data_t); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "========record[%d]=============", i); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "type:%d", record[i].type); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "heartRate:%d", record[i].heartRate); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "calorie:%d", record[i].calorie); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "altitude:%d", record[i].altitude); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "ascent:%d", record[i].ascent); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "descent:%d", record[i].descent); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "distance:%d", record[i].distance); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "lap:%d", record[i].lap); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "startTime:%d", record[i].startTime); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "endTime:%d", record[i].endTime); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "elapsedTime:%d", record[i].elapsedTime); + } -errcode_t msg_center_sport_report_data(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) -{ + ret = msg_center_send_data(cmd_id, type, data_addr, size); + free(data_addr); + if (ret != ERRCODE_SUCC) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_sport_get_record send data failed\r\n"); + return ERRCODE_FAIL; + } + OHOS::SportModel::GetInstance().ClearRecord(); return ERRCODE_SUCC; } errcode_t msg_center_camera_exit(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "recv exit camera from phone"); - OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + OHOS::NativeAbility::GetInstance().ChangeSliceToApplist(); return ERRCODE_SUCC; } errcode_t msg_center_camera_online(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "recv connect success from phone"); - #ifdef FD230_650_0723 if (OHOS::CameraMainPage::GetInstance() != nullptr) { OHOS::CameraMainPage::GetInstance()->Refresh_page(); return ERRCODE_SUCC; @@ -448,8 +337,6 @@ errcode_t msg_center_camera_online(uint8_t cmd_id, uint8_t type, void *usr_data, WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "CameraMainPage not exist\r\n"); return ERRCODE_FAIL; } - #endif - return ERRCODE_SUCC; } errcode_t msg_center_offline_log_switch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) @@ -508,22 +395,38 @@ errcode_t msg_center_set_online_log_level(uint8_t cmd_id, uint8_t type, void *us errcode_t msg_center_device_findphone(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { - uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); - uint16_t payload_len = usr_len - tl_len; - uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); bool ret = true; - #ifdef FD230_650_0723 - if ( OHOS::FindPhoneMainPage::GetInstance() != nullptr) { + if (OHOS::FindPhoneMainPage::GetInstance() != nullptr) { ret = OHOS::FindPhoneMainPage::GetInstance()->StopFindPhone(); } else { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_MSG_CENTER, "FindphonePage not exist\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "FindphonePage not exist\r\n"); } if (!ret) { return ERRCODE_FAIL; } - #endif return ERRCODE_SUCC; } + +errcode_t msg_center_device_sync_weather_rec(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) +{ + if (OHOS::WeatherMainPage::GetInstance() != nullptr) { + OHOS::WeatherMainPage::GetInstance()->ReloadPage(); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "WeatherMainPage not exist\r\n"); + } + return ERRCODE_SUCC; +} + +errcode_t msg_center_device_sync_date_rec(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) +{ + if (OHOS::DateMainPage::GetInstance() != nullptr) { + OHOS::DateMainPage::GetInstance()->ReloadPage(); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "DateMainPage not exist\r\n"); + } + return ERRCODE_SUCC; +} + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.h b/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.h index 02f3c2583..57a66e464 100644 --- a/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.h +++ b/code/sdk/application/wearable/n9/service/device_msg/msg_center_device.h @@ -1,9 +1,9 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. - * Description: Breath Ease - * Author: wangle - * Create: 2025-4-23 + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. + * Description: MsgCenter Device + * Create: 2025-06-06 */ + #ifndef MSG_CENTER_DEVICE_H #define MSG_CENTER_DEVICE_H @@ -14,45 +14,37 @@ extern "C" { #endif -typedef enum sport_action { - SPORT_ACTION_START = 1, - SPORT_ACTION_PAUSE = 2, - SPORT_ACTION_RESUME = 3, - SPORT_ACTION_STOP = 4, -} sport_action_t; - typedef enum msg_center_device_type_id { - MSGCENTER_TYPE_ID_GET_BATTERY_LEVEL = 0x1, - MSGCENTER_TYPE_ID_GET_STORAGE_INFO = 0x2, - MSGCENTER_TYPE_ID_GET_PRODUCT_INFO = 0x3, - MSGCENTER_TYPE_ID_GET_LANGUAGE_ID = 0x4, - MSGCENTER_TYPE_ID_GET_VOLUME_INFO = 0x5, - MSGCENTER_TYPE_ID_SET_LANGUAGE_ID = 0x6, - MSGCENTER_TYPE_ID_SET_VOLUME_INFO = 0x7, - MSGCENTER_TYPE_ID_DEVICE_HEARTRATE = 0x8, - MSGCENTER_TYPE_ID_DEVICE_STEPDATA = 0x9, - MSGCENTER_TYPE_ID_DEVICE_BLOODOXYGEN = 0xa, - MSGCENTER_TYPE_ID_OFFLINE_LOG_SWITCH = 0xb, - MSGCENTER_TYPE_ID_LOCATION_GET_INFO = 0x20, - MSGCENTER_TYPE_ID_LOCATION_START = 0x21, - MSGCENTER_TYPE_ID_LOCATION_STOP = 0x22, - MSGCENTER_TYPE_ID_LOCATION_REPORT = 0x23, - MSGCENTER_TYPE_ID_SPORT_ACTION = 0x27, - MSGCENTER_TYPE_ID_SPORT_GET_DATA = 0x28, - MSGCENTER_TYPE_ID_SPORT_REPORT_DATA = 0x29, - MSGCENTER_TYPE_ID_SET_ONLINELOG_CHANNEL = 0x30, - MSGCENTER_TYPE_ID_SET_ONLINELOG_LEVEL = 0x31, - MSGCENTER_TYPE_ID_ONLINELOG_REPORT = 0x33, - MSGCENTER_TYPE_ID_OTA_INIT = 0x34, - MSGCENTER_TYPE_ID_OTA_UPDATE = 0x35, - MSGCENTER_TYPE_ID_ON_FIND_PHONE = 0x36, - MSGCENTER_TYPE_ID_OFF_FIND_PHONE = 0x37, - MSGCENTER_TYPE_ID_SLEEP_DATA = 0x38, - MSGCENTER_TYPE_ID_ON_CAMERA = 0x39, - MSGCENTER_TYPE_ID_CAMERA_WATCH_EXIT = 0x40, - MSGCENTER_TYPE_ID_CAMERA_PHONE_EXIT = 0x41, - MSGCENTER_TYPE_ID_CAMERA_CONNECT_PHONE = 0x42, - MSGCENTER_TYPE_ID_CAMERA_CONNECT_PHONE_SUCCESS = 0x43, + MSGCENTER_TYPE_ID_GET_BATTERY_LEVEL = 0x01, + MSGCENTER_TYPE_ID_GET_STORAGE_INFO = 0x02, + MSGCENTER_TYPE_ID_GET_PRODUCT_INFO = 0x03, + MSGCENTER_TYPE_ID_GET_LANGUAGE_ID = 0x04, + MSGCENTER_TYPE_ID_SET_LANGUAGE_ID = 0x05, + MSGCENTER_TYPE_ID_DEVICE_HEARTRATE = 0x06, + MSGCENTER_TYPE_ID_DEVICE_STEPDATA = 0x07, + MSGCENTER_TYPE_ID_DEVICE_BLOODOXYGEN = 0x08, + MSGCENTER_TYPE_ID_SPORT_ACTION = 0x09, + MSGCENTER_TYPE_ID_SPORT_REPORT_ACTION = 0x0a, + MSGCENTER_TYPE_ID_SPORT_REPORT_DATA = 0x0b, + MSGCENTER_TYPE_ID_SPORT_GET_RECORD = 0x0c, + MSGCENTER_TYPE_ID_SET_ONLINELOG_CHANNEL = 0x0d, + MSGCENTER_TYPE_ID_SET_ONLINELOG_LEVEL = 0x0e, + MSGCENTER_TYPE_ID_OFFLINE_LOG_SWITCH = 0x0f, + MSGCENTER_TYPE_ID_ONLINELOG_REPORT = 0x10, + MSGCENTER_TYPE_ID_START_FIND_PHONE = 0x11, + MSGCENTER_TYPE_ID_STOP_FIND_PHONE = 0x12, + MSGCENTER_TYPE_ID_SLEEP_DATA = 0x13, + MSGCENTER_TYPE_ID_ON_CAMERA = 0x14, + MSGCENTER_TYPE_ID_WATCH_EXIT_CAMERA = 0x15, + MSGCENTER_TYPE_ID_PHONE_EXIT_CAMERA = 0x16, + MSGCENTER_TYPE_ID_CAMERA_CONNECTING_PHONE = 0x17, + MSGCENTER_TYPE_ID_CAMERA_CONNECTED_PHONE = 0x18, + MSGCENTER_TYPE_ID_OTA_INIT = 0x19, + MSGCENTER_TYPE_ID_OTA_UPDATE = 0x1a, + MSGCENTER_TYPE_ID_SYNC_WEATHER_REQ = 0x1b, + MSGCENTER_TYPE_ID_SYNC_WEATHER_REC = 0x1c, + MSGCENTER_TYPE_ID_SYNC_DATE_REQ = 0x1d, + MSGCENTER_TYPE_ID_SYNC_DATE_REC = 0x1e, } msg_center_device_type_id_t; // 获取电量 @@ -63,12 +55,8 @@ errcode_t msg_center_get_storage_info(uint8_t cmd_id, uint8_t type, void *usr_da errcode_t msg_center_get_product_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); // 获取语言 errcode_t msg_center_get_language_id(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); -// 获取音量 -errcode_t msg_center_get_volume_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); // 设置语言 errcode_t msg_center_set_language_id(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); -// 设置音量 -errcode_t msg_center_set_volume_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); // ota初始化 errcode_t msg_center_ota_init(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); // ota检测和本地升级 @@ -78,15 +66,9 @@ errcode_t msg_center_device_heartrate(uint8_t cmd_id, uint8_t type, void *usr_da errcode_t msg_center_device_stepdata(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); errcode_t msg_center_device_bloodoxygen(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); -/* LOCATION */ -errcode_t msg_center_location_get_info(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); -errcode_t msg_center_location_start(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); -errcode_t msg_center_location_stop(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); - /* SPORT */ errcode_t msg_center_sport_action(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); -errcode_t msg_center_sport_get_data(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); -errcode_t msg_center_sport_report_data(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_sport_get_record(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); /* 离线日志开关 */ errcode_t msg_center_offline_log_switch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); @@ -94,6 +76,12 @@ errcode_t msg_center_offline_log_switch(uint8_t cmd_id, uint8_t type, void *usr_ /* 查找手机 */ errcode_t msg_center_device_findphone(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +/* 天气 */ +errcode_t msg_center_device_sync_weather_rec(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); + +/* 日历 */ +errcode_t msg_center_device_sync_date_rec(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); + /* CAMERA */ errcode_t msg_center_camera_exit(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); errcode_t msg_center_camera_online(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); diff --git a/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-cli/libmsg_center.a b/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-cli/libmsg_center.a index c6b588af4..f787fb876 100644 Binary files a/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-cli/libmsg_center.a and b/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-cli/libmsg_center.a differ diff --git a/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-ser/libmsg_center.a b/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-ser/libmsg_center.a index 19e2cb51d..59d450a64 100644 Binary files a/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-ser/libmsg_center.a and b/code/sdk/application/wearable/n9/service/msg_center/brandy-auto-ota-ser/libmsg_center.a differ diff --git a/code/sdk/application/wearable/n9/service/msg_center/brandy-native-js/libmsg_center.a b/code/sdk/application/wearable/n9/service/msg_center/brandy-native-js/libmsg_center.a index b1e105a9c..7e69f1c2a 100644 Binary files a/code/sdk/application/wearable/n9/service/msg_center/brandy-native-js/libmsg_center.a and b/code/sdk/application/wearable/n9/service/msg_center/brandy-native-js/libmsg_center.a differ diff --git a/code/sdk/application/wearable/n9/service/msg_center/brandy-xts/libmsg_center.a b/code/sdk/application/wearable/n9/service/msg_center/brandy-xts/libmsg_center.a index 7f842a9c9..26ab44fdc 100644 Binary files a/code/sdk/application/wearable/n9/service/msg_center/brandy-xts/libmsg_center.a and b/code/sdk/application/wearable/n9/service/msg_center/brandy-xts/libmsg_center.a differ diff --git a/code/sdk/application/wearable/n9/service/msg_center/include/notify/calendar_notification.h b/code/sdk/application/wearable/n9/service/msg_center/include/notify/calendar_notification.h new file mode 100644 index 000000000..4f341bbc5 --- /dev/null +++ b/code/sdk/application/wearable/n9/service/msg_center/include/notify/calendar_notification.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. + * Description: calendar notification api + * Author: CompanyName + * Create: 2025-10-23 + */ + +#ifndef CALENDAR_NOTIFICATION_H +#define CALENDAR_NOTIFICATION_H + +static constexpr const char* CALENDAR_IMAGE_DELETE = "calendar_delete"; +static constexpr const char* CALENDAR_IMAGE_CLOCK = "calendar_clock"; +static constexpr const char* CALENDAR_VIEW_CLOSE = "calendar_close"; +static constexpr const char* CALENDAR_VIEW_DELAY = "calendar_delay"; +static constexpr const char* CALENDAR_VIEW_POPUP = "calendar_popup"; + +enum class CalendarTimerType { + NOTIFY_CALENDAR_CLOSE = 0, + NOTIFY_CALENDAR_DELAY = 1, + NOTIFY_CALENDAR_RING = 2, + NOTIFY_CALENDAR_UNKNOWN = 10, +}; + +typedef struct { + int id; + int type; + int64_t startTime; + int64_t endTime; + bool isAllDay; + bool hasReminder; + bool isRepeat; + int64_t recurrenceFrequency; + char bundlename[64]; // 外部传入字符串,内部不负责释放 + char eventContent[256]; +} CalendarEvent; + + +namespace OHOS { +UIViewGroup* CreateCalendarView(CalendarEvent *event); +void FreeCalendarView(void); + +class CalendarViewEventListener : public OHOS::UIView::OnClickListener, + public OHOS::UIView::OnLongPressListener, + public OHOS::UIView::OnTouchListener, + public OHOS::UIView::OnDragListener { +public: + CalendarViewEventListener(); + virtual ~CalendarViewEventListener(); + static CalendarViewEventListener *GetInstance(void); + bool OnDrag(UIView& view, const DragEvent& event) override; + bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override; + bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override; + bool OnPress(OHOS::UIView& view, const OHOS::PressEvent& event) override + { + return true; + } + bool OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) override + { + return true; + } + bool OnRelease(OHOS::UIView& view, const OHOS::ReleaseEvent& event) override + { + return true; + } + + bool OnDragStart(OHOS::UIView& view, const OHOS::DragEvent& event) override + { + return true; + } +}; +}; // namespace OHOS + +#endif /* CALENDAR_NOTIFICATION_H */ \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/service/msg_center/include/notify/phone_msg_notification.h b/code/sdk/application/wearable/n9/service/msg_center/include/notify/phone_msg_notification.h index 735c01edf..8a4a34165 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/include/notify/phone_msg_notification.h +++ b/code/sdk/application/wearable/n9/service/msg_center/include/notify/phone_msg_notification.h @@ -1,19 +1,21 @@ /* * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved. - * Description: phone message notification - * Author: + * Description: phone message notification + * Author: * Create: 2025-04-25 */ #ifndef PHONE_MSG_NOTIFICATION_H #define PHONE_MSG_NOTIFICATION_H +#include #include "components/ui_view_group.h" #include "components/ui_view_group.h" #include "components/ui_label.h" +#include "components/ui_image_view.h" #include "components/ui_label_button_ext.h" +#include "components/ui_scroll_view.h" #include "graphic_timer.h" -#include struct PhoneMsg { std::string appName; @@ -29,11 +31,14 @@ public: static void UpDatePhoneMsg(std::string appName, std::string titile, std::string content); static void StartPhoneMsgTimer(int32_t interval); static void DisablePhoneMsgTimer(); + static void ShowDateMsg(std::string appName, std::string title, std::string content); + static void SetControl(); static const uint32_t notifyTime = 5000; private: - static UIViewGroup *phoneMsgView_; + static UIScrollView *phoneMsgView_; static UILabel *appNameLabel_; + static UIImageView *appIcon_; static UILabel *titleLabel_; static UILabel *contentLabel_; static GraphicTimer *phoneMsgNotifyStop_; diff --git a/code/sdk/application/wearable/n9/service/msg_center/src/common/msg_center_utils.cpp b/code/sdk/application/wearable/n9/service/msg_center/src/common/msg_center_utils.cpp index 56f8f9e11..6647df929 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/src/common/msg_center_utils.cpp +++ b/code/sdk/application/wearable/n9/service/msg_center/src/common/msg_center_utils.cpp @@ -14,6 +14,7 @@ #include "element_name.h" #include "abilityms_slite_client.h" #include +#include "appexecfwk_errors.h" #ifdef __cplusplus extern "C" { @@ -64,12 +65,15 @@ errcode_t msg_center_install_js_app(char *bundleName) bool msg_center_is_js_app_install(char *bundleName) { - InstallState installState; - uint8_t installProcess; - OHOS::BundleMsClient::GetInstance().GetInstallState(bundleName, &installState, &installProcess); - if (installState == BUNDLE_INSTALL_OK) { + if (bundleName == nullptr) { + return false; + } + BundleInfo bundleInfo; + uint8_t ret = OHOS::BundleMsClient::GetInstance().GetBundleInfo(bundleName, false, &bundleInfo); + if (ret == ERR_OK) { return true; } + return false; } diff --git a/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_msg_notification.cpp b/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_msg_notification.cpp index 73000e332..9000a1d69 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_msg_notification.cpp +++ b/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_msg_notification.cpp @@ -8,42 +8,46 @@ #include "ohos_timer.h" #include "wearable_log.h" #include -#include "message/include/MessageModel.h" +#include "main/MessageModel.h" +#include "ui_resource_message.h" +#include "common/image_cache_manager.h" +#include "main/LoadImg.h" namespace OHOS { // 三方应用名 -static const uint32_t APP_NAME_POS_X = 180; -static const uint32_t APP_NAME_POS_Y = 82; -static const uint32_t APP_NAME_WIDTH = 200; -static const uint32_t APP_NAME_HEIGHT = 60; +static const uint32_t APP_NAME_POS_X = 170; +static const uint32_t APP_NAME_POS_Y = 40; +static const uint32_t APP_NAME_WIDTH = 160; +static const uint32_t APP_NAME_HEIGHT = 53; // 三方消息主题 -static const uint32_t MSG_TITLE_POS_X = 81; -static const uint32_t MSG_TITLE_POS_Y = 122; -static const uint32_t MSG_TITLE_WIDTH = 409; -static const uint32_t MSG_TITLE_HEIGHT = 83; +static const uint32_t MSG_TITLE_POS_X = 15; +static const uint32_t MSG_TITLE_POS_Y = 138; +static const uint32_t MSG_TITLE_WIDTH = 370; +static const uint32_t MSG_TITLE_HEIGHT = 50; // 三方消息内容 -static const uint32_t MSG_CONTENT_POS_X = 78; -static const uint32_t MSG_CONTENT_POS_Y = 176; -static const uint32_t MSG_CONTENT_WIDTH = 457; -static const uint32_t MSG_CONTENT_HEIGHT = 269; -// 取消通知 -static const uint32_t CANCEL_BUTTON_POS_X = 150; -static const uint32_t CANCEL_BUTTON_POS_Y = 323; -static const uint32_t CANCEL_BUTTON_WIDTH = 165; -static const uint32_t CANCEL_BUTTON_HEIGHT = 44; +static const uint32_t MSG_CONTENT_POS_X = 15; +static const uint32_t MSG_CONTENT_POS_Y = 201; +static const uint32_t MSG_CONTENT_WIDTH = 370; +static const uint32_t MSG_CONTENT_HEIGHT = 200; +// 通知图标 +static const uint32_t MSG_ICON_POS_X = 130; +static const uint32_t MSG_ICON_POS_Y = 50; +static const uint32_t MSG_ICON_WIDTH = 40; +static const uint32_t MSG_ICON_HEIGHT = 40; +static const uint32_t MSG_PAGE_WIDTH = 454; // 设置字体大小 -static const uint32_t APP_NAME_FONT_SIZE = 20; -static const uint32_t MSG_TITLE_FONT_SIZE = 20; -static const uint32_t MSG_CONTENT_FONT_SIZE = 40; +static const uint32_t APP_NAME_FONT_SIZE = 38; +static const uint32_t MSG_TITLE_FONT_SIZE = 36; +static const uint32_t MSG_CONTENT_FONT_SIZE = 36; -UIViewGroup *PhoneMsgView::phoneMsgView_ = nullptr; +UIScrollView *PhoneMsgView::phoneMsgView_ = nullptr; UILabel *PhoneMsgView::appNameLabel_ = nullptr; +UIImageView *PhoneMsgView::appIcon_ = nullptr; UILabel *PhoneMsgView::titleLabel_ = nullptr; UILabel *PhoneMsgView::contentLabel_ = nullptr; GraphicTimer *PhoneMsgView::phoneMsgNotifyStop_ = nullptr; PhoneMsg PhoneMsgView::phoneMsg_; -UILabelButtonExt *PhoneMsgView::cancelButton_ = nullptr; void PhoneMsgStopNotifyCallback(void *data) { @@ -71,9 +75,11 @@ void PhoneMsgView::DisablePhoneMsgTimer() UIViewGroup *PhoneMsgView::CreatePhoneMsgView() { if (phoneMsgView_ == nullptr) { - phoneMsgView_ = new UIViewGroup(); - phoneMsgView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + phoneMsgView_ = new UIScrollView(); + phoneMsgView_->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); phoneMsgView_->SetViewId("phoneMsgView"); + phoneMsgView_->SetThrowDrag(true); + phoneMsgView_->SetScrollBlankSize(40); } if (appNameLabel_ == nullptr) { @@ -83,20 +89,22 @@ UIViewGroup *PhoneMsgView::CreatePhoneMsgView() appNameLabel_->SetText(phoneMsg_.appName.c_str()); appNameLabel_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, APP_NAME_FONT_SIZE); appNameLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - // Add to rootView phoneMsgView_->Add(appNameLabel_); - appNameLabel_->SetVisible(true); + + if (appIcon_ == nullptr) { + appIcon_ = new UIImageView(); + } + appIcon_->SetPosition(MSG_ICON_POS_X, MSG_ICON_POS_Y, MSG_ICON_WIDTH, MSG_ICON_HEIGHT); + phoneMsgView_->Add(appIcon_); + appIcon_->SetVisible(true); if (titleLabel_ == nullptr) { titleLabel_ = new UILabel(); } titleLabel_->SetPosition(MSG_TITLE_POS_X, MSG_TITLE_POS_Y, MSG_TITLE_WIDTH, MSG_TITLE_HEIGHT); - titleLabel_->SetText(phoneMsg_.msgTitle.c_str()); titleLabel_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MSG_TITLE_FONT_SIZE); titleLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - // Add to rootView phoneMsgView_->Add(titleLabel_); - titleLabel_->SetVisible(true); if (contentLabel_ == nullptr) { contentLabel_ = new UILabel(); @@ -105,21 +113,11 @@ UIViewGroup *PhoneMsgView::CreatePhoneMsgView() contentLabel_->SetText(phoneMsg_.msgContent.c_str()); contentLabel_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MSG_CONTENT_FONT_SIZE); contentLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - // Add to rootView + contentLabel_->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); phoneMsgView_->Add(contentLabel_); - contentLabel_->SetVisible(true); - - if (cancelButton_ == nullptr) { - cancelButton_ = new UILabelButtonExt(); - } - cancelButton_->SetPosition(CANCEL_BUTTON_POS_X, CANCEL_BUTTON_POS_Y, CANCEL_BUTTON_WIDTH, CANCEL_BUTTON_HEIGHT); - cancelButton_->SetViewId("cancelButton"); - cancelButton_->SetText("取消通知"); - cancelButton_->SetTouchable(true); - cancelButton_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, APP_NAME_FONT_SIZE); - // Add to rootView - phoneMsgView_->Add(cancelButton_); + SetControl(); + phoneMsgView_->Invalidate(); phoneMsgView_->SetDraggable(true); phoneMsgView_->SetTouchable(true); UIView::OnDragListener *dragListener = @@ -128,29 +126,78 @@ UIViewGroup *PhoneMsgView::CreatePhoneMsgView() static_cast(PhoneMsgViewEventListener::GetInstance()); phoneMsgView_->SetOnDragListener(dragListener); phoneMsgView_->SetOnClickListener(clickListener); - cancelButton_->SetOnClickListener(clickListener); StartPhoneMsgTimer(PhoneMsgView::notifyTime); NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreePhoneMsgView); return phoneMsgView_; } +void PhoneMsgView::SetControl() +{ + if (strcmp(phoneMsg_.appName.c_str(), "微信") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_WX); + } else if (strcmp(phoneMsg_.appName.c_str(), "QQ") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_QQ); + } else if (strcmp(phoneMsg_.appName.c_str(), "抖音") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_DY); + } else if (strcmp(phoneMsg_.appName.c_str(), "日历") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_CALENDAR); + } else if (strcmp(phoneMsg_.appName.c_str(), "信息") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_DUANXIN); + } else if (strcmp(phoneMsg_.appName.c_str(), "短信") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_DUANXIN); + } else if (strcmp(phoneMsg_.appName.c_str(), "今日头条") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_TOUTIAO); + } else if (strcmp(phoneMsg_.appName.c_str(), "微博") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_WB); + } else if (strcmp(phoneMsg_.appName.c_str(), "小红书") == 0) { + LOADIMG::LoadImageViewImg(appIcon_, MESSAGE_IMAGE, IMAGE_MESSAGE_XHS); + } + int controlOffset = 10; + int cut = 2; + int posX = (MSG_PAGE_WIDTH - appNameLabel_->GetTextWidth() - appIcon_->GetWidth() - controlOffset) / cut; + appIcon_->SetX(posX); + appNameLabel_->SetWidth(appNameLabel_->GetTextWidth()); + appNameLabel_->SetX(posX + appIcon_->GetWidth() + controlOffset); + + titleLabel_->SetText(phoneMsg_.msgTitle.c_str()); + if (titleLabel_->GetTextWidth() > MSG_TITLE_WIDTH) { + titleLabel_->SetWidth(MSG_TITLE_WIDTH); + } else { + titleLabel_->SetWidth(titleLabel_->GetTextWidth()); + } + titleLabel_->SetX((MSG_PAGE_WIDTH - titleLabel_->GetWidth()) / cut); + + int height = contentLabel_->GetTextHeight(); + contentLabel_->SetHeight(height); + posX = (MSG_PAGE_WIDTH - contentLabel_->GetWidth()) / cut; + contentLabel_->SetX(posX); +} + void PhoneMsgView::FreePhoneMsgView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FreePhoneMsgView"); if (phoneMsgView_ != nullptr) { DisablePhoneMsgTimer(); phoneMsgView_->RemoveAll(); + RootView::GetInstance()->Remove(phoneMsgView_); + delete phoneMsgView_; + phoneMsgView_ = nullptr; + } + if (appNameLabel_ != nullptr) { delete appNameLabel_; appNameLabel_ = nullptr; + } + if (appIcon_ != nullptr) { + delete appIcon_; + appIcon_ = nullptr; + } + if (titleLabel_ != nullptr) { delete titleLabel_; titleLabel_ = nullptr; + } + if (contentLabel_ != nullptr) { delete contentLabel_; contentLabel_ = nullptr; - delete cancelButton_; - cancelButton_ = nullptr; - RootView::GetInstance()->Remove(phoneMsgView_); - delete phoneMsgView_; - phoneMsgView_ = nullptr; } } @@ -159,9 +206,23 @@ void PhoneMsgView::UpDatePhoneMsg(std::string appName, std::string titile, std:: phoneMsg_.appName = appName; phoneMsg_.msgTitle = titile; phoneMsg_.msgContent = content; - #ifdef FD230_650_0723 - MessageModel::GetInstance().GetMessageInfo(appName, titile, content); - #endif + MessageModel::GetInstance().SaveMsgToModel(appName, titile, content); + MessageModel::GetInstance().SetMsgListItems(); +} + +static OHOS::UIViewGroup* ShowMsgNotify(void) +{ + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ShowMsgNotify"); + return OHOS::PhoneMsgView::CreatePhoneMsgView(); +} + +void PhoneMsgView::ShowDateMsg(std::string appName, std::string title, std::string content) +{ + const uint16_t TOPIC_DEMO_ALL_MSG = 10001; + UpDatePhoneMsg(appName, title, content); + int prio = 2; + NotificationManager::GetInstance()->SetNotifyPriority(prio); + NotificationManager::GetInstance()->ShowNotify(ShowMsgNotify, static_cast(TOPIC_DEMO_ALL_MSG), true); } PhoneMsgViewEventListener::PhoneMsgViewEventListener() @@ -190,7 +251,7 @@ bool PhoneMsgViewEventListener::OnDragEnd(UIView &view, const DragEvent &event) std::string viewId = view.GetViewId(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PhoneMsgViewEventListener OnDragEnd %s", viewId.c_str()); if (viewId == "phoneMsgView") { - NotificationManager::GetInstance()->StopNotify(); + // NotificationManager::GetInstance()->StopNotify(); } return true; } diff --git a/code/sdk/application/wearable/n9/service/remote_msg/phone_contacts.cpp b/code/sdk/application/wearable/n9/service/remote_msg/phone_contacts.cpp new file mode 100644 index 000000000..b55356a22 --- /dev/null +++ b/code/sdk/application/wearable/n9/service/remote_msg/phone_contacts.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. + * Description: PhoneContacts + * Create: 2025-07-12 + */ + +#include "wearable_log.h" +#include "message.h" +#include "PhoneMenuSync.h" +#include "phone_contacts.h" + +#ifdef __cplusplus +extern "C" { +#endif +uint8_t updata_contacts(Request *request) +{ + std::string content((char *)request->data, request->len); + uint8_t ret = OHOS::PhoneMenuSync::ParseContactsMsg(content); + if (ret != OHOS::OK) { + return ret; + } + OHOS::PhoneMenuSync::WriteFileContact(OHOS::CONTACTS_FILE_PATH, content); + return 0; +} + +uint8_t lookup_contacts(std::string &lookupContacts) +{ + return OHOS::PhoneMenuSync::LookContacts(lookupContacts); +} +#ifdef __cplusplus +} +#endif diff --git a/code/sdk/application/wearable/n9/service/remote_msg/phone_contacts.h b/code/sdk/application/wearable/n9/service/remote_msg/phone_contacts.h new file mode 100644 index 000000000..8e517a3f8 --- /dev/null +++ b/code/sdk/application/wearable/n9/service/remote_msg/phone_contacts.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. + * Description: PhoneContacts + * Create: 2025-07-12 + */ + +#ifndef PHONE_CONTACTS_H +#define PHONE_CONTACTS_H +#include +#include "message.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif +uint8_t updata_contacts(Request *request); // 同步手机侧联系人到表侧 +uint8_t lookup_contacts(std::string &lookupContacts); // 查询表侧联系人到手机 +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif /* PHONE_CONTACTS_H */ \ No newline at end of file diff --git a/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.cpp b/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.cpp index a33965430..5f8a4509f 100644 --- a/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.cpp +++ b/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.cpp @@ -1,8 +1,9 @@ /* - * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2025-2025. All rights reserved. * Description: ota upgrade handle. * This file should be changed only infrequently and with great care. */ + #include #include "securec.h" #include "msg_center.h" @@ -13,7 +14,9 @@ #include "msg_center.h" #include "msg_center_common.h" #include "ohos_init.h" +#include "phone_contacts.h" #include "remote_msg.h" + #ifdef __cplusplus extern "C" { #endif @@ -22,6 +25,8 @@ static const msg_center_cmd_map_t g_msg_center_phone_msg_tbl[] = { {MSGCENTER_CMD_PHONE_MSG, MSGCENTER_TYPE_ID_MSG_THIRD_APP, msg_center_phone_msg_rec}, {MSGCENTER_CMD_PHONE_MSG, MSGCENTER_TYPE_ID_MSG_SMS, msg_center_phone_msg_rec}, {MSGCENTER_CMD_PHONE_MSG, MSGCENTER_TYPE_ID_MSG_PHONE, msg_center_phone_msg_rec}, + {MSGCENTER_CMD_PHONE_MSG, MSGCENTER_TYPE_ID_UPDATE_CONTACTS, msg_center_update_contacts}, + {MSGCENTER_CMD_PHONE_MSG, MSGCENTER_TYPE_ID_LOOKUP_CONTACTS, msg_center_lookup_contacts}, }; errcode_t msg_center_phone_msg_rec(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) @@ -45,6 +50,50 @@ errcode_t msg_center_phone_msg_rec(uint8_t cmd_id, uint8_t type, void *usr_data, return ERRCODE_SUCC; } +errcode_t msg_center_update_contacts(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) +{ + uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); + uint16_t payload_len = usr_len - tl_len; + uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); + errcode_t ret = ERRCODE_SUCC; + uint8_t msg_result = 0; + WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "update_contacts, cmd_id = %d, type = %d\r\n", cmd_id, type); + Request request; + request.msgId = type; + request.len = payload_len; + request.data = tlv_payload; + updata_contacts(&request); + ret = msg_center_send_data(cmd_id, type, &msg_result, sizeof(msg_result)); + if (ret != ERRCODE_SUCC) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_update_contacts fail, ret = %d\r\n", ret); + return ERRCODE_FAIL; + } + return ERRCODE_SUCC; +} + +errcode_t msg_center_lookup_contacts(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) +{ + uint8_t tl_len = msg_center_get_tlv_tl_len(usr_data); + uint16_t payload_len = usr_len - tl_len; + uint8_t *tlv_payload = (uint8_t *)msg_center_get_tlv_payload(usr_data); + errcode_t ret = ERRCODE_SUCC; + uint8_t msg_result = 0; + WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "lookup_contacts, cmd_id = %d, type = %d\r\n", cmd_id, type); + std::string lookupContacts; + uint8_t result = lookup_contacts(lookupContacts); + if (!result) { + ret = msg_center_send_data(cmd_id, type, (void *)lookupContacts.c_str(), lookupContacts.size()); + } else { + ret = msg_center_send_data(cmd_id, type, (void *)&result, 1); + } + if (ret != ERRCODE_SUCC) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_lookup_contacts fail, ret = %d\r\n", ret); + return ERRCODE_FAIL; + } + return ERRCODE_SUCC; +} + + errcode_t msg_center_phone_msg_type_dispatch(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_MSG_CENTER, "msg_center_phone_msg_type_dispatch, cmd_id = %d, type = %d\r\n", diff --git a/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.h b/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.h index 2787377ff..e974e4c31 100644 --- a/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.h +++ b/code/sdk/application/wearable/n9/service/remote_msg/remote_msg.h @@ -20,10 +20,14 @@ typedef enum msg_center_phone_msg_type_id { MSGCENTER_TYPE_ID_MSG_THIRD_APP = 0x1, // 三方应用消息 MSGCENTER_TYPE_ID_MSG_SMS, // 短信 MSGCENTER_TYPE_ID_MSG_PHONE, // 电话 + MSGCENTER_TYPE_ID_UPDATE_CONTACTS, + MSGCENTER_TYPE_ID_LOOKUP_CONTACTS, MSGCENTER_TYPE_ID_MSG_MAX, } msg_center_msg_notify_type_id_t; errcode_t msg_center_phone_msg_rec(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_update_contacts(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); +errcode_t msg_center_lookup_contacts(uint8_t cmd_id, uint8_t type, void *usr_data, uint16_t usr_len); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/application/wearable/wearable/ohos_deps/wearable_log.h b/code/sdk/application/wearable/wearable/ohos_deps/wearable_log.h new file mode 100644 index 000000000..c2945d201 --- /dev/null +++ b/code/sdk/application/wearable/wearable/ohos_deps/wearable_log.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved. + * Description: Wearable log header file. + * Author: + * Create: + */ + +#ifndef WEARABLE_LOG_H +#define WEARABLE_LOG_H + +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) +#include "soc_diag_util.h" +#include "log_oam_logger.h" +#include "log_def.h" +#else +#include "debug_print.h" +#endif +#include "wearable_onlinelog.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/** + * @brief Enumerates logging module types. + * + * The module type must be globally unique. A maximum of 64 module types can be defined. + * + * @since 1.0 + * @version 1.0 + */ +typedef enum { + /** applications */ + WEARABLE_LOG_MODULE_APP = 0, + /** Launcher Framework */ + WEARABLE_LOG_MODULE_LAUNCHER_FWK, + /** Main Service */ + WEARABLE_LOG_MODULE_MAIN_SERVICE, + /** Broadcast Service */ + WEARABLE_LOG_MODULE_BROADCASE_SERVICE, + /** Atomic Ability Framework */ + WEARABLE_LOG_MODULE_AAFWK, + /** smart voice */ + WEARABLE_LOG_MODULE_SMART_VOICE, + /* UI SERVICE */ + WEARABLE_LOG_MODULE_UI_SERVICE, + /* msg_center */ + WEARABLE_LOG_MODULE_MSG_CENTER, + + WEARABLE_LOG_MODULE_MAX +} WearableLogModuleType; + +#if !defined(SW_UART_DEBUG) && !defined(SW_RTT_DEBUG) && !defined(CONFIG_ONLINE_LOG) +#define WEARABLE_LOGE(mod, fmt, arg...) uapi_diag_error_log(0, fmt, ##arg) +#define WEARABLE_LOGW(mod, fmt, arg...) uapi_diag_warning_log(0, fmt, ##arg) +#define WEARABLE_LOGI(mod, fmt, arg...) uapi_diag_info_log(0, fmt, ##arg) +#ifdef WEARABLE_LOG_DEBUG +#define WEARABLE_LOGD(mod, fmt, arg...) uapi_diag_debug_log(0, fmt, ##arg) +#else +#define WEARABLE_LOGD(mod, fmt, arg...) +#endif +#elif (CONFIG_ONLINE_LOG == 1) && !defined(_WIN32) +#define WEARABLE_LOGE(mod, fmt, arg...) ONLINE_PRINT(ONLINE_ERROR, fmt "\n", ##arg) +#define WEARABLE_LOGW(mod, fmt, arg...) ONLINE_PRINT(ONLINE_WARN, fmt "\n", ##arg) +#define WEARABLE_LOGI(mod, fmt, arg...) ONLINE_PRINT(ONLINE_INFO, fmt "\n", ##arg) +#ifdef WEARABLE_LOG_DEBUG +#define WEARABLE_LOGD(mod, fmt, arg...) ONLINE_PRINT(ONLINE_DEBUG, fmt "\n", ##arg) +#else +#define WEARABLE_LOGD(mod, fmt, arg...) +#endif +#else +#define WEARABLE_LOGE(mod, fmt, arg...) PRINT("[WEARABLE E/] " fmt "\n", ##arg) +#define WEARABLE_LOGW(mod, fmt, arg...) PRINT("[WEARABLE W/] " fmt "\n", ##arg) +#define WEARABLE_LOGI(mod, fmt, arg...) PRINT("[WEARABLE I/] " fmt "\n", ##arg) +#ifdef WEARABLE_LOG_DEBUG +#define WEARABLE_LOGD(mod, fmt, arg...) PRINT("[WEARABLE D/] " fmt "\n", ##arg) +#else +#define WEARABLE_LOGD(mod, fmt, arg...) +#endif +#endif + +#define CHECK_NULL_AND_RETURN(pointer, mod, fmt) \ + do { \ + if ((pointer) == nullptr) { \ + WEARABLE_LOGE((mod), (fmt)); \ + return; \ + } \ + } while (0) + +#define CHECK_NULL_AND_RETURN_NULL(pointer, mod, fmt) \ + do { \ + if ((pointer) == nullptr) { \ + WEARABLE_LOGE((mod), (fmt)); \ + return nullptr; \ + } \ + } while (0) + +#define CHECK_NULL_AND_RETURN_CODE(pointer, mod, fmt, code) \ + do { \ + if ((pointer) == nullptr) { \ + WEARABLE_LOGE((mod), (fmt)); \ + return (code); \ + } \ + } while (0) + +#define DELETE_IF_NOT_NULL(pointer) \ + do { \ + if ((pointer) != nullptr) { \ + delete (pointer); \ + (pointer) = nullptr; \ + } \ + } while (0) + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif