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

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

@@ -165,6 +165,12 @@
 		6B05828A2B045E0B00D37290 /* uploadFileDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0582882B045E0B00D37290 /* uploadFileDataModel.m */; };
 		6B1FBD222B43DAD200926382 /* backupsSetViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD202B43DAD200926382 /* backupsSetViewController.h */; };
 		6B1FBD232B43DAD200926382 /* backupsSetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1FBD212B43DAD200926382 /* backupsSetViewController.m */; };
+		6B1FBD262B4503E700926382 /* photosBackupsTaskModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD242B4503E700926382 /* photosBackupsTaskModel.h */; };
+		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 */; };
 		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 */; };
@@ -562,6 +568,12 @@
 		6B0582882B045E0B00D37290 /* uploadFileDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = uploadFileDataModel.m; sourceTree = "<group>"; };
 		6B1FBD202B43DAD200926382 /* backupsSetViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = backupsSetViewController.h; sourceTree = "<group>"; };
 		6B1FBD212B43DAD200926382 /* backupsSetViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = backupsSetViewController.m; sourceTree = "<group>"; };
+		6B1FBD242B4503E700926382 /* photosBackupsTaskModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = photosBackupsTaskModel.h; sourceTree = "<group>"; };
+		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>"; };
 		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>"; };
@@ -1073,6 +1085,8 @@
 				18FCE5472AD15E750020F623 /* PlayerViewController+AppDelegate.m */,
 				6B7B65562AD9227700BE8CB3 /* PlayerViewController+otherDelegate.h */,
 				6B7B65572AD9227700BE8CB3 /* PlayerViewController+otherDelegate.mm */,
+				6B1FBD2C2B45392800926382 /* PlayerViewController+fileTransfer.h */,
+				6B1FBD2D2B45392800926382 /* PlayerViewController+fileTransfer.m */,
 				183AE6B12A8C9F5800B11CB0 /* View */,
 				183AE6A52A8C9EA900B11CB0 /* RCCommandHelp.h */,
 				183AE6A72A8C9EAA00B11CB0 /* RCCommandHelp.m */,
@@ -1285,6 +1299,8 @@
 				6B0582772AFF7C6D00D37290 /* TZAssetModel+imageData.m */,
 				6B0582872B045E0B00D37290 /* uploadFileDataModel.h */,
 				6B0582882B045E0B00D37290 /* uploadFileDataModel.m */,
+				6B1FBD242B4503E700926382 /* photosBackupsTaskModel.h */,
+				6B1FBD252B4503E700926382 /* photosBackupsTaskModel.m */,
 			);
 			path = model;
 			sourceTree = "<group>";
