瀏覽代碼

1.custom下载 初版

huangxiaodong 1 年之前
父節點
當前提交
b71a11c45a
共有 17 個文件被更改,包括 972 次插入45 次删除
  1. 56 0
      创维盒子/双子星云手机.xcodeproj/project.pbxproj
  2. 6 3
      创维盒子/双子星云手机/AppDelegate/SceneDelegate.m
  3. 24 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/NSURLSession+customDownloadTask.h
  4. 41 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/NSURLSession+customDownloadTask.m
  5. 38 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadCacheManager.h
  6. 91 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadCacheManager.m
  7. 48 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadManager.h
  8. 484 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadManager.m
  9. 67 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadOperation.h
  10. 57 0
      创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadOperation.m
  11. 6 5
      创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/boxDownloadFileRecordCell.m
  12. 14 12
      创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/receiveDownloadRecordTableView.m
  13. 2 1
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxDownloadFileManager.h
  14. 31 18
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxDownloadFileManager.m
  15. 3 3
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+downloadNasFile.m
  16. 3 2
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h
  17. 1 1
      创维盒子/双子星云手机/CloudPlayer/View/PlayerView.m

+ 56 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -393,6 +393,22 @@
 		6B34DC6D2BF2070D002DD1EF /* titleLabelReusableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B34DC6A2BF2070D002DD1EF /* titleLabelReusableView.h */; };
 		6B34DC6E2BF2070D002DD1EF /* titleLabelReusableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B34DC6B2BF2070D002DD1EF /* titleLabelReusableView.m */; };
 		6B34DC6F2BF2070D002DD1EF /* titleLabelReusableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B34DC6A2BF2070D002DD1EF /* titleLabelReusableView.h */; };
+		6B3958572C32B323003FC6C3 /* customDownloadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3958552C32B323003FC6C3 /* customDownloadManager.h */; };
+		6B3958582C32B323003FC6C3 /* customDownloadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3958562C32B323003FC6C3 /* customDownloadManager.m */; };
+		6B3958592C32B323003FC6C3 /* customDownloadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3958552C32B323003FC6C3 /* customDownloadManager.h */; };
+		6B39585A2C32B323003FC6C3 /* customDownloadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3958562C32B323003FC6C3 /* customDownloadManager.m */; };
+		6B39585D2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B39585B2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h */; };
+		6B39585E2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B39585C2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m */; };
+		6B39585F2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B39585B2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h */; };
+		6B3958602C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B39585C2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m */; };
+		6B3958632C32C37A003FC6C3 /* customDownloadOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3958612C32C37A003FC6C3 /* customDownloadOperation.h */; };
+		6B3958642C32C37A003FC6C3 /* customDownloadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3958622C32C37A003FC6C3 /* customDownloadOperation.m */; };
+		6B3958652C32C37A003FC6C3 /* customDownloadOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3958612C32C37A003FC6C3 /* customDownloadOperation.h */; };
+		6B3958662C32C37A003FC6C3 /* customDownloadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3958622C32C37A003FC6C3 /* customDownloadOperation.m */; };
+		6B3958692C32C4B4003FC6C3 /* customDownloadCacheManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3958672C32C4B4003FC6C3 /* customDownloadCacheManager.h */; };
+		6B39586A2C32C4B4003FC6C3 /* customDownloadCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3958682C32C4B4003FC6C3 /* customDownloadCacheManager.m */; };
+		6B39586B2C32C4B4003FC6C3 /* customDownloadCacheManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3958672C32C4B4003FC6C3 /* customDownloadCacheManager.h */; };
+		6B39586C2C32C4B4003FC6C3 /* customDownloadCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3958682C32C4B4003FC6C3 /* customDownloadCacheManager.m */; };
 		6B3A4B152B6F69A500F74679 /* cloudPhoneCommonModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3A4B132B6F69A500F74679 /* cloudPhoneCommonModel.h */; };
 		6B3A4B162B6F69A500F74679 /* cloudPhoneCommonModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3A4B142B6F69A500F74679 /* cloudPhoneCommonModel.m */; };
 		6B3AD6842BF48DBA0096D6B7 /* shareRecordDetailsHWViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3AD6822BF48DBA0096D6B7 /* shareRecordDetailsHWViewController.h */; };
