huangxiaodong 1 год назад
Родитель
Сommit
895c267e09

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

@@ -169,8 +169,10 @@
 		6B1FBD272B4503E700926382 /* photosBackupsTaskModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1FBD252B4503E700926382 /* photosBackupsTaskModel.m */; };
 		6B1FBD2A2B452B3800926382 /* backupsFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD282B452B3800926382 /* backupsFileManager.h */; };
 		6B1FBD2B2B452B3800926382 /* backupsFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1FBD292B452B3800926382 /* backupsFileManager.m */; };
-		6B1FBD2E2B45392800926382 /* PlayerViewController+fileTransfer.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD2C2B45392800926382 /* PlayerViewController+fileTransfer.h */; };
-		6B1FBD2F2B45392800926382 /* PlayerViewController+fileTransfer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1FBD2D2B45392800926382 /* PlayerViewController+fileTransfer.m */; };
+		6B1FBD322B455DBD00926382 /* PlayerViewController+upLoadFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD302B455DBD00926382 /* PlayerViewController+upLoadFile.h */; };
+		6B1FBD332B455DBD00926382 /* PlayerViewController+upLoadFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1FBD312B455DBD00926382 /* PlayerViewController+upLoadFile.m */; };
+		6B1FBD362B455DD600926382 /* PlayerViewController+backupsFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD342B455DD600926382 /* PlayerViewController+backupsFile.h */; };
+		6B1FBD372B455DD600926382 /* PlayerViewController+backupsFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1FBD352B455DD600926382 /* PlayerViewController+backupsFile.m */; };
 		6B2170882B1444CC00656670 /* allVersionView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2170862B1444CC00656670 /* allVersionView.h */; };
 		6B2170892B1444CC00656670 /* allVersionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2170872B1444CC00656670 /* allVersionView.m */; };
 		6B21708C2B14BDAA00656670 /* couldphoneSysInfoModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B21708A2B14BDAA00656670 /* couldphoneSysInfoModel.h */; };
@@ -572,8 +574,10 @@
 		6B1FBD252B4503E700926382 /* photosBackupsTaskModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = photosBackupsTaskModel.m; sourceTree = "<group>"; };
 		6B1FBD282B452B3800926382 /* backupsFileManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = backupsFileManager.h; sourceTree = "<group>"; };
 		6B1FBD292B452B3800926382 /* backupsFileManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = backupsFileManager.m; sourceTree = "<group>"; };
-		6B1FBD2C2B45392800926382 /* PlayerViewController+fileTransfer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PlayerViewController+fileTransfer.h"; sourceTree = "<group>"; };
-		6B1FBD2D2B45392800926382 /* PlayerViewController+fileTransfer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PlayerViewController+fileTransfer.m"; sourceTree = "<group>"; };
+		6B1FBD302B455DBD00926382 /* PlayerViewController+upLoadFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PlayerViewController+upLoadFile.h"; sourceTree = "<group>"; };
+		6B1FBD312B455DBD00926382 /* PlayerViewController+upLoadFile.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PlayerViewController+upLoadFile.m"; sourceTree = "<group>"; };
+		6B1FBD342B455DD600926382 /* PlayerViewController+backupsFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PlayerViewController+backupsFile.h"; sourceTree = "<group>"; };
+		6B1FBD352B455DD600926382 /* PlayerViewController+backupsFile.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PlayerViewController+backupsFile.m"; sourceTree = "<group>"; };
 		6B2170862B1444CC00656670 /* allVersionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = allVersionView.h; sourceTree = "<group>"; };
 		6B2170872B1444CC00656670 /* allVersionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = allVersionView.m; sourceTree = "<group>"; };
 		6B21708A2B14BDAA00656670 /* couldphoneSysInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = couldphoneSysInfoModel.h; sourceTree = "<group>"; };
@@ -1085,8 +1089,10 @@
 				18FCE5472AD15E750020F623 /* PlayerViewController+AppDelegate.m */,
 				6B7B65562AD9227700BE8CB3 /* PlayerViewController+otherDelegate.h */,
 				6B7B65572AD9227700BE8CB3 /* PlayerViewController+otherDelegate.mm */,
