\r
/*启动蓝牙ble服务,cywee有重置 mac地址的操作,会需要把 蓝牙服务开启放在cywee服务之后*/\r
#ifdef CUSTOM_UTILS\r
- start_custom_ble_service();\r
+ \r
#endif\r
+start_custom_ble_service();\r
// #ifdef SUPPORT_ALIPAY_SEC\r
// #if !defined(A5133_DEMO_SERVER) && !defined(A5133_DEMO_CLIENT)\r
// uapi_alipay_svr_init();\r
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();
{
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
}
char sliceId[ALARM_DEC_NUM_256];\r
int16_t index;\r
};\r
+#ifdef BLE_INSTRUCT\r
+void ble_alarm_init(void);\r
+#endif\r
\r
// 播放器\r
class AlarmPlayerListener : public InterruptListener {\r
#ifdef SUPPORT_BLE_SERVICE\r
#include <bleEvent.h>\r
#include "bleService.h"\r
-#include "bletest.h"\r
+#include "bleInstruct.h"\r
#endif\r
\r
//#include "hfp_hf_service.h"\r
bluetooth_set_auto_reconnect_closed(1);\r
\r
ret = enable_bt_stack();\r
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %u", ret);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %u", ret);\r
\r
// 设置安全连接\r
// gap_ble_sec_params_t sec_params = {0};\r
ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 0);\r
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt gap_br_set_bt_scan_mode ret = %u", ret);\r
/**开始ble广播*/\r
+\r
+ \r
+ // extern void custom_ble_service_start(void);\r
+\r
// custom_ble_service_start();\r
}\r
}\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback: Mobile Phone Device");\r
if (state == GAP_ACL_STATE_DISCONNECTED) {\r
/* 通知msg_center,ble状态仍用bt状态,此处不区分 */\r
- SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
+ // SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0);\r
\r
/* ---------------------------------- 补丁合入 ---------------------------------- */\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_SCAN_MODE_CONNECTABLE");\r
\r
} else if (state == GAP_ACL_STATE_CONNECTED) {\r
- SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
+ // SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0);\r
\r
/* ---------------------------------- 补丁合入 ---------------------------------- */\r
GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr));\r
\r
#ifdef SUPPORT_BLE_SERVICE\r
- SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0);\r
+ // SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0);\r
\r
\r
\r
uapi_dev_runtime_set_earphone_connect_stat(1);\r
uapi_save_runtime_log(RUNTIME_LOG_BR_CONNECT_A2DP_HEADSET);\r
- if(headset_Is_connect() == false)\r
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);\r
+ // if(headset_Is_connect() == false)\r
+ // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);\r
\r
#endif\r
\r
GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr));\r
\r
#ifdef SUPPORT_BLE_SERVICE\r
- SendMsgToUIService(EARPHONE_DISCONNECTED_TO_UI, 0, nullptr, 0);\r
+ // SendMsgToUIService(EARPHONE_DISCONNECTED_TO_UI, 0, nullptr, 0);\r
#endif\r
\r
uapi_save_runtime_log(RUNTIME_LOG_BR_DISCONNECT_A2DP_HEADSET);\r
connId, connState, pairState);\r
if (GAP_BLE_STATE_DISCONNECTED == connState) { // restart ble adv when disconnected\r
/* 通知msg_center,ble状态仍用bt状态,此处不区分 */\r
- SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
+ // SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
\r
/* ---------------------------------- 补丁合入 ---------------------------------- */\r
// send to ace network\r
net_connect_status_change(NETWORK_TYPE_BLUETOOTH_LE, CONNECTION_STATUS_DISCONNECTED);\r
/* -------------------------------------------------------------------------- */\r
} else {\r
- SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
+ // SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
(void)memcpy_s(&g_bd_addr, sizeof(bd_addr_t), addr, sizeof(bd_addr_t));\r
\r
/* ---------------------------------- 补丁合入 ---------------------------------- */\r
{\r
#ifdef SUPPORT_BLE_SERVICE\r
SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0);\r
- SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
+ // SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
#endif\r
\r
}\r
\r
if(cm_get_HFP_switch() && uapi_hfp_connect_state()==0)\r
{\r
- uapi_hfp_connect();\r
+ // uapi_hfp_connect();\r
}\r
#endif\r
\r
#ifdef SUPPORT_BLE_SERVICE\r
SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0);\r
- SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
+ // SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
#endif\r
\r
\r
extern "C" void custom_ble_service_start(void);\r
void wrapper_gatts_service_start(void)\r
{\r
- // printf("wrapper_gatts_service_start \n");\r
+ printf("wrapper_gatts_service_start \n");\r
if (!g_uuid_list.empty()) {\r
bt_uuid_t &uuid = g_uuid_list.front();\r
bt_uuid_t uuid_tmp={0};\r
// 服务异步添加,需要保证当前服务start后,再添加下一个服务\r
// g_uuid_list.pop_front();\r
errcode_t ret = gatts_add_service(gatts_server_id, &uuid_tmp, true);\r
- // 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",\r
- // uuid_tmp.uuid_len,uuid_tmp.uuid[0],uuid_tmp.uuid[1],gatts_server_id,ret,g_uuid_list.size());\r
+ 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",\r
+ uuid_tmp.uuid_len,uuid_tmp.uuid[0],uuid_tmp.uuid[1],gatts_server_id,ret,g_uuid_list.size());\r
\r
} else {\r
g_svr_handle_list.clear();\r
{
ConfigModel::GetInstance()->SetHFPState(true);
#ifdef FD230_650
- uapi_hfp_connect();
+ // uapi_hfp_connect();
#endif
classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_HFP);
}
#ifdef SUPPORT_BLE_SERVICE
#include "bleEvent.h"
-#include "bletest.h"
+#include "bleInstruct.h"
#endif
namespace OHOS
#include "uicomponents/UIComponents.h"
#ifdef SUPPORT_BLE_SERVICE
-#include "bletest.h"
+#include "bleInstruct.h"
#include "bleEvent.h"
#endif
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,
#ifdef SUPPORT_BLE_SERVICE
#include <bleEvent.h>
#include "bleService.h"
-#include "bletest.h"
+#include "bleInstruct.h"
#endif
#include "ui_resource_string.h"
#ifdef SUPPORT_BLE_SERVICE
#include <bleEvent.h>
#include "bleService.h"
-#include "bletest.h"
+#include "bleInstruct.h"
#endif
#include "NativeAbility.h"
#ifdef SUPPORT_BLE_SERVICE
#include <bleEvent.h>
#include "bleService.h"
-#include "bletest.h"
+#include "bleInstruct.h"
#endif
#include "custom_utils.h"
#ifdef SUPPORT_BLE_SERVICE
#include <bleEvent.h>
#include "bleService.h"
-#include "bletest.h"
+#include "bleInstruct.h"
#endif
#include "message/include/MessagePresenter.h"
namespace OHOS
{
+ #ifdef BLE_INSTRUCT
+ void ble_play_init();
+ #endif
class MusicPlayerModel
{
public:
};
+#ifdef BLE_INSTRUCT
+void ble_addressbook_init();
+#endif
+
+
struct Contact
{
char name[NAME_LEN];
{
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;
}
#include "bts_avrcp_controller.h"
#include "PlayersCaseListAdapter.h"
#include <unordered_map>
+#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;
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
Presenter<SaveBatView>::OnStart();\r
// 1.获取原drag\r
#ifdef CUSTOM_UTILS\r
- drag_x = get_drag_limit(0);\r
- drag_y = get_drag_limit(1);\r
+ // drag_x = get_drag_limit(0);\r
+ // drag_y = get_drag_limit(1);\r
\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "drag_x:%d,drag_y:%d", drag_x, drag_y);\r
// 2.设置drag\r
- enable_drag(0, 0);\r
- enable_drag(1, 0);\r
+ // enable_drag(0, 0);\r
+ // enable_drag(1, 0);\r
#endif\r
}\r
\r
#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
{
// 表盘类型
DEFULTDIAL,
DOWNLOADDIAL,
};
+
+
typedef struct DialLayout_
{
uint16_t dialId;
#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"
#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();
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_;
bleInstruct_t.install_Register_dial= install_Register_dial_;
}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+
#endif
} // namespace OHOS
#include "common/key_code.h"
#ifdef SUPPORT_BLE_SERVICE
#include "bleEvent.h"
-#include "bletest.h"
+#include "bleInstruct.h"
#endif
#include "NativeRegisterManager.h"
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
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
#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)
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
int write_Trainingdata_data(Trainingdata data);
+#ifdef BLE_INSTRUCT
+void ble_training_init(void);
+#endif
+
+
#ifdef __cplusplus
}
#endif
#define MAXSPORTID 176
+
+
// 运动状态
enum class ExerciseState {
End = 0,
#ifdef BLE_SERVER_ENABLE
#include "bleEvent.h"
-#include "bletest.h"
+#include "bleInstruct.h"
#include "bleService.h"
#endif
#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)
{
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
#ifdef SUPPORT_BLE_SERVICE\r
#include <bleEvent.h>\r
#include "bleService.h"\r
-#include "bletest.h"\r
+#include "bleInstruct.h"\r
#endif\r
\r
#include "components/root_view.h"\r
#include "weather/include/FutureWeatherListAdapter.h"
namespace OHOS
{
+
+#ifdef BLE_INSTRUCT
+void ble_weather_init();
+#endif
+
#if __cplusplus
extern "C"
{
{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,其对应的位图 */
${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
${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()
--- /dev/null
+/*
+ * @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
--- /dev/null
+#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
#include "VolumeSettingView.h"
#include "VolumeSettingPresenter.h"
#include "VolumeSettingView.h"
+#include "pairing_notification.h"
+#include "bleInstruct.h"
+#include "transmitting.h"
+
namespace OHOS {
#ifdef __cplusplus
{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;
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)
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);
}
}
+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},
{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)
}
}
- 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;
}
--- /dev/null
+/*
+ * @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 <cmsis_os2.h>
+#include <cmsis_os.h>
+#include <ohos_types.h>
+#include <service/graphic_service.h>
+#include "iostream"
+#include <broadcast_feature.h>
+#include <custom_utils.h>
+#include "uicomponents/UIComponents.h"
+#include "ConfigModel.h"
+#include <custom_runtime.h>
+#include "pairing_notification.h"
+
+// #include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h"
+// #include <ui_service.h>
+// #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<UIView::OnClickListener *>(&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<UIView::OnClickListener *>(&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<UIView::OnClickListener *>(&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
--- /dev/null
+#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<UIView::OnClickListener *>(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);
+ }
+
+}
TOPIC_EVENT_HFP_FINISHED,\r
TOPIC_EVENT_HFP_PHONE_TO_WATCH,\r
TOPIC_EVENT_HFP_WATCH_TO_PHONE,\r
+ \r
TOPIC_END_NUM = 20000,\r
} TopicNum;\r
\r
${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
${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()
--- /dev/null
+#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
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;
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)
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);
}
}
+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},
{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)
{
--- /dev/null
+/*
+ * @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 <cmsis_os2.h>
+#include <cmsis_os.h>
+#include <ohos_types.h>
+#include <service/graphic_service.h>
+#include "iostream"
+#include <broadcast_feature.h>
+#include <custom_utils.h>
+#include "uicomponents/UIComponents.h"
+#include "ConfigModel.h"
+#include <custom_runtime.h>
+#include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h"
+#include <ui_service.h>
+#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<UIView::OnClickListener *>(&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<UIView::OnClickListener *>(&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<UIView::OnClickListener *>(&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
--- /dev/null
+#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<UIView::OnClickListener *>(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);
+ }
+
+}
'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',
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);
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/bleInstruct.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ble_congfig_adapt.cpp
+${CMAKE_CURRENT_SOURCE_DIR}/ble_instruct_init.cpp
+
)
-bleInstruct_t_ bleInstruct_t;
+bleInstruct_t_ bleInstruct_t={NULL};
char * get_dial_path(void)
{
void ble_disconnect_ok(void)
{
+ if( bleInstruct_t.ble_disconnect_ok==NULL)
+ {
+ return;
+ }
return bleInstruct_t.ble_disconnect_ok();
}
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
}
+void ble_bin_install(void)
+{
+ return bleInstruct_t.ble_bin_install();
+}
+
+
#endif
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;
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);
////////////////闹钟相关/////////////////////////////
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);
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);
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);
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);
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
#include "../../../../../../zhihui/config/include/ConfigModelC.h"
-
+#include <dirent.h>
#include "ConfigModel.h"
#include "bleEvent.h"
#include "ui_service.h"
#include "custom_utils.h"
+
+
void set_ota_upgrade_(void)
{
OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance();
// 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_;
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
--- /dev/null
+
+#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
ble_recv_data_info_t ble_recv_data;\r
static uint8_t TRANSMIT_DATA;\r
static osTimerId_t BR_TRANSFER_timer=NULL;\r
-static uint8_t timer_flie_type=0;\r
static uint32_t timer_flie_flag=0;\r
ble_read_data* ble_read_timer_p=NULL;\r
\r
\r
if(phone_type==1)\r
{\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"IOS\r\n");\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"IOS\r\n");\r
ble_set_pair(1);\r
\r
errcode_t ret = gap_ble_set_ctkd_enable(true);\r
}\r
\r
CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,(uint8_t *)buf,devnamelen+2);\r
+ // comfirmPaire(1);\r
if(devname)\r
{ \r
ym_free(devname);\r
buf[0] = DEVICEBIND;\r
buf[1] = 0;\r
CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2);\r
+ // comfirmPaire(1);\r
\r
}\r
}\r
buf[1] = 0 ;\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"phone devname is no name!!!!!!!!!:");\r
CustomEventPublish(TOPIC_EVENT_DEVICE_BIND,buf,2);\r
+ // comfirmPaire(1);\r
}\r
#endif\r
#endif\r
time_t timestamp2 = __tm_to_secs(&tmp);\r
int16_t timezone = (timestamp2-timestamp)/60/15; \r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"timezone in quarters %d\n",timezone);\r
- uapi_set_timezone(timezone); //要在uaip_sntp_set_time_utc 之前执行才有效\r
+ // uapi_set_timezone(timezone); //要在uaip_sntp_set_time_utc 之前执行才有效\r
/********/\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"time: %d\n",timestamp );\r
\r
\r
sedent_data.frequenc = data[5];\r
\r
- set_sedent_param(&sedent_data);\r
+ // set_sedent_param(&sedent_data);\r
\r
sendBuf[17] = 1;\r
sendBuf[18] = Calculate_CRC(sendBuf,18);\r
}\r
else if(cm_get_HFP_switch())\r
{\r
- uapi_hfp_connect();\r
+ // uapi_hfp_connect();\r
}\r
\r
}\r
//获取当前数据\r
void GetCurDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
{\r
- if(!Check_CRC(data,len,crcvalue))\r
- {\r
- int data_len=0;\r
- ble_data_type type_={0x01,0x06,data_len,1,1};\r
- send_big_data(type_,NULL,0);\r
- return;\r
- }\r
- cJSON *dataJSON = cJSON_CreateObject();\r
- const char *string_value[7]={"hr","spo2","steps","duration","standup","calories","distance"};\r
- for(uint8_t i = 0;i<7;i++)\r
- {\r
- cJSON* data_arryJSON = cJSON_CreateObject();\r
- if(data_arryJSON==NULL)\r
- {\r
- return;\r
- }\r
- uint32_t value=0;\r
- if(i==0)\r
- {\r
- value=ble_get_heart_data();\r
- }\r
- else if(i==1)\r
- {\r
- value=ble_get_oxygen_data();\r
- }\r
- else if(i==2)\r
- {\r
- value=get_step_data();\r
- }\r
- else if(i==3)\r
- {\r
- value=get_fat_time_data();\r
- }\r
- else if(i==4)\r
- {\r
- value=1;\r
- }\r
- else if(i==5)\r
- {\r
- value=get_calories_data();\r
- }\r
- else if(i==6)\r
- {\r
- value=get_distance_data();\r
- }\r
-\r
-\r
- cJSON_AddNumberToObject(data_arryJSON,"value",value);\r
- uint32_t creationTime;\r
- int ret =uapi_get_timestampe_ss(&creationTime);\r
- cJSON_AddNumberToObject(data_arryJSON,"time",creationTime);\r
-\r
- cJSON_AddItemToObject(dataJSON,string_value[i],data_arryJSON);\r
- }\r
- cJSON *recJSON= ble_get_recs_data();\r
- cJSON_AddItemToObject(dataJSON,"recs",recJSON);\r
- char *json_format = cJSON_PrintUnformatted(dataJSON);\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"GetCurDataCmd %d %s\n",strlen(json_format),json_format);\r
- cJSON_Delete(dataJSON);\r
-\r
- uint32_t data_len = strlen(json_format);\r
- uint32_t surplus_len=data_len;\r
- uint32_t pack;\r
- uint16_t pack_size=(ble_nus_max_data_len-18);\r
- if(pack_size>482)pack_size=482;\r
-\r
- if(data_len%pack_size==0)\r
- {\r
- pack=data_len/pack_size;\r
- }\r
- else\r
- { \r
- pack=data_len/pack_size+1;\r
- }\r
- uint32_t pack_id=1;\r
- uint32_t offset=0;\r
- while (surplus_len!=0)\r
- {\r
- if(surplus_len>=pack_size)\r
- {\r
- surplus_len=surplus_len-pack_size;\r
+ // if(!Check_CRC(data,len,crcvalue))\r
+ // {\r
+ // int data_len=0;\r
+ // ble_data_type type_={0x01,0x06,data_len,1,1};\r
+ // send_big_data(type_,NULL,0);\r
+ // return;\r
+ // }\r
+ // cJSON *dataJSON = cJSON_CreateObject();\r
+ // const char *string_value[7]={"hr","spo2","steps","duration","standup","calories","distance"};\r
+ // for(uint8_t i = 0;i<7;i++)\r
+ // {\r
+ // cJSON* data_arryJSON = cJSON_CreateObject();\r
+ // if(data_arryJSON==NULL)\r
+ // {\r
+ // return;\r
+ // }\r
+ // uint32_t value=0;\r
+ // if(i==0)\r
+ // {\r
+ // // value=ble_get_heart_data();\r
+ // }\r
+ // else if(i==1)\r
+ // {\r
+ // value=ble_get_oxygen_data();\r
+ // }\r
+ // else if(i==2)\r
+ // {\r
+ // // value=get_step_data();\r
+ // }\r
+ // else if(i==3)\r
+ // {\r
+ // value=get_fat_time_data();\r
+ // }\r
+ // else if(i==4)\r
+ // {\r
+ // value=1;\r
+ // }\r
+ // else if(i==5)\r
+ // {\r
+ // value=get_calories_data();\r
+ // }\r
+ // else if(i==6)\r
+ // {\r
+ // value=get_distance_data();\r
+ // }\r
+\r
+\r
+ // cJSON_AddNumberToObject(data_arryJSON,"value",value);\r
+ // uint32_t creationTime;\r
+ // int ret =uapi_get_timestampe_ss(&creationTime);\r
+ // cJSON_AddNumberToObject(data_arryJSON,"time",creationTime);\r
+\r
+ // cJSON_AddItemToObject(dataJSON,string_value[i],data_arryJSON);\r
+ // }\r
+ // cJSON *recJSON= ble_get_recs_data();\r
+ // cJSON_AddItemToObject(dataJSON,"recs",recJSON);\r
+ // char *json_format = cJSON_PrintUnformatted(dataJSON);\r
+ // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"GetCurDataCmd %d %s\n",strlen(json_format),json_format);\r
+ // cJSON_Delete(dataJSON);\r
+\r
+ // uint32_t data_len = strlen(json_format);\r
+ // uint32_t surplus_len=data_len;\r
+ // uint32_t pack;\r
+ // uint16_t pack_size=(ble_nus_max_data_len-18);\r
+ // if(pack_size>482)pack_size=482;\r
+\r
+ // if(data_len%pack_size==0)\r
+ // {\r
+ // pack=data_len/pack_size;\r
+ // }\r
+ // else\r
+ // { \r
+ // pack=data_len/pack_size+1;\r
+ // }\r
+ // uint32_t pack_id=1;\r
+ // uint32_t offset=0;\r
+ // while (surplus_len!=0)\r
+ // {\r
+ // if(surplus_len>=pack_size)\r
+ // {\r
+ // surplus_len=surplus_len-pack_size;\r
\r
\r
- ble_data_type type_={0x01,0x06,data_len,pack,pack_id};\r
- send_big_data(type_,json_format+offset,pack_size);\r
+ // ble_data_type type_={0x01,0x06,data_len,pack,pack_id};\r
+ // send_big_data(type_,json_format+offset,pack_size);\r
\r
- //send_big_data(1,json_format+offset,pack_size,data_len,pack_id,pack,0x06,1);\r
- offset+=pack_size;\r
- }\r
- else\r
- {\r
+ // //send_big_data(1,json_format+offset,pack_size,data_len,pack_id,pack,0x06,1);\r
+ // offset+=pack_size;\r
+ // }\r
+ // else\r
+ // {\r
\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack);\r
- ble_data_type type_={0x01,0x06,data_len,pack,pack_id};\r
- send_big_data(type_,json_format+offset,surplus_len);\r
- //send_big_data(1,json_format+offset,surplus_len,data_len,pack_id,pack,0x06,1);\r
- break;\r
- }\r
- pack_id++;\r
- }\r
- cJSON_free(json_format);\r
+ // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack);\r
+ // ble_data_type type_={0x01,0x06,data_len,pack,pack_id};\r
+ // send_big_data(type_,json_format+offset,surplus_len);\r
+ // //send_big_data(1,json_format+offset,surplus_len,data_len,pack_id,pack,0x06,1);\r
+ // break;\r
+ // }\r
+ // pack_id++;\r
+ // }\r
+ // cJSON_free(json_format);\r
\r
}\r
//获取当手表电池电量\r
osTimerDelete(BR_TRANSFER_timer);\r
BR_TRANSFER_timer = NULL;\r
}\r
- timer_flie_type=buffer_handle->file_recv_stat.file_type;\r
ble_read_timer_p=buffer_handle;\r
timer_flie_flag=10;\r
\r
\r
if(buffer_handle->file_recv_stat.file_type==2)\r
TRANSMIT_DATA=TRANS_MP3_TRANSMITTING;\r
+\r
+ if(buffer_handle->file_recv_stat.file_type==4)\r
+ TRANSMIT_DATA=TRANS_BIN_TRANSMITTING;\r
\r
CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
}\r
return ERRCODE_FAIL;\r
}\r
}\r
+\r
+\r
+errcode_t decode_bin_json(ble_read_data *buffer_handle)\r
+{\r
+ if (uapi_dev_runtime_get_train_status() == 1) {\r
+ return ERRCODE_FAIL;\r
+ }\r
+ \r
+ uint8_t *data = buffer_handle->data+sizeof(msg_header_t);\r
+ uint16_t datalen = buffer_handle->totalDataLen;\r
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"decode_bin_json %s\n",data);\r
+\r
+ cJSON* root = cJSON_Parse((const char *)data);\r
+ \r
+ if(root != NULL)\r
+ { \r
+ cJSON* ota_type_json = cJSON_GetObjectItem(root, "type");\r
+ if(ota_type_json != NULL && cJSON_IsNumber(ota_type_json))\r
+ {\r
+ buffer_handle->file_recv_stat.file_type = ota_type_json->valueint;\r
+ }\r
+\r
+ cJSON* ota_name_json = cJSON_GetObjectItem(root, "name");\r
+ if ( ota_name_json != NULL && cJSON_IsString(ota_name_json)) {\r
+ uint32_t filenamelen=strlen(ota_name_json->valuestring)+1;\r
+\r
+ if (filenamelen > 0 && filenamelen < 255)\r
+ {\r
+ if(buffer_handle->file_recv_stat.file_name)\r
+ {\r
+ free(buffer_handle->file_recv_stat.file_name);\r
+ buffer_handle->file_recv_stat.file_name=NULL;\r
+ }\r
+ buffer_handle->file_recv_stat.file_name = malloc(filenamelen);\r
+ if (buffer_handle->file_recv_stat.file_name!=NULL)\r
+ {\r
+ memset_s(buffer_handle->file_recv_stat.file_name,filenamelen,0,filenamelen);\r
+ memcpy_s(buffer_handle->file_recv_stat.file_name,filenamelen,ota_name_json->valuestring,filenamelen);\r
+ }\r
+ \r
+ //下载完成再在 cancel download 里 free filename\r
+ }else{\r
+ buffer_handle->file_recv_stat.file_name = NULL;\r
+ }\r
+ }\r
+\r
+ cJSON* ota_size_json = cJSON_GetObjectItem(root, "size");\r
+ if(ota_size_json != NULL && cJSON_IsNumber(ota_size_json))\r
+ {\r
+ buffer_handle->file_recv_stat.file_size = ota_size_json->valueint;\r
+ }\r
+ cJSON_Delete(root);\r
+\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," bin type = %d, bin name =%s, bin size =%d \n",\r
+ buffer_handle->file_recv_stat.file_type,\r
+ buffer_handle->file_recv_stat.file_name,\r
+ buffer_handle->file_recv_stat.file_size\r
+ );\r
+ // buffer_handle->file_recv_stat.received_size = 0;\r
+ // buffer_handle->file_recv_stat.lrcvalue = 0;\r
+ // buffer_handle->receive_file_flag = 1;\r
+ // uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_HIGH);\r
+ // TRANSMIT_DATA=TRANS_MP3_TRANSMITTING;\r
+ // CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
+ if(IS_free_save_Mp3(ota_size_json->valueint)==false)\r
+ {\r
+ free(buffer_handle->file_recv_stat.file_name);\r
+ buffer_handle->file_recv_stat.file_name=NULL;\r
+\r
+ TRANSMIT_DATA=TRANS_MP3_MAX_FAIL;\r
+ CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
+\r
+ return ERRCODE_FAIL;\r
+ }\r
+ else\r
+ {\r
+ buffer_handle->file_recv_stat.received_size = 0;\r
+ buffer_handle->file_recv_stat.lrcvalue = 0;\r
+ buffer_handle->receive_file_flag = 1;\r
+ uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_HIGH);\r
+ // TRANSMIT_DATA=TRANS_MP3_TRANSMITTING;\r
+ // CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
+\r
+ return ERRCODE_SUCC;\r
+ }\r
+\r
+ }else{\r
+ buffer_handle->receive_file_flag = 0; \r
+ return ERRCODE_FAIL;\r
+ }\r
+}\r
static uint16_t ble_dial_uid=0;\r
\r
errcode_t decode_dial_info(ble_read_data *buffer_handle)\r
ble_reply_cmd(DIAL_SUCC_INSTALL,0);\r
\r
}\r
+ break;\r
+ case 4://dial\r
+ TRANSMIT_DATA=TRANS_BIN_SUCC;\r
+ CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
+ \r
+ ble_reply_cmd(FILE_SUCC_TRANSFER,1);\r
+ ble_bin_install();\r
+\r
+ // ble_mp3_list_update();\r
+\r
break;\r
default:\r
break;\r
case 3://dial\r
TRANSMIT_DATA= TRANS_DIAL_FAIL;\r
CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
+ break;\r
+\r
+ case 4://dial\r
+ TRANSMIT_DATA= TRANS_BIN_FAIL;\r
+ CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
\r
break;\r
default:\r
TRANSMIT_DATA= TRANS_DIAL_FAIL;\r
CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
break;\r
+ case 4://dial\r
+ TRANSMIT_DATA= TRANS_BIN_FAIL;\r
+ CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);\r
+ break;\r
default:\r
break;\r
}\r
#ifdef BLE_LOG\r
\r
#endif\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"typeHexOneData:0x%04X\r\n",cmd);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"typeHexOneData:0x%04X\r\n",cmd);\r
// uint8_t typeID = cmd_buf[2];\r
switch (cmd)\r
{\r
} \r
}\r
break;\r
+ case BIN_FILE_CMD :\r
+ {\r
+ if (decode_bin_json( buffer_handle) == ERRCODE_SUCC)\r
+ {\r
+ ble_reply_cmd(MP3_FILE_CMD,1);\r
+ }else{\r
+ ble_reply_cmd(MP3_FILE_CMD,2);\r
+ } \r
+ }\r
+ break;\r
+\r
+ \r
case FILE_CHECKSUM_RECV_CMD:\r
decode_file_checksum(buffer_handle);\r
break;\r
{\r
if(flag)\r
{\r
- if(timer_flie_type==1)\r
+ if(ble_read_timer_p->file_recv_stat.file_type==1)\r
{\r
TRANSMIT_DATA=TRANS_OTA_FAIL;\r
}\r
- else if (timer_flie_type==3)\r
+ else if (ble_read_timer_p->file_recv_stat.file_type==3)\r
{\r
TRANSMIT_DATA=TRANS_DIAL_FAIL;\r
}\r
- else if(timer_flie_type==2)\r
+ else if(ble_read_timer_p->file_recv_stat.file_type==2)\r
{\r
TRANSMIT_DATA=TRANS_MP3_FAIL;\r
}\r
+ else if(ble_read_timer_p->file_recv_stat.file_type==4)\r
+ {\r
+ TRANSMIT_DATA=TRANS_BIN_TRANSMITTING;\r
+ }\r
+\r
else\r
{\r
TRANSMIT_DATA=TRANS_FREE;\r
osTimerDelete(BR_TRANSFER_timer);\r
BR_TRANSFER_timer = NULL;\r
}\r
- timer_flie_type=buffer_handle->file_recv_stat.file_type;\r
ble_read_timer_p=buffer_handle;\r
timer_flie_flag=10;\r
\r
#define DIAL_SUCC_INSTALL 0x0609
#define FILE_SUCC_TRANSFER 0x060A
#define FILE_CANCEL_TRANSFER 0x060B
+#define BIN_FILE_CMD 0x060C
#ifdef __cplusplus
}
}\r
else if(cm_get_HFP_switch())\r
{\r
- uapi_hfp_connect();\r
+ // uapi_hfp_connect();\r
}\r
\r
\r
errcode_t ret = 0;\r
if (ble_gatts_cmp_uuid(uuid, &ble_service_uuid) == true) {//通过传入的uuid进行比较\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_service_add_cb ble_service_uuid\r\n");\r
+\r
srv_ble_add_chart_decr_ota(server_id,srv_handle);//ota特征值\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_ota \r\n");\r
+\r
srv_ble_add_chart_decr_andriod(server_id,srv_handle);//对18e0这个服务进行添加andiod特征值和描述符\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_andriod \r\n");\r
+\r
srv_ble_add_chart_decr_battery(server_id,srv_handle);//电池电量特征值\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_battery \r\n");\r
srv_ble_add_chart_decr_short_cmd(server_id,srv_handle);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_short_cmd \r\n");\r
srv_ble_add_chart_decr_long_cmd(server_id,srv_handle);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_long_cmd \r\n");\r
srv_ble_add_chart_decr_recv_cmd(server_id,srv_handle);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_recv_cmd \r\n");\r
srv_ble_add_chart_decr_Zhihui_ota(server_id,srv_handle);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_chart_decr_Zhihui_ota \r\n");\r
srv_ble_add_Zhihui_AI(server_id,srv_handle);\r
- \r
// srv_ble_add_chart_decr_Zhihui_AI(server_id,srv_handle);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "srv_ble_add_Zhihui_AI \r\n");\r
srv_ble_add_ZHIHUIOTA_REPLY_chart_decr_recv_cmd(server_id,srv_handle);\r
+\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_service_add_cb 1\r\n");\r
gatts_start_service(server_id, srv_handle);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_service_add_cb 2\r\n");\r
}\r
\r
// if (ble_gatts_cmp_uuid(uuid, &hid_service_uuid) == true){\r
g_ble_conn_id=conn_id;\r
uapi_save_runtime_log(RUNTIME_LOG_BLE_APP_CMD);\r
}\r
- if(is_alipay_handle(write_cb_para->handle))\r
- {\r
- g_ble_Alipay_conn_id=conn_id;\r
- uapi_save_runtime_log(RUNTIME_LOG_BLE_ALIPAY_CMD);\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"g_ble_Alipay_conn_id\r\n");\r
- }\r
+ // if(is_alipay_handle(write_cb_para->handle))\r
+ // {\r
+ // g_ble_Alipay_conn_id=conn_id;\r
+ // uapi_save_runtime_log(RUNTIME_LOG_BLE_ALIPAY_CMD);\r
+ // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"g_ble_Alipay_conn_id\r\n");\r
+ // }\r
// else\r
// {\r
// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP," ?????\r\n");\r
memcpy_s(uuid.uuid, sizeof(uuid.uuid), (char *)&ser_id, sizeof(ser_id));\r
\r
#ifndef SUPPORT_OHOSFWK\r
+xxxxxxxxxx\r
ret = gatts_register_server(&uuid, &serverId); /* 注册gatt server */\r
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_register_server ret: 0x%x serverId = 0x%x uuid.uuid_len:%d", ret, serverId,uuid.uuid_len);\r
#else\r
ret = wrapper_gatts_register_server(&uuid, &serverId); /* 注册gatt server */\r
- 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);\r
+ 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);\r
#endif\r
g_ble_server_id = serverId;\r
\r
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_service ret: 0x%x", ret);\r
#else\r
ret = wrapper_gatts_add_service(serverId, &ble_service_uuid, true);\r
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "wrapper_gatts_add_service ret: 0x%x", ret);\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "wrapper_gatts_add_service ret: 0x%x", ret);\r
#endif\r
\r
\r
void svr_ble_bluetooth_init(void)\r
{\r
// memset(&phone_addr,0,sizeof(bd_addr_t));\r
- \r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bluetooth_init");\r
+\r
+ ble_instruct_init();\r
+\r
srv_ble_server_register_gap_ble_callbacks();\r
srv_ble_server_register_gatt_callbacks();\r
\r
svr_alipay_bluetooth_init(g_ble_server_id);\r
#endif\r
\r
- ble_factory_server_init(g_ble_server_id);\r
+ // ble_factory_server_init(g_ble_server_id);\r
\r
- ble_ppgtest_server_init(g_ble_server_id);\r
+ // ble_ppgtest_server_init(g_ble_server_id);\r
\r
#ifdef SUPPORT_AT_CYWEE\r
ble_cywee_server_init(g_ble_server_id);\r
void custom_ble_service_start(void)\r
{\r
AdverFlag = true;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_ble_service_start ret");\r
+\r
svr_ble_adv_start_param();\r
}\r
\r
// mail.msg_data[2]);\r
\r
#if 1\r
- if (server_handle == get_factory_ate_write_handl()) \r
- {\r
- factory_recv_cmd_data(p_msgbuf,msg_len,server_handle);\r
- }\r
- else if (server_handle == get_factory_ota_write_handl())\r
- {\r
- factory_recv_ota_data(p_msgbuf,msg_len,server_handle);\r
- }\r
+ // if (server_handle == get_factory_ate_write_handl()) \r
+ // {\r
+ // factory_recv_cmd_data(p_msgbuf,msg_len,server_handle);\r
+ // }\r
+ // else if (server_handle == get_factory_ota_write_handl())\r
+ // {\r
+ // factory_recv_ota_data(p_msgbuf,msg_len,server_handle);\r
+ // }\r
\r
#ifdef SUPPORT_AT_CYWEE\r
- else if (server_handle == get_cywee_ate_write_handl())\r
+ // else \r
+ if (server_handle == get_cywee_ate_write_handl())\r
{\r
cywee_recv_cmd_data(p_msgbuf,msg_len,server_handle);\r
}\r
// // errcode_t ret = svr_alipay_msg_write(ALIPAY_MSG_BT, p_msgbuf, msg_len, false);\r
\r
// }\r
- else{\r
+ // else\r
+ {\r
#ifdef BLE_INSTRUCT\r
revBleOldData(p_msgbuf,msg_len,server_handle);\r
#endif\r
// 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);
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;
#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;
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) {
}
broadcastApi->Release((IUnknown *)broadcastApi);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish end!!");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish end!!");
// // 释放内存
// free(publishData);