@@ -1523,6 +1539,14 @@
 		6B34DC652BF1FFB1002DD1EF /* imageCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = imageCollectionViewCell.m; sourceTree = "<group>"; };
 		6B34DC6A2BF2070D002DD1EF /* titleLabelReusableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = titleLabelReusableView.h; sourceTree = "<group>"; };
 		6B34DC6B2BF2070D002DD1EF /* titleLabelReusableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = titleLabelReusableView.m; sourceTree = "<group>"; };
+		6B3958552C32B323003FC6C3 /* customDownloadManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = customDownloadManager.h; sourceTree = "<group>"; };
+		6B3958562C32B323003FC6C3 /* customDownloadManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = customDownloadManager.m; sourceTree = "<group>"; };
+		6B39585B2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSURLSession+customDownloadTask.h"; sourceTree = "<group>"; };
+		6B39585C2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSURLSession+customDownloadTask.m"; sourceTree = "<group>"; };
+		6B3958612C32C37A003FC6C3 /* customDownloadOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = customDownloadOperation.h; sourceTree = "<group>"; };
+		6B3958622C32C37A003FC6C3 /* customDownloadOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = customDownloadOperation.m; sourceTree = "<group>"; };
+		6B3958672C32C4B4003FC6C3 /* customDownloadCacheManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = customDownloadCacheManager.h; sourceTree = "<group>"; };
+		6B3958682C32C4B4003FC6C3 /* customDownloadCacheManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = customDownloadCacheManager.m; sourceTree = "<group>"; };
 		6B3A4B132B6F69A500F74679 /* cloudPhoneCommonModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cloudPhoneCommonModel.h; sourceTree = "<group>"; };
 		6B3A4B142B6F69A500F74679 /* cloudPhoneCommonModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = cloudPhoneCommonModel.m; sourceTree = "<group>"; };
 		6B3AD6822BF48DBA0096D6B7 /* shareRecordDetailsHWViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = shareRecordDetailsHWViewController.h; sourceTree = "<group>"; };
@@ -2399,6 +2423,7 @@
 		6B05815D2AFCD0A900D37290 /* uploadFile */ = {
 			isa = PBXGroup;
 			children = (
+				6B3958542C32B30A003FC6C3 /* customDownloadManager */,
 				6B9B7A312C2D1776001879C3 /* mixDownloadManager */,
 				6B6ABED72BFF3A6600480BAC /* receiveView */,
 				6B5D401C2B4AA70C000965CF /* downLoadFile */,
@@ -2664,6 +2689,21 @@
 			path = view;
 			sourceTree = "<group>";
 		};
+		6B3958542C32B30A003FC6C3 /* customDownloadManager */ = {
+			isa = PBXGroup;
+			children = (
+				6B3958552C32B323003FC6C3 /* customDownloadManager.h */,
+				6B3958562C32B323003FC6C3 /* customDownloadManager.m */,
+				6B3958612C32C37A003FC6C3 /* customDownloadOperation.h */,
+				6B3958622C32C37A003FC6C3 /* customDownloadOperation.m */,
+				6B3958672C32C4B4003FC6C3 /* customDownloadCacheManager.h */,
+				6B3958682C32C4B4003FC6C3 /* customDownloadCacheManager.m */,
+				6B39585B2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h */,
+				6B39585C2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m */,
+			);
+			path = customDownloadManager;
+			sourceTree = "<group>";
+		};
 		6B3F96312AD2A0FA008E349E /* netWork */ = {
 			isa = PBXGroup;
 			children = (
@@ -3350,10 +3390,12 @@
 				6B2C1E642C070ADE00FDCF82 /* ZFLandscapeRotationManager_iOS15.h in Headers */,
 				6BFF26912AF9D88200FCB4F7 /* AuthCodeTextField.h in Headers */,
 				6B5D403B2B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.h in Headers */,
+				6B3958572C32B323003FC6C3 /* customDownloadManager.h in Headers */,
 				184C8ADA2A949DAC00F26650 /* HaveNewVersionView.h in Headers */,
 				6BBB35DD2AE76AD800E4A59B /* AudioSessionObject.h in Headers */,
 				6B2C1EA02C070ADE00FDCF82 /* ZFPortraitViewController.h in Headers */,
 				6B0582782AFF7C6D00D37290 /* TZAssetModel+imageData.h in Headers */,
+				6B39585D2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h in Headers */,
 				6B8661DD2BBA578600B19846 /* HaveNoticeView.h in Headers */,
 				6B5D403F2B4CE40F000965CF /* downloadManager.h in Headers */,
 				6B5D40372B4BEEF8000965CF /* downloadThumbnailManager.h in Headers */,
@@ -3368,6 +3410,7 @@
 				6B5BE5932BFCA5FA00A1B9B3 /* videoPlayViewController.h in Headers */,
 				1868201D2AB97BE1005702A6 /* TipsQRCodeViewController.h in Headers */,
 				6B5B60602B3BC8DE009A2AE2 /* fileTransferPopView.h in Headers */,
+				6B3958632C32C37A003FC6C3 /* customDownloadOperation.h in Headers */,
 				181E85002A8F6B1800292B96 /* LogoSelectView.h in Headers */,
 				6B5B60762B3E665E009A2AE2 /* filePathCreatPopView.h in Headers */,
 				18BA24872AA5C57900BA01EE /* RSATool.h in Headers */,
@@ -3422,6 +3465,7 @@
 				18FCE53F2AD136670020F623 /* PlayerViewController+TouchPointXD.h in Headers */,
 				18FCE53E2AD136670020F623 /* PlayerViewController+AdjustBtnFrame.h in Headers */,
 				6B5BE5812BFC81E300A1B9B3 /* NASFileAndFolderModel.h in Headers */,
+				6B3958692C32C4B4003FC6C3 /* customDownloadCacheManager.h in Headers */,
 				6B7EA7BC2BF759AC002D5CC2 /* shareSecretTableViewCell.h in Headers */,
 				6B2C1E362C070ADE00FDCF82 /* ZFPlayerControlView.h in Headers */,
 				6BA08F472C01D05B00A2242D /* CWFileManager.h in Headers */,
@@ -3577,10 +3621,12 @@
 				6B2C1E652C070ADE00FDCF82 /* ZFLandscapeRotationManager_iOS15.h in Headers */,
 				6BD506A12B9576A4006E7CB0 /* AuthCodeTextField.h in Headers */,
 				6BD506A22B9576A4006E7CB0 /* PlayerViewController+downloadThumbnailImage.h in Headers */,
+				6B3958592C32B323003FC6C3 /* customDownloadManager.h in Headers */,
 				6BD506A32B9576A4006E7CB0 /* HaveNewVersionView.h in Headers */,
 				6BD506A42B9576A4006E7CB0 /* AudioSessionObject.h in Headers */,
 				6B2C1EA12C070ADE00FDCF82 /* ZFPortraitViewController.h in Headers */,
 				6BD506A52B9576A4006E7CB0 /* TZAssetModel+imageData.h in Headers */,
+				6B39585F2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.h in Headers */,
 				6B8661DE2BBA578600B19846 /* HaveNoticeView.h in Headers */,
 				6BD506A62B9576A4006E7CB0 /* downloadManager.h in Headers */,
 				6BD506A72B9576A4006E7CB0 /* downloadThumbnailManager.h in Headers */,
@@ -3595,6 +3641,7 @@
 				6B5BE5952BFCA5FA00A1B9B3 /* videoPlayViewController.h in Headers */,
 				6BD506AA2B9576A4006E7CB0 /* TipsQRCodeViewController.h in Headers */,
 				6BD506AB2B9576A4006E7CB0 /* fileTransferPopView.h in Headers */,
+				6B3958652C32C37A003FC6C3 /* customDownloadOperation.h in Headers */,
 				6BD506AC2B9576A4006E7CB0 /* LogoSelectView.h in Headers */,
 				6BD506AD2B9576A4006E7CB0 /* filePathCreatPopView.h in Headers */,
 				6BD506AE2B9576A4006E7CB0 /* RSATool.h in Headers */,
@@ -3649,6 +3696,7 @@
 				6BD506CA2B9576A4006E7CB0 /* PlayerViewController+TouchPointXD.h in Headers */,
 				6BD506CB2B9576A4006E7CB0 /* PlayerViewController+AdjustBtnFrame.h in Headers */,
 				6B5BE5832BFC81E300A1B9B3 /* NASFileAndFolderModel.h in Headers */,
+				6B39586B2C32C4B4003FC6C3 /* customDownloadCacheManager.h in Headers */,
 				6B7EA7BE2BF759AC002D5CC2 /* shareSecretTableViewCell.h in Headers */,
 				6B2C1E372C070ADE00FDCF82 /* ZFPlayerControlView.h in Headers */,
 				6BA08F482C01D05B00A2242D /* CWFileManager.h in Headers */,
@@ -4258,10 +4306,13 @@
 				6B2C1E452C070ADE00FDCF82 /* ZFSliderView.m in Sources */,
 				6B6317A52BFD9DB500FF4FB4 /* ZFCustomControlView.m in Sources */,
 				6BD5074A2B9576A4006E7CB0 /* UIView+View.m in Sources */,
+				6B3958602C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m in Sources */,
 				6B9354912BF30A8C00AA8D31 /* editTypeBottomView.m in Sources */,
 				6BD5074B2B9576A4006E7CB0 /* couldPhoneFileListModel.m in Sources */,
 				6BD5074C2B9576A4006E7CB0 /* AFNetworkActivityIndicatorManager.m in Sources */,
+				6B39586C2C32C4B4003FC6C3 /* customDownloadCacheManager.m in Sources */,
 				6BD5074D2B9576A4006E7CB0 /* downloadThumbnailManager.m in Sources */,
+				6B39585A2C32B323003FC6C3 /* customDownloadManager.m in Sources */,
 				6BD5074E2B9576A4006E7CB0 /* couldPhoneBaseInfoModel.m in Sources */,
 				6BD5074F2B9576A4006E7CB0 /* uploadFileBottomView.m in Sources */,
 				6BD507502B9576A4006E7CB0 /* LogoSelectView.m in Sources */,
@@ -4369,6 +4420,7 @@
 				6BD507972B9576A4006E7CB0 /* QRCodeScanViewController.m in Sources */,
 				6B2C1E392C070ADE00FDCF82 /* ZFPlayerControlView.m in Sources */,
 				6BD507982B9576A4006E7CB0 /* allVersionView.m in Sources */,
+				6B3958662C32C37A003FC6C3 /* customDownloadOperation.m in Sources */,
 				6BD507992B9576A4006E7CB0 /* couldPhoneCommonModel.m in Sources */,
 				6BD5079A2B9576A4006E7CB0 /* PlayerLoadingView.m in Sources */,
 				6BD5079B2B9576A4006E7CB0 /* FMDatabaseAdditions.m in Sources */,
@@ -4567,10 +4619,13 @@
 				6B2C1E442C070ADE00FDCF82 /* ZFSliderView.m in Sources */,
 				6B6317A42BFD9DB500FF4FB4 /* ZFCustomControlView.m in Sources */,
 				183AE6D52A8CAFAE00B11CB0 /* UIView+View.m in Sources */,
+				6B39585E2C32C0BB003FC6C3 /* NSURLSession+customDownloadTask.m in Sources */,
 				6B93548E2BF30A8C00AA8D31 /* editTypeBottomView.m in Sources */,
 				6B5D40282B4BC402000965CF /* couldPhoneFileListModel.m in Sources */,
 				183AE64E2A8A2CF000B11CB0 /* AFNetworkActivityIndicatorManager.m in Sources */,
+				6B39586A2C32C4B4003FC6C3 /* customDownloadCacheManager.m in Sources */,
 				6B5D40382B4BEEF8000965CF /* downloadThumbnailManager.m in Sources */,
+				6B3958582C32B323003FC6C3 /* customDownloadManager.m in Sources */,
 				6B7272582B0DAF7600C03F87 /* couldPhoneBaseInfoModel.m in Sources */,
 				6B0581B32AFE02B100D37290 /* uploadFileBottomView.m in Sources */,
 				181E85012A8F6B1800292B96 /* LogoSelectView.m in Sources */,
@@ -4678,6 +4733,7 @@
 				186820222AB98600005702A6 /* QRCodeScanViewController.m in Sources */,
 				6B2C1E382C070ADE00FDCF82 /* ZFPlayerControlView.m in Sources */,
 				6B2170892B1444CC00656670 /* allVersionView.m in Sources */,
+				6B3958642C32C37A003FC6C3 /* customDownloadOperation.m in Sources */,
 				6B5D40162B47F27A000965CF /* couldPhoneCommonModel.m in Sources */,
 				187076782A9F400300F15F7F /* PlayerLoadingView.m in Sources */,
 				A08A950127E9A4E400C544BB /* FMDatabaseAdditions.m in Sources */,

+ 6 - 3
创维盒子/双子星云手机/AppDelegate/SceneDelegate.m

@@ -36,7 +36,8 @@
 #import "queryOneShareModel.h"
 #import "boxSaveFileManager.h"
 #import "boxDownloadFileManager.h"
-#import "mixDownloadManager.h"
+//#import "mixDownloadManager.h"
+#import "customDownloadManager.h"
 
 @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate>
 @property(nonatomic, strong)   CalculatorViewController *calculatorVC;
@@ -791,7 +792,8 @@
     [[backupsFileManager shareInstance] suspendBackupsFileFun];
     
     //frp的下载
-    [[mixDownloadManager shareManager] suspendAllDownloadTask];
+    //[[mixDownloadManager shareManager] suspendAllDownloadTask];
+    [[customDownloadManager shareManager] suspendAllDownloadTask];
     
     NSString *uid =[connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
     if(uid){
@@ -801,7 +803,8 @@
         uid = @"";
     }
     
-    [mixDownloadManager shareManager].uid = uid;
+    //[mixDownloadManager shareManager].uid = uid;
+    [customDownloadManager shareManager].uid = uid;
 }
 
 #pragma mark 上报版本号信息

+ 24 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/NSURLSession+customDownloadTask.h

@@ -0,0 +1,24 @@
+//
+//  NSURLSession+customDownloadTask.h
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NSURLSession (customDownloadTask)
+/**
+ 构造一个从特定位置开始下载的任务
+
+ @param urlString 资源路径的URLstring
+ @param startSize 开始的位置
+ @return 下载任务
+ */
+- (NSURLSessionDataTask *)custom_downloadDataTaskWithURLString:(NSString *)urlString
+                                                  startSize:(int64_t)startSize;
+@end
+
+NS_ASSUME_NONNULL_END

+ 41 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/NSURLSession+customDownloadTask.m

@@ -0,0 +1,41 @@
+//
+//  NSURLSession+customDownloadTask.m
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import "NSURLSession+customDownloadTask.h"
+
+@implementation NSURLSession (customDownloadTask)
+- (NSURLSessionDataTask *)custom_downloadDataTaskWithURLString:(NSString *)urlString
+                                                  startSize:(int64_t)startSize {
+    // 校验URL
+    if (urlString.length == 0) {
+        return nil;
+    }
+    NSURL *url = [NSURL URLWithString:urlString];
+    if (url == nil) {
+        return nil;
+    }
+    
+    // 创建请求 设置请求下载的位置
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+    //NSString *tokenStr = [[UseAccountManage shareInstance] cloudAutoh];
+    //[request setValue:tokenStr forHTTPHeaderField:@"Authorization"];
+    request.HTTPMethod = @"GET";
+    
+    /*
+     bytes=0-100    请求0-100
+     bytes=200-1000
+     bytes=200-     从200开始直到结尾
+     bytes=-100
+     */
+    NSString *rangeStr = [NSString stringWithFormat:@"bytes=%lld-",startSize];
+    
+    [request setValue:rangeStr forHTTPHeaderField:@"Range"];
+    
+    // 创建task
+    return [self dataTaskWithRequest:request];
+}
+@end

+ 38 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadCacheManager.h

@@ -0,0 +1,38 @@
+//
+//  customDownloadCacheManager.h
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+#define KCustomFullPath NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]
+#define KCustomFullDirector  [self getFullDirector]
+#define KCustomDownloadDirector  @"customDownload"
+
+@interface customDownloadCacheManager : NSObject
+
+/**  查询当前文件下载了多少 */
++ (int64_t)getFileSizeWithURL:(NSString *)url;
+
+/**  删除某个文件 */
++ (BOOL)deleteFileWithUrl:(NSString *)url;
+
+/**  清理所有下载文件及下载信息 */
++ (BOOL)clearDisks;
+
+/**  取消所有当前下载的文件 清理内存缓存的数据 */
++ (BOOL)clearMemory;
+
+/**  取消所有当前下载的文件 删除磁盘所有的下载 清理内存缓存的数据 */
++ (BOOL)clearMemoryAndDisk;
+
++ (NSString *)getFullDirector;
+
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 91 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadCacheManager.m

@@ -0,0 +1,91 @@
+//
+//  customDownloadCacheManager.m
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import "customDownloadCacheManager.h"
+#import "customDownloadManager.h"
+
+static NSMutableDictionary *_downloadList;
+
+@implementation customDownloadCacheManager
+
+#pragma mark-plist
+
++ (NSString *)getFullDirector {
+
+    NSString *account = [customDownloadManager shareManager].uid;
+    if (account.length != 0)
+    {
+         NSString *fileFolder = [HWDataManager documentPathForAccount:account fileFolder:KCustomDownloadDirector];
+         return fileFolder;
+     }else {
+         HLog(@"创建下载plist文件失败!");
+         return @"";
+     }
+}
+
+/**  查询当前文件下载了多少 */
++ (int64_t)getFileSizeWithURL:(NSString *)url
+{
+    NSString* fileFullDir = [customDownloadCacheManager getFullDirector];
+    
+    // 拼接后缀名
+    NSString *urlFileName = [url lastPathComponent];
+    NSString * decodeUrlFileName= [urlFileName stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+    
+    // 设置下载路径
+    NSString*fullPath = [fileFullDir stringByAppendingPathComponent:decodeUrlFileName];
+    
+    // 获取下载进度
+    NSDictionary *fileInfo = [[NSFileManager defaultManager] attributesOfItemAtPath:fullPath error:nil];
+    // 获取已下载的长度
+    return  [fileInfo[NSFileSize] longLongValue];
+}
+
+
+/**  删除配置信息 */
++ (BOOL)deleteFileWithUrl:(NSString *)url {
+    
+    BOOL flag = NO;
+    
+    @synchronized (self) {
+        // 删除缓存的文件
+        NSString *fileFolder = [customDownloadCacheManager getFullDirector];
+        NSString *urlFileName = [url lastPathComponent];
+        NSString * decodeUrlFileName= [urlFileName stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        NSString *fileName = decodeUrlFileName;
+        NSString *fileURL = [fileFolder stringByAppendingPathComponent:fileName];
+
+        flag= [[NSFileManager defaultManager] removeItemAtPath:fileURL error:nil];
+    }
+
+    return (flag);
+}
+
+#pragma mark -
+
++ (BOOL)clearDisks {
+    // 1.删除所有的文件下载信息关联表
+    // 2.删除cache 下的download文件夹
+   return  [[NSFileManager defaultManager] removeItemAtPath:KCustomFullDirector error:nil];
+      
+}
+
+/**  取消所有当前下载的文件 清理内存缓存的数据 */
++ (BOOL)clearMemory {
+    // 删除信息关联
+    _downloadList = nil;
+    
+    return YES;
+}
+
+/**  取消所有当前下载的文件 删除磁盘所有的下载 清理内存缓存的数据 */
++ (BOOL)clearMemoryAndDisk {
+    return ([self clearMemory] && [self clearDisks]);
+}
+
+@end
+

+ 48 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadManager.h

@@ -0,0 +1,48 @@
+//
+//  customDownloadManager.h
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import <Foundation/Foundation.h>
+#import "customDownloadOperation.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** 下载中通知 */
+#define  customDownloadTaskExeing        @"customDownloadTaskExeing"
+/** 下载失败通知 */
+#define  customDownloadTaskExeError      @"customDownloadTaskExeError"
+/** 下载完成通知 */
+#define  customDownloadTaskExeEnd        @"customDownloadTaskExeEnd"
+
+@interface customDownloadManager : NSObject
+
+@property(nonatomic,strong) NSString *uid;//用户id 用来创建文件夹路径 防止不要用户的缓存关联
+@property(nonatomic,assign) NSInteger maxDownLoadCount;//默认一个
+
+/** 实例化对象(单例) */
++ (instancetype)shareManager;
+
+#pragma mark - 队列中的任务进行操作
+
+/** 添加要下载的 网络连接  */
+- (void)addDownloadWithURLs:(NSArray *)urls;
+//在添加下载地址后 启动下载
+//- (void)beginDownload;
+
+/** 开始任务(不会自动添加任务,列队中没有就直接返回) 后续改为会自动添加任务 */
+- (void)startDownLoadWithUrl:(NSString *)url;
+
+/** 暂停任务(暂停下载url内容的任务) */
+- (void)supendDownloadWithUrl:(NSString *)url;
+
+/** 暂停当前所有的下载任务 下载任务不会从列队中删除 */
+- (void)suspendAllDownloadTask;
+
+/** 删除任务(删除下载url内容的任务) */
+- (void)deleteDownloadWithUrl:(NSString *)url;
+@end
+
+NS_ASSUME_NONNULL_END

+ 484 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadManager.m

@@ -0,0 +1,484 @@
+//
+//  customDownloadManager.m
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import "customDownloadManager.h"
+#import "customDownloadOperation.h"
+#import "customDownloadCacheManager.h"
+
+@interface customDownloadManager ()<NSURLSessionDataDelegate>
+//排队等候下载的下载地址数组
+@property(nonatomic,strong) NSMutableArray *downloadWaitingUrlArr;
+//正在下载的下载地址数组
+@property(nonatomic,strong) NSMutableArray *downloadingOperationArr;
+@end
+
+@implementation customDownloadManager
++ (instancetype)shareManager {
+    static customDownloadManager *_instance;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        _instance = [[self alloc] init];
+    });
+    return _instance;
+}
+
+- (instancetype)init {
+
+    if (self = [super init]) {
+        _maxDownLoadCount = 1;
+        //[self registeNotification];
+    }
+    return self;
+}
+
+- (NSString*)uid{
+    if(!_uid || _uid.length == 0){
+        return @"customUserName";
+    }
+    
+    return _uid;
+}
+
+/** 添加要下载的 网络连接  */
+- (void)addDownloadWithURLs:(NSArray *)urls{
+    
+    for (NSString *addUrl in urls) {
+        BOOL needAddType = YES;
+        
+        //1. 排查下载中
+        for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+            if([operationDoing.url isEqualToString:addUrl]){
+                needAddType = NO;
+                break;
+            }
+        }
+        
+        //1. 排查等待下载
+        for (NSString *waitUrl in self.downloadWaitingUrlArr) {
+            if([waitUrl isEqualToString:addUrl]){
+                needAddType = NO;
+                break;
+            }
+        }
+        
+        if(needAddType){
+            [self.downloadWaitingUrlArr addObject:addUrl];
+        }
+    }
+    
+    //启动下载
+    [self beginDownload];
+}
+
+//在添加下载地址后 启动下载
+- (void)beginDownload
+{
+    @synchronized (self) {
+        if(self.downloadingOperationArr.count == _maxDownLoadCount){
+            HLog(@"正在下载的数量达到了最大值 %ld",_maxDownLoadCount)
+            return;
+        }
+        
+        if(self.downloadWaitingUrlArr.count == 0){
+            HLog(@"没有等待中的下载任务")
+            return;
+        }
+        
+        //多个要还要改
+        
+        //创建下载任务
+        NSString *downloadUrl = self.downloadWaitingUrlArr.firstObject;
+        
+        NSURLSession *session = [self creatNewSessionFun];
+        customDownloadOperation * operation = [[customDownloadOperation alloc] initWith:downloadUrl session:session];
+        [operation.dataTask resume];
+        
+        //等待下载中的任务
+        [self.downloadWaitingUrlArr removeObjectAtIndex:0];
+        //添加到下载中数组
+        [self.downloadingOperationArr addObject:operation];
+    }
+    
+}
+
+/** 开始任务(不会自动添加任务,列队中没有就直接返回) 后续改为会自动添加任务 */
+- (void)startDownLoadWithUrl:(NSString *)url
+{
+    
+    BOOL needAddType = YES;
+    
+    //1. 排查下载中
+    for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+        if([operationDoing.url isEqualToString:url]){
+            needAddType = NO;
+            break;
+        }
+    }
+    
+    //1. 排查等待下载
+    for (NSString *waitUrl in self.downloadWaitingUrlArr) {
+        if([waitUrl isEqualToString:url]){
+            needAddType = NO;
+            break;
+        }
+    }
+    
+    if(needAddType){
+        [self.downloadWaitingUrlArr addObject:url];
+    }
+    
+    //启动下载
+    [self beginDownload];
+}
+
+/** 删除任务(删除下载url内容的任务) */
+- (void)deleteDownloadWithUrl:(NSString *)url
+{
+    //1.检测等待下载的任务
+    for (NSString*waitingUrl in self.downloadWaitingUrlArr) {
+        if ([waitingUrl isEqualToString:url]) {
+            [self.downloadWaitingUrlArr removeObject:waitingUrl];
+            break;
+        }
+    }
+    
+    //2.检测下载中的任务
+    for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+        if([operationDoing.url isEqualToString:url]){
+            [operationDoing.dataTask cancel];
+//            operationDoing.dataTask = nil;
+//            operationDoing.session = nil;
+//        
+//            [operationDoing.handle closeFile];
+//            operationDoing.handle = nil;
+//            
+//            [self.downloadingOperationArr removeObject:operationDoing];
+            break;
+        }
+    }
+    
+    //3. 删除本地文件
+    [customDownloadCacheManager deleteFileWithUrl:url];
+    
+    //4.进行下一个任务
+    //[self beginDownload];
+}
+
+/** 暂停任务(暂停下载url内容的任务) */
+- (void)supendDownloadWithUrl:(NSString *)url
+{
+    //1.检测等待下载的任务
+    for (NSString*waitingUrl in self.downloadWaitingUrlArr) {
+        if ([waitingUrl isEqualToString:url]) {
+            [self.downloadWaitingUrlArr removeObject:waitingUrl];
+            break;
+        }
+    }
+    
+    //2.检测下载中的任务
+    for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+        if([operationDoing.url isEqualToString:url]){
+            operationDoing.isManualCancel = YES;
+            
+            if(operationDoing.dataTask){
+                [operationDoing.dataTask cancel];
+            }
+//            operationDoing.dataTask = nil;
+//            operationDoing.session = nil;
+//        
+//            [operationDoing.handle closeFile];
+//            operationDoing.handle = nil;
+//            
+//            //删除后 didCompleteWithError 不再处理
+//            [self.downloadingOperationArr removeObject:operationDoing];
+           
+            break;
+        }
+    }
+    
+    //进行下一个任务
+    //[self beginDownload];
+}
+
+/** 暂停当前所有的下载任务 下载任务不会从列队中删除 */
+- (void)suspendAllDownloadTask
+{
+    //1.删除等待下载的任务
+    [self.downloadWaitingUrlArr removeAllObjects];
+    
+    //2.检测下载中的任务
+    for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+        operationDoing.isManualCancel = YES;
+        if(operationDoing.dataTask){
+            [operationDoing.dataTask cancel];
+        }
+        
+        operationDoing.dataTask = nil;
+        operationDoing.session = nil;
+        [operationDoing.handle closeFile];
+        operationDoing.handle = nil;
+        
+        [self.downloadingOperationArr removeObject:operationDoing];
+        
+    }
+
+}
+
+
+#pragma mark - <NSURLSessionDataDelegate>
+
+// ssl 服务 证书信任
+- (void)URLSession:(NSURLSession *)session
+didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
+ completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler{
+    if(![challenge.protectionSpace.authenticationMethod isEqualToString:@"NSURLAuthenticationMethodServerTrust"]) {
+        return;
+    }
+    
+    // 信任该插件
+    NSURLCredential *credential = [[NSURLCredential alloc] initWithTrust:challenge.protectionSpace.serverTrust];
+    // 第一个参数 告诉系统如何处置
+    completionHandler(NSURLSessionAuthChallengeUseCredential,credential);
+}
+
+//当请求协议是https的时候回调用该方法
+//Challenge 挑战 质询(受保护空间)
+//NSURLAuthenticationMethodServerTrust 服务器信任证书
+- (void)URLSession:(NSURLSession *)session
+              task:(NSURLSessionTask *)task
+didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
+ completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * __nullable credential))completionHandler {
+    
+    if(![challenge.protectionSpace.authenticationMethod isEqualToString:@"NSURLAuthenticationMethodServerTrust"]) {
+        return;
+    }
+    
+    // 信任该插件
+    NSURLCredential *credential = [[NSURLCredential alloc] initWithTrust:challenge.protectionSpace.serverTrust];
+    // 第一个参数 告诉系统如何处置
+    completionHandler(NSURLSessionAuthChallengeUseCredential,credential);
+    
+}
+
+
+// 接受到响应调用
+- (void)URLSession:(NSURLSession *)session
+          dataTask:(NSURLSessionDataTask *)dataTask
+didReceiveResponse:(NSURLResponse *)response
+ completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler {
+    
+    // 将响应交给列队处理
+    [self handleOperateby:dataTask WithResponse:response];
+    
+    // 允许下载
+    completionHandler(NSURLSessionResponseAllow);
+}
+
+// 接受到数据碎片 的时候调用,调用多次
+- (void)URLSession:(NSURLSession *)session
+          dataTask:(NSURLSessionDataTask *)dataTask
+    didReceiveData:(NSData *)data {
+    // 接收到session 下载碎片交个列队管理
+    [self dataTask:dataTask didReceiveData:data];
+}
+
+// <NSURLSessionDataDelegate> 完成下载
+- (void)URLSession:(NSURLSession *)session
+              task:(NSURLSessionTask *)task
+didCompleteWithError:(nullable NSError *)error {
+    [self task:task didCompleteWithError:error];
+}
+
+- (void)URLSession:(NSURLSession *)session
+              task:(NSURLSessionTask *)task
+ needNewBodyStream:(void (^)(NSInputStream * _Nullable bodyStream))completionHandler {
+    
+}
+
+- (void)URLSession:(NSURLSession *)session
+              task:(NSURLSessionTask *)task
+   didSendBodyData:(int64_t)bytesSent
+    totalBytesSent:(int64_t)totalBytesSent
+totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
+    
+}
+
+#pragma mark 处理接收到的数据
+
+// 接收到相应时
+- (void)handleOperateby:(NSURLSessionTask*)dataTask WithResponse:(NSURLResponse *)response {
+    
+    customDownloadOperation *operation = nil;
+    for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+        if(operationDoing.dataTask == dataTask){
+            operation = operationDoing;
+            break;
+        }
+    }
+    
+    if (!operation) {
+        HLog(@"没找到当前下载任务");
+        [dataTask cancel];
+        return;
+    }
+    
+    // 总的size
+    if (operation.currentSize + response.expectedContentLength == 0) {
+        HLog(@"下载数据回调异常");
+        return;
+    }
+    operation.totalSize = operation.currentSize + response.expectedContentLength;
+    
+    // 创建空的文件夹
+    if (operation.currentSize == 0) {
+        // 创建空的文件
+        [[NSFileManager defaultManager]  createFileAtPath:operation.fullPath contents:nil attributes:nil];
+    }
+    
+    // 创建文件句柄
+    operation.handle = [NSFileHandle fileHandleForWritingAtPath:operation.fullPath];
+    
+    // 文件句柄移动到文件末尾 位置 // 返回值是 unsign long long
+    [operation.handle seekToEndOfFile];
+    
+    // 开始下载记录文件下载信息
+    operation.downloadState = customDownloadStateDoing;
+    
+    // 回调给外界
+    
+}
+
+- (void)dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data
+{
+    customDownloadOperation *operation = nil;
+    for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+        if(operationDoing.dataTask == dataTask){
+            operation = operationDoing;
+            break;
+        }
+    }
+    
+    if (!operation) {
+        HLog(@"没找到当前下载任务");
+        [dataTask cancel];
+        return;
+    }
+    
+    // 获得已经下载的文件大小
+    operation.currentSize += data.length;
+    HLog(@"%@\n currentSize:%lld---progress:%.2f",operation.url, operation.currentSize, 1.00*operation.currentSize/operation.totalSize);
+
+    // 写入文件
+    if(operation.handle){
+        [operation.handle writeData:data];
+    }
+
+    // 下载中通知
+    [self operationDoningWithOperation:operation];
+}
+
+- (void)task:(NSURLSessionTask *)dataTask didCompleteWithError:(NSError *)error
+{
+    customDownloadOperation *operation = nil;
+    for (customDownloadOperation *operationDoing in self.downloadingOperationArr) {
+        if(operationDoing.dataTask == dataTask){
+            operation = operationDoing;
+            [self.downloadingOperationArr removeObject:operationDoing];
+            break;
+        }
+    }
+    
+    if (!operation) {
+        HLog(@"没找到当前下载任务");
+        //[dataTask suspend];
+        return;
+    }
+    
+    if(operation.dataTask){
+        //[operation.dataTask cancel];
+        operation.dataTask = nil;
+        operation.session = nil;
+        
+        // 关闭文件句柄
+        [operation.handle closeFile];
+        // 释放文件句柄
+        operation.handle = nil;
+    }
+    
+    if(operation.isManualCancel){
+        [self beginDownload];
+        return;
+    }
+    
+    // 完成下载 通知 block
+    if (error) {
+        [self operationFailedWithOperation:operation];
+    } else {
+        operation.isFinished = YES;
+        operation.timeStamp = [iTools getNowTimeStamp];
+        [self operationSuccessWithOperation:operation];
+    }
+    
+    [self beginDownload];
+}
+
+
+#pragma mark 发送通知
+
+// 失败某一个operation 保存本地 通知外界
+- (void)operationFailedWithOperation:(customDownloadOperation *)operation {
+    HLog(@"DownloadTaskExeError \n %@",operation.url);
+    operation.downloadState = customDownloadStateFailed;
+    [[NSNotificationCenter defaultCenter] postNotificationName:customDownloadTaskExeError object:nil userInfo:@{@"operation" : operation}];
+}
+
+// 重启某一个operation 保存本地 通知外界
+- (void)operationDoningWithOperation:(customDownloadOperation *)operation {
+    HLog(@"DownloadTaskExeing");
+
+    [[NSNotificationCenter defaultCenter] postNotificationName:customDownloadTaskExeing object:nil userInfo:@{@"operation" : operation}];
+}
+
+// 等待某一个operation 保存本地 通知外界
+- (void)operationSuccessWithOperation:(customDownloadOperation *)operation {
+    HLog(@"DownloadTaskExeEnd \n %@",operation.url);
+    operation.downloadState = customDownloadStateCompleted;
+    [[NSNotificationCenter defaultCenter] postNotificationName:customDownloadTaskExeEnd object:nil userInfo:@{@"operation" : operation}];
+}
+
+-(NSURLSession*)creatNewSessionFun
+{
+    NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
+    // 设置请求超时
+    config.timeoutIntervalForRequest = -1;
+//        config.networkServiceType = NSURLNetworkServiceTypeVideo;
+    config.timeoutIntervalForResource = -1;
+//        config.TLSMaximumSupportedProtocol = kSSLProtocolAll;
+    
+    //_session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:[NSOperationQueue currentQueue]];
+    NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
+    
+    return session;
+}
+
+#pragma mark - lazy load
+- (NSMutableArray *)downloadWaitingUrlArr {
+    
+    if (!_downloadWaitingUrlArr) {
+        _downloadWaitingUrlArr = [NSMutableArray array];
+    }
+    return _downloadWaitingUrlArr;
+}
+
+- (NSMutableArray *)downloadingOperationArr {
+    
+    if (!_downloadingOperationArr) {
+        _downloadingOperationArr = [NSMutableArray array];
+    }
+    return _downloadingOperationArr;
+}
+@end

