Browse Source

1.代码暂存

huangxiaodong 1 year ago
parent
commit
cbe18d9a88

BIN
创维盒子/RayProxy/libzerotier-one.a


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

@@ -2810,7 +2810,7 @@
 				ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 15;
+				CURRENT_PROJECT_VERSION = 16;
 				DEVELOPMENT_TEAM = 6SV76WTUUR;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2889,7 +2889,7 @@
 				ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 15;
+				CURRENT_PROJECT_VERSION = 16;
 				DEVELOPMENT_TEAM = 6SV76WTUUR;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",

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

@@ -60,9 +60,9 @@ static downloadManager * cur_downloadManager = nil;
             NSMutableArray *failArr = [NSMutableArray new];
             NSMutableArray *doneArr = [NSMutableArray new];
             NSMutableArray *otherArr = [NSMutableArray new];
-            
+            if(array && array.count >0){
                 for (couldPhoneFileModel * curModel in array) {
-                
+                    
                     if(curModel.curDownloadStateType == downloadStateFail){
                         [failArr addObject:curModel];
                     }
@@ -73,7 +73,7 @@ static downloadManager * cur_downloadManager = nil;
                         [otherArr addObject:curModel];
                     }
                 }
-            
+            }
             NSLock *lock = [NSLock new];
             [lock lock];
             

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

@@ -804,6 +804,7 @@ ComontAlretViewControllerDelegate>
             
         } failure:^(NSError *error) {
             [self showNetErrorAlertFun:2];
+            [self WebSocketNeedRelinkFun];
         }];
     }
 }
@@ -1449,6 +1450,8 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 // 连接
 - (void)connectVideoServer {
     
+    internetVideoPort = [[connectDeviceManager shareInstance] tcpPortStr];
+    
     if(self.didRecyclResource){
         return;
     }
@@ -1472,6 +1475,7 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
     
     HLog(@"__连接ip__%@,端口__%@",ip,internetVideoPort);
     
+    [cachesFileManager writeLogsWithMsg:[[NSString alloc] initWithFormat:@"link ip %@,port %@",ip,internetVideoPort]];
     //
     RCCloudPhoneConnectType ConnectType = RCCloudPhoneConnectType_websocket;
     RCCloudPhoneVideoQuality VideoQuality = RCCloudPhoneVideoQuality_Default;//RCCloudPhoneVideoQuality_High;
@@ -2256,6 +2260,7 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
         return;
     }
     
+    [[connectDeviceManager shareInstance] tryReconnectFun];
     [self showNewIndicator];
     reConnectAccount = 0;
     [self tryAgain];
@@ -2292,6 +2297,10 @@ BOOL inReconnect = NO;
         return;
     }
 
+    if(linkFailAlretVC && linkFailAlretVC.view.tag == 2){
+        [self WebSocketNeedRelinkFun];//hxd add 20240229
+    }
+    
     [self reconnectDevice];
 }
 

+ 70 - 36
创维盒子/双子星云手机/CloudPlayer/View/USBInsertPopView.m

@@ -6,6 +6,7 @@
 //
 
 #import "USBInsertPopView.h"
+#import <Lottie/Lottie.h>
 
 @interface USBInsertPopView ()
 @property (nonatomic,strong) UIView* whiteBgView;
@@ -30,7 +31,7 @@
     [self addSubview:_whiteBgView];
     
     [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.height.mas_equalTo(390 + safeArea  + 20);
+        make.height.mas_equalTo(500 + safeArea  + 20);
         make.left.mas_equalTo(0.f);
         make.right.mas_equalTo(0.f);
         make.bottom.mas_equalTo(20.f);
@@ -73,45 +74,78 @@
         make.top.mas_equalTo(titleLab.mas_bottom).offset(10.f);
     }];
     
-    CGFloat imageW = SCREEN_W - 15.0*2;
-    CGFloat imageH = 184.0*imageW/343.0;
-    
-    UIImageView *topImage = [[UIImageView alloc] init];
-    topImage.image = [UIImage imageNamed:@"usb_pop_image"];
-    [_whiteBgView addSubview:topImage];
+    LOTAnimationView *animation = [LOTAnimationView animationNamed:@"usbInsertAnimation"];
+    animation.loopAnimation = YES;
+    //animation.contentMode = UIViewContentModeScaleAspectFill;
+    [_whiteBgView addSubview:animation];
+    [animation playWithCompletion:^(BOOL animationFinished) {
+      // Do Something
+    }];
     