@@ -1292,6 +1308,8 @@
 		6B0582822B0457A000D37290 /* uploadFileManager */ = {
 			isa = PBXGroup;
 			children = (
+				6B1FBD282B452B3800926382 /* backupsFileManager.h */,
+				6B1FBD292B452B3800926382 /* backupsFileManager.m */,
 				6B0582832B0457C400D37290 /* uploadFileManager.h */,
 				6B0582842B0457C400D37290 /* uploadFileManager.m */,
 				6B7272512B0CABC600C03F87 /* cachesFileManager.h */,
@@ -1795,6 +1813,7 @@
 				1810F9012AA1839C00322116 /* PhoneTimeInfoModel.h in Headers */,
 				6BA533382B16E65500D1CB5C /* TvStatusModel.h in Headers */,
 				6BBB35E22AE935C000E4A59B /* DDYLanguageTool.h in Headers */,
+				6B1FBD262B4503E700926382 /* photosBackupsTaskModel.h in Headers */,
 				6BFF26882AF8949F00FCB4F7 /* playerShowSecretkeyView.h in Headers */,
 				6BF0F3D52AD3937B000AA133 /* DeviceThirdIdModel.h in Headers */,
 				6B2170982B15CD9200656670 /* NSDictionary+Log.h in Headers */,
@@ -1814,10 +1833,12 @@
 				18FCE53E2AD136670020F623 /* PlayerViewController+AdjustBtnFrame.h in Headers */,
 				6B05815B2AFC851E00D37290 /* mySetHeadView.h in Headers */,
 				6BF52CAD2AD82EA500A617DB /* PlayerControlButTipView.h in Headers */,
+				6B1FBD2A2B452B3800926382 /* backupsFileManager.h in Headers */,
 				6B5B60652B3D5FD8009A2AE2 /* fileTransfeSetViewController.h in Headers */,
 				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 */,
@@ -2227,6 +2248,7 @@
 				183AE6532A8A2CF000B11CB0 /* AFImageDownloader.m in Sources */,
 				A003F6B327D841EE00715CBF /* UIColor+HZXColor.m in Sources */,
 				18E557222A3C5D75005CC84B /* CalculatorViewController.m in Sources */,
+				6B1FBD2B2B452B3800926382 /* backupsFileManager.m in Sources */,
 				6BFF269A2AFA16DA00FCB4F7 /* forgetSecretKeyViewController.m in Sources */,
 				18E5572F2A3C6141005CC84B /* UITextfield+NLLimit.m in Sources */,
 				183AE6B72A8CA0C100B11CB0 /* ShowImageView.m in Sources */,
@@ -2239,6 +2261,7 @@
 				183AE64D2A8A2CF000B11CB0 /* UIRefreshControl+AFNetworking.m in Sources */,
 				A003F6E327D8428200715CBF /* SceneDelegate.m in Sources */,
 				6B2170A12B15D39900656670 /* privacyModeTipViewController.m in Sources */,
+				6B1FBD272B4503E700926382 /* photosBackupsTaskModel.m in Sources */,
 				6B2170922B15BAE700656670 /* privacyModeViewController.m in Sources */,
 				183AE6552A8A2CF000B11CB0 /* AFHTTPSessionManager.m in Sources */,
 				183AE6582A8A2CF000B11CB0 /* AFNetworkReachabilityManager.m in Sources */,
@@ -2296,6 +2319,7 @@
 				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 */,

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

@@ -71,6 +71,9 @@
 /*上传文件删除通知*/
 #define uploadFileDeteleNotification                 @"uploadFileDeteleNot"
 
+/* 上传备份通知*/
+#define backupsFileBeginNotification                 @"backupsFileBeginNot"
+
 /*获取云机基本信息通知*/
 #define getCouldPhoneBaseInfoNotification                 @"getCouldPhoneBaseInfoNot"
 

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

@@ -0,0 +1,41 @@
+//
+//  photosBackupsTaskModel.h
+//  隐私保护
+//
+//  Created by xd h on 2024/1/3.
+//
+
+#import "JSONModel.h"
+#import "BGFMDB.h" //添加该头文件,本类就具有了存储功能.
+#import <Photos/Photos.h>
+#import "uploadFileDataModel.h"
+NS_ASSUME_NONNULL_BEGIN
+
+@interface photosBackupsTaskModel : JSONModel
+@property (nonatomic, assign) NSInteger count;       ///< Count of photos the album contain
+//@property (nonatomic, strong) PHFetchResult *result;
+//@property (nonatomic, strong) PHAssetCollection *collection;
+//@property (nonatomic, strong) PHFetchOptions *options;
+//@property (nonatomic, strong) NSArray *models;
+
+@property (nonatomic, copy) NSString *totalLocalIdentifier;
+@property (nonatomic, strong) NSArray *LocalIdentifierArr;
+@property (nonatomic, copy) NSString *filename;
+
+@property (nonatomic, assign) NSUInteger failCount;
+@property (nonatomic, assign) NSUInteger didBackupsCount;
+@property (nonatomic, assign) BOOL isSuspendType;
+@property (nonatomic, assign) BOOL isCompleteType;
+
+@property (nonatomic, retain) NSData *_Nullable imageData;//image
+
+@property (nonatomic, assign)  uploadStateType curUploadStateType;
+@property (nonatomic, assign)  uploadFileType curUploadFileType;
+@property (nonatomic, assign)  long didUploadBytes;//已经上传的字节数
+@property (nonatomic, assign)  long totalBytes;//总字节数
+@property (nonatomic, assign) NSTimeInterval  preTimeInterval;//计算速度用
+@property (nonatomic, assign) NSTimeInterval  curTimeInterval;//计算速度用
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 18 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/model/photosBackupsTaskModel.m

@@ -0,0 +1,18 @@
+//
+//  photosBackupsTaskModel.m
+//  隐私保护
+//
+//  Created by xd h on 2024/1/3.
+//
+
+#import "photosBackupsTaskModel.h"
+
+@implementation photosBackupsTaskModel
+/**
+ 设置不需要存储的属性, 在模型.m文件中实现该函数.
+ */
++(NSArray *)bg_ignoreKeys{
+   return @[@"LocalIdentifierArr",@"filename",@"imageData",
+            @"curUploadStateType",@"curUploadFileType",@"didUploadBytes",@"totalBytes",@"preTimeInterval",@"curTimeInterval"];
+}
+@end

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

@@ -0,0 +1,29 @@
+//
+//  backupsFileManager.h
+//  隐私保护
+//
+//  Created by xd h on 2024/1/3.
+//
+
+#import <Foundation/Foundation.h>
+#import "connectDeviceManager.h"
+#import "TZImageManager.h"
+#import "photosBackupsTaskModel.h"
+
+#define backups_photos_tableName [[NSString alloc] initWithFormat:@"backups_photos_tableName_%@",[connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn]
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface backupsFileManager : NSObject
+@property (nonatomic,strong) photosBackupsTaskModel* curPhotosBackupsTaskMod;
+
+
++(backupsFileManager *)shareInstance;
+
+
+//处理备份消息
+- (void)handlePhotosBackupsFun;
+- (void)getDataWrongToChangeFailFun;
+@end
+
+NS_ASSUME_NONNULL_END

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

@@ -0,0 +1,192 @@
+//
+//  backupsFileManager.m
+//  隐私保护
+//
+//  Created by xd h on 2024/1/3.
+//
+
+#import "backupsFileManager.h"
+
+@implementation backupsFileManager
+static backupsFileManager * cur_backupsFileShareInstance = nil;
++(backupsFileManager *)shareInstance;
+{
+    static dispatch_once_t onceToken;
+    
+    dispatch_once(&onceToken, ^{
+        cur_backupsFileShareInstance = [[backupsFileManager alloc] init];
+        
+    });
+    
+    return cur_backupsFileShareInstance;
+}
+
+- (id)init
+{
+    self = [super init];
+    
+    if (self) {
+        //[self initManager];
+    }
+    
+    return self;
+}
+
+- (void)handlePhotosBackupsFun
+{
+    BOOL haveOpenBackups = [HWDataManager getBoolWithKey:Const_photo_backups_state];
+    
+    if(!haveOpenBackups){
+        return;
+    }
+    
+    //相册权限
+    if (![[TZImageManager manager] authorizationStatusAuthorized]){
+        [HWDataManager setBoolWithKey:Const_photo_backups_state value:NO];
+        return;
+    }
+    
+    
+    [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
+        if(!array || array.count == 0){
+            [self getAllAlbumsFun];
+            return;
+        }
+        
+        photosBackupsTaskModel *lastModel = array.firstObject;
+        
+        if(lastModel.isSuspendType){
+            return;
+        }
+        
+        if(lastModel.isCompleteType){//上次备份完成
+            [self getAllAlbumsFun];
+        }
+        else{//继续上次的备份任务
+            [self handelBackupsModelFun:lastModel];
+        }
+    }];
+    
+}
+
+//备份开始查询相册
+- (void)getAllAlbumsFun
+{
+    //
+    [[TZImageManager manager] getAllAlbums:YES allowPickingImage:YES needFetchAssets:NO completion:^(NSArray<TZAlbumModel *> *models) {
+        
+        if(models.count >= 1){
+            TZAlbumModel *curAlbumModel= models.firstObject;
+            
+            photosBackupsTaskModel * taskModel = [photosBackupsTaskModel new];
+            taskModel.count = curAlbumModel.count;
+            //taskModel.result = curAlbumModel.result;
+            
+            taskModel.failCount = 0;
+            taskModel.didBackupsCount = 0;
+            taskModel.bg_tableName = backups_photos_tableName;
+            
+            NSMutableString *allLocalIdentifier= [NSMutableString new];
+            
+            for (PHAsset *asset in curAlbumModel.result) {
+                if (asset.localIdentifier) {
+                    if(allLocalIdentifier.length >0){
+                        [allLocalIdentifier appendString:@"&"];
+                    }
+                    [allLocalIdentifier appendString:asset.localIdentifier];
+                }
+            }
+            
+            taskModel.totalLocalIdentifier = allLocalIdentifier;
+            
+            [taskModel bg_saveAsync:^(BOOL isSuccess) {
+                if(!isSuccess){
+                    HLog(@"\n\nError!!!\n\n");
+                }
+                else{
+                    [self handelBackupsModelFun:taskModel];
+                }
+            }];
+        }
+    }];
+}
+
+- (void)handelBackupsModelFun:(photosBackupsTaskModel*)backupsTaskModel
+{
+    _curPhotosBackupsTaskMod = backupsTaskModel;
+    _curPhotosBackupsTaskMod.LocalIdentifierArr = [backupsTaskModel.totalLocalIdentifier componentsSeparatedByString:@"&"];
+    
+    if(_curPhotosBackupsTaskMod.LocalIdentifierArr.count
+       <= (_curPhotosBackupsTaskMod.didBackupsCount + _curPhotosBackupsTaskMod.failCount))
+    {
+        _curPhotosBackupsTaskMod.isCompleteType = YES;
+        [_curPhotosBackupsTaskMod bg_saveOrUpdateAsync:^(BOOL isSuccess) {
+                    
+        }];
+        
+        return;
+    }
+    
+    [self beginBackupsFileFun];
+}
+
+- (void)beginBackupsFileFun
+{
+    NSInteger index = _curPhotosBackupsTaskMod.didBackupsCount + _curPhotosBackupsTaskMod.failCount;
+    
+    if(index >= _curPhotosBackupsTaskMod.LocalIdentifierArr.count){
+        return;
+    }
+    
+    NSString *curLocalIdentifier = _curPhotosBackupsTaskMod.LocalIdentifierArr[index];
+    
+    if(!curLocalIdentifier || curLocalIdentifier.length == 0)
+    {
+        [self getDataWrongToChangeFailFun];
+        return;
+    }
+        
+    PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[curLocalIdentifier] options:nil];
+    PHAsset *asset = fetchResult.firstObject;
+    
+    _curPhotosBackupsTaskMod.filename = [asset valueForKey:@"filename"];
+    
+    
+    KWeakSelf
+    if(asset.mediaType == PHAssetMediaTypeImage){
+        _curPhotosBackupsTaskMod.curUploadFileType = uploadFileTypeImage;
+        [[PHImageManager defaultManager] requestImageDataForAsset:asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
+                // 直接得到最终的 NSData 数据
+                if (imageData) {
+                    [weakSelf  afterGetImageDataFun:imageData];
+                }
+                else{
+                    [weakSelf getDataWrongToChangeFailFun];
+                }
+        }];
+    }
+    else{
+        _curPhotosBackupsTaskMod.curUploadFileType = uploadFileTypeVideo;
+    }
+    
+}
+
+- (void)getDataWrongToChangeFailFun
+{
+    _curPhotosBackupsTaskMod.failCount += 1;
+    
+    [_curPhotosBackupsTaskMod bg_saveOrUpdateAsync:^(BOOL isSuccess) {
+                if(isSuccess){
+                    [self beginBackupsFileFun];
+                }
+    }];
+}
+
+- (void)afterGetImageDataFun:(NSData*)imageData
+{
+    _curPhotosBackupsTaskMod.imageData = imageData;
+    _curPhotosBackupsTaskMod.totalBytes = [imageData length];
+    [[NSNotificationCenter defaultCenter] postNotificationName:backupsFileBeginNotification object:_curPhotosBackupsTaskMod];
+}
+
+@end

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