+ 67 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadOperation.h

@@ -0,0 +1,67 @@
+//
+//  customDownloadOperation.h
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import <Foundation/Foundation.h>
+
+/** 下载状态*/
+typedef  enum : NSUInteger {
+    //customDownloadStateWaiting = 0,   /** 下载等待中 */
+    customDownloadStateDoing =0,         /** 下载中 */
+    customDownloadStateSuspended,     /** 下载暂停 */
+    customDownloadStateCompleted,     /** 下载完成 */
+    customDownloadStateFailed,        /** 下载失败 */
+} customDownloadStateType;
+
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface customDownloadOperation : NSObject
+/** 绑定的标示及task的创建 */
+@property (readonly,nonatomic, copy)NSString *url;
+
+/** 下载任务 */
+@property (nonatomic,strong,nullable)NSURLSession *session;
+
+/** 下载任务 */
+@property (nonatomic,strong,nullable)NSURLSessionDataTask *dataTask;
+
+@property(nonatomic,assign) BOOL isManualCancel;//手动取消
+
+/** 文件句柄 可以记录文件的下载的位置 */
+@property (nonatomic,strong,nullable) NSFileHandle *handle;
+
+/** 下载的文件总大小 */
+@property (nonatomic,assign) int64_t totalSize;
+
+/** 当前下载了多少 */
+@property (nonatomic,assign) int64_t currentSize;
+
+/** 当前下载文件名称 */
+@property (nonatomic,copy) NSString *fileName;
+
+/** 当前下载文件沙盒全路径 */
+@property (nonatomic,copy) NSString *fullPath;
+
+/** 文件下载状态 */
+@property (nonatomic,assign) customDownloadStateType downloadState;
+
+/** 下载完成-时间戳 */
+@property (nonatomic,assign)  NSInteger timeStamp;
+
+/** 文件类型 */
+@property (nonatomic,assign)  NSInteger fileType;
+
+/** 是否完成 */
+@property (nonatomic, assign)  NSInteger isFinished;
+
+// 创建下载操作任务
+- (instancetype)initWith:(NSString *)url session:(NSURLSession *)session;
+
+- (NSDictionary *)downLoadInfoWithFinished:(BOOL)finished;
+@end
+
+NS_ASSUME_NONNULL_END