-    [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.height.mas_equalTo(imageH);
-        make.width.mas_equalTo(imageW);
+    CGFloat animationImageW = SCREEN_W - 15.0*2;
+    CGFloat animationImageH = 232.0*animationImageW/343.0;
+    [animation mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(animationImageH);
+        make.width.mas_equalTo(animationImageW);
         make.left.mas_equalTo(15.f);
-        make.top.mas_equalTo(tip1Lab.mas_bottom).offset(20);
+        make.top.mas_equalTo(tip1Lab.mas_bottom).offset(0);
     }];
     
-    NSString *subTip1 = NSLocalizedString(@"disk_insertion_pop_tip_sub1",nil);
-    NSString *subTip2 = NSLocalizedString(@"disk_insertion_pop_tip_sub2",nil);
-    NSString *subTip3 = NSLocalizedString(@"disk_insertion_pop_tip_sub3",nil);
-  
-    NSArray *titleArr = @[subTip1,subTip2,subTip3];
-    CGFloat labelSpace = 10.0;
-    CGFloat labelWidth = (imageW -20)/3.0;
-    
-    for (int i=0; i<titleArr.count; i++) {
-        
-        UILabel *subTipLab = [[UILabel alloc] init];
-        subTipLab.text = titleArr[i];
-        subTipLab.numberOfLines = 0;
-        subTipLab.textAlignment = NSTextAlignmentCenter;
-        subTipLab.textColor = [UIColor hwColor:@"##0A132B" alpha:1.0];
-        subTipLab.font = [UIFont systemFontOfSize:14.0];
-        [topImage addSubview:subTipLab];
-        
-        [subTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.height.mas_equalTo(40);
-            make.width.mas_equalTo(labelWidth);
-            make.left.mas_equalTo(i*(labelSpace + labelWidth));
-            make.bottom.mas_equalTo(0);
-        }];
-    }
+    CGFloat imageW = SCREEN_W - 15.0*2;
+//    CGFloat imageH = 184.0*imageW/343.0;
+//
+//    UIImageView *topImage = [[UIImageView alloc] init];
+//    topImage.image = [UIImage imageNamed:@"usb_pop_image"];
+//    [_whiteBgView addSubview:topImage];
+//
+//    [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
+//        make.height.mas_equalTo(imageH);
+//        make.width.mas_equalTo(imageW);
+//        make.left.mas_equalTo(15.f);
+//        make.top.mas_equalTo(tip1Lab.mas_bottom).offset(20);
+//    }];
+//
+//    NSString *subTip1 = NSLocalizedString(@"disk_insertion_pop_tip_sub1",nil);
+//    NSString *subTip2 = NSLocalizedString(@"disk_insertion_pop_tip_sub2",nil);
+//    NSString *subTip3 = NSLocalizedString(@"disk_insertion_pop_tip_sub3",nil);
+//
+//    NSArray *titleArr = @[subTip1,subTip2,subTip3];
+//    CGFloat labelSpace = 10.0;
+//    CGFloat labelWidth = (imageW -20)/3.0;
+//
+//    for (int i=0; i<titleArr.count; i++) {
+//
+//        UILabel *subTipLab = [[UILabel alloc] init];
+//        subTipLab.text = titleArr[i];
+//        subTipLab.numberOfLines = 0;
+//        subTipLab.textAlignment = NSTextAlignmentCenter;
+//        subTipLab.textColor = [UIColor hwColor:@"##0A132B" alpha:1.0];
+//        subTipLab.font = [UIFont systemFontOfSize:14.0];
+//        [topImage addSubview:subTipLab];
+//
+//        [subTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
+//            make.height.mas_equalTo(40);
+//            make.width.mas_equalTo(labelWidth);
+//            make.left.mas_equalTo(i*(labelSpace + labelWidth));
+//            make.bottom.mas_equalTo(0);
+//        }];
+//    }
+    
+    NSString *bottomTipStr = NSLocalizedString(@"disk_insertion_pop_tip2",nil);
+    UILabel *bottomTipLab = [[UILabel alloc] init];
+    bottomTipLab.text = bottomTipStr;
+    //bottomTipLab.textAlignment = NSTextAlignmentCenter;
+    bottomTipLab.numberOfLines = 0;
+    bottomTipLab.textColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
+    bottomTipLab.font = [UIFont boldSystemFontOfSize:12.0];
+    [_whiteBgView addSubview:bottomTipLab];
+    
+    [bottomTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(50);
+        make.right.mas_equalTo(-15.f);
+        make.left.mas_equalTo(15.f);
+        make.top.mas_equalTo(animation.mas_bottom).offset(20.0);
+    }];
 
     UIButton *konwBut = [[UIButton alloc] init];
     [konwBut setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:UIControlStateNormal];