-				6B1FBD2C2B45392800926382 /* PlayerViewController+fileTransfer.h */,
-				6B1FBD2D2B45392800926382 /* PlayerViewController+fileTransfer.m */,
+				6B1FBD302B455DBD00926382 /* PlayerViewController+upLoadFile.h */,
+				6B1FBD312B455DBD00926382 /* PlayerViewController+upLoadFile.m */,
+				6B1FBD342B455DD600926382 /* PlayerViewController+backupsFile.h */,
+				6B1FBD352B455DD600926382 /* PlayerViewController+backupsFile.m */,
 				183AE6B12A8C9F5800B11CB0 /* View */,
 				183AE6A52A8C9EA900B11CB0 /* RCCommandHelp.h */,
 				183AE6A72A8C9EAA00B11CB0 /* RCCommandHelp.m */,
@@ -1817,6 +1823,7 @@
 				6BFF26882AF8949F00FCB4F7 /* playerShowSecretkeyView.h in Headers */,
 				6BF0F3D52AD3937B000AA133 /* DeviceThirdIdModel.h in Headers */,
 				6B2170982B15CD9200656670 /* NSDictionary+Log.h in Headers */,
+				6B1FBD362B455DD600926382 /* PlayerViewController+backupsFile.h in Headers */,
 				18FCE5332AD12FE00020F623 /* ConnectTestViewController.h in Headers */,
 				181E84F22A8F0A9B00292B96 /* HelpDownScrollView.h in Headers */,
 				6B2170882B1444CC00656670 /* allVersionView.h in Headers */,
@@ -1838,7 +1845,6 @@
 				6B4D23B12B33DDBC005B718A /* imageVersionRenewTipView.h in Headers */,
 				6B8FF6BD2B04EB7100800981 /* uploadFileRecordBodyView.h in Headers */,
 				6B0582892B045E0B00D37290 /* uploadFileDataModel.h in Headers */,
-				6B1FBD2E2B45392800926382 /* PlayerViewController+fileTransfer.h in Headers */,
 				6BF52C972AD5546500A617DB /* SimplePing.h in Headers */,
 				6B3F96342AD2A15A008E349E /* netWorkManager.h in Headers */,
 				6B21708C2B14BDAA00656670 /* couldphoneSysInfoModel.h in Headers */,
@@ -1871,6 +1877,7 @@
 				6B5B60722B3D8098009A2AE2 /* fileTransferPathCheckTableViewCell.h in Headers */,
 				6B05819F2AFCF4E800D37290 /* AJPhotoListView.h in Headers */,
 				18963B462AB84398006E7C50 /* GuideView.h in Headers */,
+				6B1FBD322B455DBD00926382 /* PlayerViewController+upLoadFile.h in Headers */,
 				6B72725B2B0E22D000C03F87 /* uploadFileRecordBgScorllView.h in Headers */,
 				18A909982ABC4A3300E6D2BE /* ComontAlretViewController.h in Headers */,
 				6B7272532B0CABC600C03F87 /* cachesFileManager.h in Headers */,
@@ -2191,6 +2198,7 @@
 				A084D68E27E859D300054880 /* HWToolListCell.m in Sources */,
 				183AE6512A8A2CF000B11CB0 /* UIActivityIndicatorView+AFNetworking.m in Sources */,
 				A003F6A627D841C800715CBF /* BaseViewController.m in Sources */,
+				6B1FBD332B455DBD00926382 /* PlayerViewController+upLoadFile.m in Sources */,
 				18E557212A3C5D75005CC84B /* Calculator.m in Sources */,
 				A003F6ED27D84D9C00715CBF /* HWWebViewController.m in Sources */,
 				A031DD6D27EC1FCD00909527 /* HWBookmarkListCell.m in Sources */,
@@ -2223,6 +2231,7 @@
 				6B0582642AFF4B7D00D37290 /* PhotoPreviewViewController.m in Sources */,
 				A003F6B527D841EE00715CBF /* UIView+HWCategory.m in Sources */,
 				A003F6E227D8428200715CBF /* Const.m in Sources */,
+				6B1FBD372B455DD600926382 /* PlayerViewController+backupsFile.m in Sources */,
 				6B21708D2B14BDAA00656670 /* couldphoneSysInfoModel.m in Sources */,
 				A08A94FE27E9A4E400C544BB /* BGTool.m in Sources */,
 				183AE6072A89CE3C00B11CB0 /* JSONModelClassProperty.m in Sources */,
