Browse Source

1.下载代码暂存

huangxiaodong 1 year ago
parent
commit
b808ff22cd
21 changed files with 492 additions and 32 deletions
  1. 18 2
      创维盒子/双子星云手机.xcodeproj/project.pbxproj
  2. 3 0
      创维盒子/双子星云手机/AppDelegate/Config/Notification.h
  3. 2 2
      创维盒子/双子星云手机/AppDelegate/PrefixHeader.pch
  4. 8 1
      创维盒子/双子星云手机/Class/Set/uploadFile/downLoadFile/downLoadPreviewViewController.m
  5. 1 0
      创维盒子/双子星云手机/Class/Set/uploadFile/model/uploadFileDataModel.h
  6. 4 0
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/cachesFileManager.h
  7. 16 2
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/cachesFileManager.m
  8. 36 0
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadManager.h
  9. 142 0
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadManager.m
  10. 1 0
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadThumbnailManager.m
  11. 1 24
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/uploadFileManager.m
  12. 4 0
      创维盒子/双子星云手机/CloudPlayer/Model/couldPhoneFileListModel.h
  13. 8 0
      创维盒子/双子星云手机/CloudPlayer/Model/couldPhoneFileListModel.m
  14. 18 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+downloadFile.h
  15. 129 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+downloadFile.m
  16. 1 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.h
  17. 69 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.mm
  18. 4 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h
  19. 4 1
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm
  20. 8 0
      创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.h
  21. 15 0
      创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.m

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

@@ -224,6 +224,10 @@
 		6B5D40382B4BEEF8000965CF /* downloadThumbnailManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5D40362B4BEEF8000965CF /* downloadThumbnailManager.m */; };
 		6B5D403B2B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B5D40392B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.h */; };
 		6B5D403C2B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5D403A2B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.m */; };
+		6B5D403F2B4CE40F000965CF /* downloadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B5D403D2B4CE40F000965CF /* downloadManager.h */; };
+		6B5D40402B4CE40F000965CF /* downloadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5D403E2B4CE40F000965CF /* downloadManager.m */; };
+		6B5D40432B4CF04C000965CF /* PlayerViewController+downloadFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B5D40412B4CF04C000965CF /* PlayerViewController+downloadFile.h */; };
+		6B5D40442B4CF04C000965CF /* PlayerViewController+downloadFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5D40422B4CF04C000965CF /* PlayerViewController+downloadFile.m */; };
 		6B72724B2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B7272492B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.h */; };
 		6B72724C2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B72724A2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.m */; };
 		6B72724F2B0B58E500C03F87 /* uploadFileRecordEditBottomView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B72724D2B0B58E500C03F87 /* uploadFileRecordEditBottomView.h */; };
@@ -649,6 +653,10 @@
 		6B5D40362B4BEEF8000965CF /* downloadThumbnailManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = downloadThumbnailManager.m; sourceTree = "<group>"; };
 		6B5D40392B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PlayerViewController+downloadThumbnailImage.h"; sourceTree = "<group>"; };
 		6B5D403A2B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PlayerViewController+downloadThumbnailImage.m"; sourceTree = "<group>"; };
+		6B5D403D2B4CE40F000965CF /* downloadManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = downloadManager.h; sourceTree = "<group>"; };
+		6B5D403E2B4CE40F000965CF /* downloadManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = downloadManager.m; sourceTree = "<group>"; };
+		6B5D40412B4CF04C000965CF /* PlayerViewController+downloadFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PlayerViewController+downloadFile.h"; sourceTree = "<group>"; };
+		6B5D40422B4CF04C000965CF /* PlayerViewController+downloadFile.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PlayerViewController+downloadFile.m"; sourceTree = "<group>"; };
 		6B7272492B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = uploadFileRecordTableViewHeadView.h; sourceTree = "<group>"; };
 		6B72724A2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = uploadFileRecordTableViewHeadView.m; sourceTree = "<group>"; };
 		6B72724D2B0B58E500C03F87 /* uploadFileRecordEditBottomView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = uploadFileRecordEditBottomView.h; sourceTree = "<group>"; };
@@ -1141,6 +1149,8 @@
 				6B1FBD352B455DD600926382 /* PlayerViewController+backupsFile.m */,
 				6B5D40392B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.h */,
 				6B5D403A2B4BFEB9000965CF /* PlayerViewController+downloadThumbnailImage.m */,