@@ -7,6 +7,7 @@
 
 #import "uploadFileManager.h"
 #import <AssetsLibrary/AssetsLibrary.h>
+#import "photosBackupsTaskModel.h"
 
 @implementation uploadFileManager
 static uploadFileManager * cur_uploadFileShareInstance = nil;

+ 28 - 3
创维盒子/双子星云手机/Class/Set/view/mySetHeadView.m

@@ -6,6 +6,8 @@
 //
 
 #import "mySetHeadView.h"
+#import "TZImageManager.h"
+#import "backupsFileManager.h"
 
 @interface mySetHeadView ()
 {
@@ -465,6 +467,16 @@
     [HWDataManager setBoolWithKey:Const_photo_backups_state value:NO];
     [self setBackupsStateFun];
 }
+
+- (void)openImageBackupsFun
+{
+    [HWDataManager setBoolWithKey:Const_photo_backups_state value:YES];
+    [self setBackupsStateFun];
+    [[iToast makeText:NSLocalizedString(@"set_Privacy_title_image_open",nil)] show];
+    //处理相册备份
+    [[backupsFileManager shareInstance] handlePhotosBackupsFun];
+}
+
 - (void)setBackupsStateFun
 {
     BOOL haveOpenBackups = [HWDataManager getBoolWithKey:Const_photo_backups_state];
@@ -491,12 +503,25 @@
         BOOL haveOpenBackups = [HWDataManager getBoolWithKey:Const_photo_backups_state];
         
         if(!haveOpenBackups){
-            [HWDataManager setBoolWithKey:Const_photo_backups_state value:YES];
-            [self setBackupsStateFun];
-            [[iToast makeText:NSLocalizedString(@"set_Privacy_title_image_open",nil)] show];
+            //相册权限
+            if (![[TZImageManager manager] authorizationStatusAuthorized]){
+                [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
+                    if(status == PHAuthorizationStatusAuthorized){
+                        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                            [self openImageBackupsFun];
+                        });
+                        
+                    }
+                }];
+            }
+            else{
+                [self openImageBackupsFun];
+            }
+            
             return;
         }
         