+ 57 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadOperation.m

@@ -0,0 +1,57 @@
+//
+//  customDownloadOperation.m
+//  双子星云手机
+//
+//  Created by xd h on 2024/7/1.
+//
+
+#import "customDownloadOperation.h"
+#import "customDownloadCacheManager.h"
+#import "NSURLSession+customDownloadTask.h"
+
+@implementation customDownloadOperation
+
+- (instancetype)initWith:(NSString *)url session:(NSURLSession *)session{
+    
+    if (self = [super init]) {
+        _url = url;
+        // 初始化下载信息
+        // 拼接后缀名
+        NSString *urlFileName = [url lastPathComponent];
+        NSString * decodeUrlFileName= [urlFileName stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        self.fileName = decodeUrlFileName;
+        
+        NSString* fileFullDir = [customDownloadCacheManager getFullDirector];
+        // 创建文件储存路径
+        if (![[NSFileManager defaultManager] fileExistsAtPath:fileFullDir]) {
+            [[NSFileManager defaultManager] createDirectoryAtPath:fileFullDir withIntermediateDirectories:YES attributes:nil error:nil];
+        }
+
+        // 设置下载路径
+        self.fullPath = [fileFullDir stringByAppendingPathComponent:self.fileName];
+        
+        _currentSize = [customDownloadCacheManager getFileSizeWithURL:url];
+        
+        // 偏好设置里面存储总数据
+        //_totalSize = 0;
+        
+        _timeStamp = [iTools getNowTimeStamp];
+        // 校验
+        if (self.currentSize == self.totalSize && self.totalSize != 0) {
+            return nil;
+        }
+    
+        
+        _downloadState = customDownloadStateDoing;
+        
+        _session = session;
+        _dataTask = [_session custom_downloadDataTaskWithURLString:url startSize:_currentSize];
+    }
+    return _dataTask ? self : nil;
+}
+
+
+
+#pragma mark - setups
+
+@end

+ 6 - 5
创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/boxDownloadFileRecordCell.m

@@ -10,7 +10,8 @@
 #import "cachesFileManager.h"
 #import <SDWebImage/SDWebImage.h>
 #import "downloadThumbnailManager.h"
-#import "mixDownloadManager.h"
+//#import "mixDownloadManager.h"
+#import "customDownloadManager.h"
 
 @interface boxDownloadFileRecordCell ()
 @property(nonatomic,strong) UIImageView *fileImageView;
@@ -35,7 +36,7 @@
     
     if (self)
     {
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskDownloadingNoti:) name:mixDownloadTaskExeing object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskDownloadingNoti:) name:customDownloadTaskExeing object:nil];
         [self drawView];
     }
     