+				6B5D40412B4CF04C000965CF /* PlayerViewController+downloadFile.h */,
+				6B5D40422B4CF04C000965CF /* PlayerViewController+downloadFile.m */,
 				183AE6B12A8C9F5800B11CB0 /* View */,
 				183AE6A52A8C9EA900B11CB0 /* RCCommandHelp.h */,
 				183AE6A72A8C9EAA00B11CB0 /* RCCommandHelp.m */,
@@ -1360,6 +1370,8 @@
 				6B0582842B0457C400D37290 /* uploadFileManager.m */,
 				6B5D40352B4BEEF8000965CF /* downloadThumbnailManager.h */,
 				6B5D40362B4BEEF8000965CF /* downloadThumbnailManager.m */,
+				6B5D403D2B4CE40F000965CF /* downloadManager.h */,
+				6B5D403E2B4CE40F000965CF /* downloadManager.m */,
 				6B7272512B0CABC600C03F87 /* cachesFileManager.h */,
 				6B7272522B0CABC600C03F87 /* cachesFileManager.m */,
 			);
@@ -1891,6 +1903,7 @@
 				184C8ADA2A949DAC00F26650 /* HaveNewVersionView.h in Headers */,
 				6BBB35DD2AE76AD800E4A59B /* AudioSessionObject.h in Headers */,
 				6B0582782AFF7C6D00D37290 /* TZAssetModel+imageData.h in Headers */,
+				6B5D403F2B4CE40F000965CF /* downloadManager.h in Headers */,
 				6B5D40372B4BEEF8000965CF /* downloadThumbnailManager.h in Headers */,
 				6B0582802B01C67400D37290 /* uploadFileRecordViewController.h in Headers */,
 				183AE6D12A8CA98C00B11CB0 /* CloudPhoneAPI.h in Headers */,
@@ -1958,6 +1971,7 @@
 				6B0582852B0457C400D37290 /* uploadFileManager.h in Headers */,
 				6BFF268C2AF8E1C600FCB4F7 /* forgetPwdViewController.h in Headers */,
 				6BF52C992AD5546500A617DB /* Reachability.h in Headers */,
+				6B5D40432B4CF04C000965CF /* PlayerViewController+downloadFile.h in Headers */,
 				6B5D40152B47F27A000965CF /* couldPhoneCommonModel.h in Headers */,
 				18BB18412AC417CB00A36F63 /* RYShearDeviceUDPManager.h in Headers */,
 				184C8AD52A949D5900F26650 /* AboutViewController.h in Headers */,
@@ -2300,6 +2314,7 @@
 				6B5D40302B4BCBC1000965CF /* downLoadPreViewCell.m in Sources */,
 				183AE6052A89CE3C00B11CB0 /* JSONModelError.m in Sources */,
 				6B7B65592AD9227700BE8CB3 /* PlayerViewController+otherDelegate.mm in Sources */,
+				6B5D40402B4CE40F000965CF /* downloadManager.m in Sources */,
 				A08A950027E9A4E400C544BB /* FMDatabaseQueue.m in Sources */,
 				6BF52CA72AD7D3BE00A617DB /* customLaunchView.m in Sources */,
 				A031DD7A27EC713A00909527 /* HWSetViewController.m in Sources */,
@@ -2412,6 +2427,7 @@
 				1868201A2AB94877005702A6 /* GuideLastView.m in Sources */,
 				6BA533392B16E65500D1CB5C /* TvStatusModel.m in Sources */,
 				6B5B60732B3D8098009A2AE2 /* fileTransferPathCheckTableViewCell.m in Sources */,
+				6B5D40442B4CF04C000965CF /* PlayerViewController+downloadFile.m in Sources */,
 				18F9CB002ABD3643003FF71A /* ModifyPWDSecondViewController.m in Sources */,
 				6B0582702AFF692700D37290 /* photoPreViewBottomView.m in Sources */,
 				1868201E2AB97BE1005702A6 /* TipsQRCodeViewController.m in Sources */,
@@ -2768,7 +2784,7 @@
 					"$(PROJECT_DIR)/双子星云手机/Vendor/UDP/RayProxy",
 					"$(PROJECT_DIR)/RayProxy",
 				);