+    
     }
     
     if(_didClickBut){

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

@@ -0,0 +1,29 @@
+//
+//  PlayerViewController+fileTransfer.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"
+NS_ASSUME_NONNULL_BEGIN
+
+@interface PlayerViewController (fileTransfer)
+- (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

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

@@ -0,0 +1,743 @@
+//
+//  PlayerViewController+fileTransfer.m
+//  隐私保护
+//
+//  Created by xd h on 2024/1/3.
+//
+
+#import "PlayerViewController+fileTransfer.h"
+
+@implementation PlayerViewController (fileTransfer)
+#pragma mark 监听文件开始的的通知
+- (void)beginGotoUploadFileFun:(NSNotification *)notification
+{
+    self.isSuspendUploadType = NO;
+    
+    uploadFileDataModel *uploadFileDataMod = [notification object];
+    //HLog(@"%@",uploadFileDataMod);
+    
+//    if(self.curUploadFileDataMod && uploadFileDataMod.bg_id.integerValue == self.curUploadFileDataMod.bg_id.integerValue){
+//        return;
+//    }
+    
+    self.curUploadFileDataMod = uploadFileDataMod;
+    
+    if(![uploadFileDataMod isKindOfClass:[uploadFileDataMod class]]){
+        HLog(@"上传的文件类型不对");
+        return;
+    }
+    
+    [self ApplyUploadFileFun];
+}
+
+- (void)applyUploadFileServiceResponseFun:(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"])
+                {
+                    //[self tryAgainApplyUploadFun];
+                    [self clearUploadFileDataFun];
+                    [[uploadFileManager shareInstance] uploadFileFailFun];
+                    
+                }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"];
+                            }
+                            
+                        //    [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:[fileLengthNum integerValue] withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
+                        //
+                        //    }];
+                            
+                            if([fileLengthNum integerValue] == self.curUploadFileDataMod.totalBytes){
+                                self.taskUid = nil;
+                                
+                                NSMutableArray *delArr = [NSMutableArray new];
+                                [delArr addObject:self.curUploadFileDataMod];
+                                [[uploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:NO complete:^(BOOL isSuccess) {
+                                    if (isSuccess) {
+                                        [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:self.curUploadFileDataMod];
+                                    }
+                                }];
+                                
+//                                mainBlock(^{
+//                                    [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
+//                                });
+                                
+                                HLog(@"hxd already 上传任务异常终止")
+                                return;
+                            }
+                            
+                            if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeImage){
+                                [self beginGotoUploadImageFun:fileLengthNum];
+                            }
+                            else{
+                                [self beginGotoUploadVidelFun:fileLengthNum];
+                            }
+                        }
+                    }
+                   
+                }
+            }
+        }
+        else{
+            //异常
+            [self tryAgainApplyUploadFun];
+        }
+    }
+    else{
+        //异常
+        [self tryAgainApplyUploadFun];
+    }
+}
+
+
+#pragma mark 图片上传
+-(void)beginGotoUploadImageFun:(NSNumber*)fileLengthNum{
+    
+    self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
+    
+    if(!self.cutFileDataArr){
+        [self clearUploadFileDataFun];
+        [[uploadFileManager shareInstance] uploadFileFailFun];
+        
+        self.taskUid = nil;
+        
+        mainBlock(^{
+            [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
+        });
+        HLog(@"hxd fail 上传任务异常终止")
+        return;
+    }
+    
+    //答复的taskUid 跟申请的一致 开发发送内容
+    [self upLoadFileFun];
+}
+
+
+#pragma mark 视频上传
+//每次从文件重新切一片 传一片
+-(void)beginGotoUploadVidelFun:(NSNumber*)fileLengthNum{
+    
+    NSData *data = [self cutVideoFileFunAtIndex:fileLengthNum.longLongValue];
+    HLog(@"data leng:%ld",[data length]);
+
+    self.AllFileData = data;
+    self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:0];
+    self.indexOfUploadFlie = 0;
+    HLog(@"data leng:%ld",[data length]);
+    
+    //return;
+
+//    NSString*videoPathStr = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo];
+//    self.AllFileData = [NSData dataWithContentsOfFile:videoPathStr];
+
+   // self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
+    
+    if(!self.cutFileDataArr){
+        [self clearUploadFileDataFun];
+        [[uploadFileManager shareInstance] uploadFileFailFun];
+        
+        self.taskUid = nil;
+        
+        mainBlock(^{
+            [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
+        });
+        HLog(@"hxd fail 上传任务异常终止")
+        return;
+    }
+    
+    //答复的taskUid 跟申请的一致 开发发送内容
+    [self upLoadFileFun];
+}
+
+#pragma mark 分段读视频文件
+-(NSData*)cutVideoFileFunAtIndex:(NSUInteger)dataIndex{
+    NSString *filePath = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo]; // 文件路径
+    
+    NSFileManager *manager0 = [NSFileManager defaultManager];
+    if(![manager0 fileExistsAtPath:filePath]) {
+     
+        return [NSData new];
+    }
+    
+    NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath]; // 创建文件句柄
+      
+    // 设置分段读取的大小,这里以每次读取1KB为例
+    //const NSUInteger chunkSize = 50 * 1024 *1024;
+    const NSUInteger chunkSize = 5 * 1024 *1024;
+    NSMutableData *data = [NSMutableData data];
+    
+    if (fileHandle) {
+       
+        long long endOfFile = [fileHandle seekToEndOfFile];
+        if (endOfFile >=  chunkSize) {
+            
+            // 读取文件的分段数据到某个位置
+            [fileHandle seekToFileOffset:dataIndex];
+            
+            // 读取文件的分段数据
+            NSData* chunk = [fileHandle readDataOfLength:chunkSize];
+            if (chunk) {
+                [data appendData:chunk];
+            }
+        }
+        else{
+            // 读取文件的分段数据到某个位置
+            [fileHandle seekToFileOffset:dataIndex];
+            
+            [data appendData:[fileHandle readDataToEndOfFile]];
+        }
+        
+        // 在这里可以对文件内容进行处理
+        // ...
+        
+        // 关闭文件句柄
+        [fileHandle closeFile];
+    }
+    
+    return data;
+}
+
+
+- (void)upLoadFileFunServiceResponseFun:(NSDictionary *)dataDict
+{
+    //{"type":"uploadFileRandomRet","data":{"progress":"9\/10","filePath":"/sdcard/Download/IMG_0036.JPG","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"]) {
+                    //[self tryAgainApplyUploadFun];
+                    [self clearUploadFileDataFun];
+                    [[uploadFileManager shareInstance] uploadFileFailFun];
+                    
+                }else if ([status isEqualToString:@"0"]){
+                    
+                    NSNumber * fileLengthNum = @0;
+                    if ([[data allKeys] containsObject:@"fileLenth"])
+                    {
+                        fileLengthNum = data[@"fileLenth"];
+                    }
+                    
+                    [self handleUploadingFun:fileLengthNum];
+                }
+            }
+        }
+        else{
+            //异常
+            [self tryAgainApplyUploadFun];
+        }
+    }
+    else{
+        //异常
+        [self tryAgainApplyUploadFun];
+    }
+    
+}
+
+#pragma mark 申请上传文件
+- (void)ApplyUploadFileFun
+{
+    //if(!self.taskUid){
+        self.taskUid = [iTools getTaskUidStr];
+        self.fileName = self.curUploadFileDataMod.filename;
+        if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
+            //self.AllFileData = self.curUploadFileDataMod.videoData;
+        }
+        else{
+            self.AllFileData = self.curUploadFileDataMod.imageData;
+        }
+        
+        self.indexOfUploadFlie = 0;
+        
+        //HLog(@"%@  %@",self.taskUid,self.fileName);
+        //self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
+    //}
+    
+    NSString * commandStr = [RCCommandHelp applyForUploadFileBy:self.taskUid  filePath:self.fileName];
+    [self.commandChannelManager rc_sendData:commandStr];
+}
+
+#pragma mark 遇到异常时 重新上传
+- (void)tryAgainApplyUploadFun
+{
+    self.taskUid = nil;
+    [self ApplyUploadFileFun];
+}
+
+#pragma mark 处理上传过程
+- (void)handleUploadingFun:(NSNumber*)fileLengthNum
+{
+    if(self.isSuspendUploadType){
+        //暂停
+        self.taskUid = nil;
+        //NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
+        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 = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
+        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];
+    }
+}
+
+-(void)clearUploadFileDataFun{
+    //上传数据清空
+    self.taskUid = nil;
+    self.fileName = nil;
+    self.AllFileData = nil;
+    self.indexOfUploadFlie = 0;
+    self.cutFileDataArr = nil;
+    self.curUploadFileDataMod = nil;
+    self.isSuspendUploadType = NO;
+    
+}
+
+- (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);
+}
+
+- (void)suspendUploadFileFun:(NSNotification *)notification
+{
+    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

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

@@ -6,8 +6,7 @@
 //
 
 #import "PlayerViewController.h"
-#import "uploadFileDataModel.h"
-#import "uploadFileManager.h"
+
 NS_ASSUME_NONNULL_BEGIN
 
 @interface PlayerViewController (otherDelegate)
@@ -21,13 +20,6 @@ NS_ASSUME_NONNULL_BEGIN
 //强制重启
 - (void)updateForceStartFun;
 
-- (void)beginGotoUploadFileFun:(NSNotification *)notification;
-- (void)suspendUploadFileFun:(NSNotification *)notification;
-
-- (void)applyUploadFileServiceResponseFun:(NSDictionary *)dataDict;
-- (void)upLoadFileFunServiceResponseFun:(NSDictionary *)dataDict;
-
-
 - (void)getCouldPhoneBaseInfoResponseFun:(NSDictionary *)dataDict;
 - (void)getCouldPhoneSysInfoResponseFun:(NSDictionary *)dataDict;
 - (void)getCouldPhoneTvStatusResponseFun:(NSDictionary *)dataDict;

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

@@ -202,530 +202,5 @@
     [self.view bringSubviewToFront:RenewTipView];
 }
 