+ 2 - 0
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.h

@@ -42,6 +42,8 @@ typedef void (^netWork_DidEndByOK) (NSInteger didSuc); // 0 fail 1 suc -1 处理
 
 #pragma mark 保持卡密码
 -(void)updateCardInfoBySN:(NSString*)snStr withPwdStr:(NSString*)pwd didNetEnd:(netWork_DidEndByOK)didNetEndIsOK;
+
+- (void)tryReconnectFun;
 @end
 
 NS_ASSUME_NONNULL_END

+ 84 - 9
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.m

@@ -25,6 +25,8 @@ WHPingDelegate
     WHPingTester *whPingTester;
     
     BOOL didRuiYunInitOkType;
+    
+    BOOL disconnected_cb_type;//瑞云回调链接断开了
 }
 
 @property (nonatomic, strong) NSTimer *connectCheckTimer;
@@ -252,15 +254,11 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
     /// 3. 根据对端的 SDN ID 创建连接
     [RaylinkProxy.sharedManager createNewConnection:curSdnId];
     
-    /// 4. 创建 HttpService
-    self.tcpPort = [RaylinkProxy.sharedManager createHttpService:curSdnId];
-    self.tcpPortStr = [[NSString alloc] initWithFormat:@"%ld",self.tcpPort];
+
     
     self.socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
     
-    /// 6. 添加端口防火墙
-    [RaylinkProxy.sharedManager addSdnId:curSdnId allowPort:9300];
-    [RaylinkProxy.sharedManager addSdnId:curSdnId allowPort:9100];
+
    
     
     //[self.connectBtn setEnabled:NO];
@@ -317,15 +315,33 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
     
     
     if (status == 0) {
+        
+        /// 4. 创建 HttpService
+        self.tcpPort = [RaylinkProxy.sharedManager createHttpService:sdnId];
+        self.tcpPortStr = [[NSString alloc] initWithFormat:@"%ld",self.tcpPort];
+        
+        /// 5. 添加端口防火墙
+        [RaylinkProxy.sharedManager addSdnId:sdnId allowPort:9300];
+        [RaylinkProxy.sharedManager addSdnId:sdnId allowPort:9100];
+        
         [cachesFileManager writeLogsWithMsg:@"onProxyConnected connectToHost"];
         
         /// 6. 等待连接成功回调,创建 TCP socket 连接 HttpService 的端口
-        [self.socket connectToHost:@"127.0.0.1" onPort:self.tcpPort error:NULL];
+         NSError *error;
         
-        _curConnectDeviceState = DeviceConnectDeciceOk;
+        NSString*log1 =  [[NSString alloc] initWithFormat:@"onProxyConnected connectToHost begin %ld", (long)self.tcpPort];
+        [cachesFileManager writeLogsWithMsg:log1];
+        
+        [self.socket connectToHost:@"127.0.0.1" onPort:self.tcpPort error:&error];
         
+        NSString*log2 =  [[NSString alloc] initWithFormat:@"onProxyConnected connectToHost end %ld, self.socket = %@ error = %@", (long)self.tcpPort, self.socket, error];
+        [cachesFileManager writeLogsWithMsg:log2];
+        
+        _curConnectDeviceState = DeviceConnectDeciceOk;
         _Pre_sdnId = self.DeviceThirdIdMod.data.sdnId;
         
+        disconnected_cb_type = NO;
+    
 //        [self.connectBtn setTitle:@"连接成功" forState:UIControlStateDisabled];
 //        [self.sendBtn setEnabled:YES];
     } else {
@@ -336,6 +352,65 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
     }
 }
 