@@ -2319,7 +2328,6 @@
 				18C475502A8E0DB5006129C0 /* MySetViewController.m in Sources */,
 				A003F6C127D841FF00715CBF /* FLAnimatedImageView.m in Sources */,
 				6BF0F3D62AD3937B000AA133 /* DeviceThirdIdModel.m in Sources */,
-				6B1FBD2F2B45392800926382 /* PlayerViewController+fileTransfer.m in Sources */,
 				184C8ACD2A94557200F26650 /* HidenMaskSetViewController.m in Sources */,
 				6B5B607B2B3E71B6009A2AE2 /* filePathCreatTableViewCell.m in Sources */,
 				18963B472AB84398006E7C50 /* GuideView.m in Sources */,

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

@@ -0,0 +1,25 @@
+//
+//  PlayerViewController+backupsFile.h
+//  隐私保护
+//
+//  Created by xd h on 2024/1/3.
+//
+
+#import "PlayerViewController.h"
+#import "uploadFileDataModel.h"
+#import "RCCommandHelp.h"
+#import "uploadFileManager.h"
+#import "cachesFileManager.h"
+#import <MJExtension.h>
+#import "connectDeviceManager.h"
+#import "PlayerViewController+upLoadFile.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface PlayerViewController (backupsFile)
+- (void)beginGotoBackupsFileFun:(NSNotification *)notification;
+- (void)applyBackupsFileServiceResponseFun:(NSDictionary *)dataDict;
+- (void)backupsFileFunServiceResponseFun:(NSDictionary *)dataDict;
+@end
+
+NS_ASSUME_NONNULL_END

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

