Ver código fonte

IOS端一台设备进入修改密码后,另外台设备提示被挤掉,点击重试需输入旧密码可正常进入推流

huangxiaodong 1 ano atrás
pai
commit
a9bf5b9ffd

+ 43 - 5
创维盒子/双子星云手机/Class/Calculator/CalculatorViewController.m

@@ -3,6 +3,7 @@
 #import "CalculatorViewController.h"
 #import <Masonry.h>
 #import "connectDeviceManager.h"
+#import "RSATool.h"
 
 @interface CalculatorViewController ()
 {
@@ -318,13 +319,50 @@
     }
     
     NSLog(@"tf.text = %@",tf.text);
-    if ([tf.text isEqualToString:pwd]){
-        [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
-        
-        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+    
+    if(tf.text.length == 4){
+        [self verifyPwdFun:tf.text];
+    }
+    
+//    if ([tf.text isEqualToString:pwd]){
+//        [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
+//
+//        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+//
+//        [self.view removeFromSuperview];
+//    }
+}
+
+#pragma mark 验证密码是否正确
+-(void)verifyPwdFun:(NSString*)text{
+    /*先判断本地有无设备 无设备时需要先扫码添加设备*/
+    NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
+    if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
+        //有设备了先去做链接准备  // 80bec9c5
+        NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
         
-        [self.view removeFromSuperview];
+        if(SNStr){
+            [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr didNetEnd:^(bool didSuc) {
+                
+                if(didSuc){
+                    NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
+                    NSString*desPwdStr  = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
+                    
+                    if ([desPwdStr isEqualToString:text]){
+                        [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
+                        
+                        [self.view removeFromSuperview];
+                        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+                    }
+                }
+                else{
+                    
+                }
+                
+            }];
+        }
     }
+    
 }
 
 //小数点限制方法

+ 45 - 8
创维盒子/双子星云手机/Class/Controller/HWWebViewController.m

@@ -18,6 +18,7 @@
 #import "HWHistoryModel.h"
 #import "iPhone.h"
 #import "connectDeviceManager.h"
+#import "RSATool.h"
 
 @interface HWWebViewController ()<WKScriptMessageHandler,WKNavigationDelegate,WKUIDelegate,HWToolViewControllerDelete>{
     UIView *bgView;/*引导视图*/
@@ -266,13 +267,18 @@
 #pragma mark - HWSearchBarDelegate
 - (void)searchBarWithText:(NSString *)text {
     HLog(@"搜索:%@", text)
-    if ([_pwd isEqualToString:text] && (_pwd.length == 4)){
-        [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
-        
-        [self.view removeFromSuperview];
-        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+    
+    if(text.length == 4){
+        [self verifyPwdFun:text];
     }
     
+//    if ([_pwd isEqualToString:text] && (_pwd.length == 4)){
+//        [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
+//        
+//        [self.view removeFromSuperview];
+//        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+//    }
+    
     if (text.length != 0) {
 
         if ([text hasPrefix:@"https://"] ||
@@ -288,12 +294,43 @@
 
 - (void)searchBarChangeText:(NSString *)text{
     HLog(@"\n----searchBarChangeText===%@-------",text);
-    if ([_pwd isEqualToString:text] && (_pwd.length == 4)){
-        [self.view removeFromSuperview];
-        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+    if (text.length == 4){
+        [self verifyPwdFun:text];
     }
 }
 
+#pragma mark 验证密码是否正确
+-(void)verifyPwdFun:(NSString*)text{
+    /*先判断本地有无设备 无设备时需要先扫码添加设备*/
+    NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
+    if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
+        //有设备了先去做链接准备  // 80bec9c5
+        NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
+        
+        if(SNStr){
+            [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr didNetEnd:^(bool didSuc) {
+                
+                if(didSuc){
+                    NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
+                    NSString*desPwdStr  = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
+                    
+                    if ([desPwdStr isEqualToString:text]){
+                        [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
+                        
+                        [self.view removeFromSuperview];
+                        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+                    }
+                }
+                else{
+                    
+                }
+                
+            }];
+        }
+    }
+    
+}
+
 #pragma mark - HWToolBarDelegate
 - (void)backBtnDidClick {
     HLog(@"后退");

+ 137 - 47
创维盒子/双子星云手机/Class/Guide/inputPWDViewController.m

@@ -332,59 +332,149 @@
 - (void)keyBoardBtnOKPressed{
     if (pwd.length == 4){
         /*进入下一级推拉流界面*/
-
-        //是否已经有密码了 有就是输入密码 没有就是设置密码
-        NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
         
-        NSString*desPwdStr  = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
+        [self verifyPwdFun:pwd];
+        return;
+    
+
+//        //是否已经有密码了 有就是输入密码 没有就是设置密码
+//        NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
+//
+//        NSString*desPwdStr  = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
+//
+//        if([desPwdStr isEqualToString:pwd]){
+//            [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
+//            if(_isQRCodeType){
+//                [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
+//            }
+//
+//            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+//                [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+//            });
+//
+//            //view 加载在windows上
+//            [self.view removeFromSuperview];
+//
+//        }
+//        else{
+//            [self deleteBoardBtnPressed];
+//            [self deleteBoardBtnPressed];
+//            [self deleteBoardBtnPressed];
+//            [self deleteBoardBtnPressed];
+//
+//            //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show];
+//            //[[iToast makeText:@"111"] show];
+//
+//            _pwdErrorTip = [[UILabel alloc] init];
+//            _pwdErrorTip.text = NSLocalizedString(@"logo_input_pwd_fail",nil);
+//            _pwdErrorTip.textAlignment = NSTextAlignmentCenter;
+//            _pwdErrorTip.textColor = [UIColor whiteColor];
+//            _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7];
+//            [self.view addSubview:_pwdErrorTip];
+//
+//            _pwdErrorTip.layer.masksToBounds = YES;
+//            _pwdErrorTip.layer.cornerRadius = 10;
+//
+//            [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) {
+//                make.center.mas_equalTo(0);
+//                make.width.mas_equalTo(200);
+//                make.height.mas_equalTo(40.f);
+//            }];
+//
+//            ///
+//            [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
+//
+//                [self->_pwdErrorTip removeFromSuperview];
+//                self->_pwdErrorTip = nil;
+//            }];
+//        }
+    }
+}
+
+#pragma mark 验证密码是否正确
+-(void)verifyPwdFun:(NSString*)text
+{
+    /*先判断本地有无设备 无设备时需要先扫码添加设备*/
+    NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
+    if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
+        //有设备了先去做链接准备  // 80bec9c5
+        NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
         
-        if([desPwdStr isEqualToString:pwd]){
-            [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
-            if(_isQRCodeType){
-                [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
-            }
-           
-            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-                [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
-            });
-            
-            //view 加载在windows上
-            [self.view removeFromSuperview];
-            
-        }
-        else{
-            [self deleteBoardBtnPressed];
-            [self deleteBoardBtnPressed];
-            [self deleteBoardBtnPressed];
-            [self deleteBoardBtnPressed];
-            
-            //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show];
-            //[[iToast makeText:@"111"] show];
-            
-            _pwdErrorTip = [[UILabel alloc] init];
-            _pwdErrorTip.text = NSLocalizedString(@"logo_input_pwd_fail",nil);
-            _pwdErrorTip.textAlignment = NSTextAlignmentCenter;
-            _pwdErrorTip.textColor = [UIColor whiteColor];
-            _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7];
-            [self.view addSubview:_pwdErrorTip];
-            
-            _pwdErrorTip.layer.masksToBounds = YES;
-            _pwdErrorTip.layer.cornerRadius = 10;
-            
-            [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) {
-                make.center.mas_equalTo(0);
-                make.width.mas_equalTo(200);
-                make.height.mas_equalTo(40.f);
-            }];
-            
-            ///
-            [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
+        if(SNStr){
+            [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr didNetEnd:^(bool didSuc) {
+                
+                if(didSuc){
+                    NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
+                    NSString*desPwdStr  = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
+                    
+                    if ([desPwdStr isEqualToString:text]){
+                        [self verifyPwdRightFun];
+                    }
+                    else{
+                        [self verifyPwdWrongFun];
+                    }
+                    
+                }
+                else{
+                    [self verifyPwdWrongFun];
+                }
                 
-                [self->_pwdErrorTip removeFromSuperview];
-                self->_pwdErrorTip = nil;
             }];
         }
     }
+    
+}
+
+#pragma mark 验证密码正常
+-(void)verifyPwdRightFun
+{
+    [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
+    if(_isQRCodeType){
+        [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
+    }
+   
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+    });
+    
+    //view 加载在windows上
+    [self.view removeFromSuperview];
+    
+}
+
+#pragma mark 验证密码错误
+-(void)verifyPwdWrongFun
+{
+    [self deleteBoardBtnPressed];
+    [self deleteBoardBtnPressed];
+    [self deleteBoardBtnPressed];
+    [self deleteBoardBtnPressed];
+    
+    //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show];
+    //[[iToast makeText:@"111"] show];
+    
+    _pwdErrorTip = [[UILabel alloc] init];
+    _pwdErrorTip.text = NSLocalizedString(@"logo_input_pwd_fail",nil);
+    _pwdErrorTip.textAlignment = NSTextAlignmentCenter;
+    _pwdErrorTip.textColor = [UIColor whiteColor];
+    _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7];
+    [self.view addSubview:_pwdErrorTip];
+    
+    _pwdErrorTip.layer.masksToBounds = YES;
+    _pwdErrorTip.layer.cornerRadius = 10;
+    
+    [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.center.mas_equalTo(0);
+        make.width.mas_equalTo(200);
+        make.height.mas_equalTo(40.f);
+    }];
+    
+    ///
+    [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
+        
+        [self->_pwdErrorTip removeFromSuperview];
+        self->_pwdErrorTip = nil;
+    }];
 }
 
 - (void)keyBoardBtnPressed:(id)sender{

+ 5 - 2
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.m

@@ -65,9 +65,12 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
     KWeakSelf
     [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id  _Nonnull responseObject) {
         
-        
-        weakSelf.DeviceThirdIdMod = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
+        DeviceThirdIdModel *model = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
 
+        if(model && model.data){
+            weakSelf.DeviceThirdIdMod = model;
+        }
+       
         if(weakSelf.DeviceThirdIdMod.status == 0
            && weakSelf.DeviceThirdIdMod.data)
         {