-#pragma mark 监听文件开始的的通知
-- (void)beginGotoUploadFileFun:(NSNotification *)notification
-{
-    self.isSuspendUploadType = NO;
-    
-    uploadFileDataModel *uploadFileDataMod = [notification object];
-    //HLog(@"%@",uploadFileDataMod);
-    
-//    if(self.curUploadFileDataMod && uploadFileDataMod.bg_id.integerValue == self.curUploadFileDataMod.bg_id.integerValue){
-//        return;
-//    }
-    
-    self.curUploadFileDataMod = uploadFileDataMod;
-    
-    if(![uploadFileDataMod isKindOfClass:[uploadFileDataMod class]]){
-        HLog(@"上传的文件类型不对");
-        return;
-    }
-    
-    [self ApplyUploadFileFun];
-}
-
-- (void)applyUploadFileServiceResponseFun:(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"])
-                {
-                    //[self tryAgainApplyUploadFun];
-                    [self clearUploadFileDataFun];
-                    [[uploadFileManager shareInstance] uploadFileFailFun];
-                    
-                }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"];
-                            }
-                            
-                        //    [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:[fileLengthNum integerValue] withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
-                        //
-                        //    }];
-                            
-                            if([fileLengthNum integerValue] == self.curUploadFileDataMod.totalBytes){
-                                self.taskUid = nil;
-                                
-                                NSMutableArray *delArr = [NSMutableArray new];
-                                [delArr addObject:self.curUploadFileDataMod];
-                                [[uploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:NO complete:^(BOOL isSuccess) {
-                                    if (isSuccess) {
-                                        [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:self.curUploadFileDataMod];
-                                    }
-                                }];
-                                
-//                                mainBlock(^{
-//                                    [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
-//                                });
-                                
-                                HLog(@"hxd already 上传任务异常终止")
-                                return;
-                            }
-                            
-                            if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeImage){
-                                [self beginGotoUploadImageFun:fileLengthNum];
-                            }
-                            else{
-                                [self beginGotoUploadVidelFun:fileLengthNum];
-                            }
-                        }
-                    }
-                   
-                }
-            }
-        }
-        else{
-            //异常
-            [self tryAgainApplyUploadFun];
-        }
-    }
-    else{
-        //异常
-        [self tryAgainApplyUploadFun];
-    }
-}
-
-
-#pragma mark 图片上传
--(void)beginGotoUploadImageFun:(NSNumber*)fileLengthNum{
-    
-    self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
-    
-    if(!self.cutFileDataArr){
-        [self clearUploadFileDataFun];
-        [[uploadFileManager shareInstance] uploadFileFailFun];
-        
-        self.taskUid = nil;
-        
-        mainBlock(^{
-            [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
-        });
-        HLog(@"hxd fail 上传任务异常终止")
-        return;
-    }
-    
-    //答复的taskUid 跟申请的一致 开发发送内容
-    [self upLoadFileFun];
-}
-
-
-#pragma mark 视频上传
-//每次从文件重新切一片 传一片
--(void)beginGotoUploadVidelFun:(NSNumber*)fileLengthNum{
-    
-    NSData *data = [self cutVideoFileFunAtIndex:fileLengthNum.longLongValue];
-    HLog(@"data leng:%ld",[data length]);
-
-    self.AllFileData = data;
-    self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:0];
-    self.indexOfUploadFlie = 0;
-    HLog(@"data leng:%ld",[data length]);
-    
-    //return;
-
-//    NSString*videoPathStr = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo];
-//    self.AllFileData = [NSData dataWithContentsOfFile:videoPathStr];
-
-   // self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
-    
-    if(!self.cutFileDataArr){
-        [self clearUploadFileDataFun];
-        [[uploadFileManager shareInstance] uploadFileFailFun];
-        
-        self.taskUid = nil;
-        
-        mainBlock(^{
-            [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
-        });
-        HLog(@"hxd fail 上传任务异常终止")
-        return;
-    }
-    
-    //答复的taskUid 跟申请的一致 开发发送内容
-    [self upLoadFileFun];
-}
-
-#pragma mark 分段读视频文件
--(NSData*)cutVideoFileFunAtIndex:(NSUInteger)dataIndex{
-    NSString *filePath = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo]; // 文件路径
-    
-    NSFileManager *manager0 = [NSFileManager defaultManager];
-    if(![manager0 fileExistsAtPath:filePath]) {
-     
-        return [NSData new];
-    }
-    
-    NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath]; // 创建文件句柄
-      
-    // 设置分段读取的大小,这里以每次读取1KB为例
-    //const NSUInteger chunkSize = 50 * 1024 *1024;
-    const NSUInteger chunkSize = 5 * 1024 *1024;
-    NSMutableData *data = [NSMutableData data];
-    
-    if (fileHandle) {
-       
-        long long endOfFile = [fileHandle seekToEndOfFile];
-        if (endOfFile >=  chunkSize) {
-            
-            // 读取文件的分段数据到某个位置
-            [fileHandle seekToFileOffset:dataIndex];
-            
-            // 读取文件的分段数据
-            NSData* chunk = [fileHandle readDataOfLength:chunkSize];
-            if (chunk) {
-                [data appendData:chunk];
-            }
-        }
-        else{
-            // 读取文件的分段数据到某个位置
-            [fileHandle seekToFileOffset:dataIndex];
-            
-            [data appendData:[fileHandle readDataToEndOfFile]];
-        }
-        
-        // 在这里可以对文件内容进行处理
-        // ...
-        
-        // 关闭文件句柄
-        [fileHandle closeFile];
-    }
-    
-    return data;
-}
-
-
-- (void)upLoadFileFunServiceResponseFun:(NSDictionary *)dataDict
-{
-    //{"type":"uploadFileRandomRet","data":{"progress":"9\/10","filePath":"/sdcard/Download/IMG_0036.JPG","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"]) {
-                    //[self tryAgainApplyUploadFun];
-                    [self clearUploadFileDataFun];
-                    [[uploadFileManager shareInstance] uploadFileFailFun];
-                    
-                }else if ([status isEqualToString:@"0"]){
-                    
-                    NSNumber * fileLengthNum = @0;
-                    if ([[data allKeys] containsObject:@"fileLenth"])
-                    {
-                        fileLengthNum = data[@"fileLenth"];
-                    }
-                    
-                    [self handleUploadingFun:fileLengthNum];
-                }
-            }
-        }
-        else{
-            //异常
-            [self tryAgainApplyUploadFun];
-        }
-    }
-    else{
-        //异常
-        [self tryAgainApplyUploadFun];
-    }
-    
-}
-
-#pragma mark 申请上传文件
-- (void)ApplyUploadFileFun
-{
-    //if(!self.taskUid){
-        self.taskUid = [iTools getTaskUidStr];
-        self.fileName = self.curUploadFileDataMod.filename;
-        if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
-            //self.AllFileData = self.curUploadFileDataMod.videoData;
-        }
-        else{
-            self.AllFileData = self.curUploadFileDataMod.imageData;
-        }
-        
-        self.indexOfUploadFlie = 0;
-        
-        //HLog(@"%@  %@",self.taskUid,self.fileName);
-        //self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
-    //}
-    
-    NSString * commandStr = [RCCommandHelp applyForUploadFileBy:self.taskUid  filePath:self.fileName];
-    [self.commandChannelManager rc_sendData:commandStr];
-}
-
-#pragma mark 遇到异常时 重新上传
-- (void)tryAgainApplyUploadFun
-{
-    self.taskUid = nil;
-    [self ApplyUploadFileFun];
-}
-
-#pragma mark 处理上传过程
-- (void)handleUploadingFun:(NSNumber*)fileLengthNum
-{
-    if(self.isSuspendUploadType){
-        //暂停
-        self.taskUid = nil;
-        //NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
-        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 = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
-        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];
-    }
-}
-
--(void)clearUploadFileDataFun{
-    //上传数据清空
-    self.taskUid = nil;
-    self.fileName = nil;
-    self.AllFileData = nil;
-    self.indexOfUploadFlie = 0;
-    self.cutFileDataArr = nil;
-    self.curUploadFileDataMod = nil;
-    self.isSuspendUploadType = NO;
-    
-}
-
-- (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));
-    //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);
-}
-
-- (void)suspendUploadFileFun:(NSNotification *)notification
-{
-    self.isSuspendUploadType = YES;
-}
 
 @end

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

