Browse Source

1.修改单点登录bug

huangxiaodong 2 years ago
parent
commit
bf5498d28d

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

@@ -30,6 +30,7 @@
 @property(nonatomic, strong)   customLaunchView *customLaunchV;//
 
 @property(nonatomic, assign)   bool isQRCodeType;//第一次 扫码进来的
+@property (nonatomic, assign)  BOOL isLoginAgainType;// 单点登录 点重新登录进来的
 @end
 
 @implementation SceneDelegate
@@ -83,8 +84,11 @@
     
     //有设备了先去做链接准备  // 80bec9c5
     NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
-    if(SNStr){
-        [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr];
+    NSString *sdnId = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sdnId;
+    if(SNStr && !sdnId){
+        [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr didNetEnd:^(bool didSuc) {
+            
+        }];
     }
 
    
@@ -137,7 +141,23 @@
     
     //是否已经有密码了 有就是输入密码 没有就是设置密码
     NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
-
+    sdnId = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sdnId;
+    if(!sdnId){
+        HLog(@"没有拿到sdnId");
+        
+        [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr didNetEnd:^(bool didSuc) {
+            
+        }];
+        
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            mainBlock(^{
+                [self enterMainVCFromScene];
+            });
+        });
+        
+        return;
+    }
+    
     if(curPwd && curPwd.length > 0){
         /*设置密码*/
 //        inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
@@ -157,9 +177,16 @@
     
     //每次进入
     PlayerViewController *playerRootVC = [[PlayerViewController alloc] init];
+    if(self.isLoginAgainType){
+        playerRootVC.isLoginAgainType = self.isLoginAgainType;
+    }
+    playerRootVC.isPwdVCShow = YES;
+    
     BaseNavigationController *playerNav = [[BaseNavigationController alloc] initWithRootViewController:playerRootVC];
     self.window.rootViewController = playerNav;
     
+    self.isLoginAgainType = NO;
+    
     if(!_isQRCodeType){
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
             mainBlock(^{
@@ -394,7 +421,7 @@
         [self.window addSubview:_calculatorVC.view];
     }
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:ShowPwdVCNotification object:nil];
+    //[[NSNotificationCenter defaultCenter] postNotificationName:ShowPwdVCNotification object:nil];
 }
 
 - (void)closeCalculatorVC{
@@ -479,6 +506,12 @@
 
 
 - (void)guideOk:(NSNotification*)not{
+    
+    NSString *object = not.object;
+    if(object && [object isEqualToString:@"isLoginAgainType"]){
+        self.isLoginAgainType = YES;
+    }
+    
     [self enterMainVCFromScene];
 }
 

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

@@ -13,7 +13,7 @@
 - (void)okBtnClickPressed{
     //HLog("11111");
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:@"isLoginAgainType"];
 }
 - (void)cancelBtnClickPressed{
     HLog("强制退出app");

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

@@ -78,6 +78,13 @@
 /**0:初始状态  1:切换云手机超分  2:token失效超分*/
 @property (nonatomic, assign) NSInteger         rbdNotification;
 
+//第一次链接设备 要发送指令信息 实现单点登录
+@property (nonatomic, assign)BOOL didSendfristMsg;
+
+@property (nonatomic, assign) BOOL isPwdVCShow;//当前是否有密码页面
+//第一次链接设备 要发送指令信息 实现单点登录
+@property (nonatomic, assign)BOOL isLoginAgainType;
+
 
 /**
  * @brief 云手机类型  VIP星动云手机  SVIP星曜云手机  STAR 唔即云手机

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

@@ -140,7 +140,7 @@ ComontAlretViewControllerDelegate>
 
 //音频和图片是否可以刷新
 @property (nonatomic, assign) BOOL canShowImgAndVoiceType;
-@property (nonatomic, assign) BOOL isPwdVCShow;//当前是否有密码页面
+
 @end
 
 @implementation PlayerViewController
@@ -160,7 +160,6 @@ ComontAlretViewControllerDelegate>
     }
     canControl = YES;
     _canShowImgAndVoiceType = NO;
-    _isPwdVCShow = NO;
     
     //[self opencommandChannelManagerrc_openURL];
     //[self openbusinessCommandChannelManagerrc_openURL];
@@ -1463,12 +1462,23 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 }
 
 #pragma mark 盒子第一次连接成功  给ws发送信息 单点登录 把其他账号挤下去
-bool didSendfristMsg = NO;
+
 - (void)fristConnectNeedGiveAMsgFun{
-    if(!didSendfristMsg){
+    
+    if([self isPlayerViewIsTopVCFun]){
+        //等下再发
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            [self fristConnectNeedGiveAMsgFun];
+        });
+        return;
+    }
+    
+    if(!_didSendfristMsg || _isLoginAgainType){
         NSString *commondStr  = @"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\"}";
         [self send_data:commondStr];
-        didSendfristMsg = true;
+        _didSendfristMsg = true;
+        
+        _isLoginAgainType = false;
         //test code
         //[self LogoutByOtherFun];
     }
@@ -1514,16 +1524,31 @@ bool didSendfristMsg = NO;
     [self setShowImgAndVoiceTypeFun:YES];
 }
 
+#pragma mark 判断是否为密码界面登
+- (BOOL)isPlayerViewIsTopVCFun
+{
+    UIViewController*topVc = self.navigationController.viewControllers.lastObject;
+    if(_isPwdVCShow || ![topVc isKindOfClass:[PlayerViewController class]]){
+        return YES;
+    }
+    
+    return NO;
+}
+
 -(void)setShowImgAndVoiceTypeFun:(bool)isCan
 {
     if(isCan){//判断当前是否为最前面 才能播放
-        UIViewController*topVc = self.navigationController.viewControllers.lastObject;
         
-        if(_isPwdVCShow || ![topVc isKindOfClass:[PlayerViewController class]]){
+        if([self isPlayerViewIsTopVCFun]){
             return;
         }
         
         _canShowImgAndVoiceType = isCan;
+        
+        if(_isLoginAgainType ){
+            [self opencommandChannelManagerrc_openURL];
+            _isLoginAgainType = false;
+        }
     }
     else{
         _canShowImgAndVoiceType = isCan;
@@ -1863,7 +1888,7 @@ BOOL inReconnect = NO;
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowImgAndVoiceTypeFun) name:ShowImgAndVoiceNotification object:nil];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowPwdVCTypeFun) name:ShowPwdVCNotification object:nil];
+    //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowPwdVCTypeFun) name:ShowPwdVCNotification object:nil];
 }
 
 - (void)removeNSNotification