@@ -628,10 +629,10 @@
 //#pragma mark 下载通知
 - (void)downloadTaskDownloadingNoti:(NSNotification *)notification
 {
-    mixDownloadOperation *model = notification.userInfo.allValues.firstObject;
+    customDownloadOperation *model = notification.userInfo.allValues.firstObject;
     if(!model)return;
     
-    if (model.downloadState != DownloadStateDoing) {
+    if (model.downloadState != customDownloadStateDoing) {
         return;
     }
     mainBlock(^{
@@ -640,7 +641,7 @@
 }
 
 
-- (void)downloadItem:(mixDownloadOperation *)model downloadedSize:(int64_t)downloadedSize totalSize:(int64_t)totalSize {
+- (void)downloadItem:(customDownloadOperation *)model downloadedSize:(int64_t)downloadedSize totalSize:(int64_t)totalSize {
     
     //解码
     NSString * urlString = [model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

+ 14 - 12
创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/receiveDownloadRecordTableView.m

@@ -10,7 +10,8 @@
 #import "boxDownloadFileRecordCell.h"
 #import "UIScrollView+EmptyDataSet.h"
 #import "uploadFileRecordTableViewHeadView.h"
-#import "mixDownloadManager.h"
+//#import "mixDownloadManager.h"
+#import "customDownloadManager.h"
 
 @interface receiveDownloadRecordTableView()<UITableViewDataSource,UITableViewDelegate,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
 {
@@ -699,18 +700,19 @@
 #pragma mark 下载完成
 - (void)downloadTaskFinishedNoti:(NSNotification *)notification
 {
-    mixDownloadOperation *model = notification.object;
+    customDownloadOperation *model = notification.object;
+    NSString *url = model.url;
     KWeakSelf
-    if (model.downloadState == DownloadStateCompleted) {
+    if (model.downloadState == customDownloadStateCompleted) {
         HLog(@"下载完成");
         mainBlock(^{
-            [weakSelf handldDownloadDoneDataBy:model];
+            [weakSelf handldDownloadDoneDataBy:url];
         });
     }
-    else if (model.downloadState == DownloadStateFailed){
+    else if (model.downloadState == customDownloadStateFailed){
         HLog(@"下载失败");
         mainBlock(^{
-            [weakSelf handldDownloadFailDataBy:model];
+            [weakSelf handldDownloadFailDataBy:url];
         });
     }
 }
@@ -739,19 +741,19 @@
     }
     
     //重新下载
-    [[mixDownloadManager shareManager] startAllDownloadTask];
+    [[boxDownloadFileManager shareInstance] reDownloadFileFunBy:@[] withAll:YES];
 }
 
 #pragma mark 下载失败数据回调处理
-- (void)handldDownloadFailDataBy:(mixDownloadOperation*)model
+- (void)handldDownloadFailDataBy:(NSString*)url
 {
-    NSString * urlString = [model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+    NSString * urlString = [url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     for (ShareFileDataModel*dataModel in _downloadingArr) {
        
         //HLog(@"22222222 %@\n%@",urlString,dataModel.fileUrl);
         if([urlString isEqualToString:dataModel.fileUrl]){
             //dataModel.totalSize = model.totalSize;
-            dataModel.currentSize = model.currentSize;
+            //dataModel.currentSize = model.currentSize;
             dataModel.downloadBoxStateType = downloadBoxStateFail;
             
             [_downloadfailArr insertObject:dataModel atIndex:0];
@@ -764,10 +766,10 @@
 }
 
 #pragma mark 下载完成数据回调处理
-- (void)handldDownloadDoneDataBy:(mixDownloadOperation*)model
+- (void)handldDownloadDoneDataBy:(NSString*)url
 {
     //解码
-    NSString * urlString = [model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+    NSString * urlString = [url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
 
     for (ShareFileDataModel*dataModel in _downloadingArr) {
         HLog(@"22222222 %@\n%@",urlString,dataModel.fileUrl);

+ 2 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxDownloadFileManager.h

@@ -8,7 +8,8 @@
 #import <Foundation/Foundation.h>
 #import "queryOneShareModel.h"
 #import "uploadFileManager.h"
-#import "mixDownloadManager.h"
+//#import "mixDownloadManager.h"
+#import "customDownloadManager.h"
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 31 - 18
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxDownloadFileManager.m

@@ -29,7 +29,7 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
         //[self initManager];
         //某一个YCDownloadItem下载成功通知
         //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:mixDownloadTaskExeEnd object:nil];
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:mixDownloadTaskExeEnd object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:customDownloadTaskExeEnd object:nil];
      
         [self initDownloadManagerFun];
     }
@@ -39,8 +39,8 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
 
 - (void)initDownloadManagerFun
 {
-    [mixDownloadManager shareManager].uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
-    //[mixDownloadManager shareManager]
+    //[mixDownloadManager shareManager].uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
+    [customDownloadManager shareManager].uid = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
     
     [self delItemInDoneTaskFun];
 }
@@ -271,7 +271,8 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
         NSString *urlString = dataModel.fileUrl;
         NSString *requestURLEncodedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
         
-        [[mixDownloadManager shareManager] cancelDownloadWithUrl:requestURLEncodedString];
+        //[[mixDownloadManager shareManager] cancelDownloadWithUrl:requestURLEncodedString];
+        [[customDownloadManager shareManager] deleteDownloadWithUrl:requestURLEncodedString];
     }
     
 }
@@ -310,30 +311,37 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
 //    }
     
     if(urlArr && urlArr.count > 0){
+        NSMutableArray *URLEncodedStringArr = [NSMutableArray new];
+        
         for (NSInteger i= urlArr.count-1; i>=0; i--) {
             ShareFileDataModel *fileModel = urlArr[i];
             
             NSString *urlString = fileModel.fileUrl;
             NSString *requestURLEncodedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
 
-            [[mixDownloadManager shareManager] downloadWithURL:[NSURL URLWithString:requestURLEncodedString] complete:^(NSDictionary * _Nonnull respose, NSError * _Nonnull error) {
-                HLog(@"download:%@",respose);
-            }];
+//            [[mixDownloadManager shareManager] downloadWithURL:[NSURL URLWithString:requestURLEncodedString] complete:^(NSDictionary * _Nonnull respose, NSError * _Nonnull error) {
+//                HLog(@"download:%@",respose);
+//            }];
+            
+            [URLEncodedStringArr addObject:requestURLEncodedString];
         }
+        
+        [[customDownloadManager shareManager] addDownloadWithURLs:URLEncodedStringArr];
+        
     }
 }
 
 #pragma mark 下载完成
 - (void)downloadTaskFinishedNoti:(NSNotification *)notification
 {
-    mixDownloadOperation *model = notification.userInfo.allValues.firstObject;
-    
+    customDownloadOperation *model = notification.userInfo.allValues.firstObject;
+
     if(!model)return;
     
-    if (model.downloadState == DownloadStateCompleted) {
+    if (model.downloadState == customDownloadStateCompleted) {
         [self handldDownloadDoneDataBy:model];
     }
-    else if (model.downloadState == DownloadStateFailed){
+    else if (model.downloadState == customDownloadStateFailed){
         [self handldDownloadFailDataBy:model];
     }
     
@@ -345,7 +353,7 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
 
 
 #pragma mark 下载完成数据回调处理
-- (void)handldDownloadDoneDataBy:(mixDownloadOperation*)model
+- (void)handldDownloadDoneDataBy:(customDownloadOperation*)model
 {
     //解码
     NSString * urlString = [model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
@@ -377,7 +385,7 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
 
 
 #pragma mark 下载失败数据回调处理
-- (void)handldDownloadFailDataBy:(mixDownloadOperation*)model
+- (void)handldDownloadFailDataBy:(customDownloadOperation*)model
 {
     //解码
     NSString * urlString = [model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
@@ -425,14 +433,14 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
             }
         }
         
-        [[mixDownloadManager shareManager] suspendAllDownloadTask];
+        [[customDownloadManager shareManager] suspendAllDownloadTask];
     }
     else if(dataModel){//暂停指定任务
         NSString *urlString = dataModel.fileUrl;
         NSString *requestURLEncodedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
         HLog(@"%@",urlString);
         
-        [[mixDownloadManager shareManager] supendDownloadWithUrl:requestURLEncodedString];
+        [[customDownloadManager shareManager] supendDownloadWithUrl:requestURLEncodedString];
         
         //2.修改状态
         if (_databaseArr && _databaseArr.count == 3) {
@@ -458,10 +466,15 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
 {
  
     if(isAllType){
-        [[mixDownloadManager shareManager] startAllDownloadTask];
-        
+        //[[mixDownloadManager shareManager] startAllDownloadTask];
+
         if (_databaseArr && _databaseArr.count == 3) {
+        
             NSMutableArray *downloadingArr = _databaseArr[0];
+            
+            //这里处理重新下载
+            [self beginDownloadFilesByUrls:downloadingArr];
+            
             for (ShareFileDataModel*model in downloadingArr) {
                 model.downloadBoxStateType = downloadBoxStateDownloadloading;
             }
@@ -491,7 +504,7 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
         NSString *requestURLEncodedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
         HLog(@"%@",urlString);
         
-        [[mixDownloadManager shareManager] startDownLoadWithUrl:requestURLEncodedString];
+        [[customDownloadManager shareManager] startDownLoadWithUrl:requestURLEncodedString];
         
     }
 }

+ 3 - 3
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+downloadNasFile.m

@@ -13,7 +13,7 @@
 {
     curDownloadmodel = notification.object;
     KWeakSelf
-    if (curDownloadmodel.downloadState == DownloadStateCompleted) {
+    if (curDownloadmodel.downloadState == customDownloadStateCompleted) {
         mainBlock(^{
             [weakSelf handldDownloadDoneToSaveBy:self->curDownloadmodel];
         });
@@ -21,14 +21,14 @@
 }
 
 #pragma mark 下载完后处理保持流程
-- (void)handldDownloadDoneToSaveBy:(mixDownloadOperation*)model{
+- (void)handldDownloadDoneToSaveBy:(customDownloadOperation*)model{
     //解码
     NSString * urlString = [model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     NSArray *nameArr= [urlString componentsSeparatedByString:@"."];
     NSString * pathStr= model.fullPath;
     NSString * decodePathStr= [pathStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     
-    HLog(@"%@\n%@\n%@",urlString,pathStr,[pathStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding])
+    HLog(@"downloadNasFile:%@\n%@\n%@",urlString,pathStr,[pathStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding])
     
     if(![pathStr isEqualToString:decodePathStr]){
         // 尝试移动(即重命名)文件

+ 3 - 2
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h

@@ -30,7 +30,8 @@
 #import "AudioSessionObject.h"
 #import "addLogObject.h"
 #import "ComontAlretType2ViewController.h"
-#import "mixDownloadManager.h"
+//#import "mixDownloadManager.h"
+#import "customDownloadManager.h"
 
 @protocol PlayerViewControllerDelegate <NSObject>
 
@@ -70,7 +71,7 @@
     
     //下载nas相关
     //YCDownloadItem *curYCDownloadItem;
-    mixDownloadOperation* curDownloadmodel;
+    customDownloadOperation* curDownloadmodel;
 }
 
 @property(copy,nonatomic)NSString * _Nullable internetVideoPort;

+ 1 - 1
创维盒子/双子星云手机/CloudPlayer/View/PlayerView.m

@@ -71,7 +71,7 @@ ShowImageViewDelegate>{
                   inRect:CGRectMake(0, 0, glkshowImageView.drawableWidth, glkshowImageView.drawableHeight)
                 fromRect:[ciImage extent]];
     
-    [self->glkshowImageView display];
+    //[self->glkshowImageView display];
 }
 
 - (void)showIMage