@@ -20,6 +20,8 @@
 //#import <RCCloudPhoneSDK/RCCommandChannel.h>
 #import <RCCloudPhoneSDK/RCLiveSteamManager.h>
 #import "imageVersionRenewTipView.h"
+#import "backupsFileManager.h"
+#import "photosBackupsTaskModel.h"
 
 @protocol PlayerViewControllerDelegate <NSObject>
 
@@ -110,6 +112,18 @@
 @property (nonatomic, strong) uploadFileDataModel *curUploadFileDataMod;
 @property (nonatomic, assign) BOOL isSuspendUploadType;
 
+//备份文件用到
+@property (nonatomic, copy) NSString * _Nullable backupsTaskUid;
+@property (nonatomic, copy) NSString * _Nullable backupsFileName;
+@property (nonatomic, strong) NSData * _Nullable backupsAllFileData;
+@property (nonatomic, strong) NSMutableArray * _Nullable backupsCutFileDataArr;
+@property (nonatomic, assign) NSInteger backupsIndexOfUploadFlie;
+//@property (nonatomic, assign) NSInteger cutFileEachPieceSzie;
+@property (nonatomic, strong) photosBackupsTaskModel *curPhotosBackupsTaskMod;
+@property (nonatomic, assign) BOOL isSuspendBackupsType;
+
+
+
 /**
  * @brief 云手机类型  VIP星动云手机  SVIP星曜云手机  STAR 唔即云手机
  */

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