@@ -0,0 +1,404 @@
+//
+//  PlayerViewController+backupsFile.m
+//  隐私保护
+//
+//  Created by xd h on 2024/1/3.
+//
+
+#import "PlayerViewController+backupsFile.h"
+
+@implementation PlayerViewController (backupsFile)
+/*****************备份相关**********************************/
+- (void)beginGotoBackupsFileFun:(NSNotification *)notification
+{
+    photosBackupsTaskModel *uploadFileDataMod = [notification object];
+    //HLog(@"%@",uploadFileDataMod);
+    
+    
+    self.curPhotosBackupsTaskMod = uploadFileDataMod;
+    
+    if(![uploadFileDataMod isKindOfClass:[photosBackupsTaskModel class]]){
+        HLog(@"上传的文件类型不对");
+        return;
+    }
+    
+    [self ApplyBackupsFileFun];
+}
+
+#pragma mark 申请备份文件
+- (void)ApplyBackupsFileFun
+{
+    //if(!self.taskUid){
+        self.backupsTaskUid = [iTools getTaskUidStr];
+        self.backupsFileName = self.curPhotosBackupsTaskMod.filename;
+        if(self.curPhotosBackupsTaskMod.curUploadFileType == uploadFileTypeVideo){
+           
+        }
+        else{
+            self.backupsAllFileData = self.curPhotosBackupsTaskMod.imageData;
+        }
+        
+        self.backupsIndexOfUploadFlie = 0;
+        
+        //HLog(@"%@  %@",self.taskUid,self.fileName);
+        //self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
+    //}
+    
+    NSString * commandStr = [RCCommandHelp applyForBackupsFileBy:self.backupsTaskUid withFileName:self.backupsFileName withSavePath:@"/sdcard/DCIM/"];
+    
+    //NSString * commandStr = [RCCommandHelp applyForUploadFileBy:self.taskUid  filePath:self.fileName];
+    
+    [self.commandChannelManager rc_sendData:commandStr];
+}
+
+- (void)applyBackupsFileServiceResponseFun:(NSDictionary *)dataDict
+{
+    if([dataDict isKindOfClass:[NSDictionary class]]){
+        if ([[dataDict allKeys] containsObject:@"data"]) {
+            NSDictionary *data = dataDict[@"data"];
+
+            if ([[data allKeys] containsObject:@"status"]) {
+                NSString  *status = [data objectForKey:@"status"];
+                if(![status isKindOfClass:[NSString class]]){
+                    status = [[NSString  alloc] initWithFormat:@"%@",status];
+                }
+                
+                //if(1)
+                if([status isEqualToString:@"1"])
+                {
+                    [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
+                    
+                }else if ([status isEqualToString:@"0"]){
+                    if ([[data allKeys] containsObject:@"taskUid"]) {
+                        NSString *taskUid = data[@"taskUid"];
+                        if(![status isKindOfClass:[NSString class]]){
+                            taskUid = [[NSString  alloc] initWithFormat:@"%@",taskUid];
+                        }
+                        
+                        if(taskUid &&  [taskUid isEqualToString:self.taskUid]){
+                            
+                            NSNumber * fileLengthNum = @0;
+                            if ([[data allKeys] containsObject:@"fileLength"])
+                            {
+                                fileLengthNum = data[@"fileLength"];
+                            }
+                            
+                            if([fileLengthNum integerValue] == self.curPhotosBackupsTaskMod.totalBytes){
+                                self.taskUid = nil;
+                                
+                                [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
+                                HLog(@"hxd already 上传任务异常终止")
+                                return;
+                            }
+                            
+                            if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeImage){
+                                [self beginGotoBackupsImageFun:fileLengthNum];
+                            }
+                            else{
+                                //[self beginGotoUploadVidelFun:fileLengthNum];
+                            }
+                        }
+                    }
+                   
+                }
+            }
+        }
+        else{
+            //异常
+            [self tryAgainApplyBackupsFun];
+        }
+    }
+    else{
+        //异常
+        [self tryAgainApplyBackupsFun];
+    }
+}
+
+#pragma mark 遇到异常时 重新上传
+- (void)tryAgainApplyBackupsFun
+{
+    self.taskUid = nil;
+    [self ApplyBackupsFileFun];
+}
+
+#pragma mark 图片上传
+-(void)beginGotoBackupsImageFun:(NSNumber*)fileLengthNum{
+    
+    self.cutFileDataArr = [self fileCutPartsBy:self.backupsAllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
+    
+    if(!self.cutFileDataArr){
+        [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
+        return;
+    }
+    
+    //答复的taskUid 跟申请的一致 开发发送内容
+    [self upLoadFileFun];
+}
+
+- (void)backupsFileFunServiceResponseFun:(NSDictionary *)dataDict
+{
+    //"type":"backUpFileRandomRet","data":{"progress":"0\/1","filePath":"/sdcard/DCIM/IMG_0889.JPG","fileLenth":258066,"status":"0","msg":"success"}}
+    
+    if([dataDict isKindOfClass:[NSDictionary class]]){
+        if ([[dataDict allKeys] containsObject:@"data"]) {
+            NSDictionary *data = dataDict[@"data"];
+
+            if ([[data allKeys] containsObject:@"status"]) {
+                NSString  *status = [data objectForKey:@"status"];
+                if(![status isKindOfClass:[NSString class]]){
+                    status = [[NSString  alloc] initWithFormat:@"%@",status];
+                }
+                
+                if ([status isEqualToString:@"1"]) {
+                    [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
+                    
+                }else if ([status isEqualToString:@"0"]){
+                    
+                    NSNumber * fileLengthNum = @0;
+                    if ([[data allKeys] containsObject:@"fileLenth"])
+                    {
+                        fileLengthNum = data[@"fileLenth"];
+                    }
+                    
+                    [self handleBackupsingFun:fileLengthNum];
+                }
+            }
+        }
+        else{
+            //异常
+            [self tryAgainApplyBackupsFun];
+        }
+    }
+    else{
+        //异常
+        [self tryAgainApplyBackupsFun];
+    }
+    
+}
+
+#pragma mark 处理上传过程
+- (void)handleBackupsingFun:(NSNumber*)fileLengthNum
+{
+    if(self.isSuspendBackupsType){
+        //暂停
+//        self.taskUid = nil;
+//        NSInteger didUploadSize = fileLengthNum.longLongValue;
+//        [[uploadFileManager shareInstance] changeUploadFileState:uploadStateSuspend withDidUploadBytes:didUploadSize  withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
+//
+//        }];
+        
+        return;
+    }
+    
+    if(self.indexOfUploadFlie < self.cutFileDataArr.count -1) {
+        
+        NSInteger didUploadSize = fileLengthNum.longLongValue;
+        
+//        [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:didUploadSize withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
+//
+//        }];
+        
+        self.indexOfUploadFlie ++;
+        [self upLoadFileFun];
+    }
+    else if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo && fileLengthNum && fileLengthNum.longLongValue < self.curUploadFileDataMod.totalBytes){
+        //视频做了二次切割 不一定上传完了
+        HLog(@"视频上传传完一片 再来一片");
+        //[self beginGotoUploadVidelFun:fileLengthNum];
+    }
+    else{
+        HLog(@"上传完成");
+        
+//        [self clearUploadFileDataFun];
+//        [[uploadFileManager shareInstance] uploadFileDoneFun];
+    }
+}
+
+- (Byte)getBCC:(NSData *)data {
+    Byte bcc = 0;
+    unsigned char *bytes = (unsigned char *)[data bytes];
+    for (int i = 0; i < [data length]; i++) {
+        bcc = (Byte)(bcc ^ bytes[i]);
+    }
+    return bcc;
+}
+
+#pragma mark 文件切片
+-(NSMutableArray *)fileCutPartsBy:(NSData*)curData withDidUpLoadSize:(NSInteger)didLoadSize{
+ 
+    NSData * data = curData;
+    
+    NSUInteger allLength = data.length;
+    
+    NSUInteger subs = 1*1024*1024;//4096;//要切片的大小,我这里设置的是4096字节
+    //NSUInteger subs = 31*1024;//4096;//要切片的大小,内存没有暴增
+    
+    self.cutFileEachPieceSzie = subs;
+    
+    NSInteger index = 0;//起始位置
+    
+    if(didLoadSize != 0){
+        if (didLoadSize % subs != 0){
+            //出错了
+            return nil;
+        }
+        else{
+//            index = didLoadSize/subs;
+//            allLength = allLength - didLoadSize;
+            
+            self.indexOfUploadFlie = didLoadSize/subs;
+        }
+    }
+
+    NSMutableArray *dataArray =[NSMutableArray new];
+    
+    do {
+        //@autoreleasepool {
+            if (allLength>subs) {
+                
+                NSRange range =NSMakeRange(index*subs, subs);
+                
+                index++;
+                
+                //NSLog(@"%@",NSStringFromRange(range));
+                
+                [dataArray addObject:[data subdataWithRange:range]];
+                
+                allLength = allLength - subs;
+                
+            }else{
+                NSRange range = NSMakeRange(index*subs, allLength);
+                
+                //NSLog(@"%@",NSStringFromRange(range));
+                
+                [dataArray addObject:[data subdataWithRange:range]];
+                
+                allLength = 0;
+            }
+        //}
+        
+    } while (allLength>0);
+    
+    HLog(@"dataArray leng:%ld",dataArray.count);//最后得到切片的结果,数组里面是NSData对象
+
+    return dataArray;
+}
+
+// int转NSData
+- (NSData *)int2Data:(int)i{
+    Byte b0 = i & 0xff;
+    Byte b1 = i >> 8 & 0xff;
+    Byte b2 = i >> 16 & 0xff;
+    Byte b3 = i >> 24 & 0xff;
+    // 有大小端模式问题?
+    //Byte result[] = {b0, b1, b2, b3};
+    Byte result[] = {b3, b2, b1, b0};
+    return [NSData dataWithBytes:result length:sizeof(result)];
+}
+
+// short转NSData
+- (NSData *)short2Data:(short)i{
+    Byte b0 = i & 0xff;
+    Byte b1 = i >> 8 & 0xff;
+    // 有大小端模式问题?
+    //Byte result[] = {b0, b1, b2, b3};
+    Byte result[] = { b1, b0};
+    return [NSData dataWithBytes:result length:sizeof(result)];
+}
+
+#pragma mark 可以发送文件了
+/*
+文件数据字节流byte[]
+  格式1:下载日志文件压缩包
+       |head|msgType|taskId|    datalen            | curNum | totalNum|   data   |bcc校验|end|
+  长度:  1      1      6 (curNum+totalNum+data)        4         4      datalen- 8   1     1
+       0x68  0x0e                                                        0x16
+    bcc校验从第1位 也就是从msgType起 到 校验位前(不包含校验位)数据作bcc校验
+ */
+- (void)upLoadFileFun
+{
+    //HLog(@"上传文件%ld/%ld",self.indexOfUploadFlie +1,self.cutFileDataArr.count);
+    
+    if(self.cutFileDataArr.count <= self.indexOfUploadFlie)
+    {
+        return;
+    }
+    
+    //data
+    NSData *curData = self.cutFileDataArr[self.indexOfUploadFlie];
+    //HLog(@"headData:%@",curData);
+    
+    //head
+    unsigned char headNum = 104;
+    NSData *headData = [NSMutableData dataWithBytes:&headNum length:sizeof(headNum)];
+    //HLog(@"headData:%@",headData);
+    
+    //msgType
+    //unsigned char msgType = 12;
+    unsigned char msgType = 15;
+    NSData *msgTypeData = [NSMutableData dataWithBytes:&msgType length:sizeof(msgType)];
+    //HLog(@"msgTypeData:%@",msgTypeData);
+    
+    //taskId
+    NSData *taskIdData = [self.taskUid dataUsingEncoding:NSUTF8StringEncoding];
+    //HLog(@"taskIdData:%@",taskIdData);
+    
+    //datalen
+    //int datalenNum = int([curData length] +(4+4));
+    int datalenNum = [curData length] + (4+4);
+    //NSData *datalenData = [NSData dataWithBytes:&datalenNum length:sizeof(datalenNum)];
+    NSData *datalenData = [self int2Data:datalenNum];
+    //HLog(@"datalenData %@",datalenData);
+    
+    
+    //curNum
+    int curNum = (int)self.indexOfUploadFlie;
+    //NSData *curNumData = [NSData dataWithBytes:&curNum length:sizeof(curNum)];
+    NSData * curNumData = [self int2Data:curNum];
+    //HLog(@"curNumData:%@",curNumData);
+    
+    //totalNum
+    int totalNum = (int)self.cutFileDataArr.count;
+    //NSData *totalNumData = [NSData dataWithBytes:&totalNum length:sizeof(totalNum)];
+    NSData * totalNumData = [self int2Data:totalNum];
+    //HLog(@"totalNumData:%@",totalNumData);
+    
+
+    NSMutableData *checkBCCData = [NSMutableData new];
+    [checkBCCData appendData:msgTypeData];
+    [checkBCCData appendData:taskIdData];
+    [checkBCCData appendData:datalenData];
+    [checkBCCData appendData:curNumData];
+    [checkBCCData appendData:totalNumData];
+    [checkBCCData appendData:curData];
+    
+    long length = [curData length];
+    //HLog(@"curData length %d",length);
+    
+    Byte bccCheck = [self getBCC:checkBCCData];
+    //HLog(@"bcc 000 %d",bccCheck);
+    
+    //bcc校验
+    char bccNum = (char)bccCheck;
+    NSData *bccData = [NSMutableData dataWithBytes:&bccNum length:sizeof(bccNum)];
+    //HLog(@"%@",bccData);
+    
+    //end
+    unsigned char endNum = 22;
+    NSData *endData = [NSMutableData dataWithBytes:&endNum length:sizeof(endNum)];
+    //HLog(@"%@",endData);
+    
+    NSMutableData *sendData = [NSMutableData new];
+    [sendData appendData:headData];
+    [sendData appendData:checkBCCData];
+    [sendData appendData:bccData];
+    [sendData appendData:endData];
+    
+    //HLog(@"sendData length %ld",[sendData length]);
+    [self.commandChannelManager rc_sendData:sendData];
+    //HLog(@"文件上传sendData %@",sendData);
+}
+
+
+
+@end

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

@@ -1,5 +1,5 @@
 //
-//  PlayerViewController+fileTransfer.h
+//  PlayerViewController+upLoadFile.h
 //  隐私保护
 //
 //  Created by xd h on 2024/1/3.
@@ -14,16 +14,13 @@
 #import "connectDeviceManager.h"
 NS_ASSUME_NONNULL_BEGIN
 
-@interface PlayerViewController (fileTransfer)
+@interface PlayerViewController (upLoadFile)
 - (void)beginGotoUploadFileFun:(NSNotification *)notification;
 - (void)suspendUploadFileFun:(NSNotification *)notification;
 
 - (void)applyUploadFileServiceResponseFun:(NSDictionary *)dataDict;
 - (void)upLoadFileFunServiceResponseFun:(NSDictionary *)dataDict;
 
-- (void)beginGotoBackupsFileFun:(NSNotification *)notification;
-- (void)applyBackupsFileServiceResponseFun:(NSDictionary *)dataDict;
-- (void)backupsFileFunServiceResponseFun:(NSDictionary *)dataDict;
 @end
 
 NS_ASSUME_NONNULL_END

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

@@ -1,13 +1,13 @@
 //
-//  PlayerViewController+fileTransfer.m
+//  PlayerViewController+upLoadFile.m
 //  隐私保护
 //
 //  Created by xd h on 2024/1/3.
 //
 
-#import "PlayerViewController+fileTransfer.h"
+#import "PlayerViewController+upLoadFile.h"
 
-@implementation PlayerViewController (fileTransfer)
+@implementation PlayerViewController (upLoadFile)
 #pragma mark 监听文件开始的的通知
 - (void)beginGotoUploadFileFun:(NSNotification *)notification
 {
@@ -535,209 +535,5 @@
     self.isSuspendUploadType = YES;
 }
 
-/*****************备份相关**********************************/
-- (void)beginGotoBackupsFileFun:(NSNotification *)notification
-{
-    photosBackupsTaskModel *uploadFileDataMod = [notification object];
-    //HLog(@"%@",uploadFileDataMod);
-    
-    
-    self.curPhotosBackupsTaskMod = uploadFileDataMod;
-    
-    if(![uploadFileDataMod isKindOfClass:[photosBackupsTaskModel class]]){
-        HLog(@"上传的文件类型不对");
-        return;
-    }
-    
-    [self ApplyBackupsFileFun];
-}
-
-#pragma mark 申请备份文件
-- (void)ApplyBackupsFileFun
-{
-    //if(!self.taskUid){
-        self.taskUid = [iTools getTaskUidStr];
-        self.fileName = self.curPhotosBackupsTaskMod.filename;
-        if(self.curPhotosBackupsTaskMod.curUploadFileType == uploadFileTypeVideo){
-           
-        }
-        else{
-            self.AllFileData = self.curPhotosBackupsTaskMod.imageData;
-        }
-        
-        self.indexOfUploadFlie = 0;
-        
-        //HLog(@"%@  %@",self.taskUid,self.fileName);
-        //self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
-    //}
-    
-    NSString * commandStr = [RCCommandHelp applyForBackupsFileBy:self.taskUid withFileName:self.fileName withSavePath:@"/sdcard/DCIM/"];
-    
-    //NSString * commandStr = [RCCommandHelp applyForUploadFileBy:self.taskUid  filePath:self.fileName];
-    
-    [self.commandChannelManager rc_sendData:commandStr];
-}
-
-- (void)applyBackupsFileServiceResponseFun:(NSDictionary *)dataDict
-{
-    if([dataDict isKindOfClass:[NSDictionary class]]){
-        if ([[dataDict allKeys] containsObject:@"data"]) {
-            NSDictionary *data = dataDict[@"data"];
-
-            if ([[data allKeys] containsObject:@"status"]) {
-                NSString  *status = [data objectForKey:@"status"];
-                if(![status isKindOfClass:[NSString class]]){
-                    status = [[NSString  alloc] initWithFormat:@"%@",status];
-                }
-                
-                //if(1)
-                if([status isEqualToString:@"1"])
-                {
-                    [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
-                    
-                }else if ([status isEqualToString:@"0"]){
-                    if ([[data allKeys] containsObject:@"taskUid"]) {
-                        NSString *taskUid = data[@"taskUid"];
-                        if(![status isKindOfClass:[NSString class]]){
-                            taskUid = [[NSString  alloc] initWithFormat:@"%@",taskUid];
-                        }
-                        
-                        if(taskUid &&  [taskUid isEqualToString:self.taskUid]){
-                            
-                            NSNumber * fileLengthNum = @0;
-                            if ([[data allKeys] containsObject:@"fileLength"])
-                            {
-                                fileLengthNum = data[@"fileLength"];
-                            }
-                            
-                            if([fileLengthNum integerValue] == self.curPhotosBackupsTaskMod.totalBytes){
-                                self.taskUid = nil;
-                                
-                                [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
-                                HLog(@"hxd already 上传任务异常终止")
-                                return;
-                            }
-                            
-                            if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeImage){
-                                [self beginGotoBackupsImageFun:fileLengthNum];
-                            }
-                            else{
-                                [self beginGotoUploadVidelFun:fileLengthNum];
-                            }
-                        }
-                    }
-                   
-                }
-            }
-        }
-        else{
-            //异常
-            [self tryAgainApplyBackupsFun];
-        }
-    }
-    else{
-        //异常
-        [self tryAgainApplyBackupsFun];
-    }
-}
 
-#pragma mark 遇到异常时 重新上传
-- (void)tryAgainApplyBackupsFun
-{
-    self.taskUid = nil;
-    [self ApplyBackupsFileFun];
-}
-
-#pragma mark 图片上传
--(void)beginGotoBackupsImageFun:(NSNumber*)fileLengthNum{
-    
-    self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
-    
-    if(!self.cutFileDataArr){
-        [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
-        return;
-    }
-    
-    //答复的taskUid 跟申请的一致 开发发送内容
-    [self upLoadFileFun];
-}
-
-- (void)backupsFileFunServiceResponseFun:(NSDictionary *)dataDict
-{
-    //"type":"backUpFileRandomRet","data":{"progress":"0\/1","filePath":"/sdcard/DCIM/IMG_0889.JPG","fileLenth":258066,"status":"0","msg":"success"}}
-    
-    if([dataDict isKindOfClass:[NSDictionary class]]){
-        if ([[dataDict allKeys] containsObject:@"data"]) {
-            NSDictionary *data = dataDict[@"data"];
-
-            if ([[data allKeys] containsObject:@"status"]) {
-                NSString  *status = [data objectForKey:@"status"];
-                if(![status isKindOfClass:[NSString class]]){
-                    status = [[NSString  alloc] initWithFormat:@"%@",status];
-                }
-                
-                if ([status isEqualToString:@"1"]) {
-                    [[backupsFileManager shareInstance] getDataWrongToChangeFailFun];
-                    
-                }else if ([status isEqualToString:@"0"]){
-                    
-                    NSNumber * fileLengthNum = @0;
-                    if ([[data allKeys] containsObject:@"fileLenth"])
-                    {
-                        fileLengthNum = data[@"fileLenth"];
-                    }
-                    
-                    [self handleBackupsingFun:fileLengthNum];
-                }
-            }
-        }
-        else{
-            //异常
-            [self tryAgainApplyUploadFun];
-        }
-    }
-    else{
-        //异常
-        [self tryAgainApplyUploadFun];
-    }
-    
-}
-
-#pragma mark 处理上传过程
-- (void)handleBackupsingFun:(NSNumber*)fileLengthNum
-{
-    if(self.isSuspendUploadType){
-        //暂停
-//        self.taskUid = nil;
-//        NSInteger didUploadSize = fileLengthNum.longLongValue;
-//        [[uploadFileManager shareInstance] changeUploadFileState:uploadStateSuspend withDidUploadBytes:didUploadSize  withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
-//
-//        }];
-        
-        return;
-    }
-    
-    if(self.indexOfUploadFlie < self.cutFileDataArr.count -1) {
-        
-        NSInteger didUploadSize = fileLengthNum.longLongValue;
-        
-//        [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:didUploadSize withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
-//
-//        }];
-        
-        self.indexOfUploadFlie ++;
-        [self upLoadFileFun];
-    }
-    else if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo && fileLengthNum && fileLengthNum.longLongValue < self.curUploadFileDataMod.totalBytes){
-        //视频做了二次切割 不一定上传完了
-        HLog(@"视频上传传完一片 再来一片");
-        [self beginGotoUploadVidelFun:fileLengthNum];
-    }
-    else{
-        HLog(@"上传完成");
-        
-        [self clearUploadFileDataFun];
-        [[uploadFileManager shareInstance] uploadFileDoneFun];
-    }
-}
 @end

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

@@ -11,7 +11,8 @@
 #import "PlayerViewController+AdjustBtnFrame.h"
 #import "PlayerViewController+AppDelegate.h"
 #import "PlayerViewController+otherDelegate.h"
-#import "PlayerViewController+fileTransfer.h"
+#import "PlayerViewController+upLoadFile.h"
+#import "PlayerViewController+backupsFile.h"
 
 #import "AFNetworkReachabilityManager.h"
 #import <AVFoundation/AVFoundation.h>