+++ /dev/null
-#if defined(XTS_SUPPORT) && defined(SUPPORT_CAT1_SERVICE)
-
-#include "system/include/Systemupgrade.h"
-#include "system/include/SystemPresenter.h"
-#include "wearable_log.h"
-#include "UiConfig.h"
-#include "custom_utils.h"
-#include "stdio.h"
-#include <iostream>
-#include <fstream>
-#include "cJSON.h"
-#include "ConfigModel.h"
-#ifdef SUPPORT_CAT1_SERVICE
-#include "lwip/err.h"
-#include "http_client.h"
-#endif
-#include "power_display_service.h"
-#include "cmsis_os2.h"
-#include "los_memory.h"
-#include "thread_init.h"
- #include "tcxo.h"
- #include "cat1_server.h"
- #include "linux/delay.h"
-
-//http://r-oss.thisiot.com/device-ota/2024_05_06/1787425705369333762.fwpkg?Expires=1714998097&OSSAccessKeyId=LTAI5tJa2arDBmqSUsSTQJ1T&Signature=eLmtuPN10YXS8pNUtJO2E2vt%2FPM%3D
-
-
-//https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion
-
-//http://test.iot.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion
-namespace OHOS
-{
-
-
- static SystemupgradeView *g_pSystemFactoryResetView{nullptr};
- static osThreadId_t g_alipay_task_handle = NULL;
- //static char * imei_str="864430010001091";
-// osThreadAttr_t g_alipay_attr = {
-// "alipay_task", 0, NULL, 0, NULL, ALIPAT_MSG_STACK_SIZE, TASK_PRIORITY_ALIPAY_APP, 0, 0
-// };
- static char *Path=UPDATAJSONPATH;
- static httpc_connection_t settings = {0};
- static uint8_t uri[256] ={0};// (uint8_t*)
- //"http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=V1.1_20240316_115535&imei=864430010001091";
-
- static char *Path_ota_package= UPDATAFWPKGPATH;
- static uint8_t uri_ota_package[256] ={0};
- static const char *imei_str=NULL;
- static char *report_jsonString=NULL;
- static uint32_t file_total_len = 0;
- static err_t httpc_download_headers_done_ui(httpc_state_t *connection, void *arg, struct pbuf *hdr, u16_t hdr_len, u32_t content_len)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_headers_done_ui hdrlen %d, file len %d\r\n",hdr_len,content_len);
- file_total_len = content_len;
- return 0;
- }
- static err_t httpc_download_file_recv_ui(httpc_state_t *connection, u32_t rx_len,u32_t rx_total_len)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_file_recv_ui recv %d bytes total received %d filelen %d\r\n",rx_len,rx_total_len,file_total_len);
- return 0;
- }
-
- static void httpc_download_result_report_data(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui");
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"httpc_download_result , httpc_result_t %d, rx_content_len %d , srv_res %d, err %d\n",
- httpc_result,rx_content_len,srv_res,err);
- if(srv_res==200 && err==0)
- remove(UPDATAREPORT);
-
- return ;
- }
-
-
-
-
- // // httpc_get_file(
- // const ip_addr_t* server_addr,
- // u16_t port,
- // const char* uri,
- // const httpc_connection_t *settings,
- // // // altcp_recv_fn recv_fn,
- // void* callback_arg, httpc_state_t **connection)
-
- static void report_data_by_get_file(char *data,u16_t data_len)
- {
- settings.use_proxy=0;
-
- settings.use_post=1;
- settings.args=(u8_t*)data;
- settings.arglen=data_len;
- uint8_t *otadatapath =(uint8_t *)UPDATAREPORT_;
-
- settings.result_fn=httpc_download_result_report_data;
- settings.file_rx_fn = httpc_download_file_recv_ui;
- settings.headers_done_fn = httpc_download_headers_done_ui;
-
- httpc_state_t* connection=NULL;
- err_t rett= httpc_get_file_dns_to_disk(
- HTTP_JSON_SERVER_NAME,
- PORT,
- POST_URL,
- &settings,
- NULL,
- (const char*) otadatapath,
- &connection);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"custom_start_ota_download %d \r\n",rett);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "use_post_");
- }
- //#define UP_TEST
- static void upgrade_task(void *arg)
- {
-
- // msleep(3000);
- //uapi_tcxo_delay_ms(3000);
-
-
- FILE * fp = fopen(Path,"rb+");
- if(fp==NULL)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "open fail");
- if(SystemupgradeView::GetInstance())
- SystemupgradeView::GetInstance()->set_string_value(NULL,false);
- return;
- }
- char *buf=(char *)malloc(1024);
- memset((void*)buf,0,1024);
- int ret =fread(buf,1,1024,fp);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui %d %s\r\n",ret,buf);
- if(ret==0)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fread %d",ret);
- fclose(fp);
- free(buf);
- if(SystemupgradeView::GetInstance())
- SystemupgradeView::GetInstance()->set_string_value(NULL,false);
- return;
- }
-
- // std::string jsonDataString((std::istreambuf_iterator<char>(inFile)), std::istreambuf_iterator<char>());
- // const char *jsonData = jsonDataString.c_str();
- // char *new_buf=NULL;
- // new_buf=strstr(buf,"{\"success\":");//移到json的头的位置
- cJSON *root = cJSON_Parse(buf);
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " %s",new_buf);
- free(buf);
- if(root==NULL)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui JSON_parse_fail");
- }
- else if(root!=NULL)
- {
-
- int code=cJSON_GetObjectItem(root, "code")->valueint;
-
- //char *uri = cJSON_GetObjectItem(root, "url")->valuestring;
- //
- //char *OtaPackageVersion = cJSON_GetObjectItem(root, "OtaPackageVersion")->valuestring;
- char *msg = cJSON_GetObjectItem(root, "msg")->valuestring;
- // if(msg==NULL)
- // {
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "msg????????????????");
- // }
- // else
- // //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",msg);
- int success=cJSON_GetObjectItem(root, "success")->valueint;
-
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s,%s",uri,OtaPackageVersion);
- // //SystemupgradeView::GetInstance()->newVersion->SetText(OtaPackageVersion);
- // cJSON_Delete(root);
- char msg_buf[256]={0};
- bool falg=false;
-
-
-
- sprintf(msg_buf,"%s",msg);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",msg);
- if(SystemupgradeView::GetInstance())
- SystemupgradeView::GetInstance()->set_string_value(msg_buf,falg);
-
- //RootView::GetInstance()->Invalidate();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui");
- cJSON_Delete(root);
-
- }
- fclose(fp);
-
-
- }
-
- static void upgrade_task_fwpkg(void *arg)
- {
-
- // msleep(3000);
- FILE * fp = fopen(Path_ota_package,"rb");
- if(fp!=NULL)
- {
- fclose(fp);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file open success fwpkg_is_ready");
- }
- errcode_t ret=uaip_cmd_update_request();
- if(ret!=ERRCODE_SUCC)
- {
- SystemupgradeView::GetInstance()->init_fail(0);
- }
-
- //开始升级
- //**********
-
- }
-
- // void create_ppg_queue(void)
- // {
- // if (osal_msg_queue_create("ppg_service_queue", 10, &g_app_queue,
- // 0, sizeof(PPG_CMD_TYPE_T)) != ERRCODE_SUCC) {
- // PRINT_ERR("[ppg][service] app create mail fail\n");
- // }
- // }
-
- errcode_t upgrade_service_service_init(void)
- {
-
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_ppg_service_init !\r\n");
- app_task_definition_t taskcfg={0};
- taskcfg.create_queue_handle = NULL;
- taskcfg.attr.name="upgrade_service";
- taskcfg.attr.priority = TASK_PRIORITY_APP;
- taskcfg.attr.stack_size = 1024*10;
- taskcfg.func = upgrade_task;
- taskcfg.use_mem = USE_EXTEND_MEM;
-
- errcode_t ret=uapi_create_osThread_custom(&taskcfg);
- if(ret != ERRCODE_SUCC)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"create ppg_service failed %d!\r\n",ret);
- return ERRCODE_FAIL;
- }
-
- return ERRCODE_SUCC;
- }
-
- errcode_t upgrade_service_service_init_packpage(void)
- {
-
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_ppg_service_init !\r\n");
- app_task_definition_t taskcfg={0};
- taskcfg.create_queue_handle = NULL;
- taskcfg.attr.name="upgrade_service_ota_fwpkg";
- taskcfg.attr.priority = TASK_PRIORITY_APP;
- taskcfg.attr.stack_size = 1024*8;
- taskcfg.func = upgrade_task_fwpkg;
- taskcfg.use_mem = USE_EXTEND_MEM;
-
- errcode_t ret=uapi_create_osThread_custom(&taskcfg);
- if(ret != ERRCODE_SUCC)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"create ppg_service failed %d!\r\n",ret);
- return ERRCODE_FAIL;
- }
-
- return ERRCODE_SUCC;
- }
-
-
-
-
- static void httpc_download_result_ui_packpage(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui");
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"httpc_download_result , httpc_result_t %d, rx_content_len %d , srv_res %d, err %d\n",
- httpc_result,rx_content_len,srv_res,err);
- cat1_api_keep_wakeup(0);
- if(httpc_result!=0)
- {
- SystemupgradeView::GetInstance()->init_fail(1);
- return;
- }
-
-
- upgrade_service_service_init_packpage();//线程当timer用
- return ;
- }
-
-
- static void httpc_download_result_ui(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui");
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"httpc_download_result , httpc_result_t %d, rx_content_len %d , srv_res %d, err %d\n",
- httpc_result,rx_content_len,srv_res,err);
- cat1_api_keep_wakeup(0);
- upgrade_service_service_init();//线程当timer用
-
- return ;
- }
-
- //static osTimerId_t upgrade_timer=NULL;
-
-
- static uint32_t custom_start_ota_download_ui_1( uint8_t *uri_str,uint8_t *Path,bool falg,const char *server_name)
- {
-
- //(uint8_t*)argv[0];
- uint8_t *otadatapath = (uint8_t*)Path;
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"custom_start_ota_download %s to %s\r\n",uri_str,otadatapath);
- cat1_api_keep_wakeup(1);
- if(falg)
- {
- settings.result_fn=httpc_download_result_ui;
- }
- else
- {
- settings.result_fn=httpc_download_result_ui_packpage;
- }
-
- FILE * fp= fopen((char *)Path,"rb");
- if(fp!=NULL)
- {
- fclose(fp);
- int ret= remove((char *)Path);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file remove!!!!!!!!!!!!! %d ",ret);
- }
-
- settings.file_rx_fn = httpc_download_file_recv_ui;
- settings.headers_done_fn=httpc_download_headers_done_ui;
- settings.use_post=0;
- httpc_state_t* connection=NULL;
- err_t rett = httpc_get_file_dns_to_disk(
- server_name,
- PORT,
- (const char*) uri_str,
- (const httpc_connection_t *)&settings,
- NULL,
- (const char*) otadatapath,
- &connection);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"custom_start_ota_download %d \r\n",rett);
- if(rett!=0)
- {
- if(SystemupgradeView::GetInstance())
- SystemupgradeView::GetInstance()->set_string_value(NULL,false);
- }
-
- // SystemupgradeView::GetInstance()->init_fail(0);
- return ERRCODE_SUCC;
- }
-
-
-
-
-
-
- //httpc_result_fn *result_fn;
-
-
- SystemupgradeView::SystemupgradeView()
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::SystemFactoryResetView");
- g_pSystemFactoryResetView = this;
- }
-
- SystemupgradeView::~SystemupgradeView()
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::~SystemFactoryResetView");
- ClearAll();
- g_pSystemFactoryResetView = nullptr;
- }
-
- SystemupgradeView *SystemupgradeView::GetInstance()
- {
- return g_pSystemFactoryResetView;
- }
-
- void SystemupgradeView::ClearAll()
- {
- // if (initViewStatus == true)
- // {
- if(scrollView)
- {
- scrollView->RemoveAll();
- if(container_fail)
- {
- container_fail->RemoveAll();
- if(label1_fail)
- {
- delete label1_fail;
- }
- label1_fail=nullptr;
-
- if(labelButton1_exit)
- {
- delete labelButton1_exit;
- }
- labelButton1_exit=nullptr;
-
- delete container_fail;
- container_fail = nullptr;
- }
- if(container_updating)
- {
- container_updating->RemoveAll();
- if(label_updating)
- {
- delete label_updating;
- }
- label_updating=nullptr;
- delete label_updating;
- label_updating = nullptr;
- }
- if(newVersionTitle)
- {
- delete newVersionTitle;
- }
- newVersionTitle=nullptr;
-
- if(newVersion)
- {
- delete newVersion;
- }
- newVersion=nullptr;
-
- if(systemupgrade)
- {
- delete systemupgrade;
- }
- systemupgrade=nullptr;
-
- if(FirmwareVersionTitle)
- {
- delete FirmwareVersionTitle;
- }
- FirmwareVersionTitle=nullptr;
-
- if(FirmwareVersion)
- {
- delete FirmwareVersion;
- }
- FirmwareVersion=nullptr;
-
- if(new_label)
- {
- delete new_label;
- }
- new_label=nullptr;
-
-
- if(SystemUpgradeButton_)
- {
- delete SystemUpgradeButton_;
- }
- SystemUpgradeButton_=nullptr;
-
- }
- scrollView->RemoveAll();
- delete scrollView;
- scrollView = 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();
- // }
- // int t=ConfigModel::GetInstance()->GetScreenDuration();
- // display_api->set_screen_set_keepon_timeout(t);
- ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
- // }
- }
-
-
-
- UILabel *SystemupgradeView::InitLabel(LabelConfig &labelConfig)
- {
- UILabel *label = new UILabel();
- if (label == nullptr)
- {
- return nullptr;
- }
- label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小
- label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小
- label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高
- label->SetText(labelConfig.text); // 内容
- label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。
- label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP);
- label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize);
- return label;
- }
- void SystemupgradeView::statr_down_fwpkg(void)
- {
- // if(is_new_cat1_version)
- // {
- // char *imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
- // char * version_buf=const_cast<char*>(ConfigModel::GetInstance()->GetmoderVer().c_str());
- // sprintf((char *)uri,"http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,version_buf);
- // cat1_ota_update((char *)"0");
- // container_updating->SetVisible(true);
- // scrollView->SetTouchable(false);
- // scrollView->SetDraggable(false);
- // }
- // else
- if(is_new_version)
- {
- //下载差分包
- // // //**********
- container_updating->SetVisible(true);
- scrollView->SetTouchable(false);
- scrollView->SetDraggable(false);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_start_ota_download_ui_1");
- custom_start_ota_download_ui_1(uri_ota_package,(uint8_t*)Path_ota_package,false,HTTP_FWPGK_SERVER_NAME);
- if(report_jsonString!=NULL)
- {
- uint32_t data_len=strlen(report_jsonString);
- if(data_len!=0)
- {
- FILE *FP_= fopen(UPDATAREPORT,"w+");
- printf("升级文件保存\r\n");
- fwrite(report_jsonString,1,data_len,FP_);
- fclose(FP_);
- printf("data%d %s\r\n",data_len,report_jsonString);
- cJSON_free(report_jsonString);
- report_jsonString=NULL;
- }
-
- }
-
-
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "");
- // upgrade_reported_data();
- }
- }
-
- void SystemupgradeView::cat1_up_success(void)
- {
- if(is_new_cat1_version)
- {
- label_updating->SetText(" success");
- container_updating->SetVisible(true);
- scrollView->SetTouchable(true);
- scrollView->SetDraggable(true);
- is_new_cat1_version=false;
- statr_down_fwpkg();
- }
-
- }
-
-
- static uint8_t falg_dwon_json=0;
- void SystemupgradeView::set_string_value(char *str,bool falg)
- {
- if(falg_dwon_json==0)
- {
- if(falg)
- {
- if(str!=NULL)
- {
- newVersion->SetText(str);
- }
-
- if(newVersion)
- newVersion->SetVisible(true);
-
- if(newVersionTitle)
- {
- newVersionTitle->SetText("有最新固件版本");
- newVersionTitle->SetVisible(true);
- }
-
- //new_label->SetVisible(true);
- is_new_version=true;
-
- }
- else
- {
- if(str!=NULL)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "str %s",str);
- if(newVersion)
- {
- newVersion->SetText(str);
- newVersion->SetVisible(true);
- }
-
- }
-
- if(newVersion)
- {
- newVersionTitle->SetText("获取升级失败");
- newVersionTitle->SetVisible(true);
- }
-
- is_new_version=false;
-
- }
-
- // imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
- // char * version_buf=const_cast<char*>(ConfigModel::GetInstance()->GetmoderVer().c_str());
- // sprintf((char *)uri,"https://test.app.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,version_buf);
- // custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true);
- // falg_dwon_json++;
- }
- else if (falg_dwon_json==1)
- {
- if(falg)
- {
- const char *text= newVersion->GetText();
- char buf[256]={0};
- sprintf(buf,"%s\n%s",text,str);
- newVersion->SetText(buf);
- newVersionTitle->SetText("有最新固件版本");
- newVersion->SetVisible(true);
- newVersionTitle->SetVisible(true);
- is_new_cat1_version=true;
-
- }
- else
- {
- if(is_new_version!=true)
- {
- newVersionTitle->SetText("已是最新固件版本");
- newVersionTitle->SetVisible(true);
- is_new_version=false;
- is_new_cat1_version=false;
-
- }
-
-
- }
-
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SystemPresenter::GetInstance());
- if (draglistener == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!");
- return ;
- }
- scrollView->SetOnDragListener(draglistener);
- falg_dwon_json++;
- }
-
-
-
-
-
- RootView::GetInstance()->Invalidate();
- }
-
- void SystemupgradeView::statr_upgrade(void)
- {
- if(is_fwpkg_ready)
- {
- //开始升级
- //**********
- statr_down_fwpkg();
- }
- }
-
- void SystemupgradeView::init_updating(void)
- {
- if (container_updating == nullptr) {
- container_updating = new UIViewGroup();
- container_updating->SetPosition(0, 0, 466, 480);
- //container_updating->SetStyle(STYLE_BACKGROUND_OPA, 0);
- }
-
- if (label_updating == nullptr) {
- label_updating = new UILabel();
- }
- label_updating->SetPosition(94, 207); // widget's left position and top position
- label_updating->Resize(425, 132); // widget's width and height
- label_updating->SetViewId("label1");// Set style
- label_updating->SetStyle(STYLE_TEXT_FONT, 50);
-
- // Set additional property
- label_updating->SetText("updating.....");
- label_updating->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
- label_updating->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- label_updating->SetRollSpeed(0);
- label_updating->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50);
-
- // Add to rootView
- container_updating->Add(label_updating);
- container_updating->SetVisible(false);
- container_updating->SetTouchable(false);
- container_updating->SetDraggable(false);
- scrollView->Add(container_updating);
-
-
- }
-
- void SystemupgradeView::init_fail(uint8_t falg)
- {
- if (container_fail == nullptr) {
- container_fail = new UIViewGroup();
- container_fail->SetPosition(0, 0, 466, 480);
- // container_fail->SetStyle(STYLE_BACKGROUND_OPA, 0);
- }
-
- if (label1_fail == nullptr) {
- label1_fail = new UILabel();
- }
- label1_fail->SetPosition(81, 207); // widget's left position and top position
- label1_fail->Resize(454, 142);
- // label1_fail->SetPosition(197, 207); // widget's left position and top position
- // label1_fail->Resize(425, 132); // widget's width and height
- label1_fail->SetViewId("label1");// Set style
- label1_fail->SetStyle(STYLE_TEXT_FONT, 50);
-
- // Set additional property
- if(falg==0)
- {
- label1_fail->SetText("updating fail");
- }
- else
- {
- label1_fail->SetText("download fail");
- }
-
- label1_fail->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
- label1_fail->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- label1_fail->SetRollSpeed(0);
- label1_fail->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50);
-
- // Add to rootView
- container_fail->Add(label1_fail);
- label1_fail->SetVisible(true);
-
- // Add LabelButtonExt to App
- if (labelButton1_exit == nullptr) {
- labelButton1_exit = new UILabelButtonExt();
- }
- labelButton1_exit->SetPosition(156, 326); // widget's left position and top position
- labelButton1_exit->Resize(153, 64); // widget's width and height
- labelButton1_exit->SetViewId("labelButton1_exit");// Set style
-
- // Set additional property
- labelButton1_exit->SetText("exit");
- labelButton1_exit->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35);
- labelButton1_exit->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
- labelButton1_exit->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(SystemPresenter::GetInstance());
- labelButton1_exit->SetOnClickListener(clickListener);
- // Add to rootView
- container_fail->SetTouchable(true);
- container_fail->Add(labelButton1_exit);
- container_fail->SetVisible(true);
- scrollView->Add(container_fail);
- scrollView->SetTouchable(true);
- scrollView->SetDraggable(true);
- RootView::GetInstance()->Invalidate();
- }
-
-
-
-
-
- UIScrollView *SystemupgradeView::SystemupgradeViewInit(void)
- {
-
- scrollView = new UIScrollView();
- if (scrollView == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new scrollView fail!");
- return nullptr;
- }
- scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294);
- scrollView->SetScrollBlankSize(35);
- scrollView->SetReboundSize(50);
- scrollView->SetDirection(1);
-
-
- scrollView->SetTouchable(true);
- scrollView->SetDraggable(true);
-
- LabelConfig Config = {
- .left = 190,
- .top = 52,
- .width = 60,
- .height = 35,
- .fontSize = 30,
- .lineHeigh = 35,
- .text = "系统升级",
- .lineBreakMode = UILabel::LINE_BREAK_ADAPT,
- };
- systemupgrade = InitLabel(Config);
- if (systemupgrade == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
- return nullptr;
- }
- scrollView->Add(systemupgrade);
-
- /* -------------------------------------------------------------------------- */
- Config = {
- .left = 168,
- .top = 105,
- .width = 120,
- .height = 35,
- .fontSize = 30,
- .lineHeigh = 35,
- .text = "当前固件版本",
- .lineBreakMode = UILabel::LINE_BREAK_ADAPT,
- };
- FirmwareVersionTitle = InitLabel(Config);
- if (FirmwareVersionTitle == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersionTitle new fail!");
- return nullptr;
- }
- scrollView->Add(FirmwareVersionTitle);
-
- char version_buf[128]={0};
- uint32_t version_len=128;
- uapi_get_buildversion((uint8_t*)version_buf,version_len);
- Config = {
- .left = 37,
- .top = 135,
- .width = 400,
- .height = 30,
- .fontSize = 26,
- .lineHeigh = 30,
- .text = (char*)version_buf,
- .lineBreakMode = UILabel::LINE_BREAK_WRAP,
- };
- FirmwareVersion = InitLabel(Config);
- if (FirmwareVersion == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersion new fail!");
- return nullptr;
- }
- FirmwareVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87));
- scrollView->Add(FirmwareVersion);
-
- Config = {
- .left = 140,
- .top = 210,
- .width = 120,
- .height = 35,
- .fontSize = 30,
- .lineHeigh = 35,
- .text = "最新固件版本",
- .lineBreakMode = UILabel::LINE_BREAK_ADAPT,
- };
- newVersionTitle = InitLabel(Config);
- if (newVersionTitle == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersionTitle new fail!");
- return nullptr;
- }
- newVersionTitle->SetVisible(false);
- scrollView->Add(newVersionTitle);
-
-
-
- Config = {
- .left = 37,
- .top = 240,
- .width = 400,
- .height = 30,
- .fontSize = 26,
- .lineHeigh = 30,
- .text = (char*)"",
- .lineBreakMode = UILabel::LINE_BREAK_WRAP,
- };
- newVersion = InitLabel(Config);
- newVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87));
- newVersion->SetTouchable(true);
- newVersion->SetViewId("newVersion");
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(SystemPresenter::GetInstance());
- newVersion->SetOnClickListener(clickListener);
- newVersion->SetVisible(false);
- scrollView->Add(newVersion);
-
- // Config = {
- // .left = 367,
- // .top = 240,
- // .width = 45,
- // .height = 30,
- // .fontSize = 26,
- // .lineHeigh = 30,
- // .text = "新!",
- // .lineBreakMode = UILabel::LINE_BREAK_WRAP,
- // };
- // new_label = InitLabel(Config);
- // if (FirmwareVersion == nullptr)
- // {
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersion new fail!");
- // return nullptr;
- // }
- // new_label->SetTextColor(Color::GetColorFromRGBA(0xff, 0x00, 0x00, 0x87));
- // new_label->SetVisible(false);
- // scrollView->Add(new_label);
- /* -------------------------------------------------------------------------- */
- // UILabelButtonExt * SystemUpgradeButton = new UILabelButtonExt();
- // if (SystemUpgradeButton == nullptr)
- // {
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!");
- // }
- // SystemUpgradeButton->SetPosition(43, 400, 200, 100);
- // SystemUpgradeButton->SetViewId(SYSTEM_UPGRADE);
- // SystemUpgradeButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- // SystemUpgradeButton->SetText("下载");
- // SystemUpgradeButton->SetAlign(TEXT_ALIGNMENT_LEFT);
- // SystemUpgradeButton->SetLabelPosition(45, 0);
- // SystemUpgradeButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25);
- // SystemUpgradeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
- // scrollView->Add(SystemUpgradeButton);
-
- SystemUpgradeButton_ = new UILabelButtonExt();
- if (SystemUpgradeButton_ == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!");
- }
- SystemUpgradeButton_->SetPosition(163, 400, 180, 80);
- SystemUpgradeButton_->SetViewId(SYSTEM_UPGRADE_t);
- SystemUpgradeButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- SystemUpgradeButton_->SetText("确认升级");
- SystemUpgradeButton_->SetAlign(TEXT_ALIGNMENT_LEFT);
- SystemUpgradeButton_->SetLabelPosition(45, 0);
- SystemUpgradeButton_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25);
- SystemUpgradeButton_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-
-
- UIView::OnClickListener *Click = static_cast<UIView::OnClickListener *>(SystemPresenter::GetInstance());
- SystemUpgradeButton_->SetOnClickListener(Click);
- scrollView->Add(SystemUpgradeButton_);
-
-
- init_updating();
-
- //init_fail();
-
- //SystemUpgradeButton->SetOnClickListener(clickListener);
-
- //char *Path= "/user/data/ota_start_1.json";
- // 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_screen_set_keepon_timeout(-1);
- ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
-
- memset(uri,0,256);
- imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());//"864430010001091";//const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
- //https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion
- // 860132060347507
- // v1.1_20240419_152549
- // sprintf((char *)uri,JSON_URL,"860132060347507","V1.1_20240422_161728");
- sprintf((char *)uri,JSON_URL,imei_str,version_buf);
- custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true,HTTP_JSON_SERVER_NAME);
- //report_data_by_get_file();
- falg_dwon_json=0;
- //uograde_service_service_init();
-
- return scrollView;
- }
-
-}
-#endif
\ No newline at end of file