From dc3c2b1fcafa9b8f5e6fa6bb0057572e2e8b8953 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Mon, 19 May 2025 09:49:41 +0800 Subject: [PATCH] =?utf8?q?=E5=90=88=E5=B9=B6=E8=93=9D=E7=89=99=E6=9C=8D?= =?utf8?q?=E5=8A=A1=E7=AD=89=E5=BE=85=E5=90=8E=E7=BB=AD=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../brandy/brandy_standard/thread_pri_init.c | 3 +- .../nativeui/aivoice/src/AiVoiceModel.cpp | 4 +- .../nativeui/alarm/include/AlarmClockModel.h | 3 + .../nativeui/bluetooth/src/BluetoothModel.cpp | 30 +- .../bluetooth/src/BluetoothWrapper.cpp | 6 +- .../src/BluetoothServiceOptionsPresenter.cpp | 2 +- .../nativeui/findphone/src/FindPhoneModel.cpp | 2 +- .../nativeui/findphone/src/FindPhoneView.cpp | 2 +- .../health_service/health_service.h | 4 +- .../nativeui/makephone/src/CallingView.cpp | 2 +- .../makephone/src/MainCallingPresenter.cpp | 2 +- .../makephone/src/WaitingHintsView.cpp | 2 +- .../nativeui/message/include/MessageModel.h | 2 +- .../musicplayer/include/MusicPlayerModel.h | 3 + .../phone/include/phoneaddressmodel.h | 5 + .../nativeui/phone/src/phoneaddressmodel.cpp | 5 +- .../nativeui/player/include/PlayersModel.h | 16 + .../nativeui/player/src/PlayersModel.cpp | 28 + .../nativeui/saveele/src/SaveBatPresenter.cpp | 8 +- .../nativeui/set_dial/include/SetDialModel.h | 15 + .../nativeui/set_dial/src/SetDialModel.cpp | 19 +- .../set_dial/src/SetDialPresenter.cpp | 2 +- .../nativeui/settings/src/SettingModel.cpp | 24 +- .../nativeui/sleep/include/SleepModel.h | 13 + .../nativeui/sleep/src/SleepModel.cpp | 223 +++ .../nativeui/traing/include/TraingModel.h | 7 + .../nativeui/traing/src/TraingModel.cpp | 75 +- .../include/TraingCardPresenter.h | 2 +- .../nativeui/weather/include/WeatherModel.h | 5 + .../broadcast/src/broadcast_implement.c | 2 + .../fd230/service/msg_center/CMakeLists.txt | 5 + .../include/notify/pairing_notification.h | 45 + .../msg_center/include/notify/transmitting.h | 65 + .../msg_center/src/msg_center_customer.cpp | 152 +- .../src/notify/pairing_notification.cpp | 1029 +++++++++++++ .../msg_center/src/notify/transmitting.cpp | 1329 +++++++++++++++++ .../broadcast/include/broadcast_feature.h | 1 + .../service/msg_center/CMakeLists.txt | 2 + .../msg_center/include/notify/transmitting.h | 65 + .../msg_center/src/msg_center_customer.cpp | 147 +- .../src/notify/pairing_notification.cpp | 1027 +++++++++++++ .../msg_center/src/notify/transmitting.cpp | 1191 +++++++++++++++ .../config/target_config/brandy/config.py | 4 +- code/sdk/zhihui/config/src/ConfigModel.cpp | 2 +- .../ble_service/blemoder/CMakeLists.txt | 2 + .../ble_service/blemoder/bleInstruct.cpp | 16 +- .../ble_service/blemoder/bleInstruct.h | 24 +- .../blemoder/ble_congfig_adapt.cpp | 41 +- .../blemoder/ble_instruct_init.cpp | 36 + .../ble_service/bleservice/bleEvent.c | 346 +++-- .../ble_service/bleservice/bleEvent.h | 1 + .../ble_service/bleservice/bleService.c | 67 +- code/sdk/zhihui/utils/custom_utils.c | 13 +- code/sdk/zhihui/utilscpp/custom_utilscpp.cpp | 4 +- 54 files changed, 5925 insertions(+), 205 deletions(-) create mode 100644 code/sdk/application/wearable/fd230/service/msg_center/include/notify/pairing_notification.h create mode 100644 code/sdk/application/wearable/fd230/service/msg_center/include/notify/transmitting.h create mode 100644 code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp create mode 100644 code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp create mode 100644 code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h create mode 100644 code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp create mode 100644 code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp create mode 100644 code/sdk/zhihui/services/ble_service/blemoder/ble_instruct_init.cpp diff --git a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c index 74c3b2c22..b52c3568f 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c @@ -555,8 +555,9 @@ static void thread_main(const void *unused) /*启动蓝牙ble服务,cywee有重置 mac地址的操作,会需要把 蓝牙服务开启放在cywee服务之后*/ #ifdef CUSTOM_UTILS - start_custom_ble_service(); + #endif +start_custom_ble_service(); // #ifdef SUPPORT_ALIPAY_SEC // #if !defined(A5133_DEMO_SERVER) && !defined(A5133_DEMO_CLIENT) // uapi_alipay_svr_init(); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp index 3cdf4ef9a..2da9b74f5 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp @@ -609,7 +609,7 @@ namespace OHOS int type = GetCurUsingAiModelType(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "type = %d", type); #ifdef SUPPORT_BLE_SERVICE - streamingRecordAndSend_AI(type);//实时发送录音数据 + // streamingRecordAndSend_AI(type);//实时发送录音数据 #endif #else std::string audioPath = AiVoiceModel::GetInstance().GetAIAudioPath(); @@ -747,7 +747,7 @@ namespace OHOS { AiVoiceModel::GetInstance().SetErrnote("手机蓝牙已断开"); std::string str = AiVoiceModel::GetInstance().GetErrnote(); - SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + // SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); } #endif } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarm/include/AlarmClockModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarm/include/AlarmClockModel.h index 074df441b..4b56be534 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarm/include/AlarmClockModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarm/include/AlarmClockModel.h @@ -32,6 +32,9 @@ struct AlarmPlayerCaseInfo { char sliceId[ALARM_DEC_NUM_256]; int16_t index; }; +#ifdef BLE_INSTRUCT +void ble_alarm_init(void); +#endif // 播放器 class AlarmPlayerListener : public InterruptListener { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp index ccf14147d..4df37b612 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -49,7 +49,7 @@ #ifdef SUPPORT_BLE_SERVICE #include #include "bleService.h" -#include "bletest.h" +#include "bleInstruct.h" #endif //#include "hfp_hf_service.h" @@ -183,7 +183,7 @@ static int bluetooth_init_all(void) bluetooth_set_auto_reconnect_closed(1); ret = enable_bt_stack(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %u", ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %u", ret); // 设置安全连接 // gap_ble_sec_params_t sec_params = {0}; @@ -274,6 +274,10 @@ void bluetooth_enable_all(void) ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 0); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt gap_br_set_bt_scan_mode ret = %u", ret); /**开始ble广播*/ + + + // extern void custom_ble_service_start(void); + // custom_ble_service_start(); } } @@ -1178,7 +1182,7 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback: Mobile Phone Device"); if (state == GAP_ACL_STATE_DISCONNECTED) { /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ - SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); /* ---------------------------------- 补丁合入 ---------------------------------- */ @@ -1191,7 +1195,7 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_SCAN_MODE_CONNECTABLE"); } else if (state == GAP_ACL_STATE_CONNECTED) { - SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); /* ---------------------------------- 补丁合入 ---------------------------------- */ @@ -1265,14 +1269,14 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr)); #ifdef SUPPORT_BLE_SERVICE - SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0); + // SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0); uapi_dev_runtime_set_earphone_connect_stat(1); uapi_save_runtime_log(RUNTIME_LOG_BR_CONNECT_A2DP_HEADSET); - if(headset_Is_connect() == false) - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0); + // if(headset_Is_connect() == false) + // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0); #endif @@ -1283,7 +1287,7 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr)); #ifdef SUPPORT_BLE_SERVICE - SendMsgToUIService(EARPHONE_DISCONNECTED_TO_UI, 0, nullptr, 0); + // SendMsgToUIService(EARPHONE_DISCONNECTED_TO_UI, 0, nullptr, 0); #endif uapi_save_runtime_log(RUNTIME_LOG_BR_DISCONNECT_A2DP_HEADSET); @@ -1324,14 +1328,14 @@ static void BleConnStateChangeCallback(unsigned short connId, bd_addr_t *addr, g connId, connState, pairState); if (GAP_BLE_STATE_DISCONNECTED == connState) { // restart ble adv when disconnected /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ - SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); /* ---------------------------------- 补丁合入 ---------------------------------- */ // send to ace network net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_DISCONNECTED); /* -------------------------------------------------------------------------- */ } else { - SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); (void)memcpy_s(&g_bd_addr, sizeof(bd_addr_t), addr, sizeof(bd_addr_t)); /* ---------------------------------- 补丁合入 ---------------------------------- */ @@ -1586,7 +1590,7 @@ static void BtA2dpSnkConnectStateChangedCb(bd_addr_t *bd_addr, int conn_state) { #ifdef SUPPORT_BLE_SERVICE SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); - SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); #endif } @@ -1606,13 +1610,13 @@ static void BtA2dpSnkConnectStateChangedCb(bd_addr_t *bd_addr, int conn_state) if(cm_get_HFP_switch() && uapi_hfp_connect_state()==0) { - uapi_hfp_connect(); + // uapi_hfp_connect(); } #endif #ifdef SUPPORT_BLE_SERVICE SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); - SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothWrapper.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothWrapper.cpp index 92ff850aa..eaaafecca 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothWrapper.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/bluetooth/src/BluetoothWrapper.cpp @@ -308,7 +308,7 @@ errcode_t wrapper_gatts_add_service(uint8_t server_id, bt_uuid_t *service_uuid, extern "C" void custom_ble_service_start(void); void wrapper_gatts_service_start(void) { - // printf("wrapper_gatts_service_start \n"); + printf("wrapper_gatts_service_start \n"); if (!g_uuid_list.empty()) { bt_uuid_t &uuid = g_uuid_list.front(); bt_uuid_t uuid_tmp={0}; @@ -316,8 +316,8 @@ void wrapper_gatts_service_start(void) // 服务异步添加,需要保证当前服务start后,再添加下一个服务 // g_uuid_list.pop_front(); errcode_t ret = gatts_add_service(gatts_server_id, &uuid_tmp, true); - // printf("wrapper_gatts_service_start gatts_add_service uuid len %x [0x%02X%02X],gatts_server_id %u, ret 0x%x, g_uuid_list.size %d\n", - // uuid_tmp.uuid_len,uuid_tmp.uuid[0],uuid_tmp.uuid[1],gatts_server_id,ret,g_uuid_list.size()); + printf("wrapper_gatts_service_start gatts_add_service uuid len %x [0x%02X%02X],gatts_server_id %u, ret 0x%x, g_uuid_list.size %d\n", + uuid_tmp.uuid_len,uuid_tmp.uuid[0],uuid_tmp.uuid[1],gatts_server_id,ret,g_uuid_list.size()); } else { g_svr_handle_list.clear(); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp index c10398b62..8578af9ab 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp @@ -87,7 +87,7 @@ namespace OHOS { ConfigModel::GetInstance()->SetHFPState(true); #ifdef FD230_650 - uapi_hfp_connect(); + // uapi_hfp_connect(); #endif classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_HFP); } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneModel.cpp index 793eb46c4..cf1dd93c1 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneModel.cpp @@ -12,7 +12,7 @@ #ifdef SUPPORT_BLE_SERVICE #include "bleEvent.h" -#include "bletest.h" +#include "bleInstruct.h" #endif namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneView.cpp index ea029b8e9..7266a0e8b 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/findphone/src/FindPhoneView.cpp @@ -20,7 +20,7 @@ #include "uicomponents/UIComponents.h" #ifdef SUPPORT_BLE_SERVICE -#include "bletest.h" +#include "bleInstruct.h" #include "bleEvent.h" #endif namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heart_blood/health_service/health_service.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heart_blood/health_service/health_service.h index 9028f3933..84e61041a 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heart_blood/health_service/health_service.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heart_blood/health_service/health_service.h @@ -22,7 +22,9 @@ namespace OHOS { const char *GET_HEALTH_JSON_PATH_C_STR_HEART(); const char *GET_HEALTH_JSON_PATH_C_STR_OXYGEN(); - + #ifdef BLE_INSTRUCT + void ble_HEART_init(); + #endif typedef enum { HEALTH_TYPE_HEART, HEALTH_TYPE_OXYGEN, diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp index 0af088094..7bf58bc90 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/CallingView.cpp @@ -21,7 +21,7 @@ #ifdef SUPPORT_BLE_SERVICE #include #include "bleService.h" -#include "bletest.h" +#include "bleInstruct.h" #endif #include "ui_resource_string.h" diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp index 1f260fc22..f0a078991 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp @@ -29,7 +29,7 @@ #ifdef SUPPORT_BLE_SERVICE #include #include "bleService.h" -#include "bletest.h" +#include "bleInstruct.h" #endif #include "NativeAbility.h" diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp index c2a617090..9470a5c56 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/WaitingHintsView.cpp @@ -13,7 +13,7 @@ #ifdef SUPPORT_BLE_SERVICE #include #include "bleService.h" -#include "bletest.h" +#include "bleInstruct.h" #endif #include "custom_utils.h" diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/message/include/MessageModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/message/include/MessageModel.h index 14178597c..ce8f886f7 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/message/include/MessageModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/message/include/MessageModel.h @@ -6,7 +6,7 @@ #ifdef SUPPORT_BLE_SERVICE #include #include "bleService.h" -#include "bletest.h" +#include "bleInstruct.h" #endif #include "message/include/MessagePresenter.h" diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/musicplayer/include/MusicPlayerModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/musicplayer/include/MusicPlayerModel.h index 61c477429..0c0966daa 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/musicplayer/include/MusicPlayerModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/musicplayer/include/MusicPlayerModel.h @@ -14,6 +14,9 @@ namespace OHOS { + #ifdef BLE_INSTRUCT + void ble_play_init(); + #endif class MusicPlayerModel { public: diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h index f79b08122..82ddb325f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/include/phoneaddressmodel.h @@ -20,6 +20,11 @@ struct phone_number }; +#ifdef BLE_INSTRUCT +void ble_addressbook_init(); +#endif + + struct Contact { char name[NAME_LEN]; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp index 825398cda..a1ac7b263 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/phoneaddressmodel.cpp @@ -468,11 +468,14 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneaddressbook::~phoneaddressbook"); } - + #ifdef BLE_INSTRUCT + void ble_addressbook_init(void); + #endif phoneaddressbook &phoneaddressbook::GetInstance() { static phoneaddressbook instance; + return instance; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/include/PlayersModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/include/PlayersModel.h index 0ad29d78c..f3faff759 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/include/PlayersModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/include/PlayersModel.h @@ -20,6 +20,22 @@ #include "bts_avrcp_controller.h" #include "PlayersCaseListAdapter.h" #include +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +void ble_mp3_init(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + namespace OHOS { using OHOS::Media::Player; using OHOS::Media::Source; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp index 7e33d902f..d9e1f80c4 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/player/src/PlayersModel.cpp @@ -1300,6 +1300,34 @@ extern "C" return false; } +#ifdef BLE_INSTRUCT + +#include "bleEvent.h" +#include "bleInstruct.h" + + +bool IS_free_save_Mp3_(uint32_t size) +{ + return canSyncMusic(size); +} + +void ble_mp3_list_update_(void) +{ + // SendMsgToUIService(UI_UPDATE_MUSIC_PLAYER_LIST,0,nullptr,0); +} + + + +extern bleInstruct_t_ bleInstruct_t; + +// void ble_mp3_init(void) +// { +// bleInstruct_t.IS_free_save_Mp3=IS_free_save_Mp3_; +// bleInstruct_t.ble_mp3_list_update=ble_mp3_list_update_; + +// } + +#endif #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatPresenter.cpp index c4be16f9d..a78300ac0 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatPresenter.cpp @@ -51,13 +51,13 @@ void SaveBatPresenter::OnStart() { Presenter::OnStart(); // 1.获取原drag #ifdef CUSTOM_UTILS - drag_x = get_drag_limit(0); - drag_y = get_drag_limit(1); + // drag_x = get_drag_limit(0); + // drag_y = get_drag_limit(1); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "drag_x:%d,drag_y:%d", drag_x, drag_y); // 2.设置drag - enable_drag(0, 0); - enable_drag(1, 0); + // enable_drag(0, 0); + // enable_drag(1, 0); #endif } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h index 9b37bc11c..043f27d34 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h @@ -4,6 +4,19 @@ #include "AppViewIDs.h" #include "SetDialInfo.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ +void ble_dial_init(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + namespace OHOS { // 表盘类型 @@ -12,6 +25,8 @@ namespace OHOS DEFULTDIAL, DOWNLOADDIAL, }; + + typedef struct DialLayout_ { uint16_t dialId; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp index 2f364f847..17be6291a 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp @@ -4,7 +4,7 @@ #include "NativeAbility.h" #ifdef SUPPORT_BLE_SERVICE #include "bleEvent.h" -#include "bletest.h" +#include "bleInstruct.h" #endif #include "clock/include/MainClockView.h" #include "custom_runtime.h" @@ -1007,6 +1007,13 @@ bool SetDialModel::CheckDialDownload(uint16_t ID, uint32_t dial_size) { #include "bleEvent.h" #include "bleInstruct.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + uint8_t get_dial_num_() { return OHOS::SetDialModel::GetInstance().GetDialCount(); @@ -1125,7 +1132,7 @@ void install_Register_dial_( char * name,uint16_t id) extern bleInstruct_t_ bleInstruct_t; -void ble_dial_init() +void ble_dial_init(void) { bleInstruct_t.get_dial_num_cb= get_dial_num_; bleInstruct_t.check_dial_freespace= check_dial_freespace_; @@ -1146,6 +1153,14 @@ void ble_dial_init() bleInstruct_t.install_Register_dial= install_Register_dial_; } + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + #endif } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp index 462eb9712..3d1a2ad6b 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp @@ -20,7 +20,7 @@ #include "common/key_code.h" #ifdef SUPPORT_BLE_SERVICE #include "bleEvent.h" -#include "bletest.h" +#include "bleInstruct.h" #endif #include "NativeRegisterManager.h" diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingModel.cpp index 2ef68abe8..276788979 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingModel.cpp @@ -97,14 +97,14 @@ namespace OHOS bool SettingModel::GetBlueToothConnectStatus(void) { #if SUPPORT_BLE_SERVICE - if(!uapi_a2dp_snk_get_device_connect_state()&& !uapi_hfp_connect_state()) - { - btConnectStatus = false; - } - else - { - btConnectStatus = true; - } + // if(!uapi_a2dp_snk_get_device_connect_state()&& !uapi_hfp_connect_state()) + // { + // btConnectStatus = false; + // } + // else + // { + // btConnectStatus = true; + // } #else btConnectStatus = false; #endif @@ -152,10 +152,10 @@ namespace OHOS if (PullUpDownView::GetInstance() != nullptr) { #if SUPPORT_BLE_SERVICE - if(!uapi_a2dp_snk_get_device_connect_state()&& !uapi_hfp_connect_state()) - PullUpDownView::GetInstance()->UpdateBlueToothStatus(false); - else - PullUpDownView::GetInstance()->UpdateBlueToothStatus(true); + // if(!uapi_a2dp_snk_get_device_connect_state()&& !uapi_hfp_connect_state()) + // PullUpDownView::GetInstance()->UpdateBlueToothStatus(false); + // else + // PullUpDownView::GetInstance()->UpdateBlueToothStatus(true); #else PullUpDownView::GetInstance()->UpdateBlueToothStatus(false); #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/include/SleepModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/include/SleepModel.h index 2a4f8faa5..d7cf716df 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/include/SleepModel.h @@ -21,6 +21,19 @@ #define SLEEP_STATUS_LENGTH 80 +#ifdef __cplusplus +#if __cplusplus + extern "C" + { +#endif /* __cplusplus */ +#endif /* __cplusplus */ +void ble_sleep_init(void); + +#ifdef __cplusplus +#if __cplusplus + } +#endif /* __cplusplus */ +#endif /* __cplusplus */ namespace OHOS { #pragma pack(push, 1) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/src/SleepModel.cpp index b4024fd01..be9972899 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleep/src/SleepModel.cpp @@ -1009,6 +1009,229 @@ namespace OHOS nap_update_timestamp = nap_data.wake_up_timestamp; } +#ifdef BLE_INSTRUCT + +#include "bleEvent.h" +#include "bleInstruct.h" + + + + uint8_t ble_get_sleep_data_(uint32_t file_size,uint8_t day_,uint8_t *data) +{ + char dir_path[64]={0}; + char day[12]={0}; + uapi_get_YYMMDD_Time_extend(day,'\0', day_); + sprintf_s(dir_path,64,SLEEP_DIR_PATH,day); + + uint32_t offset=0; + uint8_t sleep_count=1; + + { + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,"nap.bin"); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," fopen fail %s\r\n",file_path); + } + else + { + uint16_t sleep_file_size=0; + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + sleep_file_size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + + int mod_value=0; + mod_value=sleep_file_size%14; + if(mod_value!=0) + return 0; + uint8_t nap_count=sleep_file_size/14; + + sleep_count=nap_count+1; + + uint16_t read_size =fread(data,1,sleep_file_size,fp); + offset+=read_size; + fclose(fp); + } + } + { + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,"sleep_time.bin"); + FILE * fp = fopen(file_path,"rb+"); + if(fp) + { + uint16_t sleep_file_size=0; + + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + sleep_file_size = ftell(fp); // 获取当前文件指针位置,即文件大小 + sleep_file_size++; + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + + memcpy(data+offset,&sleep_file_size,2); + *(data+offset+2)=sleep_count; + sleep_count++; + uint16_t read_size =fread(data+offset+3,1,sleep_file_size,fp); + + if((read_size+1)!=sleep_file_size) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," fread fail read_size:%d!= sleep_file_size:%d \r\n",read_size,sleep_file_size); + } + + fclose(fp); + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,"sleep_status.bin"); + fp = fopen(file_path,"rb+"); + sleep_file_size=0; + if(fp) + { + fseek(fp, 0, SEEK_END); + sleep_file_size = ftell(fp); + fseek(fp, 0, SEEK_SET); + uint16_t read_size_status =fread(data+offset+3+read_size,1,sleep_file_size,fp); + read_size+=read_size_status; + read_size+=1; + memcpy(data+offset,&read_size,2); + fclose(fp); + + } + offset+=read_size; + offset+=3; + } + } + + return offset; +} + + + + +uint8_t ble_get_sleep_data_dir_(uint32_t *file_size,uint8_t day_) +{ + char dir_path[64]={0}; + char day[12]={0}; + uapi_get_YYMMDD_Time_extend(day,'\0', day_); + sprintf_s(dir_path,64,SLEEP_DIR_PATH,day); + + struct DIR *dir; + struct dirent *ent; + + + uint8_t file_count=0; + + if ((dir = opendir(dir_path)) != NULL) + { + while ((ent = readdir(dir)) != NULL) + { + std::string fileName = ent->d_name; + if (fileName != "." && fileName != "..") + { + + if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件 + { + + if(fileName=="sleep_time.bin") + { + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," fopen fail %s\r\n",file_path); + return file_count; + } + + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + *file_size += ftell(fp)+3; // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + fclose(fp); + } + file_count++; + } + else if (fileName=="sleep_status.bin") + { + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," fopen fail %s\r\n",file_path); + return file_count; + } + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + *file_size += ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + fclose(fp); + } + } + else if(fileName=="nap.bin") + { + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," fopen fail %s\r\n",file_path); + return file_count; + } + uint32_t size=0; + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + size= ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + fclose(fp); + } + int mod_value=0; + + mod_value=size%14; + if(mod_value!=0) + return 0; + + uint8_t nap_count=size/14; + *file_size+=nap_count*14; + + file_count+=nap_count; + } + + } + } + else if (ent->d_type == DT_DIR) // 目录 + { + continue; + } + } + } + else + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," opendir fail %s\r\n",dir_path); + return file_count; + } + closedir(dir); + + return file_count; +} + + +extern bleInstruct_t_ bleInstruct_t; + +void ble_sleep_init(void) +{ + + bleInstruct_t.ble_get_sleep_data=ble_get_sleep_data_; + bleInstruct_t.ble_get_sleep_data_dir=ble_get_sleep_data_dir_; + + + +} + +#endif #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingModel.h index 6a969d712..02212aba8 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingModel.h @@ -94,6 +94,11 @@ Trainingdata *read_Trainingdata_data(char *timedata, uint16_t offset); int write_Trainingdata_data(Trainingdata data); +#ifdef BLE_INSTRUCT +void ble_training_init(void); +#endif + + #ifdef __cplusplus } #endif @@ -126,6 +131,8 @@ namespace OHOS { #define MAXSPORTID 176 + + // 运动状态 enum class ExerciseState { End = 0, diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp index 597821675..299e5232e 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp @@ -27,7 +27,7 @@ #ifdef BLE_SERVER_ENABLE #include "bleEvent.h" -#include "bletest.h" +#include "bleInstruct.h" #include "bleService.h" #endif @@ -2370,6 +2370,11 @@ bool TraingModel::LoadDataFormJson(std::vector &sportDataVector) { #include "bleInstruct.h" //////////////////////////////ble//////////////////////////////////////////// +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ bool get_training_spead_path_(char *path ,uint32_t time,uint32_t max_len) { @@ -2397,13 +2402,79 @@ bool get_training_heart_path_(char *path ,uint32_t time,uint32_t max_len) return true; } +char * struct_to_json_buf_malloc_(uint8_t day) +{ + cJSON *dataJSON = cJSON_CreateObject(); + cJSON* data_arryJSON = cJSON_CreateArray(); + struct Trainingdata * data=NULL; + int i=0; + //char file_path[128] = {0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time_extend(timeday, '_',day); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%s\r\n",timeday); + //sprintf(file_path, "%s%s.bin", TRAINING_PATH_BLE, timeday); + + while(data=read_Trainingdata_data(timeday, i)) + { + cJSON* itemJSON = cJSON_CreateObject(); + if(data!=NULL) + { + cJSON_AddNumberToObject(itemJSON,"src",data->src); + cJSON_AddNumberToObject(itemJSON,"bt",data->bt); + cJSON_AddNumberToObject(itemJSON,"ty",data->ty); + cJSON_AddNumberToObject(itemJSON,"st",data->st); + cJSON_AddNumberToObject(itemJSON,"sp",data->sp); + cJSON_AddNumberToObject(itemJSON,"tgt",data->tgt); + cJSON_AddNumberToObject(itemJSON,"tg",data->tg); + cJSON_AddNumberToObject(itemJSON,"pg",data->pg); + cJSON_AddNumberToObject(itemJSON,"du",data->du); + cJSON_AddNumberToObject(itemJSON,"ca",data->ca); + cJSON_AddNumberToObject(itemJSON,"di",data->di); + cJSON_AddNumberToObject(itemJSON,"hr",data->hr); + cJSON_AddNumberToObject(itemJSON,"stp",data->stp); + cJSON_AddNumberToObject(itemJSON,"ti",data->ti); + cJSON_AddNumberToObject(itemJSON,"cir",data->cir); + cJSON_AddNumberToObject(itemJSON,"alt",data->alt); + cJSON_AddNumberToObject(itemJSON,"apc",data->apc); + cJSON_AddNumberToObject(itemJSON,"fpc",data->fpc); + cJSON_AddNumberToObject(itemJSON,"spc",data->spc); + cJSON_AddNumberToObject(itemJSON,"std",data->std); + cJSON_AddNumberToObject(itemJSON,"cdc",data->cdc); + + cJSON_AddItemReferenceToArray(data_arryJSON,itemJSON); + free(data); + data=NULL; + } + else{ + break; + } + i++; + } + cJSON_AddItemToObject(dataJSON,"recs",data_arryJSON); + + char *json_format = cJSON_PrintUnformatted(dataJSON); + + int pSize = cJSON_GetArraySize(dataJSON); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"训练历史数据:%s\r\n",json_format); + cJSON_Delete(dataJSON); + return json_format; +} + + extern bleInstruct_t_ bleInstruct_t; -void ble_training_init() +void ble_training_init(void) { bleInstruct_t.get_training_spead_path_cb= get_training_spead_path_; bleInstruct_t.get_training_heart_path_cb= get_training_heart_path_; + bleInstruct_t.struct_to_json_buf_malloc= struct_to_json_buf_malloc_; +} + +#ifdef __cplusplus +#if __cplusplus } +#endif /* __cplusplus */ +#endif /* __cplusplus */ #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardPresenter.h index b2f2fdd26..8e46e56c1 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardPresenter.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardPresenter.h @@ -12,7 +12,7 @@ #ifdef SUPPORT_BLE_SERVICE #include #include "bleService.h" -#include "bletest.h" +#include "bleInstruct.h" #endif #include "components/root_view.h" diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/weather/include/WeatherModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/weather/include/WeatherModel.h index c3343153e..eb2f19ced 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/weather/include/WeatherModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/weather/include/WeatherModel.h @@ -14,6 +14,11 @@ #include "weather/include/FutureWeatherListAdapter.h" namespace OHOS { + +#ifdef BLE_INSTRUCT +void ble_weather_init(); +#endif + #if __cplusplus extern "C" { diff --git a/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c index 2560ff487..62a936e3b 100644 --- a/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c @@ -32,6 +32,8 @@ static const TopicToCore topicToCoreArray[] = { {TOPIC_EVENT_HFP_FINISHED, A_CORE_MASK, 1}, {TOPIC_EVENT_HFP_PHONE_TO_WATCH, A_CORE_MASK, 1}, {TOPIC_EVENT_HFP_WATCH_TO_PHONE, A_CORE_MASK, 1}, + {TOPIC_EVENT_DEVICE_BIND, A_CORE_MASK, 1}, + {TOPIC_EVENT_BLE_TRANSMIT, A_CORE_MASK, 1}, }; /* 所有的topic,其对应的位图 */ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt index 1a21912b2..59ce45d7a 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt @@ -145,6 +145,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_utils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/transmitting.cpp ) else() set(SOURCES @@ -154,6 +156,9 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/transmitting.cpp + ) endif() diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/notify/pairing_notification.h b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/pairing_notification.h new file mode 100644 index 000000000..62318a6f3 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/pairing_notification.h @@ -0,0 +1,45 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-22 09:48:07 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-12-23 18:15:47 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h + */ +#ifndef PAIRING_NOTIFICATION_H +#define PAIRING_NOTIFICATION_H + +// #include "BaseView.h" +namespace OHOS +{ + UIViewGroup *CreateDeviceBindingView(void); + UIViewGroup *CreateDeviceUnBindingView(void); + UIViewGroup *CreateDeviceUnbindingRequestGroupView(void); + UIViewGroup *showShutDownAnimation(void); + void set_shutDownAnimation_falg(uint8_t falg); + + void FreeDeviceBindingView(void); + void FreeDeviceUnBindingView(void); + void FreeDeviceUnbindingRequestGroupView(void); + class PairingViewEventListener : public OHOS::UIView::OnClickListener,public RootView::OnKeyActListener + { + public: + static PairingViewEventListener &GetInstance(void); + bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + void SetDeviceName(char *Name); + char *GetDeviceName(); + void DeviceUnBindingViewIsVisible(bool state); + void Pairing_StartTimer(uint32_t interval = 1000 * 40); + void Pairing_StopTimer(void); + char DeviceName[50]; + + private: + PairingViewEventListener(); + ~PairingViewEventListener(); + PairingViewEventListener(const PairingViewEventListener &) = delete; + const PairingViewEventListener &operator=(const PairingViewEventListener &) = delete; + }; + +} + +#endif diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/notify/transmitting.h b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/transmitting.h new file mode 100644 index 000000000..3c16f7cd3 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/transmitting.h @@ -0,0 +1,65 @@ +#ifndef TRANSMITTING_H +#define TRANSMITTING_H +#include "components/ui_image_animator.h" +#include "bleInstruct.h" +#include "components/ui_view_group.h" + +namespace OHOS +{ + // UIViewGroup *ChargingStatuShow(void); + // UIView *view_ = nullptr; + + #ifdef __cplusplus +#if __cplusplus +extern "C" { + void get_updatafail_data(void); +}; +#endif + +#endif + + UIViewGroup* transmittingShow(void); + bool transmittingISShow(void); + void set_transmittingShow_falg(uint8_t falg); + void Freetransmitting(void); + + + class transmittingViewEventListener : public OHOS::UIView::OnClickListener, + public OHOS::UIView::OnLongPressListener, + public OHOS::UIView::OnTouchListener, + public OHOS::UIView::OnDragListener + { +public: + transmittingViewEventListener(); + virtual ~transmittingViewEventListener(); + static transmittingViewEventListener *GetInstance(void); + + bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override; + bool OnDrag(UIView& view, const DragEvent& event) override + { + return true; + } + bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override + { + return true; + } + virtual bool OnPress(OHOS::UIView& view, const OHOS::PressEvent& event) override + { + return true; + } + virtual bool OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) override + { + return true; + } + virtual bool OnRelease(OHOS::UIView& view, const OHOS::ReleaseEvent& event) override + { + return true; + } + + virtual bool OnDragStart(OHOS::UIView& view, const OHOS::DragEvent& event) override + { + return true; + } +}; +}; +#endif /* CHARGE_NOTIFICATION_H */ \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp index b2522644d..b0ceb311d 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp @@ -33,6 +33,10 @@ #include "VolumeSettingView.h" #include "VolumeSettingPresenter.h" #include "VolumeSettingView.h" +#include "pairing_notification.h" +#include "bleInstruct.h" +#include "transmitting.h" + namespace OHOS { #ifdef __cplusplus @@ -49,6 +53,11 @@ const PriorityMapper PRI_MAPPER[] = { {TOPIC_EVENT_HFP_WATCH_ACTIVE, PRIORITY_ONE}, {TOPIC_EVENT_HFP_WATCH_TO_PHONE, PRIORITY_ONE}, {TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE}, + {TOPIC_EVENT_DEVICE_BIND, PRIORITY_ONE}, + {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE} + // {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO}, + // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, PRIORITY_TWO}, + }; bool g_pressFlag = false; @@ -81,6 +90,9 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_FINISHED); MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_PHONE_TO_WATCH); MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_TO_PHONE); + MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND); + MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRANSMIT); + } static OHOS::UIViewGroup* ShowAlarmNotify(void) @@ -103,6 +115,29 @@ 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* showtransmitNotify(void) +{ + return OHOS::transmittingShow(); +} + void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -178,6 +213,115 @@ void MsgCenterNotifyHfpWatchProc(const Topic topic, Request* req) } } +void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req) +{ + //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; + uint8_t len_name = req->len; + char devname[len_name]; + if(data!=NULL && req->len>=2) + { + switch(data[0]) + { + case DEVICEBIND: + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + len_name = req->len-2; + memset(devname,0,len_name); + if(len_name > 0) + { + memcpy(devname,(char *)req->data+2,len_name); + PairingViewEventListener::GetInstance().SetDeviceName(devname); + }else{ + PairingViewEventListener::GetInstance().SetDeviceName(NULL); + } + NotificationManager::GetInstance()->ShowNotify(showDeviceBindingNotify, (uint16_t)topic, true); + break; + case DEVICEUNBIND: + + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + len_name = req->len-2; + memset(devname,0,len_name); + if(len_name > 0) + { + memcpy(devname,(char *)req->data+2,len_name); + // printf("devname:%s\r\n",devname); + 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; + } + + } + +} +void MsgCenterNotifybleTransmit(const Topic topic, Request* req) +{ + unused(topic); + uint8_t* data=(uint8_t*)req->data; + + + 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); + } + // unused(req); + +} /* 订阅事件通知逻辑可定制 */ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_ALARM_RING, MsgCenterNotifyAlarmProc}, @@ -188,6 +332,12 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_HFP_WATCH_TO_PHONE, MsgCenterNotifyHfpPhoneProc}, {TOPIC_EVENT_HFP_WATCH_ACTIVE, MsgCenterNotifyHfpWatchProc}, {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc}, + {TOPIC_EVENT_BLE_TRANSMIT, MsgCenterNotifybleTransmit}, + + {TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc}, + // {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc}, + // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, MsgCenterNotifyDeviceUnBindingRequestProc}, + }; static MsgCenterNotifyTable *MsgCenterGetNotifyTblCb(uint8_t idx) @@ -318,7 +468,7 @@ bool MsgCenterNotifyProc(const Topic topic, Request* req) } } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: Can not find the cb!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: Can not find the cb!"); return false; } diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp new file mode 100644 index 000000000..5319d241c --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp @@ -0,0 +1,1029 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-22 10:04:36 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2025-01-15 11:34:47 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp + */ +#include "notification_manager.h" +#include "wearable_log.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_animator.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" +#ifdef SUPPORT_BLE_SERVICE +#include "bleEvent.h" +#endif + +#include +#include +#include +#include +#include "iostream" +#include +#include +#include "uicomponents/UIComponents.h" +#include "ConfigModel.h" +#include +#include "pairing_notification.h" + +// #include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h" +// #include +// #include "rebootandshutdown/include/ShutDownImageAnimatorView.h" +namespace OHOS +{ + UIViewGroup *DeviceBindingView{nullptr}; + UIScrollView *DeviceBindingScrollView{nullptr}; + UILabelExt *DeviceBindingViewTitleLabel{nullptr}; // 标题 :设备绑定 + UILabelExt *DeviceBindingName{nullptr}; // 绑定的设备名称 + UIButton *DeviceBindingButtonOK{nullptr}; // 设备绑定确认 + UIButton *DeviceBindingButtonCancel{nullptr}; // 设备绑定取消 + + UIImageAnimatorView *DeviceBindingAnimatorView{nullptr}; // 设备绑定动画 + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_X = 183; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_Y = 125; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_W = 100; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_H = 66; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE = 70; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 25; // 绑定动画帧数 + const ImageInfo **BindPathsArray{nullptr}; + ImageAnimatorInfo BindImageInfo[BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; + static constexpr const char *BIND_IMAGE_SRC = "/user/res/remind/bind/"; + + UIViewGroup *DeviceUnBindingView{nullptr}; + UIScrollView *DeviceUnBindingScrollView{nullptr}; + UILabelExt *DeviceUnBindingViewTitleLabel{nullptr}; // 标题 :设备解绑 + UILabelExt *DeviceUnBindingName{nullptr}; // 解绑的设备名称 + UIButton *DeviceUnBindingButtonOK{nullptr}; // 设备解绑定确认 + UIButton *DeviceUnBindingButtonCancel{nullptr}; // 设备解绑取消 + + UIImageAnimatorView *DeviceUnBindingAnimatorView{nullptr}; // 设备解绑动画 + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_X = 193; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_Y = 118; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_W = 80; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_H = 80; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE = 100; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 25; // 解绑动画帧数 + const ImageInfo **UnBindPathsArray{nullptr}; + ImageAnimatorInfo UnBindImageInfo[UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; + static constexpr const char *UNBIND_IMAGE_SRC = "/user/res/remind/unbind/"; + + UIViewGroup *DeviceUnbindingRequestGroupView{nullptr}; + UIScrollView *DeviceUnbindingRequestScrollView{nullptr}; // 设备解除绑定请求(与新设备连接)视图 + UILabelExt *DeviceUnbindingRequestViewTitleLabel{nullptr}; // 标题 :注意 + UIImageView *DeviceUnbindingRequestViewImageView{nullptr}; // + UILabelExt *DeviceUnbindingRequestViewLabel[3]{nullptr}; // + UIButton *DeviceUnbindingRequestButtonOK{nullptr}; // 设备解除绑定请求(与新设备连接)确认 + UIButton *DeviceUnbindingRequestButtonCancel{nullptr}; // 设备解除绑定请求(与新设备连接)取消 + + // ShutDownImageAnimatorView *p_ShutDownImageAnimatorView{nullptr}; // 关机动画 + // UIViewGroup *ShutDownImageAnimatorGroupView{nullptr}; + + // ShutDownImageAnimatorView *shutDownImageAnimatorView{nullptr}; // 关机动画 + // UIViewGroup *shutDownImageAnimatorGroupView{nullptr}; + + PairingViewEventListener::PairingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::PairingViewEventListener"); + } + + PairingViewEventListener::~PairingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::~PairingViewEventListener"); + } + + PairingViewEventListener &PairingViewEventListener::GetInstance(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::GetInstance"); + static PairingViewEventListener instance; + return instance; + } + + bool PairingViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::OnClick"); + UNUSED(event); + if (&view == DeviceBindingButtonCancel) // 设备绑定取消按钮 + { + PairingViewEventListener::GetInstance().Pairing_StopTimer(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonCancel OnClick"); +// 终止当前的绑定流程并关闭相关的通知界面。 +#ifdef SUPPORT_BLE_SERVICE + comfirmPaire(0); +#endif + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceBindingButtonOK) // 设备绑定确认按钮 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonOK OnClick"); + /* + * 可能会执行的绑定流程: + * 1.启动绑定过程. + * 2.更新设备绑定状态. + * 3.发送绑定请求到设备或服务器等. + */ + PairingViewEventListener::GetInstance().Pairing_StopTimer(); +// 关闭通知界面 +#ifdef SUPPORT_BLE_SERVICE + comfirmPaire(1); +#endif + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceUnBindingButtonCancel) // 设备解绑取消按钮 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonCancel OnClick"); +// 不想执行解绑动作,并关闭解绑的通知界面。 +#ifdef SUPPORT_BLE_SERVICE + cleanUnbindInfor(0); +#endif + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceUnBindingButtonOK) // 设备解绑确认按钮 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonOK OnClick"); + // 切换到再次确认解绑弹窗 + if (DeviceUnbindingRequestGroupView == nullptr) + { + RootView::GetInstance()->Add(CreateDeviceUnbindingRequestGroupView()); + } + DeviceUnBindingViewIsVisible(false); + } + else if (&view == DeviceUnbindingRequestButtonOK) // 设备解除绑定请求(与新设备连接)确认 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonOK OnClick"); + // if (p_ShutDownImageAnimatorView == nullptr) + // { + // p_ShutDownImageAnimatorView = new ShutDownImageAnimatorView(); + // if (p_ShutDownImageAnimatorView == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_ShutDownImageAnimatorView new fail!!"); + // return false; + // } + // ShutDownImageAnimatorGroupView = p_ShutDownImageAnimatorView->ShutDownAnimatorViewInit(); + // if (ShutDownImageAnimatorGroupView == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorGroupView new fail!!"); + // return false; + // } + // DeviceUnbindingRequestGroupView->SetVisible(false); + // /* -------------------------------------------------------------------------- */ + // RootView::GetInstance()->ClearOnKeyActListener(); + // RootView::GetInstance()->SetOnKeyActListener(this); + // /* -------------------------------------------------------------------------- */ + // RootView::GetInstance()->Add(ShutDownImageAnimatorGroupView); + // } + // ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(3); + } + else if (&view == DeviceUnbindingRequestButtonCancel) // 设备解除绑定请求(与新设备连接)取消 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonCancel OnClick"); + DeviceUnBindingViewIsVisible(true); + } + return true; + } + + bool PairingViewEventListener::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + //消耗按键事件 + return true; + } + + static UIButton *CreateButton(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const char *imageSrc) + { + UIButton *button = new UIButton(); + if (button == nullptr) + { + return nullptr; + } + button->SetPosition(x, y, w, h); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x19); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button->SetImageSrc(imageSrc, imageSrc); + return button; + } + + void PairingViewEventListener::SetDeviceName(char *Name) + { + // printf("Name:%s\r\n",Name); + memset(DeviceName, 0, sizeof(DeviceName)); + if (Name == NULL) + { + strcpy(DeviceName, "phone"); + return; + } + int len = strlen(Name); + if (len > sizeof(DeviceName)) + len = sizeof(DeviceName); + Name[len] = '\0'; + + memcpy(DeviceName, Name, len); + } + + void PairingViewEventListener::DeviceUnBindingViewIsVisible(bool state) + { + if (DeviceUnBindingView && DeviceUnbindingRequestGroupView) + { + DeviceUnBindingView->SetVisible(state); + DeviceUnbindingRequestGroupView->SetVisible(!state); + } + } + + /*获取设备名称*/ + char *PairingViewEventListener::GetDeviceName(void) + { + return DeviceName; + } + + /* + * @brief 创建设备绑定视图 + */ + UIViewGroup *CreateDeviceBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView]"); + /* ---------------------------- DeviceBindingView --------------------------- */ + if (DeviceBindingView == nullptr) + { + DeviceBindingView = new UIViewGroup(); + if (nullptr == DeviceBindingView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingView new fail!!"); + return nullptr; + } + DeviceBindingView->SetPosition(0, 0, 466, 466); + DeviceBindingView->SetDraggable(true); + DeviceBindingView->SetTouchable(true); + /* ------------------------- DeviceBindingScrollView ------------------------ */ + if (DeviceBindingScrollView == nullptr) + { + DeviceBindingScrollView = new UIScrollView(); + if (DeviceBindingScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeviceBindingScrollView new fail"); + return nullptr; + } + } + DeviceBindingScrollView->SetPosition(0, 0, 466, 466); + DeviceBindingScrollView->SetThrowDrag(true); + DeviceBindingScrollView->SetDraggable(true); + DeviceBindingScrollView->SetTouchable(true); + DeviceBindingScrollView->SetReboundSize(30); + DeviceBindingScrollView->SetScrollBlankSize(30); + DeviceBindingScrollView->SetSwipeACCLevel(200); // 800: compensation distance + DeviceBindingScrollView->SetDragACCLevel(5); // 5: drag acceleration + DeviceBindingScrollView->SetMaxScrollDistance(1000); + DeviceBindingScrollView->SetDirection(UIScrollView::VERTICAL); + DeviceBindingScrollView->RequestFocus(); + DeviceBindingScrollView->SetRotateFactor(1.0); + /* ----------------------- DeviceBindingViewTitleLabel ---------------------- */ + if (DeviceBindingViewTitleLabel == nullptr) + { + DeviceBindingViewTitleLabel = new UILabelExt(); + if (DeviceBindingViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingViewTitleLabel new fail!!"); + return nullptr; + } + } + DeviceBindingViewTitleLabel->SetPosition(83, 50, 300, 35); + DeviceBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + + // DeviceBindingViewTitleLabel->SetText("设备绑定"); + DeviceBindingViewTitleLabel->SetTextId(STR_DEVICE_BINDING); + DeviceBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + DeviceBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + DeviceBindingViewTitleLabel->SetRollSpeed(23); + /* ----------------------- DeviceBindingAnimatorView ---------------------- */ + BindPathsArray = CreateImageInfoArray(BIND_IMAGE_SRC, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + if (DeviceBindingAnimatorView == nullptr) + { + DeviceBindingAnimatorView = new UIImageAnimatorView(); + if (DeviceBindingAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]DeviceBindingAnimatorView new fail"); + return nullptr; + } + for (uint8_t i = 0; i < BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + BindImageInfo[i].imageInfo = (BindPathsArray[i]); + BindImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; + BindImageInfo[i].pos.x = BIND_IMAGE_ANIMATOR_VIEW_X; + BindImageInfo[i].pos.y = BIND_IMAGE_ANIMATOR_VIEW_Y; + BindImageInfo[i].width = BIND_IMAGE_ANIMATOR_VIEW_W; + BindImageInfo[i].height = BIND_IMAGE_ANIMATOR_VIEW_H; + } + DeviceBindingAnimatorView->SetPosition(BIND_IMAGE_ANIMATOR_VIEW_X, BIND_IMAGE_ANIMATOR_VIEW_Y, BIND_IMAGE_ANIMATOR_VIEW_W, BIND_IMAGE_ANIMATOR_VIEW_H); + DeviceBindingAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + DeviceBindingAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + DeviceBindingAnimatorView->SetImageAnimatorSrc(BindImageInfo, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, BIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE); + DeviceBindingAnimatorView->SetRepeat(true); + DeviceBindingAnimatorView->SetAutoEnable(false); + DeviceBindingAnimatorView->SetResizeMode(UIImageAnimatorView::CENTER); + DeviceBindingAnimatorView->Start(); + DeviceBindingAnimatorView->SetSizeFixed(true); + } + /* ---------------------------- DeviceBindingName --------------------------- */ + if (DeviceBindingName == nullptr) + { + DeviceBindingName = new UILabelExt(); + if (DeviceBindingName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingName new fail!!"); + return nullptr; + } + } + + char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); + DeviceBindingName->SetPosition(53, 230, 360, 70); + DeviceBindingName->SetStyle(STYLE_TEXT_FONT, 30); + DeviceBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceBindingName->SetTextId(STR_DEVICE_BINDING_NOTE); // XX想要与你进行连接绑定 + + if (strlen(devanme)) + { + // DeviceBindingName->SetText(devanme); + UpdateLabel(DeviceBindingName, devanme, STR_DEVICE_BINDING_NOTE); + } + else + { + // DeviceBindingName->SetText(" "); + UpdateLabel(DeviceBindingName, " ", STR_DEVICE_BINDING_NOTE); + } + DeviceBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + DeviceBindingName->SetRollSpeed(23); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + int y = DeviceBindingName->GetY() + DeviceBindingName->GetTextHeight() + 20; + DeviceBindingButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); + if (DeviceBindingButtonCancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingButtonCancel new fail!!"); + return nullptr; + } + /* -------------------------------- DeviceBindingButtonOK -------------------------------- */ + DeviceBindingButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); + if (DeviceBindingButtonOK == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingButtonOK new fail!!"); + return nullptr; + } + + UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); + if (listener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] PairingViewEventListener::GetInstance fail!!"); + return nullptr; + } + DeviceBindingButtonCancel->SetOnClickListener(listener); + DeviceBindingButtonOK->SetOnClickListener(listener); + /* ----------------------------------- Add ---------------------------------- */ + DeviceBindingScrollView->Add(DeviceBindingViewTitleLabel); + DeviceBindingScrollView->Add(DeviceBindingAnimatorView); + DeviceBindingScrollView->Add(DeviceBindingName); + DeviceBindingScrollView->Add(DeviceBindingButtonCancel); + DeviceBindingScrollView->Add(DeviceBindingButtonOK); + DeviceBindingView->Add(DeviceBindingScrollView); + } + + // 震动一次 + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + // ui_api_vibrate_once_func(); + } + + // ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 + + PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 + + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceBindingView); + return DeviceBindingView; + } + + /* + * @brief 创建设备解绑视图 + */ + UIViewGroup *CreateDeviceUnBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]"); + /* ---------------------------- DeviceUnBindingView --------------------------- */ + if (DeviceUnBindingView == nullptr) + { + DeviceUnBindingView = new UIViewGroup(); + if (nullptr == DeviceUnBindingView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new fail!!"); + return nullptr; + } + DeviceUnBindingView->SetPosition(0, 0, 466, 466); + DeviceUnBindingView->SetDraggable(true); + DeviceUnBindingView->SetTouchable(true); + /* ------------------------- DeviceUnBindingScrollView ------------------------ */ + if (DeviceUnBindingScrollView == nullptr) + { + DeviceUnBindingScrollView = new UIScrollView(); + if (DeviceUnBindingScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeviceUnBindingScrollView new fail"); + return nullptr; + } + } + DeviceUnBindingScrollView->SetPosition(0, 0, 466, 466); + DeviceUnBindingScrollView->SetThrowDrag(true); + DeviceUnBindingScrollView->SetDraggable(true); + DeviceUnBindingScrollView->SetTouchable(true); + DeviceUnBindingScrollView->SetReboundSize(30); + DeviceUnBindingScrollView->SetScrollBlankSize(30); + DeviceUnBindingScrollView->SetSwipeACCLevel(200); // 800: compensation distance + DeviceUnBindingScrollView->SetDragACCLevel(5); // 5: drag acceleration + DeviceUnBindingScrollView->SetMaxScrollDistance(1000); + DeviceUnBindingScrollView->SetDirection(UIScrollView::VERTICAL); + DeviceUnBindingScrollView->RequestFocus(); + DeviceUnBindingScrollView->SetRotateFactor(1.0); + /* ----------------------- DeviceUnBindingAnimatorView ---------------------- */ + UnBindPathsArray = CreateImageInfoArray(UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + if (DeviceUnBindingAnimatorView == nullptr) + { + DeviceUnBindingAnimatorView = new UIImageAnimatorView(); + if (DeviceUnBindingAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]DeviceUnBindingAnimatorView new fail"); + return nullptr; + } + for (uint8_t i = 0; i < UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + UnBindImageInfo[i].imageInfo = (UnBindPathsArray[i]); + UnBindImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; + UnBindImageInfo[i].pos.x = UNBIND_IMAGE_ANIMATOR_VIEW_X; + UnBindImageInfo[i].pos.y = UNBIND_IMAGE_ANIMATOR_VIEW_Y; + UnBindImageInfo[i].width = UNBIND_IMAGE_ANIMATOR_VIEW_W; + UnBindImageInfo[i].height = UNBIND_IMAGE_ANIMATOR_VIEW_H; + } + DeviceUnBindingAnimatorView->SetPosition(UNBIND_IMAGE_ANIMATOR_VIEW_X, UNBIND_IMAGE_ANIMATOR_VIEW_Y, UNBIND_IMAGE_ANIMATOR_VIEW_W, UNBIND_IMAGE_ANIMATOR_VIEW_H); + DeviceUnBindingAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + DeviceUnBindingAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + DeviceUnBindingAnimatorView->SetImageAnimatorSrc(UnBindImageInfo, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, UNBIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE); + DeviceUnBindingAnimatorView->SetRepeat(true); + DeviceUnBindingAnimatorView->SetSizeFixed(true); + DeviceUnBindingAnimatorView->Start(); + } + /* ----------------------- DeviceUnBindingViewTitleLabel ---------------------- */ + if (DeviceUnBindingViewTitleLabel == nullptr) + { + DeviceUnBindingViewTitleLabel = new UILabelExt(); + if (DeviceUnBindingViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingViewTitleLabel new fail!!"); + return nullptr; + } + } + DeviceUnBindingViewTitleLabel->SetPosition(83, 50, 300, 35); + DeviceUnBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // DeviceUnBindingViewTitleLabel->SetText("设备解绑"); + DeviceUnBindingViewTitleLabel->SetTextId(STR_EQUIPMENT_UNTYING); + DeviceUnBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + DeviceUnBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ---------------------------- DeviceUnBindingName --------------------------- */ + if (DeviceUnBindingName == nullptr) + { + DeviceUnBindingName = new UILabelExt(); + if (DeviceUnBindingName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName new fail!!"); + return nullptr; + } + } + DeviceUnBindingName->SetPosition(53, 230, 360, 70); + DeviceUnBindingName->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnBindingName->SetTextId(STR_EQUIPMENT_UNTYING_NOTE); // XX想要与你进行解绑 + + char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName devanme :%s", devanme); + + if (strlen(devanme)) + { + // DeviceUnBindingName->SetText(devanme); + UpdateLabel(DeviceUnBindingName, devanme, STR_EQUIPMENT_UNTYING_NOTE); + } + else + { + // DeviceUnBindingName->SetText(" "); + UpdateLabel(DeviceUnBindingName, " ", STR_EQUIPMENT_UNTYING_NOTE); + } + // DeviceUnBindingName->SetText("小米5\n"); + DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + int y = DeviceUnBindingName->GetY() + DeviceUnBindingName->GetTextHeight() + 20; + DeviceUnBindingButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); + if (DeviceUnBindingButtonCancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingButtonCancel new fail!!"); + return nullptr; + } + /* -------------------------------- DeviceUnBindingButtonOK -------------------------------- */ + DeviceUnBindingButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); + if (DeviceUnBindingButtonOK == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingButtonOK new fail!!"); + return nullptr; + } + /* ------------------------- button OnClickListener ------------------------- */ + UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); + if (nullptr == listener) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] PairingViewEventListener::GetInstance fail!!"); + return nullptr; + } + DeviceUnBindingButtonCancel->SetOnClickListener(listener); + DeviceUnBindingButtonOK->SetOnClickListener(listener); + /* ----------------------------------- Add ---------------------------------- */ + DeviceUnBindingScrollView->Add(DeviceUnBindingViewTitleLabel); + DeviceUnBindingScrollView->Add(DeviceUnBindingAnimatorView); + DeviceUnBindingScrollView->Add(DeviceUnBindingName); + DeviceUnBindingScrollView->Add(DeviceUnBindingButtonCancel); + DeviceUnBindingScrollView->Add(DeviceUnBindingButtonOK); + DeviceUnBindingView->Add(DeviceUnBindingScrollView); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new success!!"); + + /* -------------------------------------------------------------------------- */ + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + // ui_api_vibrate_once_func(); // 震动一次 + } + + // ScreenTurnOff(); //先设置为0 + // ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 + + PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 + /* -------------------------------------------------------------------------- */ + + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceUnBindingView); + return DeviceUnBindingView; + } + + /* + * @brief 创建解除绑定请求(与新设备连接)视图 + */ + UIViewGroup *CreateDeviceUnbindingRequestGroupView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]"); + + if (nullptr == DeviceUnbindingRequestGroupView) + { + /* --------------------- DeviceUnbindingRequestGroupView -------------------- */ + DeviceUnbindingRequestGroupView = new UIViewGroup(); + if (DeviceUnbindingRequestGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestGroupView is nullptr"); + return nullptr; + } + DeviceUnbindingRequestGroupView->SetPosition(0, 0, 466, 466); + DeviceUnbindingRequestGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0); + DeviceUnbindingRequestGroupView->SetVisible(false); + /* -------------------- DeviceUnbindingRequestScrollView -------------------- */ + DeviceUnbindingRequestScrollView = new UIScrollView(); + if (DeviceUnbindingRequestScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestScrollView is nullptr"); + return nullptr; + } + DeviceUnbindingRequestScrollView->SetPosition(0, 0, 466, 466); + DeviceUnbindingRequestScrollView->SetThrowDrag(true); + DeviceUnbindingRequestScrollView->SetDraggable(true); + DeviceUnbindingRequestScrollView->SetTouchable(true); + DeviceUnbindingRequestScrollView->SetReboundSize(30); + DeviceUnbindingRequestScrollView->SetScrollBlankSize(30); + DeviceUnbindingRequestScrollView->SetSwipeACCLevel(200); // 800: compensation distance + DeviceUnbindingRequestScrollView->SetDragACCLevel(5); // 5: drag acceleration + DeviceUnbindingRequestScrollView->SetMaxScrollDistance(1000); + DeviceUnbindingRequestScrollView->SetDirection(UIScrollView::VERTICAL); + DeviceUnbindingRequestScrollView->RequestFocus(); + DeviceUnbindingRequestScrollView->SetRotateFactor(1.0); + /* ------------------ DeviceUnbindingRequestViewTitleLabel ------------------ */ + if (DeviceUnbindingRequestViewTitleLabel == nullptr) + { + DeviceUnbindingRequestViewTitleLabel = new UILabelExt(); + if (DeviceUnbindingRequestViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewTitleLabel is nullptr"); + return nullptr; + } + } + DeviceUnbindingRequestViewTitleLabel->SetPosition(83, 50, 300, 35); + DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // DeviceUnbindingRequestViewTitleLabel->SetText("注意"); + DeviceUnbindingRequestViewTitleLabel->SetTextId(STR_LOOK_OUT); + DeviceUnbindingRequestViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + DeviceUnbindingRequestViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------- DeviceUnbindingRequestViewImageView ------------------ */ + if (DeviceUnbindingRequestViewImageView == nullptr) + { + DeviceUnbindingRequestViewImageView = new UIImageView(); + if (DeviceUnbindingRequestViewImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewImageView is nullptr"); + return nullptr; + } + } + DeviceUnbindingRequestViewImageView->SetPosition(193, 121, 80, 80); + const char *imageimagesPath = "/user/res/Attention.bin"; + DeviceUnbindingRequestViewImageView->SetSrc(imageimagesPath); + + /* --------------------- DeviceUnbindingRequestViewLabel[0] -------------------- */ + if (nullptr == DeviceUnbindingRequestViewLabel[0]) + { + DeviceUnbindingRequestViewLabel[0] = new UILabelExt(); + if (DeviceUnbindingRequestViewLabel[0] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[0] is nullptr"); + return nullptr; + } + } + DeviceUnbindingRequestViewLabel[0]->SetPosition(53, 242, 360, 70); + DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnbindingRequestViewLabel[0]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE1); + + char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); + if (strlen(devanme)) + { + UpdateLabel(DeviceUnbindingRequestViewLabel[0], devanme, STR_NEWDEVICE_BIND_REMIND_NOTE1); + } + else + { + UpdateLabel(DeviceUnbindingRequestViewLabel[0], " ", STR_NEWDEVICE_BIND_REMIND_NOTE1); + } + + DeviceUnbindingRequestViewLabel[0]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnbindingRequestViewLabel[0]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewLabel[0]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------- DeviceUnbindingRequestViewLabel[1] ------------------- */ + if (DeviceUnbindingRequestViewLabel[1] == nullptr) + { + DeviceUnbindingRequestViewLabel[1] = new UILabelExt(); + if (DeviceUnbindingRequestViewLabel[1] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[1] is nullptr"); + return nullptr; + } + } + int y = DeviceUnbindingRequestViewLabel[0]->GetY() + DeviceUnbindingRequestViewLabel[0]->GetTextHeight() + 50; + DeviceUnbindingRequestViewLabel[1]->SetPosition(53, y, 360, 280); + DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnbindingRequestViewLabel[1]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE2); + if (strlen(devanme)) + { + UpdateLabel(DeviceUnbindingRequestViewLabel[1], devanme, STR_NEWDEVICE_BIND_REMIND_NOTE2); + } + else + { + UpdateLabel(DeviceUnbindingRequestViewLabel[1], " ", STR_NEWDEVICE_BIND_REMIND_NOTE2); + } + DeviceUnbindingRequestViewLabel[1]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnbindingRequestViewLabel[1]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewLabel[1]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------- DeviceUnbindingRequestViewLabel[2] ------------------- */ + if (DeviceUnbindingRequestViewLabel[2] == nullptr) + { + DeviceUnbindingRequestViewLabel[2] = new UILabelExt(); + if (DeviceUnbindingRequestViewLabel[2] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[2] is nullptr"); + return nullptr; + } + } + y = DeviceUnbindingRequestViewLabel[1]->GetY() + DeviceUnbindingRequestViewLabel[1]->GetTextHeight() + 50; + DeviceUnbindingRequestViewLabel[2]->SetPosition(53, y, 360, 35); + DeviceUnbindingRequestViewLabel[2]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[2]->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnbindingRequestViewLabel[2]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE3); + DeviceUnbindingRequestViewLabel[2]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnbindingRequestViewLabel[2]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewLabel[2]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + y = DeviceUnbindingRequestViewLabel[2]->GetY() + DeviceUnbindingRequestViewLabel[2]->GetTextHeight() + 50; + DeviceUnbindingRequestButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); + if (DeviceUnbindingRequestButtonCancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnbindingRequestButtonCancel new fail!!"); + return nullptr; + } + + /* -------------------------------- DeviceUnbindingRequestButtonOK -------------------------------- */ + DeviceUnbindingRequestButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); + if (DeviceUnbindingRequestButtonOK == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnbindingRequestButtonOK new fail!!"); + return nullptr; + } + /* ------------------------- button OnClickListener ------------------------- */ + UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); + if (listener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] PairingViewEventListener::GetInstance fail!!"); + return nullptr; + } + DeviceUnbindingRequestButtonCancel->SetOnClickListener(listener); + DeviceUnbindingRequestButtonOK->SetOnClickListener(listener); + /* -------------------------------------------------------------------------- */ + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewTitleLabel); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewImageView); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[0]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[1]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[2]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonCancel); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonOK); + DeviceUnbindingRequestGroupView->Add(DeviceUnbindingRequestScrollView); + } + return DeviceUnbindingRequestGroupView; + } + + /* + * @brief 销毁设备绑定视图 + */ + void FreeDeviceBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView]"); + if (DeviceBindingView != nullptr) + { + PairingViewEventListener::GetInstance().Pairing_StopTimer(); + DeviceBindingView->RemoveAll(); + if (DeviceBindingScrollView != nullptr) + { + DeviceBindingScrollView->RemoveAll(); + if (DeviceBindingViewTitleLabel) + { + delete DeviceBindingViewTitleLabel; + DeviceBindingViewTitleLabel = nullptr; + } + if (DeviceBindingName) + { + delete DeviceBindingName; + DeviceBindingName = nullptr; + } + if (DeviceBindingAnimatorView) + { + DeviceBindingAnimatorView->Stop(); + delete DeviceBindingAnimatorView; + DeviceBindingAnimatorView = nullptr; + FreeImageInfoArray(BindPathsArray, BIND_IMAGE_SRC, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + } + if (DeviceBindingButtonCancel) + { + delete DeviceBindingButtonCancel; + DeviceBindingButtonCancel = nullptr; + } + if (DeviceBindingButtonOK) + { + delete DeviceBindingButtonOK; + DeviceBindingButtonOK = nullptr; + } + DeviceBindingScrollView->ClearFocus(); + delete DeviceBindingScrollView; + DeviceBindingScrollView = nullptr; + } + RootView::GetInstance()->Remove(DeviceBindingView); + delete DeviceBindingView; + DeviceBindingView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView] success"); + // ScreenTurnOff(); + } + } + + /* + * @brief 销毁设备解绑视图 + */ + void FreeDeviceUnBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView]"); + if (DeviceUnBindingView != nullptr) + { + PairingViewEventListener::GetInstance().Pairing_StopTimer(); + DeviceUnBindingView->RemoveAll(); + if (DeviceUnBindingScrollView != nullptr) + { + DeviceUnBindingScrollView->RemoveAll(); + if (DeviceUnBindingViewTitleLabel) + { + delete DeviceUnBindingViewTitleLabel; + DeviceUnBindingViewTitleLabel = nullptr; + } + if (DeviceUnBindingAnimatorView) + { + DeviceUnBindingAnimatorView->Stop(); + delete DeviceUnBindingAnimatorView; + DeviceUnBindingAnimatorView = nullptr; + FreeImageInfoArray(UnBindPathsArray, UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + } + if (DeviceUnBindingName) + { + delete DeviceUnBindingName; + DeviceUnBindingName = nullptr; + } + if (DeviceUnBindingButtonCancel) + { + delete DeviceUnBindingButtonCancel; + DeviceUnBindingButtonCancel = nullptr; + } + if (DeviceUnBindingButtonOK) + { + delete DeviceUnBindingButtonOK; + DeviceUnBindingButtonOK = nullptr; + } + DeviceUnBindingScrollView->ClearFocus(); + delete DeviceUnBindingScrollView; + DeviceUnBindingScrollView = nullptr; + } + RootView::GetInstance()->Remove(DeviceUnBindingView); + delete DeviceUnBindingView; + DeviceUnBindingView = nullptr; + FreeDeviceUnbindingRequestGroupView(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView] success"); + // ScreenTurnOff(); + } + } + + /* + * @brief 销毁解除绑定请求(与新设备连接)视图 + */ + void FreeDeviceUnbindingRequestGroupView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView]"); + if (DeviceUnbindingRequestGroupView != nullptr) + { + DeviceUnbindingRequestGroupView->RemoveAll(); + if (nullptr != DeviceUnbindingRequestScrollView) + { + DeviceUnbindingRequestScrollView->RemoveAll(); + if (DeviceUnbindingRequestViewTitleLabel) + { + delete DeviceUnbindingRequestViewTitleLabel; + DeviceUnbindingRequestViewTitleLabel = nullptr; + } + if (DeviceUnbindingRequestViewImageView) + { + delete DeviceUnbindingRequestViewImageView; + DeviceUnbindingRequestViewImageView = nullptr; + } + for (int i = 0; i < (sizeof(DeviceUnbindingRequestViewLabel) / sizeof(DeviceUnbindingRequestViewLabel[0])); i++) + { + if (DeviceUnbindingRequestViewLabel[i]) + { + delete DeviceUnbindingRequestViewLabel[i]; + DeviceUnbindingRequestViewLabel[i] = nullptr; + } + } + if (DeviceUnbindingRequestButtonOK) + { + delete DeviceUnbindingRequestButtonOK; + DeviceUnbindingRequestButtonOK = nullptr; + } + if (DeviceUnbindingRequestButtonCancel) + { + delete DeviceUnbindingRequestButtonCancel; + DeviceUnbindingRequestButtonCancel = nullptr; + } + DeviceUnbindingRequestScrollView->ClearFocus(); + delete DeviceUnbindingRequestScrollView; + DeviceUnbindingRequestScrollView = nullptr; + } + RootView::GetInstance()->Remove(DeviceUnbindingRequestGroupView); + delete DeviceUnbindingRequestGroupView; + DeviceUnbindingRequestGroupView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView] success"); + } + // if (p_ShutDownImageAnimatorView != nullptr) + // { + // RootView::GetInstance()->Remove(ShutDownImageAnimatorGroupView); + // delete p_ShutDownImageAnimatorView; + // p_ShutDownImageAnimatorView; + // } + } + + /* -------------------------------------------------------------------------- */ + + // 声明定时器变量 + static osTimerId_t g_timer = NULL; + + /*定时器到期时的处理*/ + static void Pairing_TimerCallbackProc(int data) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Pairing_TimerCallbackProc"); + NotificationManager::GetInstance()->StopNotify(); + } + + /* + * @brief 回调函数 + */ + static void Pairing_TimerCallback(int data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(Pairing_TimerCallbackProc, data)); + } + + /* + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void PairingViewEventListener::Pairing_StartTimer(uint32_t interval) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::Pairing_StartTimer"); + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */ + if (g_timer != NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer already exists!!"); + return; + } + + /* --------------------------------- 2.创建定时器 -------------------------------- */ + g_timer = osTimerNew((osTimerFunc_t)Pairing_TimerCallback, osTimerOnce, NULL, NULL); + // 检查定时器创建是否成功 + if (g_timer == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer create failed!!"); + return; + } + + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */ + int tick = osMs2Tick(interval); + + /* --------------------------------- 4.启动定时器 -------------------------------- */ + osStatus_t ret = osTimerStart(g_timer, tick); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 NULL -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CountDown_StartTimer] osTimerDelete failed, ret = %lx!!", ret); + if (g_timer != NULL) + { + ret = osTimerDelete(g_timer); + } + g_timer = NULL; + return; + } + return; + } + + /* + * @brief 停止定时器 + */ + void PairingViewEventListener::Pairing_StopTimer(void) + { + // 检查定时器是否存在 + if (g_timer != NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::Pairing_StopTimer"); + osTimerStop(g_timer); + // 删除定时器并置为 NULL + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = NULL; + } + } + static uint8_t shutDownAnimation_falg = -1; //关机动画标志位 + void set_shutDownAnimation_falg(uint8_t falg) + { + shutDownAnimation_falg = falg; + } + /* + * @brief 显示关机动画 + */ + // UIViewGroup *showShutDownAnimation(void) + // { + // if (shutDownImageAnimatorView == nullptr) + // { + // shutDownImageAnimatorView = new ShutDownImageAnimatorView(); + // if (shutDownImageAnimatorView == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorView new fail!!"); + // return nullptr; + // } + // shutDownImageAnimatorGroupView = shutDownImageAnimatorView->ShutDownAnimatorViewInit(); + // if (shutDownImageAnimatorGroupView == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorGroupView new fail!!"); + // return nullptr; + // } + // shutDownImageAnimatorView->ShutDownImageAnimator_Start(shutDownAnimation_falg); + // RootView::GetInstance()->ClearOnKeyActListener(); + // } + // return shutDownImageAnimatorGroupView; + // } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp new file mode 100644 index 000000000..79a87cdf9 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp @@ -0,0 +1,1329 @@ +#include "notification_manager.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "AlarmPopUpPresenter.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_label_button_ext.h" +#include "battery_service.h" +#include "NativeAbility.h" +#include "custom_utils.h" +#include "components/ui_slider.h" +// #include "UiConfig.h" +#include "bleEvent.h" +#include "power_display_service.h" +#include "uicomponents/UIComponents.h" +#include "upg.h" +#include "custom_runtime.h" +#include "PhoneService.h" +#include "ConfigModelC.h" +#include "ConfigModel.h" +#include "bleInstruct.h" +#include "transmitting.h" +// #include "languagecode/LanguageInit.h" +namespace OHOS +{ + static UIImageView *imageCharge = nullptr; + static UIViewGroup *UIViewGroup_transmitting=nullptr; + + static UIImageView *transmitting_img=nullptr; + + static UISlider *updatasider=nullptr; + + static UILabelExt *Title=nullptr; + + static UILabelExt *label_=nullptr; + + static UIImageAnimatorView *downImageAnimatorView=nullptr; + + static constexpr char *ShutDownPaths = "/user/res/down/"; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 24; // 图片帧数 + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 150; // 图片更新间隔 + static ImageAnimatorInfo ImageInfo_animator[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息 + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_X = 183; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y = 140; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_W = 100; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_H = 100; + + const ImageInfo **imageInfo_dwon{nullptr}; // 关机图片路径数组 + + #define TRANSMITTING_SUCC_PATH PNG_SUCC_IMAGE; + #define TRANSMITTING_FAIL_PATH PNG_ATTENTION_IMAGE; + #define TRANSMITTING_OTA_DOWN "/user/res/system/KUMILOGO.bin" + + + + #define LOW_POWER_BUTTON "LOW_POWER_BUTTON" + + + + static void CreatetransmittingAnimator(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView"); + imageInfo_dwon = CreateImageInfoArray(ShutDownPaths,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, "bin"); + + if (downImageAnimatorView == nullptr) + { + downImageAnimatorView = new UIImageAnimatorView(); + if (downImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new downImageAnimatorView fail"); + return; + } + for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + ImageInfo_animator[i].imageInfo = (imageInfo_dwon[i]); + ImageInfo_animator[i].imageType = IMG_SRC_IMAGE_INFO; + ImageInfo_animator[i].pos.x = SHUTDOWN_IMAGE_ANIMATOR_VIEW_X; + ImageInfo_animator[i].pos.y = SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y; + ImageInfo_animator[i].width = SHUTDOWN_IMAGE_ANIMATOR_VIEW_W; + ImageInfo_animator[i].height = SHUTDOWN_IMAGE_ANIMATOR_VIEW_H; + } + downImageAnimatorView->SetPosition(SHUTDOWN_IMAGE_ANIMATOR_VIEW_X, SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y, SHUTDOWN_IMAGE_ANIMATOR_VIEW_W, SHUTDOWN_IMAGE_ANIMATOR_VIEW_H); + downImageAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + downImageAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + downImageAnimatorView->SetImageAnimatorSrc(ImageInfo_animator, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100); + downImageAnimatorView->SetRepeat(true); + downImageAnimatorView->SetRepeatTimes(1); + + } + downImageAnimatorView->SetVisible(true); + downImageAnimatorView->Start(); + //downImageAnimatorView->Start(); + + return ; + } + + + + + static uint8_t Transmitting_falg=1; + void set_transmittingShow_falg(uint8_t falg) + { + Transmitting_falg=falg; + } + + static osTimerId_t transmitting_timer= NULL; + + void Freetransmitting(void) + { + if (UIViewGroup_transmitting != nullptr) + { + UIViewGroup_transmitting->RemoveAll(); + + if(transmitting_img) + { + delete transmitting_img; + transmitting_img = nullptr; + } + if(Title) + { + delete Title; + Title = nullptr; + } + if(label_) + { + delete label_; + label_ = nullptr; + } + if(downImageAnimatorView) + { + FreeImageInfoArray(imageInfo_dwon,ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES,"bin"); + delete downImageAnimatorView; + downImageAnimatorView = nullptr; + } + if(updatasider) + { + delete updatasider; + updatasider = nullptr; + } + if(transmitting_timer) + { + + osTimerStop(transmitting_timer); + osStatus_t ret = osTimerDelete(transmitting_timer); + if (ret != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed ret = %lx!", ret); + //return; + } + transmitting_timer = nullptr; + } + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_auto_timeout_function(true); + + uapi_take_to_wake(1); + + RootView::GetInstance()->Remove(UIViewGroup_transmitting); + delete UIViewGroup_transmitting; + UIViewGroup_transmitting = nullptr; + + uapi_dev_runtime_set_transmitting_status(0); + } + } + static uint8_t timer_falg_low_power=5; + + static uint8_t test_flag=0; + + static void OTATimerCallBackProc(int data) + { + #if 0 + if(updatasider) + updatasider->SetValue(test_flag++); + #else + if(updatasider) + updatasider->SetValue(get_OTA_recv_value()); + #endif + if(updatasider) + updatasider->Invalidate(); + } + + void OTATimerCallBack(int data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(OTATimerCallBackProc, data)); + } + + void dialtimerCallBack(int data) + { + NotificationManager::GetInstance()->StopNotify(); + } + + + + void creat_down_OTA() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(83, 50); // widget's left position and top position + Title->Resize(300, 35); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA下载中"); + Title->SetTextId (STR_OTA_DOWNLOAD); + + Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + + if (updatasider == nullptr) + { + updatasider = new UISlider(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView new fail"); + + } + + updatasider->SetSliderColor(Color::Gray(), Color::Silver()); + updatasider->SetPosition(63, 317, 340, 50); + updatasider->SetViewId("SystemUpdateView_updatasider"); + updatasider->SetRange(0, 100); + + updatasider->SetStyle(STYLE_BORDER_RADIUS, 100); + updatasider->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); + updatasider->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); + updatasider->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); + updatasider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); + updatasider->SetDraggable(false); + updatasider->SetTouchable(false); + updatasider->SetValue(0); + UIViewGroup_transmitting->Add(updatasider); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 220); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("软件正在更新"); + label_->SetTextId(STR_OTA_DOWNLOADING); + label_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + + } + transmitting_img->SetPosition(117, 87, 230, 160); + const char *imagesPath = TRANSMITTING_OTA_DOWN; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + + Set_OTA_recv_value(); + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)OTATimerCallBack, osTimerPeriodic, NULL, NULL); + tick =500;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + } + static upg_result_t upg_result; + static uint32_t last_image_index; + + static char updata_fail_str[32]={0}; + + static uint8_t TRANSMIT_DATA; + + void get_updatafail_data(void) + { + errcode_t ret; + ret = uapi_upg_get_result(&upg_result, &last_image_index); + if (ret != ERRCODE_SUCC) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_upg_get_result error = 0x%x\r\n", ret); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"upg_result = %d, last_image_index:%d\r\n", upg_result, last_image_index); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_upg_get_result OK!!\r\n"); + if(upg_result!=UPG_RESULT_UPDATE_SUCCESS) + { + sprintf_s(updata_fail_str,32,"%d_%d",(int)upg_result,last_image_index); + TRANSMIT_DATA=OTA_UPDATA_FAIL; + if(ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_OTA_UPGRADE)) + { + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ConfigModel::GetInstance()->set_condigData_Int(ConfigModel::CONFIGMODEL_ITEM_OTA_UPGRADE,0); + } + } + + } + } + + void Creat_OTA_Updata_FAIL() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(83, 50); // widget's left position and top position + Title->Resize(300, 35); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA upgrade failure"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(Title); + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + char fail_str[128]={0}; + sprintf_s(fail_str,128,"ota升级失败,请尝试重启设备"); + + label_->SetText(fail_str); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(label_); + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + void Creat_CAT1_OTA_Updata() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(83, 50); // widget's left position and top position + Title->Resize(300, 35); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("CAT1 OTA upgradeing"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(Title); + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + + label_->SetText("4G模块OTA升级中,请勿操作,升级成功后会自动重启"); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(label_); + + // Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + + + + + void creat_down_OTA_FAIL() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(143, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA下载失败"); + Title->SetTextId (STR_OTA_DOWNLOADFIAL); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("下载升级包失败,请退出或者重新下载"); + label_->SetTextId(STR_OTA_DOWNLOADFIAL_TRY); + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + UIViewGroup_transmitting->Add(label_); + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(117, 87, 230, 160); + const char *imagesPath = TRANSMITTING_OTA_DOWN; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + void creat_down_OTA_SUCC() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(143, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA下载成功"); + Title->SetTextId (STR_OTA_DOWNLOADSUCC); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("下载升级包成功,可以开始升级手表"); + label_->SetTextId(STR_OTA_DOWNLOADSUCC_UPDATA); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + + } + transmitting_img->SetPosition(117, 87, 230, 160); + const char *imagesPath = TRANSMITTING_OTA_DOWN; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + + + + void creat_down_Dial() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(158, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("表盘安装中"); + Title->SetTextId (STR_DIAL_DOWNLOADING_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("正在安装表盘,请不要做其他操作或关闭手表"); + label_->SetTextId(STR_DIAL_DOWNLOADING_LABEL); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + CreatetransmittingAnimator(); + // UIViewGroup_transmitting->Add(updatasider); + + UIViewGroup_transmitting->Add(downImageAnimatorView); + } + + + void creat_down_MP3() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(158, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("音乐传输中"); + Title->SetTextId (STR_MUSIC_TRANSMIT); + + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("正在传输音乐,请不要做其他操作或关闭手表"); + label_->SetTextId(STR_MUSIC_TRANSMIT_NOTE); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + CreatetransmittingAnimator(); + // UIViewGroup_transmitting->Add(updatasider); + + UIViewGroup_transmitting->Add(downImageAnimatorView); + } + + void creat_down_BIN() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(158, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("数据传输中"); + // Title->SetTextId (STR_MUSIC_TRANSMIT); + + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("正在下载应用,请不要做其他操作或关闭手表"); + // label_->SetTextId(STR_MUSIC_TRANSMIT_NOTE); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + CreatetransmittingAnimator(); + // UIViewGroup_transmitting->Add(updatasider); + + UIViewGroup_transmitting->Add(downImageAnimatorView); + } + + + void creat_down_MP3_succ() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("传输成功"); + Title->SetTextId (STR_MP3_SUCC_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("音乐传输成功正在校验,请稍等"); + label_->SetTextId(STR_MUSIC_TRANSMIT_SUCCESS_NOTE); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_SUCC_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)dialtimerCallBack, osTimerPeriodic, NULL, NULL); + tick =2000;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + } + + + void creat_down_BIN_succ() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("传输成功"); + // Title->SetTextId (STR_MP3_SUCC_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("应用安装中,请稍等"); + // label_->SetTextId(STR_MUSIC_TRANSMIT_SUCCESS_NOTE); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_SUCC_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)dialtimerCallBack, osTimerPeriodic, NULL, NULL); + tick =2000;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + } + + + + void creat_down_Dial_succ() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("安装成功"); + Title->SetTextId (STR_DIAL_SUCC_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("表盘安装成功正在更新表盘,请稍等"); + label_->SetTextId(STR_DIAL_SUCC_LABEL); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_SUCC_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)dialtimerCallBack, osTimerPeriodic, NULL, NULL); + tick =2000;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + } + + + void creat_down_max_Dial_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetTextId(STR_OPERAT_FAIL);//TODO:多国语言 + //Title->SetTextId (STR_DIAL_FAIL_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + label_->SetTextId(STR_DIAL_NOTE);//TODO:多国语言 + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + void creat_down_max_MP3_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetTextId(STR_OPERAT_FAIL);//TODO:多国语言 + //Title->SetTextId (STR_DIAL_FAIL_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + // label_->SetTextId(STR_DIAL_NOTE);//TODO:多国语言 + // + // + // if(ConfigModel::GetInstance()->GetLanguage() == ZH_CN) + label_->SetText("本地下载音乐已达到存储上限;请先删除部分歌曲再进行上传"); + // else + // label_->SetText( + // "The storage capacity of locally downloaded music has reached the upper limit.\ + // Please delete some songs before uploading"); + + + + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + void creat_down_Dial_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("安装失败"); + Title->SetTextId (STR_DIAL_FAIL_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + + label_->SetTextId(STR_DIAL_FAIL_LABEL); + + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + void creat_down_MP3_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("传输失败"); + Title->SetTextId (STR_MP3_FAIL_TITL); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("音乐传输失败,请退出或重新安装"); + label_->SetTextId(STR_MP3_FAIL_LABEL); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + + bool transmittingISShow(void) + { + if(uapi_dev_runtime_get_transmitting_status()) + return true; + else + return false; + } + + UIViewGroup *transmittingShow() + { + + if (UIViewGroup_transmitting == nullptr) { + UIViewGroup_transmitting = new UIViewGroup(); + UIViewGroup_transmitting->SetPosition(0, 0, 466, 466); + //UIViewGroup_transmitting->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + else + { + UIViewGroup_transmitting->RemoveAll(); + } + uapi_dev_runtime_set_transmitting_status(1); + switch (Transmitting_falg) + { + case TRANS_DIAL_TRANSMITTING: + creat_down_Dial(); + break; + case TRANS_DIAL_SUCC: + creat_down_Dial_succ(); + break; + case TRANS_DIAL_FAIL: + creat_down_Dial_fail(); + break; + case TRANS_DIAL_MAX_FAIL: + creat_down_max_Dial_fail(); + break; + + case TRANS_OTA_TRANSMITTING: + creat_down_OTA(); + break; + case TRANS_OTA_SUCC: + creat_down_OTA_SUCC(); + break; + case TRANS_OTA_FAIL: + creat_down_OTA_FAIL(); + break; + case TRANS_MP3_TRANSMITTING: + creat_down_MP3(); + break; + case TRANS_MP3_SUCC: + creat_down_MP3_succ(); + break; + case TRANS_MP3_FAIL: + creat_down_MP3_fail(); + break; + case OTA_UPDATA_FAIL: + Creat_OTA_Updata_FAIL(); + break; + case START_CAT1_OTA: + Creat_CAT1_OTA_Updata(); + break; + case TRANS_MP3_MAX_FAIL: + creat_down_max_MP3_fail(); + break; + case TRANS_BIN_TRANSMITTING: + creat_down_BIN(); + break; + case TRANS_BIN_SUCC: + creat_down_BIN_succ(); + break; + + + default: + break; + } + if(Transmitting_falg==TRANS_DIAL_TRANSMITTING || Transmitting_falg==TRANS_OTA_TRANSMITTING || Transmitting_falg==TRANS_MP3_TRANSMITTING) + { + // if(uapi_hfp_connect_state()) + // { + // uapi_hfp_disconnect(); + // } + } + else if(Transmitting_falg!=OTA_UPDATA_FAIL) + { + // if(uapi_dev_runtime_get_bt_powerstat() && cm_get_HFP_switch()) + // { + // uapi_hfp_connect(); + // } + + } + + UIView::OnClickListener *button1Click = static_cast(transmittingViewEventListener::GetInstance()); + UIViewGroup_transmitting->SetOnClickListener(button1Click); + UIViewGroup_transmitting->SetTouchable(true); + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_auto_timeout_function(false); + uapi_take_to_wake(0); + + + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(Freetransmitting); + return UIViewGroup_transmitting; + } + + transmittingViewEventListener::transmittingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallViewEventListener :%p", this); + } + + transmittingViewEventListener::~transmittingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~CallViewEventListener"); + } + + transmittingViewEventListener *transmittingViewEventListener::GetInstance(void) + { + static transmittingViewEventListener lowppowrViewEventListene_t; + return &lowppowrViewEventListene_t; + } + + + bool transmittingViewEventListener::OnClick(UIView& view, const ClickEvent& event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick"); + if(Transmitting_falg!=TRANS_DIAL_TRANSMITTING + && Transmitting_falg!=TRANS_OTA_TRANSMITTING + && Transmitting_falg!=TRANS_MP3_TRANSMITTING + && Transmitting_falg!=START_CAT1_OTA + && Transmitting_falg!=TRANS_BIN_TRANSMITTING) + { + NotificationManager::GetInstance()->StopNotify(); + } + return true; + UNUSED(event); + } + +} diff --git a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h index 2ce1f73d3..54854380c 100644 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -43,6 +43,7 @@ typedef enum { TOPIC_EVENT_HFP_FINISHED, TOPIC_EVENT_HFP_PHONE_TO_WATCH, TOPIC_EVENT_HFP_WATCH_TO_PHONE, + TOPIC_END_NUM = 20000, } TopicNum; diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index 1a21912b2..a1ac91cb3 100644 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -145,6 +145,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_utils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp ) else() set(SOURCES @@ -154,6 +155,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/ketinput/src/NotifyOnKeyListener.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp ) endif() diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h b/code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h new file mode 100644 index 000000000..d5371ae8c --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/include/notify/transmitting.h @@ -0,0 +1,65 @@ +#ifndef TRANSMITTING_H +#define TRANSMITTING_H +#include "components/ui_image_animator.h" +#include "bletest.h" +#include "components/ui_view_group.h" + +namespace OHOS +{ + // UIViewGroup *ChargingStatuShow(void); + // UIView *view_ = nullptr; + + #ifdef __cplusplus +#if __cplusplus +extern "C" { + void get_updatafail_data(void); +}; +#endif + +#endif + + UIViewGroup* transmittingShow(void); + bool transmittingISShow(void); + void set_transmittingShow_falg(uint8_t falg); + void Freetransmitting(void); + + + class transmittingViewEventListener : public OHOS::UIView::OnClickListener, + public OHOS::UIView::OnLongPressListener, + public OHOS::UIView::OnTouchListener, + public OHOS::UIView::OnDragListener + { +public: + transmittingViewEventListener(); + virtual ~transmittingViewEventListener(); + static transmittingViewEventListener *GetInstance(void); + + bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override; + bool OnDrag(UIView& view, const DragEvent& event) override + { + return true; + } + bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override + { + return true; + } + virtual bool OnPress(OHOS::UIView& view, const OHOS::PressEvent& event) override + { + return true; + } + virtual bool OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) override + { + return true; + } + virtual bool OnRelease(OHOS::UIView& view, const OHOS::ReleaseEvent& event) override + { + return true; + } + + virtual bool OnDragStart(OHOS::UIView& view, const OHOS::DragEvent& event) override + { + return true; + } +}; +}; +#endif /* CHARGE_NOTIFICATION_H */ \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index b2522644d..04e3aa018 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -43,13 +43,18 @@ extern "C" { const PriorityMapper PRI_MAPPER[] = { {TOPIC_EVENT_ALARM_RING, PRIORITY_TWO}, {TOPIC_EVENT_NEXTDAY_UPDATE, PRIORITY_TWO}, + {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE}, {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}, -}; + {TOPIC_EVENT_DEVICE_BIND, PRIORITY_ONE}, + // {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO}, + // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, PRIORITY_TWO}, + + }; bool g_pressFlag = false; bool g_longPressFlag = false; @@ -81,6 +86,7 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_FINISHED); MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_PHONE_TO_WATCH); MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_TO_PHONE); + MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND); } static OHOS::UIViewGroup* ShowAlarmNotify(void) @@ -103,6 +109,28 @@ 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* showtransmitNotify(void) +{ + return OHOS::transmittingShow(); +} void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -178,6 +206,115 @@ void MsgCenterNotifyHfpWatchProc(const Topic topic, Request* req) } } +void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req) +{ + //unused(req); + WEARABLE_LOGI(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; + uint8_t len_name = req->len; + char devname[len_name]; + if(data!=NULL && req->len>=2) + { + switch(data[0]) + { + case DEVICEBIND: + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + len_name = req->len-2; + memset(devname,0,len_name); + if(len_name > 0) + { + memcpy(devname,(char *)req->data+2,len_name); + PairingViewEventListener::GetInstance().SetDeviceName(devname); + }else{ + PairingViewEventListener::GetInstance().SetDeviceName(NULL); + } + NotificationManager::GetInstance()->ShowNotify(showDeviceBindingNotify, (uint16_t)topic, true); + break; + case DEVICEUNBIND: + + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + len_name = req->len-2; + memset(devname,0,len_name); + if(len_name > 0) + { + memcpy(devname,(char *)req->data+2,len_name); + // printf("devname:%s\r\n",devname); + 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; + } + + } + +} +void MsgCenterNotifybleTransmit(const Topic topic, Request* req) +{ + unused(topic); + uint8_t* data=(uint8_t*)req->data; + + + 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); + } + // unused(req); + +} /* 订阅事件通知逻辑可定制 */ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_ALARM_RING, MsgCenterNotifyAlarmProc}, @@ -188,7 +325,13 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_HFP_WATCH_TO_PHONE, MsgCenterNotifyHfpPhoneProc}, {TOPIC_EVENT_HFP_WATCH_ACTIVE, MsgCenterNotifyHfpWatchProc}, {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc}, -}; +{TOPIC_EVENT_BLE_TRANSMIT, MsgCenterNotifybleTransmit}, + + {TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc}, + // {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc}, + // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, MsgCenterNotifyDeviceUnBindingRequestProc}, + + }; static MsgCenterNotifyTable *MsgCenterGetNotifyTblCb(uint8_t idx) { diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp new file mode 100644 index 000000000..f01f7f7b7 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp @@ -0,0 +1,1027 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-22 10:04:36 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2025-01-15 11:34:47 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp + */ +#include "notification_manager.h" +#include "wearable_log.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_animator.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" +#ifdef SUPPORT_BLE_SERVICE +#include "bleEvent.h" +#endif + +#include +#include +#include +#include +#include "iostream" +#include +#include +#include "uicomponents/UIComponents.h" +#include "ConfigModel.h" +#include +#include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h" +#include +#include "rebootandshutdown/include/ShutDownImageAnimatorView.h" +namespace OHOS +{ + UIViewGroup *DeviceBindingView{nullptr}; + UIScrollView *DeviceBindingScrollView{nullptr}; + UILabelExt *DeviceBindingViewTitleLabel{nullptr}; // 标题 :设备绑定 + UILabelExt *DeviceBindingName{nullptr}; // 绑定的设备名称 + UIButton *DeviceBindingButtonOK{nullptr}; // 设备绑定确认 + UIButton *DeviceBindingButtonCancel{nullptr}; // 设备绑定取消 + + UIImageAnimatorView *DeviceBindingAnimatorView{nullptr}; // 设备绑定动画 + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_X = 183; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_Y = 125; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_W = 100; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_H = 66; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE = 70; + static constexpr int BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 25; // 绑定动画帧数 + const ImageInfo **BindPathsArray{nullptr}; + ImageAnimatorInfo BindImageInfo[BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; + static constexpr const char *BIND_IMAGE_SRC = "/user/res/remind/bind/"; + + UIViewGroup *DeviceUnBindingView{nullptr}; + UIScrollView *DeviceUnBindingScrollView{nullptr}; + UILabelExt *DeviceUnBindingViewTitleLabel{nullptr}; // 标题 :设备解绑 + UILabelExt *DeviceUnBindingName{nullptr}; // 解绑的设备名称 + UIButton *DeviceUnBindingButtonOK{nullptr}; // 设备解绑定确认 + UIButton *DeviceUnBindingButtonCancel{nullptr}; // 设备解绑取消 + + UIImageAnimatorView *DeviceUnBindingAnimatorView{nullptr}; // 设备解绑动画 + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_X = 193; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_Y = 118; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_W = 80; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_H = 80; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE = 100; + static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 25; // 解绑动画帧数 + const ImageInfo **UnBindPathsArray{nullptr}; + ImageAnimatorInfo UnBindImageInfo[UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; + static constexpr const char *UNBIND_IMAGE_SRC = "/user/res/remind/unbind/"; + + UIViewGroup *DeviceUnbindingRequestGroupView{nullptr}; + UIScrollView *DeviceUnbindingRequestScrollView{nullptr}; // 设备解除绑定请求(与新设备连接)视图 + UILabelExt *DeviceUnbindingRequestViewTitleLabel{nullptr}; // 标题 :注意 + UIImageView *DeviceUnbindingRequestViewImageView{nullptr}; // + UILabelExt *DeviceUnbindingRequestViewLabel[3]{nullptr}; // + UIButton *DeviceUnbindingRequestButtonOK{nullptr}; // 设备解除绑定请求(与新设备连接)确认 + UIButton *DeviceUnbindingRequestButtonCancel{nullptr}; // 设备解除绑定请求(与新设备连接)取消 + + ShutDownImageAnimatorView *p_ShutDownImageAnimatorView{nullptr}; // 关机动画 + UIViewGroup *ShutDownImageAnimatorGroupView{nullptr}; + + ShutDownImageAnimatorView *shutDownImageAnimatorView{nullptr}; // 关机动画 + UIViewGroup *shutDownImageAnimatorGroupView{nullptr}; + + PairingViewEventListener::PairingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::PairingViewEventListener"); + } + + PairingViewEventListener::~PairingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::~PairingViewEventListener"); + } + + PairingViewEventListener &PairingViewEventListener::GetInstance(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::GetInstance"); + static PairingViewEventListener instance; + return instance; + } + + bool PairingViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::OnClick"); + UNUSED(event); + if (&view == DeviceBindingButtonCancel) // 设备绑定取消按钮 + { + PairingViewEventListener::GetInstance().Pairing_StopTimer(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonCancel OnClick"); +// 终止当前的绑定流程并关闭相关的通知界面。 +#ifdef SUPPORT_BLE_SERVICE + comfirmPaire(0); +#endif + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceBindingButtonOK) // 设备绑定确认按钮 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonOK OnClick"); + /* + * 可能会执行的绑定流程: + * 1.启动绑定过程. + * 2.更新设备绑定状态. + * 3.发送绑定请求到设备或服务器等. + */ + PairingViewEventListener::GetInstance().Pairing_StopTimer(); +// 关闭通知界面 +#ifdef SUPPORT_BLE_SERVICE + comfirmPaire(1); +#endif + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceUnBindingButtonCancel) // 设备解绑取消按钮 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonCancel OnClick"); +// 不想执行解绑动作,并关闭解绑的通知界面。 +#ifdef SUPPORT_BLE_SERVICE + cleanUnbindInfor(0); +#endif + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceUnBindingButtonOK) // 设备解绑确认按钮 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonOK OnClick"); + // 切换到再次确认解绑弹窗 + if (DeviceUnbindingRequestGroupView == nullptr) + { + RootView::GetInstance()->Add(CreateDeviceUnbindingRequestGroupView()); + } + DeviceUnBindingViewIsVisible(false); + } + else if (&view == DeviceUnbindingRequestButtonOK) // 设备解除绑定请求(与新设备连接)确认 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonOK OnClick"); + if (p_ShutDownImageAnimatorView == nullptr) + { + p_ShutDownImageAnimatorView = new ShutDownImageAnimatorView(); + if (p_ShutDownImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_ShutDownImageAnimatorView new fail!!"); + return false; + } + ShutDownImageAnimatorGroupView = p_ShutDownImageAnimatorView->ShutDownAnimatorViewInit(); + if (ShutDownImageAnimatorGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorGroupView new fail!!"); + return false; + } + DeviceUnbindingRequestGroupView->SetVisible(false); + /* -------------------------------------------------------------------------- */ + RootView::GetInstance()->ClearOnKeyActListener(); + RootView::GetInstance()->SetOnKeyActListener(this); + /* -------------------------------------------------------------------------- */ + RootView::GetInstance()->Add(ShutDownImageAnimatorGroupView); + } + ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(3); + } + else if (&view == DeviceUnbindingRequestButtonCancel) // 设备解除绑定请求(与新设备连接)取消 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonCancel OnClick"); + DeviceUnBindingViewIsVisible(true); + } + return true; + } + + bool PairingViewEventListener::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + //消耗按键事件 + return true; + } + + static UIButton *CreateButton(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const char *imageSrc) + { + UIButton *button = new UIButton(); + if (button == nullptr) + { + return nullptr; + } + button->SetPosition(x, y, w, h); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x19); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button->SetImageSrc(imageSrc, imageSrc); + return button; + } + + void PairingViewEventListener::SetDeviceName(char *Name) + { + // printf("Name:%s\r\n",Name); + memset(DeviceName, 0, sizeof(DeviceName)); + if (Name == NULL) + { + strcpy(DeviceName, "phone"); + return; + } + int len = strlen(Name); + if (len > sizeof(DeviceName)) + len = sizeof(DeviceName); + Name[len] = '\0'; + + memcpy(DeviceName, Name, len); + } + + void PairingViewEventListener::DeviceUnBindingViewIsVisible(bool state) + { + if (DeviceUnBindingView && DeviceUnbindingRequestGroupView) + { + DeviceUnBindingView->SetVisible(state); + DeviceUnbindingRequestGroupView->SetVisible(!state); + } + } + + /*获取设备名称*/ + char *PairingViewEventListener::GetDeviceName(void) + { + return DeviceName; + } + + /* + * @brief 创建设备绑定视图 + */ + UIViewGroup *CreateDeviceBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView]"); + /* ---------------------------- DeviceBindingView --------------------------- */ + if (DeviceBindingView == nullptr) + { + DeviceBindingView = new UIViewGroup(); + if (nullptr == DeviceBindingView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingView new fail!!"); + return nullptr; + } + DeviceBindingView->SetPosition(0, 0, 466, 466); + DeviceBindingView->SetDraggable(true); + DeviceBindingView->SetTouchable(true); + /* ------------------------- DeviceBindingScrollView ------------------------ */ + if (DeviceBindingScrollView == nullptr) + { + DeviceBindingScrollView = new UIScrollView(); + if (DeviceBindingScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeviceBindingScrollView new fail"); + return nullptr; + } + } + DeviceBindingScrollView->SetPosition(0, 0, 466, 466); + DeviceBindingScrollView->SetThrowDrag(true); + DeviceBindingScrollView->SetDraggable(true); + DeviceBindingScrollView->SetTouchable(true); + DeviceBindingScrollView->SetReboundSize(30); + DeviceBindingScrollView->SetScrollBlankSize(30); + DeviceBindingScrollView->SetSwipeACCLevel(200); // 800: compensation distance + DeviceBindingScrollView->SetDragACCLevel(5); // 5: drag acceleration + DeviceBindingScrollView->SetMaxScrollDistance(1000); + DeviceBindingScrollView->SetDirection(UIScrollView::VERTICAL); + DeviceBindingScrollView->RequestFocus(); + DeviceBindingScrollView->SetRotateFactor(1.0); + /* ----------------------- DeviceBindingViewTitleLabel ---------------------- */ + if (DeviceBindingViewTitleLabel == nullptr) + { + DeviceBindingViewTitleLabel = new UILabelExt(); + if (DeviceBindingViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingViewTitleLabel new fail!!"); + return nullptr; + } + } + DeviceBindingViewTitleLabel->SetPosition(83, 50, 300, 35); + DeviceBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + + // DeviceBindingViewTitleLabel->SetText("设备绑定"); + DeviceBindingViewTitleLabel->SetTextId(STR_DEVICE_BINDING); + DeviceBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + DeviceBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + DeviceBindingViewTitleLabel->SetRollSpeed(23); + /* ----------------------- DeviceBindingAnimatorView ---------------------- */ + BindPathsArray = CreateImageInfoArray(BIND_IMAGE_SRC, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + if (DeviceBindingAnimatorView == nullptr) + { + DeviceBindingAnimatorView = new UIImageAnimatorView(); + if (DeviceBindingAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]DeviceBindingAnimatorView new fail"); + return nullptr; + } + for (uint8_t i = 0; i < BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + BindImageInfo[i].imageInfo = (BindPathsArray[i]); + BindImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; + BindImageInfo[i].pos.x = BIND_IMAGE_ANIMATOR_VIEW_X; + BindImageInfo[i].pos.y = BIND_IMAGE_ANIMATOR_VIEW_Y; + BindImageInfo[i].width = BIND_IMAGE_ANIMATOR_VIEW_W; + BindImageInfo[i].height = BIND_IMAGE_ANIMATOR_VIEW_H; + } + DeviceBindingAnimatorView->SetPosition(BIND_IMAGE_ANIMATOR_VIEW_X, BIND_IMAGE_ANIMATOR_VIEW_Y, BIND_IMAGE_ANIMATOR_VIEW_W, BIND_IMAGE_ANIMATOR_VIEW_H); + DeviceBindingAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + DeviceBindingAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + DeviceBindingAnimatorView->SetImageAnimatorSrc(BindImageInfo, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, BIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE); + DeviceBindingAnimatorView->SetRepeat(true); + DeviceBindingAnimatorView->SetAutoEnable(false); + DeviceBindingAnimatorView->SetResizeMode(UIImageAnimatorView::CENTER); + DeviceBindingAnimatorView->Start(); + DeviceBindingAnimatorView->SetSizeFixed(true); + } + /* ---------------------------- DeviceBindingName --------------------------- */ + if (DeviceBindingName == nullptr) + { + DeviceBindingName = new UILabelExt(); + if (DeviceBindingName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingName new fail!!"); + return nullptr; + } + } + + char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); + DeviceBindingName->SetPosition(53, 230, 360, 70); + DeviceBindingName->SetStyle(STYLE_TEXT_FONT, 30); + DeviceBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceBindingName->SetTextId(STR_DEVICE_BINDING_NOTE); // XX想要与你进行连接绑定 + + if (strlen(devanme)) + { + // DeviceBindingName->SetText(devanme); + UpdateLabel(DeviceBindingName, devanme, STR_DEVICE_BINDING_NOTE); + } + else + { + // DeviceBindingName->SetText(" "); + UpdateLabel(DeviceBindingName, " ", STR_DEVICE_BINDING_NOTE); + } + DeviceBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + DeviceBindingName->SetRollSpeed(23); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + int y = DeviceBindingName->GetY() + DeviceBindingName->GetTextHeight() + 20; + DeviceBindingButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); + if (DeviceBindingButtonCancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingButtonCancel new fail!!"); + return nullptr; + } + /* -------------------------------- DeviceBindingButtonOK -------------------------------- */ + DeviceBindingButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); + if (DeviceBindingButtonOK == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingButtonOK new fail!!"); + return nullptr; + } + + UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); + if (listener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] PairingViewEventListener::GetInstance fail!!"); + return nullptr; + } + DeviceBindingButtonCancel->SetOnClickListener(listener); + DeviceBindingButtonOK->SetOnClickListener(listener); + /* ----------------------------------- Add ---------------------------------- */ + DeviceBindingScrollView->Add(DeviceBindingViewTitleLabel); + DeviceBindingScrollView->Add(DeviceBindingAnimatorView); + DeviceBindingScrollView->Add(DeviceBindingName); + DeviceBindingScrollView->Add(DeviceBindingButtonCancel); + DeviceBindingScrollView->Add(DeviceBindingButtonOK); + DeviceBindingView->Add(DeviceBindingScrollView); + } + + // 震动一次 + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + ui_api_vibrate_once_func(); + } + + ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 + + PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 + + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceBindingView); + return DeviceBindingView; + } + + /* + * @brief 创建设备解绑视图 + */ + UIViewGroup *CreateDeviceUnBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]"); + /* ---------------------------- DeviceUnBindingView --------------------------- */ + if (DeviceUnBindingView == nullptr) + { + DeviceUnBindingView = new UIViewGroup(); + if (nullptr == DeviceUnBindingView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new fail!!"); + return nullptr; + } + DeviceUnBindingView->SetPosition(0, 0, 466, 466); + DeviceUnBindingView->SetDraggable(true); + DeviceUnBindingView->SetTouchable(true); + /* ------------------------- DeviceUnBindingScrollView ------------------------ */ + if (DeviceUnBindingScrollView == nullptr) + { + DeviceUnBindingScrollView = new UIScrollView(); + if (DeviceUnBindingScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeviceUnBindingScrollView new fail"); + return nullptr; + } + } + DeviceUnBindingScrollView->SetPosition(0, 0, 466, 466); + DeviceUnBindingScrollView->SetThrowDrag(true); + DeviceUnBindingScrollView->SetDraggable(true); + DeviceUnBindingScrollView->SetTouchable(true); + DeviceUnBindingScrollView->SetReboundSize(30); + DeviceUnBindingScrollView->SetScrollBlankSize(30); + DeviceUnBindingScrollView->SetSwipeACCLevel(200); // 800: compensation distance + DeviceUnBindingScrollView->SetDragACCLevel(5); // 5: drag acceleration + DeviceUnBindingScrollView->SetMaxScrollDistance(1000); + DeviceUnBindingScrollView->SetDirection(UIScrollView::VERTICAL); + DeviceUnBindingScrollView->RequestFocus(); + DeviceUnBindingScrollView->SetRotateFactor(1.0); + /* ----------------------- DeviceUnBindingAnimatorView ---------------------- */ + UnBindPathsArray = CreateImageInfoArray(UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + if (DeviceUnBindingAnimatorView == nullptr) + { + DeviceUnBindingAnimatorView = new UIImageAnimatorView(); + if (DeviceUnBindingAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]DeviceUnBindingAnimatorView new fail"); + return nullptr; + } + for (uint8_t i = 0; i < UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + UnBindImageInfo[i].imageInfo = (UnBindPathsArray[i]); + UnBindImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; + UnBindImageInfo[i].pos.x = UNBIND_IMAGE_ANIMATOR_VIEW_X; + UnBindImageInfo[i].pos.y = UNBIND_IMAGE_ANIMATOR_VIEW_Y; + UnBindImageInfo[i].width = UNBIND_IMAGE_ANIMATOR_VIEW_W; + UnBindImageInfo[i].height = UNBIND_IMAGE_ANIMATOR_VIEW_H; + } + DeviceUnBindingAnimatorView->SetPosition(UNBIND_IMAGE_ANIMATOR_VIEW_X, UNBIND_IMAGE_ANIMATOR_VIEW_Y, UNBIND_IMAGE_ANIMATOR_VIEW_W, UNBIND_IMAGE_ANIMATOR_VIEW_H); + DeviceUnBindingAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + DeviceUnBindingAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + DeviceUnBindingAnimatorView->SetImageAnimatorSrc(UnBindImageInfo, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, UNBIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE); + DeviceUnBindingAnimatorView->SetRepeat(true); + DeviceUnBindingAnimatorView->SetSizeFixed(true); + DeviceUnBindingAnimatorView->Start(); + } + /* ----------------------- DeviceUnBindingViewTitleLabel ---------------------- */ + if (DeviceUnBindingViewTitleLabel == nullptr) + { + DeviceUnBindingViewTitleLabel = new UILabelExt(); + if (DeviceUnBindingViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingViewTitleLabel new fail!!"); + return nullptr; + } + } + DeviceUnBindingViewTitleLabel->SetPosition(83, 50, 300, 35); + DeviceUnBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // DeviceUnBindingViewTitleLabel->SetText("设备解绑"); + DeviceUnBindingViewTitleLabel->SetTextId(STR_EQUIPMENT_UNTYING); + DeviceUnBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + DeviceUnBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ---------------------------- DeviceUnBindingName --------------------------- */ + if (DeviceUnBindingName == nullptr) + { + DeviceUnBindingName = new UILabelExt(); + if (DeviceUnBindingName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName new fail!!"); + return nullptr; + } + } + DeviceUnBindingName->SetPosition(53, 230, 360, 70); + DeviceUnBindingName->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnBindingName->SetTextId(STR_EQUIPMENT_UNTYING_NOTE); // XX想要与你进行解绑 + + char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName devanme :%s", devanme); + + if (strlen(devanme)) + { + // DeviceUnBindingName->SetText(devanme); + UpdateLabel(DeviceUnBindingName, devanme, STR_EQUIPMENT_UNTYING_NOTE); + } + else + { + // DeviceUnBindingName->SetText(" "); + UpdateLabel(DeviceUnBindingName, " ", STR_EQUIPMENT_UNTYING_NOTE); + } + // DeviceUnBindingName->SetText("小米5\n"); + DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + int y = DeviceUnBindingName->GetY() + DeviceUnBindingName->GetTextHeight() + 20; + DeviceUnBindingButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); + if (DeviceUnBindingButtonCancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingButtonCancel new fail!!"); + return nullptr; + } + /* -------------------------------- DeviceUnBindingButtonOK -------------------------------- */ + DeviceUnBindingButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); + if (DeviceUnBindingButtonOK == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingButtonOK new fail!!"); + return nullptr; + } + /* ------------------------- button OnClickListener ------------------------- */ + UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); + if (nullptr == listener) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] PairingViewEventListener::GetInstance fail!!"); + return nullptr; + } + DeviceUnBindingButtonCancel->SetOnClickListener(listener); + DeviceUnBindingButtonOK->SetOnClickListener(listener); + /* ----------------------------------- Add ---------------------------------- */ + DeviceUnBindingScrollView->Add(DeviceUnBindingViewTitleLabel); + DeviceUnBindingScrollView->Add(DeviceUnBindingAnimatorView); + DeviceUnBindingScrollView->Add(DeviceUnBindingName); + DeviceUnBindingScrollView->Add(DeviceUnBindingButtonCancel); + DeviceUnBindingScrollView->Add(DeviceUnBindingButtonOK); + DeviceUnBindingView->Add(DeviceUnBindingScrollView); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new success!!"); + + /* -------------------------------------------------------------------------- */ + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + ui_api_vibrate_once_func(); // 震动一次 + } + + // ScreenTurnOff(); //先设置为0 + ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 + + PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 + /* -------------------------------------------------------------------------- */ + + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceUnBindingView); + return DeviceUnBindingView; + } + + /* + * @brief 创建解除绑定请求(与新设备连接)视图 + */ + UIViewGroup *CreateDeviceUnbindingRequestGroupView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]"); + + if (nullptr == DeviceUnbindingRequestGroupView) + { + /* --------------------- DeviceUnbindingRequestGroupView -------------------- */ + DeviceUnbindingRequestGroupView = new UIViewGroup(); + if (DeviceUnbindingRequestGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestGroupView is nullptr"); + return nullptr; + } + DeviceUnbindingRequestGroupView->SetPosition(0, 0, 466, 466); + DeviceUnbindingRequestGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0); + DeviceUnbindingRequestGroupView->SetVisible(false); + /* -------------------- DeviceUnbindingRequestScrollView -------------------- */ + DeviceUnbindingRequestScrollView = new UIScrollView(); + if (DeviceUnbindingRequestScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestScrollView is nullptr"); + return nullptr; + } + DeviceUnbindingRequestScrollView->SetPosition(0, 0, 466, 466); + DeviceUnbindingRequestScrollView->SetThrowDrag(true); + DeviceUnbindingRequestScrollView->SetDraggable(true); + DeviceUnbindingRequestScrollView->SetTouchable(true); + DeviceUnbindingRequestScrollView->SetReboundSize(30); + DeviceUnbindingRequestScrollView->SetScrollBlankSize(30); + DeviceUnbindingRequestScrollView->SetSwipeACCLevel(200); // 800: compensation distance + DeviceUnbindingRequestScrollView->SetDragACCLevel(5); // 5: drag acceleration + DeviceUnbindingRequestScrollView->SetMaxScrollDistance(1000); + DeviceUnbindingRequestScrollView->SetDirection(UIScrollView::VERTICAL); + DeviceUnbindingRequestScrollView->RequestFocus(); + DeviceUnbindingRequestScrollView->SetRotateFactor(1.0); + /* ------------------ DeviceUnbindingRequestViewTitleLabel ------------------ */ + if (DeviceUnbindingRequestViewTitleLabel == nullptr) + { + DeviceUnbindingRequestViewTitleLabel = new UILabelExt(); + if (DeviceUnbindingRequestViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewTitleLabel is nullptr"); + return nullptr; + } + } + DeviceUnbindingRequestViewTitleLabel->SetPosition(83, 50, 300, 35); + DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // DeviceUnbindingRequestViewTitleLabel->SetText("注意"); + DeviceUnbindingRequestViewTitleLabel->SetTextId(STR_LOOK_OUT); + DeviceUnbindingRequestViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + DeviceUnbindingRequestViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------- DeviceUnbindingRequestViewImageView ------------------ */ + if (DeviceUnbindingRequestViewImageView == nullptr) + { + DeviceUnbindingRequestViewImageView = new UIImageView(); + if (DeviceUnbindingRequestViewImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewImageView is nullptr"); + return nullptr; + } + } + DeviceUnbindingRequestViewImageView->SetPosition(193, 121, 80, 80); + const char *imageimagesPath = "/user/res/Attention.bin"; + DeviceUnbindingRequestViewImageView->SetSrc(imageimagesPath); + + /* --------------------- DeviceUnbindingRequestViewLabel[0] -------------------- */ + if (nullptr == DeviceUnbindingRequestViewLabel[0]) + { + DeviceUnbindingRequestViewLabel[0] = new UILabelExt(); + if (DeviceUnbindingRequestViewLabel[0] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[0] is nullptr"); + return nullptr; + } + } + DeviceUnbindingRequestViewLabel[0]->SetPosition(53, 242, 360, 70); + DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnbindingRequestViewLabel[0]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE1); + + char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); + if (strlen(devanme)) + { + UpdateLabel(DeviceUnbindingRequestViewLabel[0], devanme, STR_NEWDEVICE_BIND_REMIND_NOTE1); + } + else + { + UpdateLabel(DeviceUnbindingRequestViewLabel[0], " ", STR_NEWDEVICE_BIND_REMIND_NOTE1); + } + + DeviceUnbindingRequestViewLabel[0]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnbindingRequestViewLabel[0]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewLabel[0]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------- DeviceUnbindingRequestViewLabel[1] ------------------- */ + if (DeviceUnbindingRequestViewLabel[1] == nullptr) + { + DeviceUnbindingRequestViewLabel[1] = new UILabelExt(); + if (DeviceUnbindingRequestViewLabel[1] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[1] is nullptr"); + return nullptr; + } + } + int y = DeviceUnbindingRequestViewLabel[0]->GetY() + DeviceUnbindingRequestViewLabel[0]->GetTextHeight() + 50; + DeviceUnbindingRequestViewLabel[1]->SetPosition(53, y, 360, 280); + DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnbindingRequestViewLabel[1]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE2); + if (strlen(devanme)) + { + UpdateLabel(DeviceUnbindingRequestViewLabel[1], devanme, STR_NEWDEVICE_BIND_REMIND_NOTE2); + } + else + { + UpdateLabel(DeviceUnbindingRequestViewLabel[1], " ", STR_NEWDEVICE_BIND_REMIND_NOTE2); + } + DeviceUnbindingRequestViewLabel[1]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnbindingRequestViewLabel[1]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewLabel[1]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------- DeviceUnbindingRequestViewLabel[2] ------------------- */ + if (DeviceUnbindingRequestViewLabel[2] == nullptr) + { + DeviceUnbindingRequestViewLabel[2] = new UILabelExt(); + if (DeviceUnbindingRequestViewLabel[2] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[2] is nullptr"); + return nullptr; + } + } + y = DeviceUnbindingRequestViewLabel[1]->GetY() + DeviceUnbindingRequestViewLabel[1]->GetTextHeight() + 50; + DeviceUnbindingRequestViewLabel[2]->SetPosition(53, y, 360, 35); + DeviceUnbindingRequestViewLabel[2]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[2]->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnbindingRequestViewLabel[2]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE3); + DeviceUnbindingRequestViewLabel[2]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnbindingRequestViewLabel[2]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewLabel[2]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + y = DeviceUnbindingRequestViewLabel[2]->GetY() + DeviceUnbindingRequestViewLabel[2]->GetTextHeight() + 50; + DeviceUnbindingRequestButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); + if (DeviceUnbindingRequestButtonCancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnbindingRequestButtonCancel new fail!!"); + return nullptr; + } + + /* -------------------------------- DeviceUnbindingRequestButtonOK -------------------------------- */ + DeviceUnbindingRequestButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); + if (DeviceUnbindingRequestButtonOK == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnbindingRequestButtonOK new fail!!"); + return nullptr; + } + /* ------------------------- button OnClickListener ------------------------- */ + UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); + if (listener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] PairingViewEventListener::GetInstance fail!!"); + return nullptr; + } + DeviceUnbindingRequestButtonCancel->SetOnClickListener(listener); + DeviceUnbindingRequestButtonOK->SetOnClickListener(listener); + /* -------------------------------------------------------------------------- */ + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewTitleLabel); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewImageView); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[0]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[1]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[2]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonCancel); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonOK); + DeviceUnbindingRequestGroupView->Add(DeviceUnbindingRequestScrollView); + } + return DeviceUnbindingRequestGroupView; + } + + /* + * @brief 销毁设备绑定视图 + */ + void FreeDeviceBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView]"); + if (DeviceBindingView != nullptr) + { + PairingViewEventListener::GetInstance().Pairing_StopTimer(); + DeviceBindingView->RemoveAll(); + if (DeviceBindingScrollView != nullptr) + { + DeviceBindingScrollView->RemoveAll(); + if (DeviceBindingViewTitleLabel) + { + delete DeviceBindingViewTitleLabel; + DeviceBindingViewTitleLabel = nullptr; + } + if (DeviceBindingName) + { + delete DeviceBindingName; + DeviceBindingName = nullptr; + } + if (DeviceBindingAnimatorView) + { + DeviceBindingAnimatorView->Stop(); + delete DeviceBindingAnimatorView; + DeviceBindingAnimatorView = nullptr; + FreeImageInfoArray(BindPathsArray, BIND_IMAGE_SRC, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + } + if (DeviceBindingButtonCancel) + { + delete DeviceBindingButtonCancel; + DeviceBindingButtonCancel = nullptr; + } + if (DeviceBindingButtonOK) + { + delete DeviceBindingButtonOK; + DeviceBindingButtonOK = nullptr; + } + DeviceBindingScrollView->ClearFocus(); + delete DeviceBindingScrollView; + DeviceBindingScrollView = nullptr; + } + RootView::GetInstance()->Remove(DeviceBindingView); + delete DeviceBindingView; + DeviceBindingView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView] success"); + ScreenTurnOff(); + } + } + + /* + * @brief 销毁设备解绑视图 + */ + void FreeDeviceUnBindingView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView]"); + if (DeviceUnBindingView != nullptr) + { + PairingViewEventListener::GetInstance().Pairing_StopTimer(); + DeviceUnBindingView->RemoveAll(); + if (DeviceUnBindingScrollView != nullptr) + { + DeviceUnBindingScrollView->RemoveAll(); + if (DeviceUnBindingViewTitleLabel) + { + delete DeviceUnBindingViewTitleLabel; + DeviceUnBindingViewTitleLabel = nullptr; + } + if (DeviceUnBindingAnimatorView) + { + DeviceUnBindingAnimatorView->Stop(); + delete DeviceUnBindingAnimatorView; + DeviceUnBindingAnimatorView = nullptr; + FreeImageInfoArray(UnBindPathsArray, UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + } + if (DeviceUnBindingName) + { + delete DeviceUnBindingName; + DeviceUnBindingName = nullptr; + } + if (DeviceUnBindingButtonCancel) + { + delete DeviceUnBindingButtonCancel; + DeviceUnBindingButtonCancel = nullptr; + } + if (DeviceUnBindingButtonOK) + { + delete DeviceUnBindingButtonOK; + DeviceUnBindingButtonOK = nullptr; + } + DeviceUnBindingScrollView->ClearFocus(); + delete DeviceUnBindingScrollView; + DeviceUnBindingScrollView = nullptr; + } + RootView::GetInstance()->Remove(DeviceUnBindingView); + delete DeviceUnBindingView; + DeviceUnBindingView = nullptr; + FreeDeviceUnbindingRequestGroupView(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView] success"); + ScreenTurnOff(); + } + } + + /* + * @brief 销毁解除绑定请求(与新设备连接)视图 + */ + void FreeDeviceUnbindingRequestGroupView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView]"); + if (DeviceUnbindingRequestGroupView != nullptr) + { + DeviceUnbindingRequestGroupView->RemoveAll(); + if (nullptr != DeviceUnbindingRequestScrollView) + { + DeviceUnbindingRequestScrollView->RemoveAll(); + if (DeviceUnbindingRequestViewTitleLabel) + { + delete DeviceUnbindingRequestViewTitleLabel; + DeviceUnbindingRequestViewTitleLabel = nullptr; + } + if (DeviceUnbindingRequestViewImageView) + { + delete DeviceUnbindingRequestViewImageView; + DeviceUnbindingRequestViewImageView = nullptr; + } + for (int i = 0; i < (sizeof(DeviceUnbindingRequestViewLabel) / sizeof(DeviceUnbindingRequestViewLabel[0])); i++) + { + if (DeviceUnbindingRequestViewLabel[i]) + { + delete DeviceUnbindingRequestViewLabel[i]; + DeviceUnbindingRequestViewLabel[i] = nullptr; + } + } + if (DeviceUnbindingRequestButtonOK) + { + delete DeviceUnbindingRequestButtonOK; + DeviceUnbindingRequestButtonOK = nullptr; + } + if (DeviceUnbindingRequestButtonCancel) + { + delete DeviceUnbindingRequestButtonCancel; + DeviceUnbindingRequestButtonCancel = nullptr; + } + DeviceUnbindingRequestScrollView->ClearFocus(); + delete DeviceUnbindingRequestScrollView; + DeviceUnbindingRequestScrollView = nullptr; + } + RootView::GetInstance()->Remove(DeviceUnbindingRequestGroupView); + delete DeviceUnbindingRequestGroupView; + DeviceUnbindingRequestGroupView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView] success"); + } + if (p_ShutDownImageAnimatorView != nullptr) + { + RootView::GetInstance()->Remove(ShutDownImageAnimatorGroupView); + delete p_ShutDownImageAnimatorView; + p_ShutDownImageAnimatorView; + } + } + + /* -------------------------------------------------------------------------- */ + + // 声明定时器变量 + static osTimerId_t g_timer = NULL; + + /*定时器到期时的处理*/ + static void Pairing_TimerCallbackProc(int data) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Pairing_TimerCallbackProc"); + NotificationManager::GetInstance()->StopNotify(); + } + + /* + * @brief 回调函数 + */ + static void Pairing_TimerCallback(int data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(Pairing_TimerCallbackProc, data)); + } + + /* + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void PairingViewEventListener::Pairing_StartTimer(uint32_t interval) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::Pairing_StartTimer"); + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */ + if (g_timer != NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer already exists!!"); + return; + } + + /* --------------------------------- 2.创建定时器 -------------------------------- */ + g_timer = osTimerNew((osTimerFunc_t)Pairing_TimerCallback, osTimerOnce, NULL, NULL); + // 检查定时器创建是否成功 + if (g_timer == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer create failed!!"); + return; + } + + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */ + int tick = osMs2Tick(interval); + + /* --------------------------------- 4.启动定时器 -------------------------------- */ + osStatus_t ret = osTimerStart(g_timer, tick); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 NULL -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CountDown_StartTimer] osTimerDelete failed, ret = %lx!!", ret); + if (g_timer != NULL) + { + ret = osTimerDelete(g_timer); + } + g_timer = NULL; + return; + } + return; + } + + /* + * @brief 停止定时器 + */ + void PairingViewEventListener::Pairing_StopTimer(void) + { + // 检查定时器是否存在 + if (g_timer != NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::Pairing_StopTimer"); + osTimerStop(g_timer); + // 删除定时器并置为 NULL + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = NULL; + } + } + static uint8_t shutDownAnimation_falg = -1; //关机动画标志位 + void set_shutDownAnimation_falg(uint8_t falg) + { + shutDownAnimation_falg = falg; + } + /* + * @brief 显示关机动画 + */ + UIViewGroup *showShutDownAnimation(void) + { + if (shutDownImageAnimatorView == nullptr) + { + shutDownImageAnimatorView = new ShutDownImageAnimatorView(); + if (shutDownImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorView new fail!!"); + return nullptr; + } + shutDownImageAnimatorGroupView = shutDownImageAnimatorView->ShutDownAnimatorViewInit(); + if (shutDownImageAnimatorGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorGroupView new fail!!"); + return nullptr; + } + shutDownImageAnimatorView->ShutDownImageAnimator_Start(shutDownAnimation_falg); + RootView::GetInstance()->ClearOnKeyActListener(); + } + return shutDownImageAnimatorGroupView; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp new file mode 100644 index 000000000..85920cae1 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp @@ -0,0 +1,1191 @@ +#include "notification_manager.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "AlarmPopUpPresenter.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_label_button_ext.h" +#include "battery_service.h" +#include "NativeAbility.h" +#include "custom_utils.h" +#include "components/ui_slider.h" +// #include "UiConfig.h" +#include "bleEvent.h" +#include "power_display_service.h" +#include "uicomponents/UIComponents.h" +#include "upg.h" +#include "custom_runtime.h" +#include "PhoneService.h" +#include "ConfigModelC.h" +#include "ConfigModel.h" +#include "languagecode/LanguageInit.h" +namespace OHOS +{ + static UIImageView *imageCharge = nullptr; + static UIViewGroup *UIViewGroup_transmitting=nullptr; + + static UIImageView *transmitting_img=nullptr; + + static UISlider *updatasider=nullptr; + + static UILabelExt *Title=nullptr; + + static UILabelExt *label_=nullptr; + + static UIImageAnimatorView *downImageAnimatorView=nullptr; + + static constexpr char *ShutDownPaths = "/user/res/down/"; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 24; // 图片帧数 + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 150; // 图片更新间隔 + static ImageAnimatorInfo ImageInfo_animator[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息 + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_X = 183; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y = 140; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_W = 100; + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_H = 100; + + const ImageInfo **imageInfo_dwon{nullptr}; // 关机图片路径数组 + + #define TRANSMITTING_SUCC_PATH PNG_SUCC_IMAGE; + #define TRANSMITTING_FAIL_PATH PNG_ATTENTION_IMAGE; + #define TRANSMITTING_OTA_DOWN "/user/res/system/KUMILOGO.bin" + + + + #define LOW_POWER_BUTTON "LOW_POWER_BUTTON" + + + + static void CreatetransmittingAnimator(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView"); + imageInfo_dwon = CreateImageInfoArray(ShutDownPaths,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, "bin"); + + if (downImageAnimatorView == nullptr) + { + downImageAnimatorView = new UIImageAnimatorView(); + if (downImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new downImageAnimatorView fail"); + return; + } + for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + ImageInfo_animator[i].imageInfo = (imageInfo_dwon[i]); + ImageInfo_animator[i].imageType = IMG_SRC_IMAGE_INFO; + ImageInfo_animator[i].pos.x = SHUTDOWN_IMAGE_ANIMATOR_VIEW_X; + ImageInfo_animator[i].pos.y = SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y; + ImageInfo_animator[i].width = SHUTDOWN_IMAGE_ANIMATOR_VIEW_W; + ImageInfo_animator[i].height = SHUTDOWN_IMAGE_ANIMATOR_VIEW_H; + } + downImageAnimatorView->SetPosition(SHUTDOWN_IMAGE_ANIMATOR_VIEW_X, SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y, SHUTDOWN_IMAGE_ANIMATOR_VIEW_W, SHUTDOWN_IMAGE_ANIMATOR_VIEW_H); + downImageAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + downImageAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + downImageAnimatorView->SetImageAnimatorSrc(ImageInfo_animator, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100); + downImageAnimatorView->SetRepeat(true); + downImageAnimatorView->SetRepeatTimes(1); + + } + downImageAnimatorView->SetVisible(true); + downImageAnimatorView->Start(); + //downImageAnimatorView->Start(); + + return ; + } + + + + + static uint8_t Transmitting_falg=1; + void set_transmittingShow_falg(uint8_t falg) + { + Transmitting_falg=falg; + } + + static osTimerId_t transmitting_timer= NULL; + + void Freetransmitting(void) + { + if (UIViewGroup_transmitting != nullptr) + { + UIViewGroup_transmitting->RemoveAll(); + + if(transmitting_img) + { + delete transmitting_img; + transmitting_img = nullptr; + } + if(Title) + { + delete Title; + Title = nullptr; + } + if(label_) + { + delete label_; + label_ = nullptr; + } + if(downImageAnimatorView) + { + FreeImageInfoArray(imageInfo_dwon,ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES,"bin"); + delete downImageAnimatorView; + downImageAnimatorView = nullptr; + } + if(updatasider) + { + delete updatasider; + updatasider = nullptr; + } + if(transmitting_timer) + { + + osTimerStop(transmitting_timer); + osStatus_t ret = osTimerDelete(transmitting_timer); + if (ret != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed ret = %lx!", ret); + //return; + } + transmitting_timer = nullptr; + } + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_auto_timeout_function(true); + + uapi_take_to_wake(1); + + RootView::GetInstance()->Remove(UIViewGroup_transmitting); + delete UIViewGroup_transmitting; + UIViewGroup_transmitting = nullptr; + + uapi_dev_runtime_set_transmitting_status(0); + } + } + static uint8_t timer_falg_low_power=5; + + static uint8_t test_flag=0; + + static void OTATimerCallBackProc(int data) + { + #if 0 + if(updatasider) + updatasider->SetValue(test_flag++); + #else + if(updatasider) + updatasider->SetValue(get_OTA_recv_value()); + #endif + if(updatasider) + updatasider->Invalidate(); + } + + void OTATimerCallBack(int data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(OTATimerCallBackProc, data)); + } + + void dialtimerCallBack(int data) + { + NotificationManager::GetInstance()->StopNotify(); + } + + + + void creat_down_OTA() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(83, 50); // widget's left position and top position + Title->Resize(300, 35); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA下载中"); + Title->SetTextId (STR_OTA_DOWNLOAD); + + Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + + if (updatasider == nullptr) + { + updatasider = new UISlider(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView new fail"); + + } + + updatasider->SetSliderColor(Color::Gray(), Color::Silver()); + updatasider->SetPosition(63, 317, 340, 50); + updatasider->SetViewId("SystemUpdateView_updatasider"); + updatasider->SetRange(0, 100); + + updatasider->SetStyle(STYLE_BORDER_RADIUS, 100); + updatasider->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); + updatasider->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); + updatasider->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); + updatasider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); + updatasider->SetDraggable(false); + updatasider->SetTouchable(false); + updatasider->SetValue(0); + UIViewGroup_transmitting->Add(updatasider); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 220); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("软件正在更新"); + label_->SetTextId(STR_OTA_DOWNLOADING); + label_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + + } + transmitting_img->SetPosition(117, 87, 230, 160); + const char *imagesPath = TRANSMITTING_OTA_DOWN; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + + Set_OTA_recv_value(); + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)OTATimerCallBack, osTimerPeriodic, NULL, NULL); + tick =500;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + } + static upg_result_t upg_result; + static uint32_t last_image_index; + + static char updata_fail_str[32]={0}; + + static uint8_t TRANSMIT_DATA; + + void get_updatafail_data(void) + { + errcode_t ret; + ret = uapi_upg_get_result(&upg_result, &last_image_index); + if (ret != ERRCODE_SUCC) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_upg_get_result error = 0x%x\r\n", ret); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"upg_result = %d, last_image_index:%d\r\n", upg_result, last_image_index); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_upg_get_result OK!!\r\n"); + if(upg_result!=UPG_RESULT_UPDATE_SUCCESS) + { + sprintf_s(updata_fail_str,32,"%d_%d",(int)upg_result,last_image_index); + TRANSMIT_DATA=OTA_UPDATA_FAIL; + if(ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_OTA_UPGRADE)) + { + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + ConfigModel::GetInstance()->set_condigData_Int(ConfigModel::CONFIGMODEL_ITEM_OTA_UPGRADE,0); + } + } + + } + } + + void Creat_OTA_Updata_FAIL() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(83, 50); // widget's left position and top position + Title->Resize(300, 35); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA upgrade failure"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(Title); + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + char fail_str[128]={0}; + sprintf_s(fail_str,128,"ota升级失败,请尝试重启设备"); + + label_->SetText(fail_str); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(label_); + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + void Creat_CAT1_OTA_Updata() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(83, 50); // widget's left position and top position + Title->Resize(300, 35); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("CAT1 OTA upgradeing"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(Title); + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + + label_->SetText("4G模块OTA升级中,请勿操作,升级成功后会自动重启"); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + UIViewGroup_transmitting->Add(label_); + + // Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + + + + + void creat_down_OTA_FAIL() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(143, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA下载失败"); + Title->SetTextId (STR_OTA_DOWNLOADFIAL); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("下载升级包失败,请退出或者重新下载"); + label_->SetTextId(STR_OTA_DOWNLOADFIAL_TRY); + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + UIViewGroup_transmitting->Add(label_); + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(117, 87, 230, 160); + const char *imagesPath = TRANSMITTING_OTA_DOWN; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + void creat_down_OTA_SUCC() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(143, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("OTA下载成功"); + Title->SetTextId (STR_OTA_DOWNLOADSUCC); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("下载升级包成功,可以开始升级手表"); + label_->SetTextId(STR_OTA_DOWNLOADSUCC_UPDATA); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + + + //Add ImageView to App + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + + } + transmitting_img->SetPosition(117, 87, 230, 160); + const char *imagesPath = TRANSMITTING_OTA_DOWN; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + } + + + + + void creat_down_Dial() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(158, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("表盘安装中"); + Title->SetTextId (STR_DIAL_DOWNLOADING_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("正在安装表盘,请不要做其他操作或关闭手表"); + label_->SetTextId(STR_DIAL_DOWNLOADING_LABEL); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + CreatetransmittingAnimator(); + // UIViewGroup_transmitting->Add(updatasider); + + UIViewGroup_transmitting->Add(downImageAnimatorView); + } + + + void creat_down_MP3() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(158, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("音乐传输中"); + Title->SetTextId (STR_MUSIC_TRANSMIT); + + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("正在传输音乐,请不要做其他操作或关闭手表"); + label_->SetTextId(STR_MUSIC_TRANSMIT_NOTE); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + CreatetransmittingAnimator(); + // UIViewGroup_transmitting->Add(updatasider); + + UIViewGroup_transmitting->Add(downImageAnimatorView); + } + + void creat_down_MP3_succ() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("传输成功"); + Title->SetTextId (STR_MP3_SUCC_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("音乐传输成功正在校验,请稍等"); + label_->SetTextId(STR_MUSIC_TRANSMIT_SUCCESS_NOTE); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_SUCC_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)dialtimerCallBack, osTimerPeriodic, NULL, NULL); + tick =2000;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + } + + + + void creat_down_Dial_succ() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("安装成功"); + Title->SetTextId (STR_DIAL_SUCC_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("表盘安装成功正在更新表盘,请稍等"); + label_->SetTextId(STR_DIAL_SUCC_LABEL); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_SUCC_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + uint32_t tick; + osStatus_t retTimer; + if(transmitting_timer!=NULL) + { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + transmitting_timer = osTimerNew((osTimerFunc_t)dialtimerCallBack, osTimerPeriodic, NULL, NULL); + tick =2000;// osMs2Tick(1000); + retTimer = osTimerStart(transmitting_timer, tick); + if (retTimer != osOK && transmitting_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + return ; + } + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + } + + + void creat_down_max_Dial_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetTextId(STR_OPERAT_FAIL);//TODO:多国语言 + //Title->SetTextId (STR_DIAL_FAIL_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + label_->SetTextId(STR_DIAL_NOTE);//TODO:多国语言 + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + void creat_down_max_MP3_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetTextId(STR_OPERAT_FAIL);//TODO:多国语言 + //Title->SetTextId (STR_DIAL_FAIL_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + // label_->SetTextId(STR_DIAL_NOTE);//TODO:多国语言 + // + // + if(ConfigModel::GetInstance()->GetLanguage() == ZH_CN) + label_->SetText("本地下载音乐已达到存储上限;请先删除部分歌曲再进行上传"); + else + label_->SetText( + "The storage capacity of locally downloaded music has reached the upper limit.\ + Please delete some songs before uploading"); + + + + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + void creat_down_Dial_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("安装失败"); + Title->SetTextId (STR_DIAL_FAIL_TITLE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + + + label_->SetTextId(STR_DIAL_FAIL_LABEL); + + + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + void creat_down_MP3_fail() + { + if (Title == nullptr) { + Title = new UILabelExt(); + } + Title->SetPosition(173, 51); // widget's left position and top position + Title->Resize(800, 88); // widget's width and height + Title->SetViewId("label1");// Set style + Title->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + Title->SetText("传输失败"); + Title->SetTextId (STR_MP3_FAIL_TITL); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(0); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + UIViewGroup_transmitting->Add(Title); + Title->SetVisible(true); + + + if (label_ == nullptr) { + label_ = new UILabelExt(); + } + label_->SetPosition(60, 281); // widget's left position and top position + label_->Resize(345, 101); // widget's width and height + label_->SetViewId("label2");// Set style + label_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_->SetText("音乐传输失败,请退出或重新安装"); + label_->SetTextId(STR_MP3_FAIL_LABEL); + label_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label_->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_->SetRollSpeed(0); + label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + + + if (transmitting_img == nullptr) + { + transmitting_img = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + } + transmitting_img->SetPosition(193, 150,80, 80); + const char *imagesPath = TRANSMITTING_FAIL_PATH; + transmitting_img->SetSrc(imagesPath); + UIViewGroup_transmitting->Add(transmitting_img); + + // Add to rootView + UIViewGroup_transmitting->Add(label_); + label_->SetVisible(true); + + + + } + + + bool transmittingISShow(void) + { + if(uapi_dev_runtime_get_transmitting_status()) + return true; + else + return false; + } + + UIViewGroup *transmittingShow() + { + + if (UIViewGroup_transmitting == nullptr) { + UIViewGroup_transmitting = new UIViewGroup(); + UIViewGroup_transmitting->SetPosition(0, 0, 466, 466); + //UIViewGroup_transmitting->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + else + { + UIViewGroup_transmitting->RemoveAll(); + } + uapi_dev_runtime_set_transmitting_status(1); + switch (Transmitting_falg) + { + case TRANS_DIAL_TRANSMITTING: + creat_down_Dial(); + break; + case TRANS_DIAL_SUCC: + creat_down_Dial_succ(); + break; + case TRANS_DIAL_FAIL: + creat_down_Dial_fail(); + break; + case TRANS_DIAL_MAX_FAIL: + creat_down_max_Dial_fail(); + break; + + case TRANS_OTA_TRANSMITTING: + creat_down_OTA(); + break; + case TRANS_OTA_SUCC: + creat_down_OTA_SUCC(); + break; + case TRANS_OTA_FAIL: + creat_down_OTA_FAIL(); + break; + case TRANS_MP3_TRANSMITTING: + creat_down_MP3(); + break; + case TRANS_MP3_SUCC: + creat_down_MP3_succ(); + break; + case TRANS_MP3_FAIL: + creat_down_MP3_fail(); + break; + case OTA_UPDATA_FAIL: + Creat_OTA_Updata_FAIL(); + break; + case START_CAT1_OTA: + Creat_CAT1_OTA_Updata(); + break; + case TRANS_MP3_MAX_FAIL: + creat_down_max_MP3_fail(); + break; + + + default: + break; + } + if(Transmitting_falg==TRANS_DIAL_TRANSMITTING || Transmitting_falg==TRANS_OTA_TRANSMITTING || Transmitting_falg==TRANS_MP3_TRANSMITTING) + { + if(uapi_hfp_connect_state()) + { + uapi_hfp_disconnect(); + } + } + else if(Transmitting_falg!=OTA_UPDATA_FAIL) + { + if(uapi_dev_runtime_get_bt_powerstat() && cm_get_HFP_switch()) + { + uapi_hfp_connect(); + } + + } + + UIView::OnClickListener *button1Click = static_cast(transmittingViewEventListener::GetInstance()); + UIViewGroup_transmitting->SetOnClickListener(button1Click); + UIViewGroup_transmitting->SetTouchable(true); + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_auto_timeout_function(false); + uapi_take_to_wake(0); + + + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(Freetransmitting); + return UIViewGroup_transmitting; + } + + transmittingViewEventListener::transmittingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallViewEventListener :%p", this); + } + + transmittingViewEventListener::~transmittingViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~CallViewEventListener"); + } + + transmittingViewEventListener *transmittingViewEventListener::GetInstance(void) + { + static transmittingViewEventListener lowppowrViewEventListene_t; + return &lowppowrViewEventListene_t; + } + + bool transmittingViewEventListener::OnClick(UIView& view, const ClickEvent& event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick"); + if(Transmitting_falg!=TRANS_DIAL_TRANSMITTING + && Transmitting_falg!=TRANS_OTA_TRANSMITTING + && Transmitting_falg!=TRANS_MP3_TRANSMITTING + && Transmitting_falg!=START_CAT1_OTA) + { + NotificationManager::GetInstance()->StopNotify(); + } + return true; + UNUSED(event); + } + +} diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 3ba17fa21..2218894ed 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -354,12 +354,12 @@ target = { 'ENCODER_SUPPORT', # 'SUPPORT_SPO2_NOTIFICATION', # 'SUPPORT_SPO2_NOTIFICATION_TEST', - # 'SUPPORT_DEVICE_PAIRING_NOTIFICATION', + 'SUPPORT_DEVICE_PAIRING_NOTIFICATION', # 'ENABLE_FONT_VECTOR_GLOBAL', # 'ENABLE_SHAPING', 'SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION', # 'SUPPORT_AT_CUSTOMUTILS', - # 'SUPPORT_BLE_SERVICE', + 'SUPPORT_BLE_SERVICE', 'FD230', # 'SUPPORT_AUTO_OTA_SERVER', # 'CONFIG_DFX_SUPPORT_DIAG_UP_MACHINE=1', diff --git a/code/sdk/zhihui/config/src/ConfigModel.cpp b/code/sdk/zhihui/config/src/ConfigModel.cpp index 066ecfcab..43d7eef39 100644 --- a/code/sdk/zhihui/config/src/ConfigModel.cpp +++ b/code/sdk/zhihui/config/src/ConfigModel.cpp @@ -1311,7 +1311,7 @@ extern "C" { void installize_dev_runtime(void) { int16_t timezone = cm_get_timezone_quarters(); - uapi_set_timezone(timezone); + // uapi_set_timezone(timezone); //更新24小时显示模式 uint8_t showtype=cm_get_hour_show_model(); uapi_dev_runtime_set_time_hour_show_model(showtype); diff --git a/code/sdk/zhihui/services/ble_service/blemoder/CMakeLists.txt b/code/sdk/zhihui/services/ble_service/blemoder/CMakeLists.txt index 9a777d37d..dfd4d789f 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/CMakeLists.txt +++ b/code/sdk/zhihui/services/ble_service/blemoder/CMakeLists.txt @@ -62,6 +62,8 @@ set(PRIVATE_HEADER set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/bleInstruct.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ble_congfig_adapt.cpp +${CMAKE_CURRENT_SOURCE_DIR}/ble_instruct_init.cpp + ) diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp index c98b1c2ab..35f21cc2f 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp @@ -50,7 +50,7 @@ extern "C" { -bleInstruct_t_ bleInstruct_t; +bleInstruct_t_ bleInstruct_t={NULL}; char * get_dial_path(void) { @@ -179,6 +179,10 @@ void ble_connect_ok(void) void ble_disconnect_ok(void) { + if( bleInstruct_t.ble_disconnect_ok==NULL) + { + return; + } return bleInstruct_t.ble_disconnect_ok(); } @@ -750,9 +754,9 @@ char * struct_to_json_buf_malloc_Alarm(void) return bleInstruct_t.struct_to_json_buf_malloc_Alarm(); } -char * struct_to_json_buf_malloc_(uint8_t day) +char * struct_to_json_buf_malloc(uint8_t day) { - return bleInstruct_t.struct_to_json_buf_malloc_(day); + return bleInstruct_t.struct_to_json_buf_malloc(day); } #define TAR_PATH EXC_TAR_PATH @@ -1225,6 +1229,12 @@ bool IS_free_save_Mp3(uint32_t size) } +void ble_bin_install(void) +{ + return bleInstruct_t.ble_bin_install(); +} + + #endif diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.h b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.h index a5c0fd2aa..e60fcacad 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.h +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.h @@ -49,10 +49,14 @@ extern "C" START_CAT1_OTA, + TRANS_BIN_TRANSMITTING, + TRANS_BIN_SUCC, + TRANS_BIN_FAIL, OTA_UPDATA_FAIL, FILE_IS_DONE, + IS_NEED_CAT1_OTA, TRANS_FREE, } transmitting_type; @@ -183,7 +187,7 @@ int get_goal_durationcount(void);//获取目标燃脂时间 void set_goal_standupcount(uint32_t time);//设置目标战立次数 int get_goal_standupcount(void);//获取目标站立次数 -char* struct_to_json_buf_malloc_(uint8_t day); +char* struct_to_json_buf_malloc(uint8_t day); char * struct_to_json_buf_malloc_Alarm(void); ////////////////闹钟相关///////////////////////////// @@ -412,7 +416,7 @@ errcode_t get_dial_file_path(char* input_dialname ,uint32_t input_size, char* ou uint16_t get_str_nodisplay_number(char *str, uint32_t max_len); - +void ble_bin_install(void); typedef struct bleInstruct { uint16_t (*get_str_nodisplay_number_cb)(char *str, uint32_t max_len); @@ -453,11 +457,11 @@ typedef struct bleInstruct bool (*get_lcd_state)(void); - uint8_t (*ble_get_heart_data)(); - uint8_t (*ble_get_oxygen_data)(); + uint8_t (*ble_get_heart_data)(void); + uint8_t (*ble_get_oxygen_data)(void); - cJSON* (*ble_get_recs_data)(); + cJSON* (*ble_get_recs_data)(void); cJSON* (*ble_get_Trainingdata_by_timetamp)(uint32_t timetamp); @@ -520,7 +524,7 @@ typedef struct bleInstruct char * (*struct_to_json_buf_malloc_Alarm)(void); - char * (*struct_to_json_buf_malloc_)(uint8_t day); + char * (*struct_to_json_buf_malloc)(uint8_t day); void (*get_tar_dir_file_count)(void); void (*add_addressbookToRead)(char *data); @@ -614,7 +618,7 @@ typedef struct bleInstruct void (*ble_UpdateMainWeatherData)(void); void (*ble_add_message_index)(uint32_t old_index); - uint32_t (*ble_get_message_index)(); + uint32_t (*ble_get_message_index)(void); void (*SendDtfmStrNumberToCat1)(char ch) ; void (*ble_mp3_list_update)(void); @@ -627,12 +631,18 @@ typedef struct bleInstruct void (*ble_disconnect_ok)(void); void (*hand_watch_first_time_Paired)(void); + void (*ble_bin_install)(void); } bleInstruct_t_; extern bleInstruct_t_ bleInstruct_t; +void ble_config_init(void); + +void ble_instruct_init(void); + +void ble_mp3_init(void); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp b/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp index 3bfd43eb0..7c1346941 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp @@ -2,7 +2,7 @@ #include "../../../../../../zhihui/config/include/ConfigModelC.h" - +#include #include "ConfigModel.h" #include "bleEvent.h" @@ -11,6 +11,8 @@ #include "ui_service.h" #include "custom_utils.h" + + void set_ota_upgrade_(void) { OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); @@ -531,10 +533,39 @@ int get_ScreenDuration_(void) //获取亮屏时长 // OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); // return p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_MESSAGE_INDEX); // } +void null_doing(void) +{ + return; +} + + + +bool IS_free_save_Mp3_(uint32_t size) +{ + return true;//canSyncMusic(size); +} + +void ble_mp3_list_update_(void) +{ + // SendMsgToUIService(UI_UPDATE_MUSIC_PLAYER_LIST,0,nullptr,0); +} + + extern bleInstruct_t_ bleInstruct_t; -void ble_config_init() +void ble_mp3_init(void) +{ + bleInstruct_t.IS_free_save_Mp3=IS_free_save_Mp3_; + bleInstruct_t.ble_mp3_list_update=ble_mp3_list_update_; + +} + + + +extern bleInstruct_t_ bleInstruct_t; + +void ble_config_init(void) { bleInstruct_t.set_ota_upgrade_cb=set_ota_upgrade_; bleInstruct_t.is_first_pair_cb=is_first_pair_; @@ -584,5 +615,11 @@ void ble_config_init() bleInstruct_t.get_brigthness= get_brigthness_; bleInstruct_t.set_ScreenDuration= set_ScreenDuration_; bleInstruct_t. get_ScreenDuration=get_ScreenDuration_; + + bleInstruct_t.ble_disconnect_ok=null_doing; + bleInstruct_t.ble_connect_ok=null_doing; + bleInstruct_t.hand_watch_first_time_Paired=null_doing; + + } #endif \ No newline at end of file diff --git a/code/sdk/zhihui/services/ble_service/blemoder/ble_instruct_init.cpp b/code/sdk/zhihui/services/ble_service/blemoder/ble_instruct_init.cpp new file mode 100644 index 000000000..dc2de890b --- /dev/null +++ b/code/sdk/zhihui/services/ble_service/blemoder/ble_instruct_init.cpp @@ -0,0 +1,36 @@ + +#include "bleInstruct.h" +#include "WeatherModel.h" +#include "SetDialModel.h" +#include "health_service.h" +#include "MusicPlayerModel.h" +#include "phoneaddressmodel.h" +#include "TraingModel.h" +// #include "AlarmClockModel.h" +// #include "SetDialModel.h" +#include "SleepModel.h" +// #include "PlayersModel.h" + +void ble_instruct_init(void) +{ + ble_dial_init(); + + // OHOS::ble_alarm_init(); + + ble_mp3_init(); + + ble_sleep_init(); + + OHOS::ble_HEART_init(); + + OHOS::ble_play_init(); + + OHOS::ble_addressbook_init(); + + ble_training_init(); + + OHOS::ble_weather_init(); + + ble_config_init(); + +} \ No newline at end of file diff --git a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c index 634c38d4e..d745430a0 100644 --- a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c +++ b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c @@ -113,7 +113,6 @@ static bool ANCSBigBufFlag = 0;//ANCS多包数据flag ble_recv_data_info_t ble_recv_data; static uint8_t TRANSMIT_DATA; static osTimerId_t BR_TRANSFER_timer=NULL; -static uint8_t timer_flie_type=0; static uint32_t timer_flie_flag=0; ble_read_data* ble_read_timer_p=NULL; @@ -1208,7 +1207,7 @@ void sendBindInfor(uint8_t *data) if(phone_type==1) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"IOS\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"IOS\r\n"); ble_set_pair(1); errcode_t ret = gap_ble_set_ctkd_enable(true); @@ -1224,6 +1223,7 @@ void sendBindInfor(uint8_t *data) } CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)buf,devnamelen+2); + // comfirmPaire(1); if(devname) { ym_free(devname); @@ -1236,6 +1236,7 @@ void sendBindInfor(uint8_t *data) buf[0] = DEVICEBIND; buf[1] = 0; CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); + // comfirmPaire(1); } } @@ -1246,6 +1247,7 @@ void sendBindInfor(uint8_t *data) buf[1] = 0 ; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"phone devname is no name!!!!!!!!!:"); CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2); + // comfirmPaire(1); } #endif #endif @@ -1584,7 +1586,7 @@ static uint8_t jsonCheck_time(uint8_t *buf)//json 格式解析 time_t timestamp2 = __tm_to_secs(&tmp); int16_t timezone = (timestamp2-timestamp)/60/15; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"timezone in quarters %d\n",timezone); - uapi_set_timezone(timezone); //要在uaip_sntp_set_time_utc 之前执行才有效 + // uapi_set_timezone(timezone); //要在uaip_sntp_set_time_utc 之前执行才有效 /********/ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"time: %d\n",timestamp ); @@ -2244,7 +2246,7 @@ void SetsedentarinessSetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t sedent_data.frequenc = data[5]; - set_sedent_param(&sedent_data); + // set_sedent_param(&sedent_data); sendBuf[17] = 1; sendBuf[18] = Calculate_CRC(sendBuf,18); @@ -2919,7 +2921,7 @@ uint8_t parse_jsonCheck_weather(uint8_t *buf,uint8_t *check)//json 格式解析 } else if(cm_get_HFP_switch()) { - uapi_hfp_connect(); + // uapi_hfp_connect(); } } @@ -4095,107 +4097,107 @@ static void GetSDSpaceCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *total //获取当前数据 void GetCurDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { - if(!Check_CRC(data,len,crcvalue)) - { - int data_len=0; - ble_data_type type_={0x01,0x06,data_len,1,1}; - send_big_data(type_,NULL,0); - return; - } - cJSON *dataJSON = cJSON_CreateObject(); - const char *string_value[7]={"hr","spo2","steps","duration","standup","calories","distance"}; - for(uint8_t i = 0;i<7;i++) - { - cJSON* data_arryJSON = cJSON_CreateObject(); - if(data_arryJSON==NULL) - { - return; - } - uint32_t value=0; - if(i==0) - { - value=ble_get_heart_data(); - } - else if(i==1) - { - value=ble_get_oxygen_data(); - } - else if(i==2) - { - value=get_step_data(); - } - else if(i==3) - { - value=get_fat_time_data(); - } - else if(i==4) - { - value=1; - } - else if(i==5) - { - value=get_calories_data(); - } - else if(i==6) - { - value=get_distance_data(); - } - - - cJSON_AddNumberToObject(data_arryJSON,"value",value); - uint32_t creationTime; - int ret =uapi_get_timestampe_ss(&creationTime); - cJSON_AddNumberToObject(data_arryJSON,"time",creationTime); - - cJSON_AddItemToObject(dataJSON,string_value[i],data_arryJSON); - } - cJSON *recJSON= ble_get_recs_data(); - cJSON_AddItemToObject(dataJSON,"recs",recJSON); - char *json_format = cJSON_PrintUnformatted(dataJSON); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"GetCurDataCmd %d %s\n",strlen(json_format),json_format); - cJSON_Delete(dataJSON); - - uint32_t data_len = strlen(json_format); - uint32_t surplus_len=data_len; - uint32_t pack; - uint16_t pack_size=(ble_nus_max_data_len-18); - if(pack_size>482)pack_size=482; - - if(data_len%pack_size==0) - { - pack=data_len/pack_size; - } - else - { - pack=data_len/pack_size+1; - } - uint32_t pack_id=1; - uint32_t offset=0; - while (surplus_len!=0) - { - if(surplus_len>=pack_size) - { - surplus_len=surplus_len-pack_size; + // if(!Check_CRC(data,len,crcvalue)) + // { + // int data_len=0; + // ble_data_type type_={0x01,0x06,data_len,1,1}; + // send_big_data(type_,NULL,0); + // return; + // } + // cJSON *dataJSON = cJSON_CreateObject(); + // const char *string_value[7]={"hr","spo2","steps","duration","standup","calories","distance"}; + // for(uint8_t i = 0;i<7;i++) + // { + // cJSON* data_arryJSON = cJSON_CreateObject(); + // if(data_arryJSON==NULL) + // { + // return; + // } + // uint32_t value=0; + // if(i==0) + // { + // // value=ble_get_heart_data(); + // } + // else if(i==1) + // { + // value=ble_get_oxygen_data(); + // } + // else if(i==2) + // { + // // value=get_step_data(); + // } + // else if(i==3) + // { + // value=get_fat_time_data(); + // } + // else if(i==4) + // { + // value=1; + // } + // else if(i==5) + // { + // value=get_calories_data(); + // } + // else if(i==6) + // { + // value=get_distance_data(); + // } + + + // cJSON_AddNumberToObject(data_arryJSON,"value",value); + // uint32_t creationTime; + // int ret =uapi_get_timestampe_ss(&creationTime); + // cJSON_AddNumberToObject(data_arryJSON,"time",creationTime); + + // cJSON_AddItemToObject(dataJSON,string_value[i],data_arryJSON); + // } + // cJSON *recJSON= ble_get_recs_data(); + // cJSON_AddItemToObject(dataJSON,"recs",recJSON); + // char *json_format = cJSON_PrintUnformatted(dataJSON); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"GetCurDataCmd %d %s\n",strlen(json_format),json_format); + // cJSON_Delete(dataJSON); + + // uint32_t data_len = strlen(json_format); + // uint32_t surplus_len=data_len; + // uint32_t pack; + // uint16_t pack_size=(ble_nus_max_data_len-18); + // if(pack_size>482)pack_size=482; + + // if(data_len%pack_size==0) + // { + // pack=data_len/pack_size; + // } + // else + // { + // pack=data_len/pack_size+1; + // } + // uint32_t pack_id=1; + // uint32_t offset=0; + // while (surplus_len!=0) + // { + // if(surplus_len>=pack_size) + // { + // surplus_len=surplus_len-pack_size; - ble_data_type type_={0x01,0x06,data_len,pack,pack_id}; - send_big_data(type_,json_format+offset,pack_size); + // ble_data_type type_={0x01,0x06,data_len,pack,pack_id}; + // send_big_data(type_,json_format+offset,pack_size); - //send_big_data(1,json_format+offset,pack_size,data_len,pack_id,pack,0x06,1); - offset+=pack_size; - } - else - { + // //send_big_data(1,json_format+offset,pack_size,data_len,pack_id,pack,0x06,1); + // offset+=pack_size; + // } + // else + // { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack); - ble_data_type type_={0x01,0x06,data_len,pack,pack_id}; - send_big_data(type_,json_format+offset,surplus_len); - //send_big_data(1,json_format+offset,surplus_len,data_len,pack_id,pack,0x06,1); - break; - } - pack_id++; - } - cJSON_free(json_format); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack); + // ble_data_type type_={0x01,0x06,data_len,pack,pack_id}; + // send_big_data(type_,json_format+offset,surplus_len); + // //send_big_data(1,json_format+offset,surplus_len,data_len,pack_id,pack,0x06,1); + // break; + // } + // pack_id++; + // } + // cJSON_free(json_format); } //获取当手表电池电量 @@ -6998,7 +7000,6 @@ errcode_t decode_ota_data(ble_read_data *buffer_handle,uint8_t *data,uint16_t da osTimerDelete(BR_TRANSFER_timer); BR_TRANSFER_timer = NULL; } - timer_flie_type=buffer_handle->file_recv_stat.file_type; ble_read_timer_p=buffer_handle; timer_flie_flag=10; @@ -7021,6 +7022,9 @@ errcode_t decode_ota_data(ble_read_data *buffer_handle,uint8_t *data,uint16_t da if(buffer_handle->file_recv_stat.file_type==2) TRANSMIT_DATA=TRANS_MP3_TRANSMITTING; + + if(buffer_handle->file_recv_stat.file_type==4) + TRANSMIT_DATA=TRANS_BIN_TRANSMITTING; CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); } @@ -7298,6 +7302,97 @@ errcode_t decode_mp3_json(ble_read_data *buffer_handle) return ERRCODE_FAIL; } } + + +errcode_t decode_bin_json(ble_read_data *buffer_handle) +{ + if (uapi_dev_runtime_get_train_status() == 1) { + return ERRCODE_FAIL; + } + + uint8_t *data = buffer_handle->data+sizeof(msg_header_t); + uint16_t datalen = buffer_handle->totalDataLen; + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"decode_bin_json %s\n",data); + + cJSON* root = cJSON_Parse((const char *)data); + + if(root != NULL) + { + cJSON* ota_type_json = cJSON_GetObjectItem(root, "type"); + if(ota_type_json != NULL && cJSON_IsNumber(ota_type_json)) + { + buffer_handle->file_recv_stat.file_type = ota_type_json->valueint; + } + + cJSON* ota_name_json = cJSON_GetObjectItem(root, "name"); + if ( ota_name_json != NULL && cJSON_IsString(ota_name_json)) { + uint32_t filenamelen=strlen(ota_name_json->valuestring)+1; + + if (filenamelen > 0 && filenamelen < 255) + { + if(buffer_handle->file_recv_stat.file_name) + { + free(buffer_handle->file_recv_stat.file_name); + buffer_handle->file_recv_stat.file_name=NULL; + } + buffer_handle->file_recv_stat.file_name = malloc(filenamelen); + if (buffer_handle->file_recv_stat.file_name!=NULL) + { + memset_s(buffer_handle->file_recv_stat.file_name,filenamelen,0,filenamelen); + memcpy_s(buffer_handle->file_recv_stat.file_name,filenamelen,ota_name_json->valuestring,filenamelen); + } + + //下载完成再在 cancel download 里 free filename + }else{ + buffer_handle->file_recv_stat.file_name = NULL; + } + } + + cJSON* ota_size_json = cJSON_GetObjectItem(root, "size"); + if(ota_size_json != NULL && cJSON_IsNumber(ota_size_json)) + { + buffer_handle->file_recv_stat.file_size = ota_size_json->valueint; + } + cJSON_Delete(root); + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," bin type = %d, bin name =%s, bin size =%d \n", + buffer_handle->file_recv_stat.file_type, + buffer_handle->file_recv_stat.file_name, + buffer_handle->file_recv_stat.file_size + ); + // buffer_handle->file_recv_stat.received_size = 0; + // buffer_handle->file_recv_stat.lrcvalue = 0; + // buffer_handle->receive_file_flag = 1; + // uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_HIGH); + // TRANSMIT_DATA=TRANS_MP3_TRANSMITTING; + // CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + if(IS_free_save_Mp3(ota_size_json->valueint)==false) + { + free(buffer_handle->file_recv_stat.file_name); + buffer_handle->file_recv_stat.file_name=NULL; + + TRANSMIT_DATA=TRANS_MP3_MAX_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + + return ERRCODE_FAIL; + } + else + { + buffer_handle->file_recv_stat.received_size = 0; + buffer_handle->file_recv_stat.lrcvalue = 0; + buffer_handle->receive_file_flag = 1; + uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_HIGH); + // TRANSMIT_DATA=TRANS_MP3_TRANSMITTING; + // CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + + return ERRCODE_SUCC; + } + + }else{ + buffer_handle->receive_file_flag = 0; + return ERRCODE_FAIL; + } +} static uint16_t ble_dial_uid=0; errcode_t decode_dial_info(ble_read_data *buffer_handle) @@ -7710,6 +7805,16 @@ void decode_file_checksum_2AE6(ble_read_data *buffer_handle) ble_reply_cmd(DIAL_SUCC_INSTALL,0); } + break; + case 4://dial + TRANSMIT_DATA=TRANS_BIN_SUCC; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + + ble_reply_cmd(FILE_SUCC_TRANSFER,1); + ble_bin_install(); + + // ble_mp3_list_update(); + break; default: break; @@ -7730,6 +7835,11 @@ void decode_file_checksum_2AE6(ble_read_data *buffer_handle) case 3://dial TRANSMIT_DATA= TRANS_DIAL_FAIL; CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + break; + + case 4://dial + TRANSMIT_DATA= TRANS_BIN_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); break; default: @@ -7754,6 +7864,10 @@ void decode_file_checksum_2AE6(ble_read_data *buffer_handle) TRANSMIT_DATA= TRANS_DIAL_FAIL; CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); break; + case 4://dial + TRANSMIT_DATA= TRANS_BIN_FAIL; + CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1); + break; default: break; } @@ -7990,7 +8104,7 @@ void type2AE6Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u #ifdef BLE_LOG #endif - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"typeHexOneData:0x%04X\r\n",cmd); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"typeHexOneData:0x%04X\r\n",cmd); // uint8_t typeID = cmd_buf[2]; switch (cmd) { @@ -8051,6 +8165,18 @@ void type2AE6Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u } } break; + case BIN_FILE_CMD : + { + if (decode_bin_json( buffer_handle) == ERRCODE_SUCC) + { + ble_reply_cmd(MP3_FILE_CMD,1); + }else{ + ble_reply_cmd(MP3_FILE_CMD,2); + } + } + break; + + case FILE_CHECKSUM_RECV_CMD: decode_file_checksum(buffer_handle); break; @@ -8126,18 +8252,23 @@ errcode_t cancel_recv_file(uint8_t flag) { if(flag) { - if(timer_flie_type==1) + if(ble_read_timer_p->file_recv_stat.file_type==1) { TRANSMIT_DATA=TRANS_OTA_FAIL; } - else if (timer_flie_type==3) + else if (ble_read_timer_p->file_recv_stat.file_type==3) { TRANSMIT_DATA=TRANS_DIAL_FAIL; } - else if(timer_flie_type==2) + else if(ble_read_timer_p->file_recv_stat.file_type==2) { TRANSMIT_DATA=TRANS_MP3_FAIL; } + else if(ble_read_timer_p->file_recv_stat.file_type==4) + { + TRANSMIT_DATA=TRANS_BIN_TRANSMITTING; + } + else { TRANSMIT_DATA=TRANS_FREE; @@ -8323,7 +8454,6 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t osTimerDelete(BR_TRANSFER_timer); BR_TRANSFER_timer = NULL; } - timer_flie_type=buffer_handle->file_recv_stat.file_type; ble_read_timer_p=buffer_handle; timer_flie_flag=10; diff --git a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h index d75740f62..52652927d 100644 --- a/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h +++ b/code/sdk/zhihui/services/ble_service/bleservice/bleEvent.h @@ -867,6 +867,7 @@ uint8_t Calculate_CRC_Big(uint8_t *data,uint16_t len);//计算20byte #define DIAL_SUCC_INSTALL 0x0609 #define FILE_SUCC_TRANSFER 0x060A #define FILE_CANCEL_TRANSFER 0x060B +#define BIN_FILE_CMD 0x060C #ifdef __cplusplus } diff --git a/code/sdk/zhihui/services/ble_service/bleservice/bleService.c b/code/sdk/zhihui/services/ble_service/bleservice/bleService.c index a599c1c37..f00047da3 100644 --- a/code/sdk/zhihui/services/ble_service/bleservice/bleService.c +++ b/code/sdk/zhihui/services/ble_service/bleservice/bleService.c @@ -783,7 +783,7 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s } else if(cm_get_HFP_switch()) { - uapi_hfp_connect(); + // uapi_hfp_connect(); } @@ -1301,18 +1301,31 @@ static void svr_ble_bt_gatts_service_add_cb(uint8_t server_id, bt_uuid_t *uuid, errcode_t ret = 0; if (ble_gatts_cmp_uuid(uuid, &ble_service_uuid) == true) {//通过传入的uuid进行比较 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_service_add_cb ble_service_uuid\r\n"); + srv_ble_add_chart_decr_ota(server_id,srv_handle);//ota特征值 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_ota \r\n"); + srv_ble_add_chart_decr_andriod(server_id,srv_handle);//对18e0这个服务进行添加andiod特征值和描述符 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_andriod \r\n"); + srv_ble_add_chart_decr_battery(server_id,srv_handle);//电池电量特征值 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_battery \r\n"); srv_ble_add_chart_decr_short_cmd(server_id,srv_handle); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_short_cmd \r\n"); srv_ble_add_chart_decr_long_cmd(server_id,srv_handle); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_long_cmd \r\n"); srv_ble_add_chart_decr_recv_cmd(server_id,srv_handle); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_recv_cmd \r\n"); srv_ble_add_chart_decr_Zhihui_ota(server_id,srv_handle); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_Zhihui_ota \r\n"); srv_ble_add_Zhihui_AI(server_id,srv_handle); - // srv_ble_add_chart_decr_Zhihui_AI(server_id,srv_handle); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_Zhihui_AI \r\n"); srv_ble_add_ZHIHUIOTA_REPLY_chart_decr_recv_cmd(server_id,srv_handle); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_service_add_cb 1\r\n"); gatts_start_service(server_id, srv_handle); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_service_add_cb 2\r\n"); } // if (ble_gatts_cmp_uuid(uuid, &hid_service_uuid) == true){ @@ -1869,12 +1882,12 @@ static void svr_ble_bt_gatts_req_write_cb(uint8_t server_id, uint16_t conn_id, g g_ble_conn_id=conn_id; uapi_save_runtime_log(RUNTIME_LOG_BLE_APP_CMD); } - if(is_alipay_handle(write_cb_para->handle)) - { - g_ble_Alipay_conn_id=conn_id; - uapi_save_runtime_log(RUNTIME_LOG_BLE_ALIPAY_CMD); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"g_ble_Alipay_conn_id\r\n"); - } + // if(is_alipay_handle(write_cb_para->handle)) + // { + // g_ble_Alipay_conn_id=conn_id; + // uapi_save_runtime_log(RUNTIME_LOG_BLE_ALIPAY_CMD); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"g_ble_Alipay_conn_id\r\n"); + // } // else // { // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," ?????\r\n"); @@ -1985,11 +1998,12 @@ static void svr_ble_register_service(void) memcpy_s(uuid.uuid, sizeof(uuid.uuid), (char *)&ser_id, sizeof(ser_id)); #ifndef SUPPORT_OHOSFWK +xxxxxxxxxx ret = gatts_register_server(&uuid, &serverId); /* 注册gatt server */ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_register_server ret: 0x%x serverId = 0x%x uuid.uuid_len:%d", ret, serverId,uuid.uuid_len); #else ret = wrapper_gatts_register_server(&uuid, &serverId); /* 注册gatt server */ - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "wrapper_gatts_register_server ret: 0x%x serverId = 0x%x uuid.uuid_len:%d", ret, serverId,uuid.uuid_len); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "wrapper_gatts_register_server ret: 0x%x serverId = 0x%x uuid.uuid_len:%d", ret, serverId,uuid.uuid_len); #endif g_ble_server_id = serverId; @@ -2001,7 +2015,7 @@ static void svr_ble_register_service(void) WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_service ret: 0x%x", ret); #else ret = wrapper_gatts_add_service(serverId, &ble_service_uuid, true); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "wrapper_gatts_add_service ret: 0x%x", ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "wrapper_gatts_add_service ret: 0x%x", ret); #endif @@ -2040,7 +2054,10 @@ void ble_unregist_server(void) void svr_ble_bluetooth_init(void) { // memset(&phone_addr,0,sizeof(bd_addr_t)); - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bluetooth_init"); + + ble_instruct_init(); + srv_ble_server_register_gap_ble_callbacks(); srv_ble_server_register_gatt_callbacks(); @@ -2054,9 +2071,9 @@ void svr_ble_bluetooth_init(void) svr_alipay_bluetooth_init(g_ble_server_id); #endif - ble_factory_server_init(g_ble_server_id); + // ble_factory_server_init(g_ble_server_id); - ble_ppgtest_server_init(g_ble_server_id); + // ble_ppgtest_server_init(g_ble_server_id); #ifdef SUPPORT_AT_CYWEE ble_cywee_server_init(g_ble_server_id); @@ -2100,6 +2117,8 @@ void uapi_ble_disconnect_device() void custom_ble_service_start(void) { AdverFlag = true; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_ble_service_start ret"); + svr_ble_adv_start_param(); } @@ -2222,17 +2241,18 @@ static void blesrv_service_check_task(void const *arg) // mail.msg_data[2]); #if 1 - if (server_handle == get_factory_ate_write_handl()) - { - factory_recv_cmd_data(p_msgbuf,msg_len,server_handle); - } - else if (server_handle == get_factory_ota_write_handl()) - { - factory_recv_ota_data(p_msgbuf,msg_len,server_handle); - } + // if (server_handle == get_factory_ate_write_handl()) + // { + // factory_recv_cmd_data(p_msgbuf,msg_len,server_handle); + // } + // else if (server_handle == get_factory_ota_write_handl()) + // { + // factory_recv_ota_data(p_msgbuf,msg_len,server_handle); + // } #ifdef SUPPORT_AT_CYWEE - else if (server_handle == get_cywee_ate_write_handl()) + // else + if (server_handle == get_cywee_ate_write_handl()) { cywee_recv_cmd_data(p_msgbuf,msg_len,server_handle); } @@ -2244,7 +2264,8 @@ static void blesrv_service_check_task(void const *arg) // // errcode_t ret = svr_alipay_msg_write(ALIPAY_MSG_BT, p_msgbuf, msg_len, false); // } - else{ + // else + { #ifdef BLE_INSTRUCT revBleOldData(p_msgbuf,msg_len,server_handle); #endif diff --git a/code/sdk/zhihui/utils/custom_utils.c b/code/sdk/zhihui/utils/custom_utils.c index c8e27d7d2..d875c7cd1 100644 --- a/code/sdk/zhihui/utils/custom_utils.c +++ b/code/sdk/zhihui/utils/custom_utils.c @@ -458,10 +458,13 @@ bool start_custom_ble_service(void) // uint32_t irq_sts = osal_irq_lock(); #ifdef SUPPORT_BLE_SERVICE #ifdef FD230_COMPONENT + PRINT("start custom protocol classic bt ble service !\r\n"); bluetooth_enable_all(); #endif #endif + bluetooth_enable_all(); + //if(!uapi_dev_runtime_get_saveele_status()) { uapi_dev_runtime_set_bt_powerstat(1); @@ -723,16 +726,18 @@ errcode_t uapi_get_timestampe_ss_extend(uint32_t *tm,int year, int month, int da errcode_t uaip_set_time_utc_zone(uint32_t seconds,int16_t zone_quarters) { - return sync_time_utc(seconds,zone_quarters); + // return sync_time_utc(seconds,zone_quarters); + return 0; } errcode_t uaip_sntp_set_time_utc(uint32_t seconds) { - int zone_quarters = uapi_get_timezone(); + int zone_quarters = 0;//uapi_get_timezone(); - errcode_t ret = sync_time_utc(seconds,zone_quarters); + // = sync_time_utc(seconds,zone_quarters); + errcode_t ret=0; time_t rawtime; struct tm timeinfo; @@ -4148,7 +4153,7 @@ errcode_t enable_offline_log_nv(uint8_t log_enable) #ifdef SUPPORT_BLE_SERVICE -void factorytest_send_big_data(ble_data_type type,char *data, uint16 datalen) +void factorytest_send_big_data(ble_data_type type,char *data, uint16_t datalen) { // 动态分配内存空间,防止堆栈溢出 uint8_t *buf =NULL; diff --git a/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp b/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp index 2b9c6632d..bec737bec 100644 --- a/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp +++ b/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp @@ -260,7 +260,7 @@ void CustomEventPublish(uint16_t topic, uint8_t *data, uint32_t size) { BroadcastApi *broadcastApi = NULL; IUnknown *api = NULL; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish topic=%u!!", topic); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish topic=%u!!", topic); void *publishData = nullptr; if (size > 0) { @@ -300,7 +300,7 @@ void CustomEventPublish(uint16_t topic, uint8_t *data, uint32_t size) { } broadcastApi->Release((IUnknown *)broadcastApi); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish end!!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish end!!"); // // 释放内存 // free(publishData); -- 2.17.1