PY升级流程修改
authorhcj <1224667075@qq.com>
Mon, 3 Mar 2025 10:09:39 +0000 (18:09 +0800)
committerhcj <1224667075@qq.com>
Mon, 3 Mar 2025 10:09:39 +0000 (18:09 +0800)
code/sdk/application/wearable/service/ble_service/blemoder/bletest.h
code/sdk/application/wearable/service/msg_center/CMakeLists.txt
code/sdk/application/wearable/service/msg_center/include/notify/cat1_updata_notification.h [new file with mode: 0644]
code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/cat1_updata_notification.cpp [new file with mode: 0644]
code/sdk/drivers/peripheral/slip/cat1Service/cat1_tcpServer.cpp

index 99201ee..85d0e33 100644 (file)
@@ -224,6 +224,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/common/msg_center_common.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/charge_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/cat1_updata_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp
     # ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp
@@ -245,6 +246,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_cmd.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/charge_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/cat1_updata_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp
diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/cat1_updata_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/cat1_updata_notification.h
new file mode 100644 (file)
index 0000000..336f847
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef CAT1_NOTIFICATION_H
+#define CAT1_NOTIFICATION_H
+#include "components/ui_image_animator.h" 
+
+namespace OHOS
+{
+
+    UIViewGroup* Cat1PythonUpdataShow(void);
+    void FreeCat1PythonUpdataShow(void);
+   
+    class Cat1PythonUpdataShowListener : public OHOS::UIView::OnClickListener,
+                              public OHOS::UIView::OnLongPressListener,
+                              public OHOS::UIView::OnTouchListener,
+                              public OHOS::UIView::OnDragListener 
+    {
+public:
+    Cat1PythonUpdataShowListener();
+       virtual ~Cat1PythonUpdataShowListener();
+       static Cat1PythonUpdataShowListener *GetInstance(void);
+
+    bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override;
+    bool OnDrag(OHOS::UIView& view, const OHOS::DragEvent& event) override
+    {
+        return true;
+    }
+    bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override;
+    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
index 3f3a966..366b94d 100644 (file)
@@ -36,6 +36,8 @@
 #include "message_notification.h"
 #include "sleep_notification.h"
 #include "motion_recognition_notification.h"
+#include "cat1_updata_notification.h"
+
 #include "debug_output_notification/debug_output_notification.h"
 
 constexpr uint16_t HALF_SCREEN = 2;
index 33d6569..4a7d10b 100644 (file)
@@ -374,6 +374,11 @@ static OHOS::UIViewGroup* showcallfailNotify(void)
     return OHOS::CALL_FAIL_HINT();
 }
 
+static OHOS::UIViewGroup* showCat1UpdataNotify(void)
+{
+    return OHOS::Cat1PythonUpdataShow();
+}
+
 
 void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
 {
@@ -1874,6 +1879,13 @@ void MsgCenterNotifybleTransmit(const Topic topic, Request* req)
         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]);
diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/cat1_updata_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/cat1_updata_notification.cpp
new file mode 100644 (file)
index 0000000..6660d7c
--- /dev/null
@@ -0,0 +1,240 @@
+#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 "cmsis_os2.h"
+#include "linux/delay.h"
+#include "components/ui_circle_progress.h"
+#include "battery_hal.h"
+#include "uicomponents/UIComponents.h"
+#include "cat1_tcpServer.h"
+//#include "ui_resource_string.h"
+
+namespace OHOS
+{
+    UIViewGroup *UIViewGroup_Cat1Updata=nullptr;
+    UIImageView *cat1_img=nullptr;
+    UILabelExt *CAT1_UILabel=nullptr;
+    UILabelButtonExt *Cat1_labelbutton=nullptr;
+    static UILabelExt *Title=nullptr;
+    static UILabelExt *FAIL_Hint_UILabel=nullptr;
+
+    #define LOW_POWER_BUTTON "LOW_POWER_BUTTON"
+    #define TRANSMITTING_OTA_DOWN  "/user/res/system/KUMILOGO.bin"
+
+   void FreeCat1PythonUpdataShow(void)
+    {
+       if (UIViewGroup_Cat1Updata != nullptr) 
+       {
+        UIViewGroup_Cat1Updata->RemoveAll();
+        if(cat1_img)
+        {
+            delete cat1_img;
+            cat1_img = nullptr;
+        }
+        if(CAT1_UILabel)
+        {
+            delete CAT1_UILabel;
+            CAT1_UILabel = nullptr;
+        }
+         if(Cat1_labelbutton)
+        {
+            delete Cat1_labelbutton;
+            Cat1_labelbutton = nullptr;
+        }
+        if(Title)
+        {
+            delete Title;
+            Title = nullptr;
+        }
+        if(FAIL_Hint_UILabel)
+        {
+            delete FAIL_Hint_UILabel;
+            FAIL_Hint_UILabel = nullptr;
+        }
+        
+        RootView::GetInstance()->Remove(UIViewGroup_Cat1Updata);
+        delete UIViewGroup_Cat1Updata;
+        UIViewGroup_Cat1Updata = nullptr;
+        }
+    }
+
+
+    UIViewGroup *Cat1PythonUpdataShow()
+    {
+    
+        if (UIViewGroup_Cat1Updata == nullptr) {
+            UIViewGroup_Cat1Updata = new UIViewGroup();
+            UIViewGroup_Cat1Updata->SetPosition(0, 0, 466, 466);
+        }
+
+         if (Title == nullptr) {
+        Title = new UILabelExt();
+        }
+        Title->SetPosition(83, 45);         // 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("是否进行模组升级");
+        // Title->SetTextId (STR_OTA_DOWNLOAD);
+        
+        Title->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+        Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        Title->SetRollSpeed(0);
+        Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+
+        UIViewGroup_Cat1Updata->Add(Title);
+
+         if (cat1_img == nullptr) {
+            cat1_img = new UIImageView();
+        }
+        cat1_img->SetPosition(117, 77, 230, 160);
+        cat1_img->SetViewId("image1");// Set style
+        const char *imageimagesPath = TRANSMITTING_OTA_DOWN;
+        cat1_img->SetSrc(imageimagesPath);
+
+        // Add to rootView
+        UIViewGroup_Cat1Updata->Add(cat1_img);
+        cat1_img->SetVisible(true);
+
+        // Add Label to App
+        if (CAT1_UILabel == nullptr) {
+            CAT1_UILabel = new UILabelExt();
+        }
+        CAT1_UILabel->SetPosition(68, 202);         // widget's left position and top position
+        CAT1_UILabel->Resize(328, 60);          // widget's width and height
+        CAT1_UILabel->SetViewId("label1");// Set style
+        CAT1_UILabel->SetStyle(STYLE_TEXT_FONT, 25);
+        CAT1_UILabel->SetText("是否进行4G模组升级,全升级过程将会自动重启两次,中途请勿操作,保证手表电量高于80%,若确定升级请点击确认,否则左滑退出");
+        CAT1_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+        CAT1_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        CAT1_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25);
+        // Add to rootView
+        UIViewGroup_Cat1Updata->Add(CAT1_UILabel);
+        CAT1_UILabel->SetVisible(true);
+        
+        // Add LabelButtonExt to App
+        if (Cat1_labelbutton == nullptr) {
+            Cat1_labelbutton = new UILabelButtonExt();
+        }
+        // Cat1_labelbutton->SetPosition(165, 378);         // widget's left position and top position
+        // Cat1_labelbutton->Resize(135, 88);          // widget's width and height
+        Cat1_labelbutton->SetViewId(LOW_POWER_BUTTON);// Set style
+        Cat1_labelbutton->SetPosition(0, 366, 466, 100);
+        const char *ImgSrc = "/user/res/466x100button.bin";
+        Cat1_labelbutton->SetImageSrc(ImgSrc, ImgSrc);
+        // Set additional property
+        Cat1_labelbutton->SetText("确认");
+        // Cat1_labelbutton->SetTextId(STR_KONW);
+        Cat1_labelbutton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        Cat1_labelbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+        UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(Cat1PythonUpdataShowListener::GetInstance());
+        Cat1_labelbutton->SetOnClickListener(button1Click);
+
+        UIView::OnDragListener *OnDragListener = static_cast<UIView::OnDragListener *>(Cat1PythonUpdataShowListener::GetInstance());
+        UIViewGroup_Cat1Updata->SetOnDragListener(OnDragListener);
+
+        // Add to rootView
+        UIViewGroup_Cat1Updata->Add(Cat1_labelbutton);
+        Cat1_labelbutton->SetVisible(true);
+        UIViewGroup_Cat1Updata->SetTouchable(true);
+        Cat1_labelbutton->SetTouchable(true);
+        UIViewGroup_Cat1Updata->SetDraggable(true);
+
+
+         if (FAIL_Hint_UILabel == nullptr) {
+        FAIL_Hint_UILabel = new UILabelExt();
+        }
+        FAIL_Hint_UILabel->SetPosition(62, 199);         // widget's left position and top position
+        FAIL_Hint_UILabel->Resize(340, 30);          // widget's width and height
+        FAIL_Hint_UILabel->SetViewId("label3");// Set style
+        FAIL_Hint_UILabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffAAAAAA);
+        FAIL_Hint_UILabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        FAIL_Hint_UILabel->SetStyle(STYLE_BORDER_RADIUS, 27);
+        FAIL_Hint_UILabel->SetStyle(STYLE_TEXT_FONT, 40);
+        FAIL_Hint_UILabel->SetStyle(STYLE_LINE_SPACE, 0);
+
+        FAIL_Hint_UILabel->SetText("电量过低不建议升级,请左滑退出");
+        FAIL_Hint_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+        FAIL_Hint_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        FAIL_Hint_UILabel->SetRollSpeed(0);
+        FAIL_Hint_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
+
+        UIViewGroup_Cat1Updata->Add(FAIL_Hint_UILabel);
+        FAIL_Hint_UILabel->SetVisible(false);
+        FAIL_Hint_UILabel->LayoutCenterOfParent();
+
+
+
+
+        NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeCat1PythonUpdataShow);
+        return UIViewGroup_Cat1Updata;
+    }
+
+    Cat1PythonUpdataShowListener::Cat1PythonUpdataShowListener()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallViewEventListener :%p", this);
+    }
+
+    Cat1PythonUpdataShowListener::~Cat1PythonUpdataShowListener()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~CallViewEventListener");
+    }
+
+    Cat1PythonUpdataShowListener *Cat1PythonUpdataShowListener::GetInstance(void)
+    {
+        static Cat1PythonUpdataShowListener lowppowrViewEventListene_t;
+        return &lowppowrViewEventListene_t;
+    }
+
+    bool Cat1PythonUpdataShowListener::OnClick(UIView& view, const ClickEvent& event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick.....");
+        UNUSED(event);
+        if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)==0)
+        {
+            float voltage = 0.0F;
+            uint8_t power = battery_get_voltage(&voltage);
+
+            if(power>80)
+            {
+                Cat1_OTA(CAT1_TCP_START_OTA);
+            }
+            else
+            {
+                FAIL_Hint_UILabel->SetVisible(true);
+            }
+          
+        }
+        return true;
+        
+    }
+
+
+    bool Cat1PythonUpdataShowListener::OnDragEnd(UIView& view, const DragEvent& event)
+    {
+        UNUSED(view);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnDragEnd.....");
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NotificationManager::GetInstance()->StopNotify();
+        }
+        return true;
+
+    }
+
+   
+
+
+
+}
index f0ef599..a21c3d6 100644 (file)
@@ -1183,7 +1183,8 @@ void re_connect(void)
 }
 
 uint8_t errno_count=0;
-
+static uint8_t IS_need_ota=1;
+extern uint8_t g_py_ver;
 void cat1_server_file_task(void *pvParameters)
 {
     char rx_buffer[512];
@@ -1242,6 +1243,20 @@ void cat1_server_file_task(void *pvParameters)
     
         errno_count=0;
 
+        if(IS_need_ota)
+        {
+            IS_need_ota=0;
+            if(g_py_ver==16)
+            {
+                uint8_t TRANSMIT_DATA=IS_NEED_CAT1_OTA;
+                    
+                CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);
+            }
+            else if(g_py_ver==17)
+            {
+                Cat1_OTA(CAT1_TCP_START_OTA);
+            }
+        }
         
         while (1) {
 
@@ -1286,7 +1301,7 @@ void cat1_server_file_task(void *pvParameters)
 #define CAT1_SERVICE_TASK_SIZE       (0x800*5)
 #define CAT1_SERVICE_TASK_PRIO       5
 
-extern uint8_t g_py_ver;
+
 
 errcode_t cat1_tcp_server_init(void)
 {