// Add to rootView\r
container_->Add(button);\r
button->SetVisible(true);\r
+\r
+ \r
+ }\r
+\r
+ void PhoneCallView ::container_child_init()\r
+ {\r
+ if (container_child == nullptr)\r
+ {\r
+ container_child = new UIViewGroup();\r
+ container_child->SetPosition(0, 0, 466, 466);\r
+ //container_child->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+ }\r
+ container_child->SetViewId("button_4G_and_BT");\r
+ //button_4G = params.button;\r
+ if (button_4G == nullptr)\r
+ {\r
+ button_4G = new UIButton();\r
+ }\r
+ button_4G->SetPosition(73, 144);\r
+ button_4G->Resize(140, 188);\r
+ button_4G->SetViewId("button_4G");\r
+ button_4G->SetStyle(STYLE_BACKGROUND_COLOR, 0xff14ff00);\r
+ button_4G->SetStyle(STYLE_BORDER_RADIUS, 50);\r
+ // Set additional properties\r
+ //button->SetImageSrc(defaultImgSrc, triggeredImgSrc);\r
+ button_4G->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+ button_4G->SetStyleForState(STYLE_BORDER_RADIUS,50,UIButton::PRESSED);\r
+ // Add the callback for events\r
+ UIView::OnClickListener *buttonClick = static_cast<UIView::OnClickListener *>(PhoneCallPresenter::GetInstance());\r
+ button_4G->SetOnClickListener(buttonClick);\r
+\r
+ // Add to rootView\r
+ container_child->Add(button_4G);\r
+\r
+ if (button_BT == nullptr)\r
+ {\r
+ button_BT = new UIButton();\r
+ }\r
+\r
+ button_BT->SetPosition(263, 144);\r
+ button_BT->Resize(140, 188);\r
+ button_BT->SetViewId("button_BT");\r
+ button_BT->SetStyle(STYLE_BACKGROUND_COLOR, 0xff0092ff);\r
+ button_BT->SetStyle(STYLE_BORDER_RADIUS, 50);\r
+ // Set additional properties\r
+ //button->SetImageSrc(defaultImgSrc, triggeredImgSrc);\r
+ button_BT->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+ button_BT->SetStyleForState(STYLE_BORDER_RADIUS,50,UIButton::PRESSED);\r
+ // Add the callback for events\r
+ //UIView::OnClickListener *buttonClick = static_cast<UIView::OnClickListener *>(PhoneCallPresenter::GetInstance());\r
+ button_BT->SetOnClickListener(buttonClick);\r
+\r
+ // Add to rootView\r
+ container_child->Add(button_BT);\r
+\r
+ if (label_4G == nullptr)\r
+ {\r
+ label_4G = new UILabel();\r
+ }\r
+ label_4G->SetPosition(112, 211); // widget's left position and top position\r
+ label_4G->Resize(236, 47); // widget's width and height\r
+ label_4G->SetViewId("label1"); // Set style\r
+ label_4G->SetStyle(STYLE_TEXT_FONT, 40);\r
+\r
+ // Set additional property\r
+\r
+ label_4G->SetText("4G");\r
+ //printf("view phoneNumber: %s\n", PhoneCallPresenter::GetInstance()->phoneNumber.c_str());\r
+ label_4G->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ label_4G->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label_4G->SetRollSpeed(0);\r
+ label_4G->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);\r
+ container_child->Add(label_4G);\r
+\r
+ if (label_BT == nullptr)\r
+ {\r
+ label_BT = new UILabel();\r
+ }\r
+ label_BT->SetPosition(302, 211); // widget's left position and top position\r
+ label_BT->Resize(236, 47); // widget's width and height\r
+ label_BT->SetViewId("label2"); // Set style\r
+ label_BT->SetStyle(STYLE_TEXT_FONT, 40);\r
+\r
+ // Set additional property\r
+\r
+ label_BT->SetText("BT");\r
+ //printf("view phoneNumber: %s\n", PhoneCallPresenter::GetInstance()->phoneNumber.c_str());\r
+ label_BT->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ label_BT->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label_BT->SetRollSpeed(0);\r
+ label_BT->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);\r
+ container_child->Add(label_BT);\r
+\r
+\r
+ container_child->SetVisible(false);\r
+\r
+\r
+ }\r
+\r
+ void PhoneCallView::container_child_SetVisible(bool falg)\r
+ {\r
+ container_child->SetVisible(falg);\r
}\r
\r
void PhoneCallView::Init()\r
{\r
initButton(params);\r
}\r
+ container_child_init();\r
+ container_->Add(container_child);\r
}\r
void PhoneCallView::ReLabel()\r
{\r
void PhoneCallView::DeInit()\r
{\r
printf("DeInit is ok !\n");\r
+\r
if (container_ != nullptr)\r
{\r
container_->RemoveAll();\r
}\r
+ if(container_child!=NULL)\r
+ {\r
+ container_->RemoveAll();\r
+ }\r
+ if(button_4G!=NULL)\r
+ {\r
+ delete button_4G;\r
+ button_4G = nullptr;\r
+ }\r
+ if(button_BT!=NULL)\r
+ {\r
+ delete button_BT;\r
+ button_BT = nullptr;\r
+ }\r
+ if(label_4G!=NULL)\r
+ {\r
+ delete label_4G;\r
+ label_4G = nullptr;\r
+ }\r
+ if(label_BT!=NULL)\r
+ {\r
+ delete label_BT;\r
+ label_BT = nullptr;\r
+ }\r
if (button1_ != nullptr)\r
{\r
delete button1_;\r
#include "wearable_log.h"
#include "UiConfig.h"
#include "custom_utils.h"
+#include "stdio.h"
+#include <iostream>
+#include <fstream>
+#include "cJSON.h"
+#include "config/include/ConfigModel.h"
+#include "lwip/err.h"
+#include "power_display_service.h"
+#include "cmsis_os2.h"
+#include "los_memory.h"
+#include "thread_init.h"
+ #include "lwip/apps/http_client.h"
+ #include "tcxo.h"
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= "/user/data/ota_start_3.json";
+ 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= "/user/update.fwpkg";
+ static uint8_t uri_ota_package[124] ={0};
+ #define UP_TEST
+ static void upgrade_task(void *arg)
+ {
+
+ uapi_tcxo_delay_ms(3000);
+ char buf[1024]={0};
+ FILE * fp = fopen(Path,"rb");
+ if(fp==NULL)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "open fail");
+ SystemupgradeView::GetInstance()->set_string_value(NULL,false);
+ return;
+ }
+ int ret =fread(buf,1,1024,fp);
+ if(ret==0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fread %d",ret);
+ fclose(fp);
+ SystemupgradeView::GetInstance()->set_string_value(NULL,false);
+ return;
+ }
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui %d",ret);
+ // std::string jsonDataString((std::istreambuf_iterator<char>(inFile)), std::istreambuf_iterator<char>());
+ // const char *jsonData = jsonDataString.c_str();
+ cJSON *root = cJSON_Parse(buf);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui");
+ if(root!=NULL)
+ {
+ bool falg=cJSON_GetObjectItem(root, "UptoDate")->valueint;
+ char *uri = cJSON_GetObjectItem(root, "url")->valuestring;
+ sprintf((char *)uri_ota_package,"%s",uri);
+ char *OtaPackageVersion = cJSON_GetObjectItem(root, "OtaPackageVersion")->valuestring;
+ char *description = cJSON_GetObjectItem(root, "description")->valuestring;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s,%s",uri,OtaPackageVersion);
+ //SystemupgradeView::GetInstance()->newVersion->SetText(OtaPackageVersion);
+ cJSON_Delete(root);
+ char buf[1024]={0};
+ sprintf(buf,"%s\n\n%s",OtaPackageVersion,description);
+ #ifdef UP_TEST
+ SystemupgradeView::GetInstance()->set_string_value(buf,true);
+ #else
+ if(falg)
+ {
+ SystemupgradeView::GetInstance()->set_string_value(buf,true);
+ }
+ else
+ {
+ SystemupgradeView::GetInstance()->set_string_value(NULL,false);
+ }
+ #endif
+ //RootView::GetInstance()->Invalidate();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui");
+
+ }
+ fclose(fp);
+
+ }
+
+ static void upgrade_task_fwpkg(void *arg)
+ {
+
+ uapi_tcxo_delay_ms(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)
+ {
+
+ PRINT("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*8;
+ taskcfg.func = upgrade_task;
+ taskcfg.use_mem = USE_EXTEND_MEM;
+
+ errcode_t ret=uapi_create_osThread_custom(&taskcfg);
+ if(ret != ERRCODE_SUCC)
+ {
+ PRINT("create ppg_service failed %d!\r\n",ret);
+ return ERRCODE_FAIL;
+ }
+
+ return ERRCODE_SUCC;
+ }
+
+ errcode_t upgrade_service_service_init_packpage(void)
+ {
+
+ PRINT("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)
+ {
+ PRINT("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");
+ PRINT("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);
+ uapi_cat1_wakeup_cat1(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");
+ PRINT("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);
+ uapi_cat1_wakeup_cat1(0);
+ upgrade_service_service_init();//线程当timer用
+
+ return ;
+ }
+
+ //static osTimerId_t upgrade_timer=NULL;
+ 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");
+ return 0;
+ }
+
+
+
+ static uint32_t custom_start_ota_download_ui_1( uint8_t *uri_str,uint8_t *Path,bool falg)
+ {
+
+ //(uint8_t*)argv[0];
+ uint8_t *otadatapath = (uint8_t*)Path;
+ PRINT("custom_start_ota_download %s to %s\r\n",uri_str,otadatapath);
+
+ uapi_cat1_wakeup_cat1(1);
+ if(falg)
+ {
+ settings.result_fn=httpc_download_result_ui;
+ }
+ else
+ {
+ settings.result_fn=httpc_download_result_ui_packpage;
+ }
+
+ settings.headers_done_fn=httpc_download_headers_done_ui;
+ httpc_state_t* connection=NULL;
+ err_t rett = httpc_get_file_dns_to_disk(
+ (const char*) "icfota.snicker.com.cn",
+ 8089,
+ (const char*) uri_str,
+ (const httpc_connection_t *)&settings,
+ NULL,
+ (const char*) otadatapath,
+ &connection);
+
+ PRINT("custom_start_ota_download %d \r\n",rett);
+ if(rett!=0)
+ SystemupgradeView::GetInstance()->set_string_value(NULL,false);
+ // SystemupgradeView::GetInstance()->init_fail(0);
+ return ERRCODE_SUCC;
+ }
+
+
+
+
+
+
+ //httpc_result_fn *result_fn;
+
SystemupgradeView::SystemupgradeView()
{
void SystemupgradeView::ClearAll()
{
- if (initViewStatus == true)
+ // if (initViewStatus == true)
+ // {
+ if(scrollView)
{
scrollView->RemoveAll();
- delete FactoryResetImage;
- FactoryResetImage = nullptr;
- delete FactoryResetButtonCheckOn;
- FactoryResetButtonCheckOn = nullptr;
- delete FactoryResetButtonCheckOff;
- FactoryResetButtonCheckOff = nullptr;
+ 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()->GetScreenDurationRadioButtonSlectValue();
+ display_api->set_screen_set_keepon_timeout(5000+t*5000);
+ // }
}
+
+
UILabel *SystemupgradeView::InitLabel(LabelConfig &labelConfig)
{
UILabel *label = new UILabel();
label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize);
return label;
}
+ void SystemupgradeView::statr_down_fwpkg(void)
+ {
+ 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);
+ }
+ }
+
+ void SystemupgradeView::set_string_value(char *str,bool falg)
+ {
+ if(falg)
+ {
+ newVersion->SetText(str);
+ newVersionTitle->SetText("有最新固件版本");
+ newVersion->SetVisible(true);
+ newVersionTitle->SetVisible(true);
+ new_label->SetVisible(true);
+ is_new_version=true;
+
+ }
+ else
+ {
+ newVersionTitle->SetText("已是最新固件版本");
+ newVersionTitle->SetVisible(true);
+ is_new_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);
+
+ RootView::GetInstance()->Invalidate();
+ }
+
+ void SystemupgradeView::statr_upgrade(void)
+ {
+ if(is_fwpkg_ready)
+ {
+ // char* Path="/user/data/update.fwpkg";
+ // FILE * fp = fopen(Path,"rb");
+ // if(fp!=NULL)
+ // {
+ // fclose(fp);
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file open succse fwpkg_is_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("退出");
+ 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->SetReboundSize(50);
scrollView->SetDirection(1);
- 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 NULL;
- }
- scrollView->SetOnDragListener(draglistener);
+
scrollView->SetTouchable(true);
scrollView->SetDraggable(true);
uapi_get_buildversion((uint8_t*)version_buf,version_len);
Config = {
.left = 37,
- .top = 110,
+ .top = 135,
.width = 400,
.height = 30,
.fontSize = 26,
scrollView->Add(FirmwareVersion);
Config = {
- .left = 168,
- .top = 200,
+ .left = 140,
+ .top = 210,
.width = 120,
.height = 35,
.fontSize = 30,
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersionTitle new fail!");
return nullptr;
}
+ newVersionTitle->SetVisible(false);
scrollView->Add(newVersionTitle);
char version_buf_1[128]={0};
uapi_get_buildversion((uint8_t*)version_buf_1,version_len);
Config = {
.left = 37,
- .top = 210,
+ .top = 240,
.width = 400,
.height = 30,
.fontSize = 26,
return nullptr;
}
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);
- UILabelButtonExt * SystemUpgradeButton = new UILabelButtonExt();
- if (SystemUpgradeButton == nullptr)
+ 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::SystemUpgradeButtonExt new fail!");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersion new fail!");
+ return nullptr;
}
- SystemUpgradeButton->SetPosition(43, 400, 100, 100);
- SystemUpgradeButton->SetViewId(SYSTEM_UPGRADE);
- SystemUpgradeButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- //SystemUpgradeButton->SetImagePosition(326, 37);
- //SystemUpgradeButton->SetImageSrc("/user/res/SETTING_NEXT.bin", "/user/res/SETTING_NEXT.bin");
- SystemUpgradeButton->SetText("开始下载");
- SystemUpgradeButton->SetAlign(TEXT_ALIGNMENT_LEFT);
- SystemUpgradeButton->SetLabelPosition(45, 0);
- SystemUpgradeButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- SystemUpgradeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
- scrollView->Add(SystemUpgradeButton);
-
- UILabelButtonExt * SystemUpgradeButton_2 = new UILabelButtonExt();
- if (SystemUpgradeButton == 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_2->SetPosition(163, 400, 100, 100);
- SystemUpgradeButton_2->SetViewId(SYSTEM_UPGRADE);
- SystemUpgradeButton_2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- //SystemUpgradeButton->SetImagePosition(326, 37);
- //SystemUpgradeButton->SetImageSrc("/user/res/SETTING_NEXT.bin", "/user/res/SETTING_NEXT.bin");
- SystemUpgradeButton_2->SetText("开始升级");
- SystemUpgradeButton_2->SetAlign(TEXT_ALIGNMENT_LEFT);
- SystemUpgradeButton_2->SetLabelPosition(45, 0);
- SystemUpgradeButton_2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- SystemUpgradeButton_2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+ SystemUpgradeButton_->SetPosition(163, 400, 180, 80);
+ 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);
UIView::OnClickListener *Click = static_cast<UIView::OnClickListener *>(SystemPresenter::GetInstance());
- SystemUpgradeButton_2->SetOnClickListener(Click);
- scrollView->Add(SystemUpgradeButton_2);
- //SystemUpgradeButton->SetOnClickListener(clickListener);
-
+ SystemUpgradeButton_->SetOnClickListener(Click);
+ scrollView->Add(SystemUpgradeButton_);
+
+
+ init_updating();
+ //init_fail();
+ //SystemUpgradeButton->SetOnClickListener(clickListener);
+
+ //char *Path= "/user/data/ota_start_1.json";
+
+ FILE * fp = fopen(Path,"rb");
+ if(fp!=NULL)
+ {
+ fclose(fp);
+ int ret= remove(Path);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file remove!!!!!!!!!!!!! %d ",ret);
+ }
+
+ 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);
+ memset(uri,0,256);
+ char *imei_str= ConfigModel::GetInstance()->Getimei();
+ sprintf((char *)uri,"http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=%s&imei=%s",version_buf,imei_str);
+ custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true);
+
+ //uograde_service_service_init();
+
return scrollView;
}