-				MARKETING_VERSION = 1.2.0;
+				MARKETING_VERSION = 1.3.0;
 				PRODUCT_BUNDLE_IDENTIFIER = com.armcloud.privacy.x.box;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2847,7 +2863,7 @@
 					"$(PROJECT_DIR)/双子星云手机/Vendor/UDP/RayProxy",
 					"$(PROJECT_DIR)/RayProxy",
 				);
-				MARKETING_VERSION = 1.2.0;
+				MARKETING_VERSION = 1.3.0;
 				PRODUCT_BUNDLE_IDENTIFIER = com.armcloud.privacy.x.box;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";

+ 3 - 0
创维盒子/双子星云手机/AppDelegate/Config/Notification.h

@@ -79,6 +79,9 @@
 /* 下载缩略图通知*/
 #define downloadThumbnailBeginNotification                 @"downloadThumbnailBeginNot"
 
+/* 下载文件通知*/
+#define downloadFileBeginNotification                 @"downloadFileBeginNot"
+
 /* 创建文件夹通知*/
 #define createFolderBeginNotification                 @"createFolderBeginNot"
 /* 创建文件夹通知*/

+ 2 - 2
创维盒子/双子星云手机/AppDelegate/PrefixHeader.pch

@@ -82,8 +82,8 @@ isBangsScreen; \
 //#define CloudService           @"http://14.18.190.141:11180"
 //#define CloudService           @"http://14.18.190.141:1280"
 //创维盒子 测试地址
-//#define CloudService   @"http://14.18.190.141:1801"
-#define CloudService   @"http://hiboxde.armclouding.com:7780"
+#define CloudService   @"http://14.18.190.141:1801"
+//#define CloudService   @"http://hiboxde.armclouding.com:7780"
 
 
 #define AESCODEKEEYY @"fvO8gAfNSr1tbdQe"

+ 8 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/downLoadFile/downLoadPreviewViewController.m

@@ -10,6 +10,7 @@
 #import "downLoadPreViewCell.h"
 #import "downloadFileBottomView.h"
 #import "downloadThumbnailManager.h"
+#import "downloadManager.h"
 
 @interface downLoadPreviewViewController ()<UITableViewDelegate,UITableViewDataSource>
 @property (nonatomic, strong) UITableView *tableView;
@@ -79,7 +80,7 @@
     
     KWeakSelf
     _downloadFileBottomV.didClickDownloadFile = ^{
-        //[weakSelf gotoUploadFileRecordFun];
+        [weakSelf gotoDownloadloadFileRecordFun];
     };
     
 }
@@ -239,5 +240,11 @@
     [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailWith:_curCouldPhoneFileListMod.data.list];
 }
 
+- (void)gotoDownloadloadFileRecordFun
+{
+    [[downloadManager shareInstance] handleCouldPhoneFileModelToDownloadFileDataFunBy:_downloadFileBottomV.indexPathsForSelectedItems complete:^(NSMutableArray * _Nonnull Arr) {
+        
+    }];
+}
 
 @end

+ 1 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/model/uploadFileDataModel.h

@@ -23,6 +23,7 @@ typedef enum{
     uploadFileTypeVideo,
     uploadFileTypeUnkonw,
     DownLoadThumbnail,//下载缩略图
+    DownLoadFileType,//下载文件
 }uploadFileType;
 
 //self.fileName = [assetModel.asset valueForKey:@"filename"];

+ 4 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/cachesFileManager.h

@@ -16,6 +16,10 @@
 //下载缩略图 图片 DownLoadThumbnail
 #define kSHPath_DownLoadThumbnail [cachesFileManager getCreateFilePath:[NSString stringWithFormat:@"%@/DownLoadThumbnail",CachesPatch]]
 
+//下载文件 图片 DownLoadFile
+#define kSHPath_DownLoadFlie [cachesFileManager getCreateFilePath:[NSString stringWithFormat:@"%@/DownLoadFlie",CachesPatch]]
+
+
 NS_ASSUME_NONNULL_BEGIN
 
 @interface cachesFileManager : NSObject

+ 16 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/cachesFileManager.m

@@ -21,10 +21,9 @@
 }
 
 
