From 5e080d063f213f2b2c2ed34e1d54b9fd7df1c6b0 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 23 十一月 2023 19:28:47 +0800
Subject: [PATCH] 2023年11月23日19:28:37

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
index 18a7ce7..36f0772 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -267,6 +267,11 @@
                         this.uniUpgradeGatewayDriver(data, callback);
                     }
                     break;
+                    //璁惧鍙栨秷涓嬭浇鍗囩骇鏂囦欢
+                    case HDLUniMP.UNI_EVENT_REPLY_OTA_DRIVER_CANCEL_DOWNLOAD: {
+                        this.uniCancelDownloadingUpgradeFile(data, callback);
+                    }
+                    break;
 
                 }
             }
@@ -553,7 +558,7 @@
     }
 
     /**
-     * 鍚戜簯绔彂璧枫�愯澶囬┍鍔ㄣ�戜笅杞芥寚浠�
+     * 鍚戜簯绔彂璧枫�愯澶囬┍鍔ㄤ笅杞姐�戞寚浠�
      */
     private void uniGatewayDriverDownload(Object data, DCUniMPJSCallback callback) {
         String deviceOid = getKeyValue("oid", getKeyValue("data", data));//缃戝叧璁惧oid
@@ -567,10 +572,13 @@
         HdlOtaLogic.getInstance().getDeviceDriverDownloadFile(url, new CloudCallBeak<ResponseBody>() {
             @Override
             public void onSuccess(ResponseBody responseBody) {
-                byte[] bytes = HdlOtaLogic.getInstance().disposeDownLoadFile(responseBody, md5);
-                HdlFileLogic.getInstance().deleteFile(localUrl);//鍒犻櫎鏃ф枃浠�
                 String drivePathFileName = HdlFileLogic.getInstance().getDrivePathFileName(driverCode, version);
-                HdlFileLogic.getInstance().writeFile(drivePathFileName, bytes);//鍐欏叆鏂版枃浠�
+                boolean isBoolean = HdlOtaLogic.getInstance().disposeDownLoadFile(drivePathFileName, responseBody, md5, HdlOtaLogic.driver_type);
+                if (isBoolean) {
+                    HdlFileLogic.getInstance().deleteFile(localUrl);//涓嬭浇鎴愬姛,鍒犻櫎鏃ф枃浠�;
+                } else {
+                    HdlFileLogic.getInstance().deleteFile(drivePathFileName);//涓嬭浇澶辫触鍒犻櫎涓嶅畬鎴愭暟鎹�;
+                }
                 HdlLogLogic.print("鍐欏叆鏂伴┍鍔ㄦ枃浠跺埌鍐呭瓨鎴愬姛.", false);
             }
 
@@ -630,17 +638,17 @@
                 }
             });
         } else {
-            //杩滅▼鍗囩骇闇�瑕佹娴嬪湪閫嗗彉鍣ㄦ湁娌℃湁杩炴帴涓婁簯
+            //杩滅▼鍗囩骇闇�瑕併�愭娴嬨�戝湪閫嗗彉鍣ㄦ湁娌℃湁杩炴帴涓婁簯
             HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                 @Override
                 public void onSuccess(CloudInverterDeviceBean cloudInverterDeviceBean) {
-                    //1:寰呮満,2:杩炴帴涓�,3:鏁呴殰,4:杩愯,5:绂荤嚎,6:閫嗗彉鍣ㄨ繛涓嶄笂浜�(鑷畾涔�)
+                    //1锛氳繛鎺ヤ腑,2锛氭晠闅�,3锛氳繍琛�,4锛氱绾�,6:閫嗗彉鍣ㄨ繛涓嶄笂浜�(鑷畾涔�)
                     if (cloudInverterDeviceBean == null) {
-                        uniCallbackData(null, 6, HDLApp.getInstance().getString(R.string.ota_not_cloud_upgrade_fails), callback);
+                        uniCallbackData(null, 6, HDLApp.getInstance().getString(R.string.ota_binding_cloud_upgrade_fails), callback);
                         return;
                     }
-                    if (cloudInverterDeviceBean.getDeviceStatus() != 4) {
-                        uniCallbackData(null, cloudInverterDeviceBean.getDeviceStatus(), getDeviceStatusString(cloudInverterDeviceBean.getDeviceStatus()), callback);
+                    if (cloudInverterDeviceBean.getDeviceStatus() != 3) {
+                        uniCallbackData(null, cloudInverterDeviceBean.getDeviceStatus(), HDLApp.getInstance().getString(R.string.ota_not_cloud_upgrade_fails), callback);
                         return;
                     }
                     //4:杩愯
@@ -667,6 +675,13 @@
         }
     }
 
+    /**
+     * 鍙栨秷涓嬭浇鍗囩骇鏂囦欢
+     */
+    private void uniCancelDownloadingUpgradeFile(Object data, DCUniMPJSCallback callback) {
+        HdlOtaLogic.getInstance().setStopDriversDownload();
+    }
+
 
     /**
      * @param deviceStatus 閫嗗彉鍣ㄨ繛鎺ヤ簯绔姸鎬佸�硷紙 1:寰呮満,2:杩炴帴涓�,3:鏁呴殰,4:杩愯,5:绂荤嚎锛�

--
Gitblit v1.8.0