+- (void)OnProxyDisconnected_cb:(NSString *)sdnId {
+    [RaylinkProxy.sharedManager closeHttpService:sdnId];
+    [cachesFileManager writeLogsWithMsg:@"OnProxyDisconnected_cb"];
+    disconnected_cb_type = YES;
+}
+
+//瑞云sock 断开了 需要重连
+- (void)tryReconnectFun{
+    
+    [cachesFileManager writeLogsWithMsg:@"tryReconnect"];
+    if(!disconnected_cb_type){
+        [cachesFileManager writeLogsWithMsg:@"tryReconnect return"];
+        return;
+    }
+    
+    NSURL *logUrl = [[NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].firstObject URLByAppendingPathComponent:@"logs"];
+    
+    if (![NSFileManager.defaultManager fileExistsAtPath:logUrl.path]) {
+        [NSFileManager.defaultManager createDirectoryAtURL:logUrl withIntermediateDirectories:YES attributes:NULL error:NULL];
+    }
+    
+    dispatch_queue_t reinitProxyQueue = dispatch_queue_create("reinit_proxy", 0);
+    
+    
+    [cachesFileManager writeLogsWithMsg:@"tryReconnect initProxy 0"];
+    dispatch_async(reinitProxyQueue, ^{
+        NSData *sdnInfo = [NSData dataWithContentsOfURL:[[NSBundle.mainBundle bundleURL] URLByAppendingPathComponent:@"planet.1ali_3ry_peer"]];
+        
+        /// 1. 初始化代理库
+        [cachesFileManager writeLogsWithMsg:@"tryReconnect initProxy 1"];
+        self->disconnected_cb_type = NO;
+        [RaylinkProxy.sharedManager initProxy:logUrl.path rootSdnInfo:sdnInfo];
+        [cachesFileManager writeLogsWithMsg:@"tryReconnect initProxy 2"];
+    });
+    
+//    //KWeakSelf
+//    NSMutableDictionary *paraDict = [NSMutableDictionary new];
+//    if(self.DeviceThirdIdMod.data.sn){
+//        [paraDict setValue:self.DeviceThirdIdMod.data.sn forKey:@"sn"];
+//    }
+//
+//    [cachesFileManager writeLogsWithMsg:@"tryReconnect CommonGetWithCallBackCode"];
+//    [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id  _Nonnull responseObject) {
+//
+//        dispatch_async(self->initProxyQueue, ^{
+//            NSData *sdnInfo = [NSData dataWithContentsOfURL:[[NSBundle.mainBundle bundleURL] URLByAppendingPathComponent:@"planet.1ali_3ry_peer"]];
+//
+//            /// 1. 初始化代理库
+//            [RaylinkProxy.sharedManager initProxy:logUrl.path rootSdnInfo:sdnInfo];
+//            [cachesFileManager writeLogsWithMsg:@"tryReconnect initProxy"];
+//        });
+//
+//
+//    } failure:^(NSError * _Nonnull error) {
+//        HLog("网络报错");
+//    }];
+    
+}
+
 - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
     
     NSLog(@"didConnectToHost %d", port);
@@ -352,7 +427,7 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
     [thread start];
     
     /// 7. Socket 连接成功后,通过 socket  发送, self.peerPortTF 为对端服务端口
-    [sock writeData:[[NSString stringWithFormat:@"CONNECT 127.0.0.1:%@ HTTP/1.0\r\n\r\n", @"9100"] dataUsingEncoding:NSUTF8StringEncoding] withTimeout:-1 tag:0];
+    //[sock writeData:[[NSString stringWithFormat:@"CONNECT 127.0.0.1:%@ HTTP/1.0\r\n\r\n", @"9100"] dataUsingEncoding:NSUTF8StringEncoding] withTimeout:-1 tag:0];
 
     NSLog(@"readDataToData");