From: hcj <1224667075@qq.com> Date: Thu, 21 Mar 2024 09:37:15 +0000 (+0800) Subject: 网络下载升级 X-Git-Tag: release_V1.2.70_20241020_135402~1278^2~3 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=9264e3c00fd1f9cc49f88308f8bcde9ac8d32597;p=mirrors%2FFD230.git 网络下载升级 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h index 4d96adf12..8cde88931 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h @@ -34,6 +34,8 @@ namespace OHOS int GetHeartRateOrBloodOxygenQuickAccessSwitch(void); void SetDialId(uint8_t id); int GetDialId(); + char * Getimei(); + void Setimei(char *str); /* -------------------------------------------------------------------------- */ private: ConfigModel(); // 私有构造函数,确保无法在外部实例化 @@ -51,6 +53,7 @@ namespace OHOS bool TradionalBlueToothToggleButtonState{false}; // 用来记录蓝牙开关状态,默认关闭状态 int HeartRateOrBloodOxygenQuickAccessSwitch{0}; // 心率或血氧快速访问开关,默认快速访问血氧打开 int dialid; + char * imei_str=NULL; /* -------------------------------------------------------------------------- */ }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index 4bba51e37..51690d413 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -141,6 +141,28 @@ namespace OHOS return dialid; } + char* ConfigModel::Getimei() + { + + return imei_str; + } + + void ConfigModel::Setimei(char *str) + { + if(imei_str==NULL || strcmp(imei_str,str)!=0) + { + if(imei_str==NULL) + { + imei_str=(char*)malloc(strlen(str)); + strcpy(imei_str,str); + } + else + { + strcpy(imei_str,str); + } + } + return ; + } /* ------------------------------ ImageAnimator ----------------------------- */ ImageAnimator::ImageAnimator() diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h index e56056e60..80dc7244e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h @@ -70,9 +70,10 @@ namespace OHOS void ReLabel(); void Init(); void DeInit(); - + void container_child_init(); void initButton(const ButtonInitParams ¶ms); void UpdateLabel(const std::string &text); + void container_child_SetVisible(bool); UIView *GetView(); private: @@ -80,7 +81,10 @@ namespace OHOS PhoneCallView(PhoneCallView &&) = delete; PhoneCallView &operator=(PhoneCallView &&) = delete; UIViewGroup *container_ = nullptr; + UIViewGroup *container_child = nullptr; UILabel *label_ = nullptr; + UILabel *label_4G = nullptr; + UILabel *label_BT = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; UIButton *button3_ = nullptr; @@ -93,6 +97,9 @@ namespace OHOS UIButton *button0_ = nullptr; UIButton *buttoncall_ = nullptr; UIButton *buttondel_ = nullptr; + UIButton *button_4G =NULL; + UIButton *button_BT =NULL; + }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp index 212cfc974..0987a0b0d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp @@ -4,6 +4,8 @@ #include "phone/include/PhoneCallPresenter.h" #include #include "cat1_server_hal.h" +#include "PhoneService.h" +#include "phone/include/PhoneCallView.h" namespace OHOS { @@ -56,13 +58,27 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + if(strcmp( view.GetViewId(), "button_4G_and_BT") == 0) + { + PhoneCallView::GetInstance()->container_child_SetVisible(false); + return true; + } + } - if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) && - (event.GetStartPoint().y > 300)) + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING); + NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); } + + + + + // if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) && + // (event.GetStartPoint().y > 300)) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING); + // } UNUSED(view); return true; } @@ -71,12 +87,24 @@ namespace OHOS // 获取控件id const char *viewId = view.GetViewId(); + if (strcmp(viewId, "button_4G") == 0) + { + // 拨号键 + //NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING); + calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); + } + else if (strcmp(viewId, "button_BT") == 0) + { + + DialCall((unsigned char *)phoneNumber.c_str(),phoneNumber.length()); + } // 根据控件id处理点击事件 if (strcmp(viewId, BUTTONCALL) == 0) { // 拨号键 //NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING); - calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); + //calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); + PhoneCallView::GetInstance()->container_child_SetVisible(true); } else if (strcmp(viewId, BUTTONDEL) == 0) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp index 1873f5e6f..7447602ba 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp @@ -62,6 +62,108 @@ namespace OHOS // Add to rootView container_->Add(button); button->SetVisible(true); + + + } + + void PhoneCallView ::container_child_init() + { + if (container_child == nullptr) + { + container_child = new UIViewGroup(); + container_child->SetPosition(0, 0, 466, 466); + //container_child->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + container_child->SetViewId("button_4G_and_BT"); + //button_4G = params.button; + if (button_4G == nullptr) + { + button_4G = new UIButton(); + } + button_4G->SetPosition(73, 144); + button_4G->Resize(140, 188); + button_4G->SetViewId("button_4G"); + button_4G->SetStyle(STYLE_BACKGROUND_COLOR, 0xff14ff00); + button_4G->SetStyle(STYLE_BORDER_RADIUS, 50); + // Set additional properties + //button->SetImageSrc(defaultImgSrc, triggeredImgSrc); + button_4G->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button_4G->SetStyleForState(STYLE_BORDER_RADIUS,50,UIButton::PRESSED); + // Add the callback for events + UIView::OnClickListener *buttonClick = static_cast(PhoneCallPresenter::GetInstance()); + button_4G->SetOnClickListener(buttonClick); + + // Add to rootView + container_child->Add(button_4G); + + if (button_BT == nullptr) + { + button_BT = new UIButton(); + } + + button_BT->SetPosition(263, 144); + button_BT->Resize(140, 188); + button_BT->SetViewId("button_BT"); + button_BT->SetStyle(STYLE_BACKGROUND_COLOR, 0xff0092ff); + button_BT->SetStyle(STYLE_BORDER_RADIUS, 50); + // Set additional properties + //button->SetImageSrc(defaultImgSrc, triggeredImgSrc); + button_BT->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button_BT->SetStyleForState(STYLE_BORDER_RADIUS,50,UIButton::PRESSED); + // Add the callback for events + //UIView::OnClickListener *buttonClick = static_cast(PhoneCallPresenter::GetInstance()); + button_BT->SetOnClickListener(buttonClick); + + // Add to rootView + container_child->Add(button_BT); + + if (label_4G == nullptr) + { + label_4G = new UILabel(); + } + label_4G->SetPosition(112, 211); // widget's left position and top position + label_4G->Resize(236, 47); // widget's width and height + label_4G->SetViewId("label1"); // Set style + label_4G->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + + label_4G->SetText("4G"); + //printf("view phoneNumber: %s\n", PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + label_4G->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label_4G->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_4G->SetRollSpeed(0); + label_4G->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + container_child->Add(label_4G); + + if (label_BT == nullptr) + { + label_BT = new UILabel(); + } + label_BT->SetPosition(302, 211); // widget's left position and top position + label_BT->Resize(236, 47); // widget's width and height + label_BT->SetViewId("label2"); // Set style + label_BT->SetStyle(STYLE_TEXT_FONT, 40); + + // Set additional property + + label_BT->SetText("BT"); + //printf("view phoneNumber: %s\n", PhoneCallPresenter::GetInstance()->phoneNumber.c_str()); + label_BT->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label_BT->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_BT->SetRollSpeed(0); + label_BT->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + container_child->Add(label_BT); + + + container_child->SetVisible(false); + + + } + + void PhoneCallView::container_child_SetVisible(bool falg) + { + container_child->SetVisible(falg); } void PhoneCallView::Init() @@ -113,6 +215,8 @@ namespace OHOS { initButton(params); } + container_child_init(); + container_->Add(container_child); } void PhoneCallView::ReLabel() { @@ -121,10 +225,35 @@ namespace OHOS void PhoneCallView::DeInit() { printf("DeInit is ok !\n"); + if (container_ != nullptr) { container_->RemoveAll(); } + if(container_child!=NULL) + { + container_->RemoveAll(); + } + if(button_4G!=NULL) + { + delete button_4G; + button_4G = nullptr; + } + if(button_BT!=NULL) + { + delete button_BT; + button_BT = nullptr; + } + if(label_4G!=NULL) + { + delete label_4G; + label_4G = nullptr; + } + if(label_BT!=NULL) + { + delete label_BT; + label_BT = nullptr; + } if (button1_ != nullptr) { delete button1_; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h index f588801cd..a92a604e4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h @@ -18,6 +18,7 @@ namespace OHOS SYSTEMLANGUAGEVIEW, // 系统语言视图(subView) FACTORYRESETVIEW, // 恢复出厂设置视图(subView)upgrade SYSTEMLUPGRADE, + TEST, MAX_SYSTEMVIEWID, } SYSTEMVIEWID; @@ -70,7 +71,7 @@ namespace OHOS void OnStop() override; static SystemPresenter *GetInstance(); - + void set_key_falg(bool); private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h index a3aae396e..bba3ef1ce 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h @@ -9,6 +9,7 @@ #include "components/ui_scroll_view.h" #include "components/ui_label.h" #include "components/ui_label_button_ext.h" +#include "cat1_ctl.h" namespace OHOS { @@ -22,7 +23,7 @@ namespace OHOS UIScrollView *SystemupgradeViewInit(void); void ClearAll(void); - + void set_string_value(char *str,bool); struct LabelConfig { int16_t left; @@ -36,19 +37,36 @@ namespace OHOS }; UILabel *InitLabel(LabelConfig &labelConfig); - private: - UIScrollView *scrollView{nullptr}; - UIImageView *FactoryResetImage{nullptr}; // 恢复出厂设置背景图片 - UIButton *FactoryResetButtonCheckOn{nullptr}; // 重置确认 - UIButton *FactoryResetButtonCheckOff{nullptr}; // 重置否定 + UILabel *newVersionTitle{nullptr}; // "最新软件版本" + UILabel *newVersion{nullptr}; - UILabel *systemupgrade{nullptr}; // "固件版本" + void detection_update(void); + + void statr_down_fwpkg(void); + + void statr_upgrade(void); UILabel *FirmwareVersionTitle{nullptr}; // "固件版本" UILabel *FirmwareVersion{nullptr}; + UILabel *new_label{nullptr}; + void init_fail(uint8_t); + private: + UIScrollView *scrollView{nullptr}; + //UIImageView *FactoryResetImage{nullptr}; // 恢复出厂设置背景图片 + //UIButton *FactoryResetButtonCheckOn{nullptr}; // 重置确认 + // UIButton *FactoryResetButtonCheckOff{nullptr}; // 重置否定 + UILabelButtonExt * SystemUpgradeButton_; + UILabel *systemupgrade{nullptr}; // "固件版本" + UILabel *label_updating{nullptr}; + UILabel *label1_fail{nullptr}; + UIViewGroup *container_updating{nullptr}; + UIViewGroup *container_fail{nullptr}; + UILabelButtonExt *labelButton1_exit=NULL; + void init_updating(); + + bool is_new_version=false; - UILabel *newVersionTitle{nullptr}; // "最新软件版本" - UILabel *newVersion{nullptr}; + bool is_fwpkg_ready=false; bool initViewStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp index beb1bc73d..010117f8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -28,7 +28,8 @@ namespace OHOS {SUPERVISEVIEW,"SuperviseButton",true}, {SYSTEMLANGUAGEVIEW,"SystemLanguageButton",false}, {FACTORYRESETVIEW,"FactoryResetButton",true}, - {SYSTEMLUPGRADE,"systemupgread",true}}; + {SYSTEMLUPGRADE,"systemupgread",true}, + //{TEST,"testButton",true}}; // {ABOUTTHEWATCHVIEW, &SystemView::ChangeSystemAboutView}, // {SUPERVISEVIEW, &SystemView::ChangeSystemSuperviseView}, @@ -115,6 +116,12 @@ namespace OHOS { if(strcmp(view.GetViewId(),ViewMapper_t[i].viewid_str) == 0) { + if(i==5) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TEST); + break; + } + if(ViewMapper_t[i].enable_falg==true) SystemView::GetInstance()->ChangeView(SYSTEMVIEW, ViewMapper_t[i].viewId); return true; @@ -132,11 +139,18 @@ namespace OHOS p_SystemView->ChangeView(FACTORYRESETVIEW, SYSTEMVIEW); return true; } - else if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) + + + if(strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uaip_cmd_update_request"); - uaip_cmd_update_request(); - return true; + isSystemUpgradeState=true; + SystemupgradeView::GetInstance()->statr_down_fwpkg(); + } + if(strcmp(view.GetViewId(),"labelButton1_exit")==0) + { + // SystemView::GetInstance()->ChangeSlice(VIEW_SETTING);; + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + isSystemUpgradeState=false; } return false; } @@ -151,6 +165,7 @@ namespace OHOS { if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)) { + SystemPresenter:: GetInstance()->set_key_falg(false); NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); } return true; @@ -241,4 +256,9 @@ namespace OHOS } return true; } + + void SystemPresenter::set_key_falg(bool falg) // 增加按键事件 + { + isSystemUpgradeState=falg; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp index 2079ddf91..736640df6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp @@ -3,10 +3,250 @@ #include "wearable_log.h" #include "UiConfig.h" #include "custom_utils.h" +#include "stdio.h" +#include +#include +#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(inFile)), std::istreambuf_iterator()); + // 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() { @@ -28,20 +268,100 @@ namespace OHOS 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(); @@ -58,6 +378,165 @@ namespace OHOS 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(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(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) { @@ -75,13 +554,7 @@ namespace OHOS scrollView->SetReboundSize(50); scrollView->SetDirection(1); - UIView::OnDragListener *draglistener = static_cast(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); @@ -127,7 +600,7 @@ namespace OHOS uapi_get_buildversion((uint8_t*)version_buf,version_len); Config = { .left = 37, - .top = 110, + .top = 135, .width = 400, .height = 30, .fontSize = 26, @@ -145,8 +618,8 @@ namespace OHOS scrollView->Add(FirmwareVersion); Config = { - .left = 168, - .top = 200, + .left = 140, + .top = 210, .width = 120, .height = 35, .fontSize = 30, @@ -160,6 +633,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersionTitle new fail!"); return nullptr; } + newVersionTitle->SetVisible(false); scrollView->Add(newVersionTitle); char version_buf_1[128]={0}; @@ -167,7 +641,7 @@ namespace OHOS uapi_get_buildversion((uint8_t*)version_buf_1,version_len); Config = { .left = 37, - .top = 210, + .top = 240, .width = 400, .height = 30, .fontSize = 26, @@ -182,50 +656,98 @@ namespace OHOS return nullptr; } newVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + newVersion->SetTouchable(true); + newVersion->SetViewId("newVersion"); + UIView::OnClickListener *clickListener = static_cast(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(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; } diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index c833df4eb..0c68d2e95 100755 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -12,6 +12,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/callerlog/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/phoneservice/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/producttest/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/config/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/main/include/dial ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/bloodoxygen/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/heartrate/include @@ -103,6 +104,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/alarmclocktimerconfig/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/alarm/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/producttest/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/config/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/callerlog/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/phoneservice/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/main/include diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 642c0a77c..e1cb869de 100755 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -36,6 +36,7 @@ #include "testchanging.h" #include "testcat1.h" #include "testhrsenson.h" +#include "ConfigModel.h" namespace OHOS { #ifdef __cplusplus @@ -487,6 +488,7 @@ void MsgCenterNotifyCat1SignalUpdateProc(const Topic topic, Request* req) tokbuf=strtok(NULL,","); cat1_msg_T.imei=(char*)malloc(strlen(tokbuf)); strcpy( cat1_msg_T.imei,tokbuf); + ConfigModel::GetInstance()->Setimei(cat1_msg_T.imei); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",cat1_msg_T.imei); tokbuf=strtok(NULL,":"); tokbuf=strtok(NULL,","); diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 6a94c08a3..df87b5110 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -412,11 +412,13 @@ static int udp_packet_parse(char *rx_buffer, int len) index = cat1_handle_call_disconnected(msg); break; case UDP_CMD_CAT1_OTA_UPDATE: - printf("CAT1_OTA_UPDATE reply %s",msg->buffer); + printf("CAT1_OTA_UPDATE reply %s\n",msg->buffer); break; case UDP_MSG_REPLY: - printf("UDP_MSG_REPLY reply %s",msg->buffer); - + printf("UDP_MSG_REPLY reply %s\n",msg->buffer); + //BOOTUP,pyVer,PY_SRV_V4,modemVer,EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312 + if(strstr(msg->buffer,"BOOTUP")!=NULL) + cat1_getsignal(); break; case UDP_CMD_GET_CAT1VER: index = cat1_handle_networ_msg(msg);