-#pragma mark - 获取文件夹(没有的话创建)
+#pragma mark - 获取文件夹
 + (BOOL)checkFileIsSaveState:(NSString *)fileName withType:(uploadFileType)type
 {
-    
     NSString * path = [cachesFileManager getFilePathWithName:fileName type:type];
     return [[NSFileManager defaultManager] fileExistsAtPath:path];
 }
@@ -80,6 +79,16 @@
         }
             break;
             
+        case DownLoadFileType://
+        {
+            filePath = [NSString stringWithFormat:@"%@/%@",kSHPath_DownLoadFlie,fileName];
+            
+            if ([content isKindOfClass:[NSData class]]) {
+                data = content;
+            }
+        }
+            break;
+            
         default:
             break;
     }
@@ -128,6 +137,11 @@
             name = [NSString stringWithFormat:@"%@/%@",kSHPath_DownLoadThumbnail,name];
         }
             break;
+        case DownLoadFileType://
+        {
+            name = [NSString stringWithFormat:@"%@/%@",kSHPath_DownLoadFlie,name];
+        }
+            break;
         default:
             break;
     }

+ 36 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadManager.h

@@ -0,0 +1,36 @@
+//
+//  downloadManager.h
+//  隐私保护
+//
+//  Created by xd h on 2024/1/9.
+//
+
+#import <Foundation/Foundation.h>
+//#import "couldPhoneFileModel.h"
+#import "couldPhoneFileListModel.h"
+#import "uploadFileManager.h"
+
+#define download_tableName [[NSString alloc] initWithFormat:@"download_tableName_%@",[connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn]
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface downloadManager : NSObject
+
+//数据库数据
+@property (nonatomic, strong) NSMutableArray * _Nullable databaseArr;
+@property (nonatomic, strong) NSMutableArray * _Nullable downLoadFileModelDataArr;
+@property (nonatomic, strong) couldPhoneFileModel *  curDownloadFileModel;
+@property (nonatomic, assign) BOOL  isSuspendType;
+@property (nonatomic, assign) BOOL  isDownloadIngType;
+
++(downloadManager *)shareInstance;
+#pragma mark 读取数据库数据
+- (void)getDataInDatabaseFun:(BOOL)isReGet complete:(custom_complete_Arr)complete;
+
+- (void)handleCouldPhoneFileModelToDownloadFileDataFunBy:(NSMutableArray*)indexPathsForSelectedItems complete:(custom_complete_Arr)complete;
+
+- (void)DownloadFileDoneOneFileFun;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 142 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadManager.m