@@ -11,6 +11,7 @@
 #import "PlayerViewController+AdjustBtnFrame.h"
 #import "PlayerViewController+AppDelegate.h"
 #import "PlayerViewController+otherDelegate.h"
+#import "PlayerViewController+fileTransfer.h"
 
 #import "AFNetworkReachabilityManager.h"
 #import <AVFoundation/AVFoundation.h>
@@ -717,6 +718,12 @@ ComontAlretViewControllerDelegate>
             else if ([messageType isEqualToString:@"uploadFileRandomRet"]){/*文件上传得到答复*/
                 [weakSelf upLoadFileFunServiceResponseFun:dataDict];
             }
+            else if ([messageType isEqualToString:@"backUpFileRandomReady"]){/*文件备份得到答复*/
+                [weakSelf applyBackupsFileServiceResponseFun:dataDict];
+            }
+            else if ([messageType isEqualToString:@"backUpFileRandomRet"]){/*文件备份得到答复*/
+                [weakSelf backupsFileFunServiceResponseFun:dataDict];
+            }
             else if ([messageType isEqualToString:@"getBaseInfo"]){/*获取云机的基本信息*/
                 [weakSelf getCouldPhoneBaseInfoResponseFun:dataDict];
             }
@@ -1602,6 +1609,10 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
             self->linkFailAlretVC = nil;
         });
     }