@@ -0,0 +1,142 @@
+//
+//  downloadManager.m
+//  隐私保护
+//
+//  Created by xd h on 2024/1/9.
+//
+
+#import "downloadManager.h"
+
+@implementation downloadManager
+static downloadManager * cur_downloadManager = nil;
++(downloadManager *)shareInstance;
+{
+    static dispatch_once_t onceToken;
+    
+    dispatch_once(&onceToken, ^{
+        cur_downloadManager = [[downloadManager alloc] init];
+        
+    });
+    
+    return cur_downloadManager;
+}
+
+- (id)init
+{
+    self = [super init];
+    
+    if (self) {
+        //[self initManager];
+    }
+    
+    return self;
+}
+
+
+#pragma mark 读取数据库数据
+- (void)getDataInDatabaseFun:(BOOL)isReGet complete:(custom_complete_Arr)complete
+{
+    if(_databaseArr && _databaseArr.count == 3 && !isReGet){
+        complete(_databaseArr);
+        return;
+    }
+    
+    if(!_databaseArr)
+    {
+        _databaseArr = [NSMutableArray new];
+    }
+    
+    //KWeakSelf
+    //dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
+        [couldPhoneFileModel bg_findAsync:download_tableName limit:0 orderBy:nil desc:NO complete:^(NSArray * _Nullable array) {
+            NSMutableArray *failArr = [NSMutableArray new];
+            NSMutableArray *doneArr = [NSMutableArray new];
+            NSMutableArray *otherArr = [NSMutableArray new];
+            
+                for (couldPhoneFileModel * curModel in array) {
+                
+                    if(curModel.curDownloadStateType == downloadStateFail){
+                        [failArr addObject:curModel];
+                    }
+                    else if(curModel.curDownloadStateType == downloadStateDone){
+                        [doneArr addObject:curModel];
+                    }
+                    else{
+                        [otherArr addObject:curModel];
+                    }
+                }
+            
+            NSLock *lock = [NSLock new];
+            [lock lock];
+            
+            NSMutableArray *newArr = [NSMutableArray new];
+            [newArr addObject:otherArr];
+            [newArr addObject:doneArr];
+            [newArr addObject:failArr];
+            self->_databaseArr = newArr;
+            
+            [lock unlock];
+            
+            complete(self->_databaseArr);
+        }];
+    //});
+
+}
+
+- (void)handleCouldPhoneFileModelToDownloadFileDataFunBy:(NSMutableArray*)indexPathsForSelectedItems complete:(custom_complete_Arr)complete
+{
+    if(!indexPathsForSelectedItems && indexPathsForSelectedItems.count == 0){
+        complete(nil);
+        return;
+    }
+    
+ 
+    for (couldPhoneFileModel*model in indexPathsForSelectedItems) {
+        model.bg_tableName = download_tableName;
+    }
+    
+    KWeakSelf
+    [couldPhoneFileModel bg_saveOrUpdateArrayAsync:indexPathsForSelectedItems complete:^(BOOL isSuccess) {
+        
+        [weakSelf getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
+            complete(Arr);
+            [weakSelf planToDownloadFileFun];
+        }];
+    }];
+    
+}
+
+- (void)planToDownloadFileFun
+{
+    if(!_databaseArr || _databaseArr.count != 3){
+        return;
+    }
+    
+    _downLoadFileModelDataArr = _databaseArr[0];
+    
+    [self beginDownloadFileFun];
+}
+
+- (void)beginDownloadFileFun
+{
+    if(_downLoadFileModelDataArr.count == 0)
+    {
+        return;
+    }
+    
+    _isSuspendType = NO;
+    _isDownloadIngType = YES;
+    _curDownloadFileModel = _downLoadFileModelDataArr.lastObject;
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName:downloadFileBeginNotification object:_curDownloadFileModel];
+}
+
+- (void)DownloadFileDoneOneFileFun
+{
+    _curDownloadFileModel.curDownloadStateType = downloadStateDone;
+    
+    [_downLoadFileModelDataArr removeObject:_curDownloadFileModel];
+    
+    [self beginDownloadFileFun];
+}
+@end

+ 1 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadThumbnailManager.m

@@ -53,6 +53,7 @@ static downloadThumbnailManager * cur_downloadFileShareInstance = nil;
         //NSLog(@"%ld----",idx);
         
         couldPhoneFileModel *addModel = newTaskArr[idx];
+        addModel.bg_tableName = downloadThumbnail_tableName;
         
         NSString *newFileName =  [addModel getFileNameFun];
         BOOL isNeedAdd = YES;

+ 1 - 24
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/uploadFileManager.m

@@ -216,30 +216,7 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
         return;
     }
     
-    NSMutableArray *curArr = totalArr[0];
-    
-    //for (int i=0; i<_curUploadModelNumbers; i++)
-    NSLock *lock = [NSLock new];
-    [lock lock];
-    [_fileModelDataArr removeAllObjects];
-    for (int i=0; i<curArr.count; i++)
-    {
-       uploadFileDataModel *bg_mod  = curArr[i];
-       [_fileModelDataArr addObject:bg_mod];
-    }
-    [lock unlock];
-    
-//    for (int i=0; i<_fileModelDataArr.count; i++) {
-//       uploadFileDataModel *bg_mod  = _fileModelDataArr[i];
-//
-//       for (uploadFileDataModel *data_mod in curArr) {
-//           if([data_mod.filename isEqualToString:bg_mod.filename]){
-//               bg_mod.bg_id = data_mod.bg_id;
-//               //HLog(@"bg_id:%@",data_mod.bg_id);
-//               break;
-//           }
-//       }
-//   }
+    _fileModelDataArr = totalArr[0];
     
     [self beginUploadFileFun];
 }

+ 4 - 0
创维盒子/双子星云手机/CloudPlayer/Model/couldPhoneFileListModel.h