+    
+    
+    //处理相册备份
+    [[backupsFileManager shareInstance] handlePhotosBackupsFun];
 }
 
 #pragma mark 盒子第一次连接成功  给ws发送信息 单点登录 把其他账号挤下去
@@ -2284,6 +2295,7 @@ BOOL inReconnect = NO;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(beginGotoUploadFileFun:) name:uploadFileBeginNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspendUploadFileFun:) name:uploadFileSuspendNotification object:nil];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(beginGotoBackupsFileFun:) name:backupsFileBeginNotification object:nil];
 }
 
 - (void)removeNSNotification

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

@@ -195,6 +195,14 @@ NS_ASSUME_NONNULL_BEGIN
  * @param filePath 传file name
  */
 + (NSString *)applyForUploadFileBy:(NSString*)taskUid filePath:(NSString *)filePath;
+
+/**
+ * @brief 申请备份文件 请求
+ *
+ * @param taskUid
+ * @param fileName 传file name
+ */
++ (NSString *)applyForBackupsFileBy:(NSString*)taskUid withFileName:(NSString *)fileName withSavePath:(NSString *)savePath;
 @end
 
 NS_ASSUME_NONNULL_END

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

@@ -995,4 +995,20 @@
     return dataStr;
 }
 
++ (NSString *)applyForBackupsFileBy:(NSString*)taskUid withFileName:(NSString *)fileName withSavePath:(NSString *)savePath
+{
+    NSString *curPath = [[NSString alloc] initWithFormat:@"%@%@",savePath,fileName];
+    NSString *dataStr =[NSString stringWithFormat:@"{\"data\":{\"taskUid\":\"%@\",\"fileName\":\"%@\",\"savePath\":\"%@\"},\"type\":\"backUpFileRandom\"}",taskUid,fileName,curPath];
+    
+    if (USENEWCONTROLLCOMMONDNO500)
+    {
+//        dataStr = [self commondAppendingHeadAndEndStrWithSourStr:dataStr];
+    }
+    else
+    {
+        dataStr = [self commandAppending00StringWithSourStr:dataStr];
+    }
+    
+    return dataStr;
+}
 @end