@@ -43,6 +43,10 @@ typedef enum{
 //自定义
 @property (nonatomic, assign) BOOL isSelectType;
 @property (nonatomic, assign) downloadStateType curDownloadStateType;
+@property (nonatomic, assign)  long didDownloadBytes;//已经上传的字节数
+
+@property (nonatomic, assign) NSTimeInterval  preTimeInterval;//计算速度用
+@property (nonatomic, assign) NSTimeInterval  curTimeInterval;//计算速度用
 
 - (NSString*)getFileNameFun;
 @end

+ 8 - 0
创维盒子/双子星云手机/CloudPlayer/Model/couldPhoneFileListModel.m

@@ -12,6 +12,14 @@
 {
     return [[NSString alloc] initWithFormat:@"%ld_%@",self.length,self.name];
 }
+
+/**
+ 设置不需要存储的属性, 在模型.m文件中实现该函数.
+ */
++(NSArray *)bg_ignoreKeys{
+   return @[@"preTimeInterval",@"curTimeInterval",@"isSelectType"];
+}
+
 @end
 
 @implementation couldPhoneFileArrModel

+ 18 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+downloadFile.h

@@ -0,0 +1,18 @@
+//
+//  PlayerViewController+downloadFile.h
+//  隐私保护
+//
+//  Created by xd h on 2024/1/9.
+//
+
+#import "PlayerViewController.h"
+#import "RCCommandHelp.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface PlayerViewController (downloadFile)
+- (void)begindownloadFileFun:(NSNotification *)notification;
+- (void)downloadFileFunServiceResponseFun:(NSData *)fileData with:(BOOL)isDownloadDone;
+@end
+
+NS_ASSUME_NONNULL_END

+ 129 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+downloadFile.m

@@ -0,0 +1,129 @@
+//
+//  PlayerViewController+downloadFile.m
+//  隐私保护
+//
+//  Created by xd h on 2024/1/9.
+//
+
+#import "PlayerViewController+downloadFile.h"
+#import "cachesFileManager.h"
+#import "downloadManager.h"
+
+@implementation PlayerViewController (downloadFile)
+- (void)begindownloadFileFun:(NSNotification *)notification
+{
+    self.curDownloadFileModel = [notification object];
+    
+    if(!self.curDownloadFileModel
+       || ![self.curDownloadFileModel isKindOfClass:[couldPhoneFileModel class]]){
+        return;
+    }
+    
+    [self ApplyDownloadFileFun];
+}
+
+#pragma mark 申请下载缩略图
+- (void)ApplyDownloadFileFun
+{
+    
+    self.downloadFileTaskUid = [iTools getTaskUidStr];
+ 
+    NSString * commandStr = [RCCommandHelp applyForDownloadFileBy:self.downloadFileTaskUid withFilePath:self.curDownloadFileModel.path withPosition:self.curDownloadFileModel.didDownloadBytes];
+
+    [self.commandChannelManager rc_sendData:commandStr];
+    
+}
+
+- (void)downloadFileFunServiceResponseFun:(NSData *)fileData  with:(BOOL)isDownloadDone
+{
+    NSString *fileName = [self.curDownloadFileModel getFileNameFun];
+        
+    NSString*pathStr = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
+    
+    NSFileManager *manager0 = [NSFileManager defaultManager];
+    long long endOfFile = 0;
+    
+    if(![manager0 fileExistsAtPath:pathStr]) {
+        [cachesFileManager getFileNameWithContent:fileData fileName:fileName type:DownLoadFileType];
+    }
+    else{
+        NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:pathStr]; // 创建文件句柄
+        if (fileHandle) {
+            endOfFile = [fileHandle seekToEndOfFile];
+            if (endOfFile >=  0) {
+                [fileHandle writeData:fileData];
+            }
+            
+            //[fileHandle writeData:fileData];
+            
+            endOfFile = [fileHandle seekToEndOfFile];
+            // 关闭文件句柄
+            [fileHandle closeFile];
+        }
+    }
+    
+    long didDownloadBytes = fileData.length;
+    if(endOfFile > 0){
+        didDownloadBytes = endOfFile;
+    }
+    
+    self.curDownloadFileModel.didDownloadBytes = didDownloadBytes;
+   
+    if(isDownloadDone || endOfFile == self.curDownloadFileModel.length){
+        [self handleDownloadDoneFun];
+    }
+    else{//获取下一片
+        NSString * commandStr = [RCCommandHelp applyForDownloadFileBy:self.downloadFileTaskUid withFilePath:self.curDownloadFileModel.path withPosition:didDownloadBytes];
+        [self.commandChannelManager rc_sendData:commandStr];
+    }
+    
+}
+
+- (void)handleDownloadDoneFun
+{
+    if([self.curDownloadFileModel.fileType isEqualToString:@"jpg"]){
+        NSString *fileName = [self.curDownloadFileModel getFileNameFun];
+        NSString*pathStr = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
+        UIImage *image = [UIImage imageWithContentsOfFile:pathStr];
+        
+        if(image){
+            [self loadImageFinished:image];
+        }
+    }
+    else if([self.curDownloadFileModel.fileType isEqualToString:@"video"]){
+        [self loadVideoFinished];
+    }
+    
+    [[downloadManager shareInstance] DownloadFileDoneOneFileFun];
+}
+
+
+- (void)loadImageFinished:(UIImage *)image
+{
+    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
+         //写入图片到相册
+         PHAssetChangeRequest *req = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
+            
+     } completionHandler:^(BOOL success, NSError * _Nullable error) {
+         NSLog(@"success = %d, error = %@", success, error);
+    }];
+}
+
+- (void)loadVideoFinished
+{
+    NSString *fileName = [self.curDownloadFileModel getFileNameFun];
+    NSString*pathStr = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
+    
+    PHPhotoLibrary *photoLibrary = [PHPhotoLibrary sharedPhotoLibrary];
+    [photoLibrary performChanges:^{
+        [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:[NSURL
+    fileURLWithPath:pathStr]];
+    } completionHandler:^(BOOL success, NSError * _Nullable error) {
+        if (success) {
+            NSLog(@"已将视频保存至相册");
+        } else {
+            NSLog(@"未能保存视频到相册");
+        }
+    }];
+}
+@end

+ 1 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.h

@@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)searchFileListBeginFun:(NSNotification *)notification;
 - (void)searchFileListResponseFun:(NSDictionary *)dataDict;
 
+- (void)handleDownloadResponseFunBy:(id)message;
 @end
 
 NS_ASSUME_NONNULL_END

+ 69 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.mm

@@ -15,6 +15,7 @@
 #import <MJExtension.h>
 #import "HaveNewVersionView.h"
 #import "connectDeviceManager.h"
+#import "PlayerViewController+downloadFile.h"
 
 @implementation PlayerViewController (otherDelegate)
 
@@ -252,4 +253,72 @@
 {
     [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListDoneNotification object:dataDict];/*发送通知*/
 }
+
+
+// NSData转int
+- (int)data2Int:(NSData *)data{
+    Byte *byte = (Byte *)[data bytes];
+    // 有大小端模式问题?
+     return (byte[0] << 24) + (byte[1] << 16) + (byte[2] << 8) + (byte[3]);
+}
+
+
+- (void)handleDownloadResponseFunBy:(id)message
+{
+    NSData *curData = (NSData *)message;
+    
+    if(curData.length < 22){
+        return;
+    }
+    
+    //head
+    NSData *headData = [curData subdataWithRange:NSMakeRange(0, 1)];
+    char head = 0;//104;
+    [headData getBytes:&head length:sizeof(head)];
+    //HLog(@"head: %d",head);
+    
+    //msgType  0x11(17)
+    NSData *msgTypeData = [curData subdataWithRange:NSMakeRange(1, 1)];
+    char msgType = 0;
+    [msgTypeData getBytes:&msgType length:sizeof(msgType)];
+    //HLog(@"msgType: %d",msgType);
+    
+    //taskId  6位字符串
+    NSData *taskIdData = [curData subdataWithRange:NSMakeRange(2, 6)];
+    NSString* taskIdStr = [[NSString alloc] initWithData:taskIdData encoding:NSUTF8StringEncoding];;
+    //HLog(@"taskId: %@",taskIdStr);
+    
+    //datalen
+    NSData *datalenData = [curData subdataWithRange:NSMakeRange(8, 4)];
+    int datalen = [self data2Int:datalenData];
+    //HLog(@"datalen: %d",datalen);
+
+    //curNum
+    NSData *curNumData = [curData subdataWithRange:NSMakeRange(12, 4)];
+    int curNum = [self data2Int:curNumData];;
+    //HLog(@"curNum: %d",curNum);
+    
+    //totalNum
+    NSData *totalNumData = [curData subdataWithRange:NSMakeRange(16, 4)];
+    int totalNum = [self data2Int:totalNumData];
+    //HLog(@"totalNum: %d",totalNum);
+    
+    HLog(@"taskId:%@ curNum:%d totalNum: %d",taskIdStr,curNum,totalNum);
+    
+    if(curData.length <= (20 + datalen - 8)){
+        HLog(@"下载数据解析出错了");
+        return;
+    }
+    
+    NSData *fileData = [curData subdataWithRange:NSMakeRange(20, datalen-8)];
+
+
+    if([taskIdStr isEqualToString:self.downloadFileTaskUid]){
+        
+        BOOL isDownloadDone = curNum == totalNum ? YES : NO;
+        
+        [self downloadFileFunServiceResponseFun:fileData with:isDownloadDone];
+    }
+    
+}
 @end

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

@@ -127,6 +127,10 @@
 @property (nonatomic, copy) NSString * _Nullable downloadThumbnailTaskUid;
 @property (nonatomic, strong) couldPhoneFileModel *curDownloadThumbnailModel;
 
+//下载文件用到
+@property (nonatomic, copy) NSString * _Nullable downloadFileTaskUid;
+@property (nonatomic, strong) couldPhoneFileModel *curDownloadFileModel;
+
 
 /**
  * @brief 云手机类型  VIP星动云手机  SVIP星曜云手机  STAR 唔即云手机

+ 4 - 1
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

@@ -13,7 +13,7 @@
 #import "PlayerViewController+otherDelegate.h"
 #import "PlayerViewController+upLoadFile.h"
 #import "PlayerViewController+backupsFile.h"
-
+#import "PlayerViewController+downloadFile.h"
 
 #import <AVFoundation/AVFoundation.h>
 
@@ -512,6 +512,7 @@ ComontAlretViewControllerDelegate>
             NSDictionary *dataDict = [NSJSONSerialization JSONObjectWithData:message options:NSJSONReadingMutableContainers error:&error];
             
             if(!dataDict){
+                [weakSelf handleDownloadResponseFunBy:message];
                 return;
             }
             
@@ -2316,6 +2317,8 @@ BOOL inReconnect = NO;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchFileListBeginFun:) name:searchFileListBeginNotification object:nil];
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(begindownloadThumbnailImageFun:) name:downloadThumbnailBeginNotification object:nil];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(begindownloadFileFun:) name:downloadFileBeginNotification object:nil];
 }
 
 - (void)removeNSNotification

+ 8 - 0
创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.h

@@ -224,6 +224,14 @@ NS_ASSUME_NONNULL_BEGIN
  * @param fileType  文件类型 jpg 图片 audio 音频 video 视频 apk 应用 doc 文档 other 其他文件 dir 文件夹
  */
 + (NSString *)searchCouldPhoneFilewithType:(NSString *)fileType;
+
+/**
+ * @brief 下载文件
+ *
+ * @param taskUid
+ */
++ (NSString *)applyForDownloadFileBy:(NSString *)taskUid withFilePath:(NSString *)filePath withPosition:(long)position;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 15 - 0
创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.m

@@ -1062,5 +1062,20 @@
     return dataStr;
 }
 
++ (NSString *)applyForDownloadFileBy:(NSString *)taskUid withFilePath:(NSString *)filePath withPosition:(long)position
+{
+    NSString *dataStr =[NSString stringWithFormat:@"{\"data\":{\"taskUid\":\"%@\",\"filePath\":\"%@\",\"position\":\"%ld\"},\"type\":\"fileCommand\"}",taskUid,filePath,position];
+    
+    if (USENEWCONTROLLCOMMONDNO500)
+    {
+//        dataStr = [self commondAppendingHeadAndEndStrWithSourStr:dataStr];
+    }
+    else
+    {
+        dataStr = [self commandAppending00StringWithSourStr:dataStr];
+    }
+    
+    return dataStr;
+}
 
 @end