Explorar o código

1.关于启动输入密码相关

huangxiaodong %!s(int64=2) %!d(string=hai) anos
pai
achega
82036ba20f

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

@@ -152,6 +152,10 @@
 		6BF52C992AD5546500A617DB /* Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BF52C932AD5546500A617DB /* Reachability.h */; };
 		6BF52C9A2AD5546500A617DB /* WHPingTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF52C942AD5546500A617DB /* WHPingTester.m */; };
 		6BF52C9B2AD5546500A617DB /* SimplePing.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF52C952AD5546500A617DB /* SimplePing.m */; };
+		6BF52CA12AD7C2F600A617DB /* inputPWDViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BF52C9F2AD7C2F600A617DB /* inputPWDViewController.h */; };
+		6BF52CA22AD7C2F600A617DB /* inputPWDViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF52CA02AD7C2F600A617DB /* inputPWDViewController.m */; };
+		6BF52CA62AD7D3BE00A617DB /* customLaunchView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BF52CA42AD7D3BE00A617DB /* customLaunchView.h */; };
+		6BF52CA72AD7D3BE00A617DB /* customLaunchView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF52CA52AD7D3BE00A617DB /* customLaunchView.m */; };
 		6C21BF39CEECF8E81BD97788 /* libPods-双子星云手机Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 16C83602E592F43A82A92B3E /* libPods-双子星云手机Tests.a */; };
 		82762E13327622CA8A8512E6 /* libPods-隐私保护-双子星云手机UITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A7C795CAC690A410AE1E306 /* libPods-隐私保护-双子星云手机UITests.a */; };
 		A00221DB27EAFF4A00E45F78 /* HWAddBookmarkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A00221D927EAFF4A00E45F78 /* HWAddBookmarkViewController.m */; };
@@ -451,6 +455,10 @@
 		6BF52C932AD5546500A617DB /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; };
 		6BF52C942AD5546500A617DB /* WHPingTester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WHPingTester.m; sourceTree = "<group>"; };
 		6BF52C952AD5546500A617DB /* SimplePing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimplePing.m; sourceTree = "<group>"; };
+		6BF52C9F2AD7C2F600A617DB /* inputPWDViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = inputPWDViewController.h; sourceTree = "<group>"; };
+		6BF52CA02AD7C2F600A617DB /* inputPWDViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = inputPWDViewController.m; sourceTree = "<group>"; };
+		6BF52CA42AD7D3BE00A617DB /* customLaunchView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = customLaunchView.h; sourceTree = "<group>"; };
+		6BF52CA52AD7D3BE00A617DB /* customLaunchView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = customLaunchView.m; sourceTree = "<group>"; };
 		71D630B0FBD97501D316E4AB /* Pods-隐私保护.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-隐私保护.release.xcconfig"; path = "Target Support Files/Pods-隐私保护/Pods-隐私保护.release.xcconfig"; sourceTree = "<group>"; };
 		86FBD9FD629A5194B7C58D9F /* Pods-双子星云手机-双子星云手机UITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-双子星云手机-双子星云手机UITests.debug.xcconfig"; path = "Target Support Files/Pods-双子星云手机-双子星云手机UITests/Pods-双子星云手机-双子星云手机UITests.debug.xcconfig"; sourceTree = "<group>"; };
 		A00221D827EAFF4A00E45F78 /* HWAddBookmarkViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HWAddBookmarkViewController.h; sourceTree = "<group>"; };
@@ -692,6 +700,8 @@
 				186820242AB9B5BF005702A6 /* SetPWDFirstViewController.m */,
 				18EC79DA2ABC109F0084836A /* SetPWDSecondViewController.h */,
 				18EC79DB2ABC109F0084836A /* SetPWDSecondViewController.m */,
+				6BF52C9F2AD7C2F600A617DB /* inputPWDViewController.h */,
+				6BF52CA02AD7C2F600A617DB /* inputPWDViewController.m */,
 			);
 			path = Guide;
 			sourceTree = "<group>";
@@ -1022,6 +1032,15 @@
 			path = pingTool;
 			sourceTree = "<group>";
 		};
+		6BF52CA32AD7D3AA00A617DB /* customLaunchView */ = {
+			isa = PBXGroup;
+			children = (
+				6BF52CA42AD7D3BE00A617DB /* customLaunchView.h */,
+				6BF52CA52AD7D3BE00A617DB /* customLaunchView.m */,
+			);
+			path = customLaunchView;
+			sourceTree = "<group>";
+		};
 		A003F69D27D841C800715CBF /* Base */ = {
 			isa = PBXGroup;
 			children = (
@@ -1106,6 +1125,7 @@
 		A003F6D427D8428200715CBF /* AppDelegate */ = {
 			isa = PBXGroup;
 			children = (
+				6BF52CA32AD7D3AA00A617DB /* customLaunchView */,
 				A003F6D627D8428200715CBF /* Config */,
 				A003F6D527D8428200715CBF /* AppDelegate.h */,
 				A003F6DF27D8428200715CBF /* AppDelegate.m */,
@@ -1407,8 +1427,10 @@
 				18F9CB072ABD7835003FF71A /* QRCodeScanForChangeDeviceViewController.h in Headers */,
 				18664FF62AC2B3A4008F8A61 /* ShearDeviceUDPManager.h in Headers */,
 				18F9CAFF2ABD3643003FF71A /* ModifyPWDSecondViewController.h in Headers */,
+				6BF52CA12AD7C2F600A617DB /* inputPWDViewController.h in Headers */,
 				6BF52C982AD5546500A617DB /* WHPingTester.h in Headers */,
 				18FCE5392AD1351B0020F623 /* PlayerViewController.h in Headers */,
+				6BF52CA62AD7D3BE00A617DB /* customLaunchView.h in Headers */,
 				183AE7C72A8CB39100B11CB0 /* SafeForKey.h in Headers */,
 				186820252AB9B5BF005702A6 /* SetPWDFirstViewController.h in Headers */,
 			);
@@ -1698,6 +1720,7 @@
 				183AE6012A89CE3C00B11CB0 /* NSArray+JSONModel.m in Sources */,
 				A00221DB27EAFF4A00E45F78 /* HWAddBookmarkViewController.m in Sources */,
 				18664FF52AC2B3A4008F8A61 /* ShearDeviceUDPManager.m in Sources */,
+				6BF52CA22AD7C2F600A617DB /* inputPWDViewController.m in Sources */,
 				A003F6B627D841EE00715CBF /* UIColor+Colors.m in Sources */,
 				18E557292A3C60ED005CC84B /* PwdInPutView.m in Sources */,
 				18BB18422AC417CB00A36F63 /* RYShearDeviceUDPManager.m in Sources */,
@@ -1711,6 +1734,7 @@
 				A031DD6D27EC1FCD00909527 /* HWBookmarkListCell.m in Sources */,
 				183AE6052A89CE3C00B11CB0 /* JSONModelError.m in Sources */,
 				A08A950027E9A4E400C544BB /* FMDatabaseQueue.m in Sources */,
+				6BF52CA72AD7D3BE00A617DB /* customLaunchView.m in Sources */,
 				A031DD7A27EC713A00909527 /* HWSetViewController.m in Sources */,
 				183AE6022A89CE3C00B11CB0 /* JSONValueTransformer.m in Sources */,
 				183AE6522A8A2CF000B11CB0 /* AFAutoPurgingImageCache.m in Sources */,

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

@@ -18,10 +18,16 @@
 #import "ConnectTestViewController.h"
 #import "PlayerViewController.h"
 #import "connectDeviceManager.h"
+#import "inputPWDViewController.h"
+#import "customLaunchView.h"
+#import "RSATool.h"
 
 @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate>
 @property(nonatomic, strong)   CalculatorViewController *calculatorVC;
 @property(nonatomic, strong)   HWWebViewController *webVC;
+@property(nonatomic, strong)   inputPWDViewController *inputVC;
+@property(nonatomic, strong)   NSTimer *checkSNDataTimer;//
+@property(nonatomic, strong)   customLaunchView *customLaunchV;//
 @end
 
 @implementation SceneDelegate
@@ -91,7 +97,49 @@
         return;
     }
     
-    if (![[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
+//    if (![[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
+//        /*没有设置密码*/
+//        SetPWDFirstViewController *qrCodeVC = [[SetPWDFirstViewController alloc] init];
+//        BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
+//        self.window.rootViewController = qrCodeVCNav;
+//
+//        return;
+//    }
+    
+    //确保通过SN号拿到密码了
+    //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
+    if(![connectDeviceManager shareInstance].DeviceThirdIdMod){
+        if(!_checkSNDataTimer){
+            _checkSNDataTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(enterMainVCFromScene) userInfo:nil repeats:YES];
+            
+            BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
+            
+            //添加默认启动图片
+            if(!_customLaunchV && !haveOpenMask){
+                _customLaunchV = [[customLaunchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
+                [self.window addSubview:_customLaunchV];
+            }
+            
+        }
+        return;
+    }
+   
+    if(_checkSNDataTimer){
+        [_checkSNDataTimer invalidate];
+        [_customLaunchV removeFromSuperview];
+        _customLaunchV = nil;
+    }
+    
+    //是否已经有密码了 有就是输入密码 没有就是设置密码
+    NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
+
+    if(curPwd && curPwd.length > 0){
+        /*设置密码*/
+//        inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
+//        BaseNavigationController *nextVCNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
+//        self.window.rootViewController = nextVCNav;
+    }
+    else{
         /*没有设置密码*/
         SetPWDFirstViewController *qrCodeVC = [[SetPWDFirstViewController alloc] init];
         BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
@@ -100,10 +148,23 @@
         return;
     }
     
+   
+    
+    //每次进入
     PlayerViewController *playerRootVC = [[PlayerViewController alloc] init];
     BaseNavigationController *playerNav = [[BaseNavigationController alloc] initWithRootViewController:playerRootVC];
     self.window.rootViewController = playerNav;
     
+    BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
+    if (!haveOpenMask){
+        //输入密码界面
+        _inputVC = [[inputPWDViewController alloc] init];
+        [self.window addSubview:_inputVC.view];
+    }
+    else{
+        [self showCalculatorVC];
+    }
+    
 //    MySetViewController *playerRootVC = [[MySetViewController alloc] init];
 //    BaseNavigationController *playerNav = [[BaseNavigationController alloc] initWithRootViewController:playerRootVC];
 //    self.window.rootViewController = playerNav;
@@ -276,9 +337,12 @@
     /*无有效时长直接返回不加载任何加密界面*/
     NSString *str = nil;
     NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
+    
+    //本地密码补在判断 密码改在服务器保持
     if ([[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
         str = [deviceDict objectForKey:Const_Have_Add_Device_PWD];
     }
+
     
     if (!str || [str isEqualToString:@""])
     {

+ 16 - 0
创维盒子/双子星云手机/AppDelegate/customLaunchView/customLaunchView.h

@@ -0,0 +1,16 @@
+//
+//  customLaunchView.h
+//  隐私保护
+//
+//  Created by xd h on 2023/10/12.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface customLaunchView : UIView
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 27 - 0
创维盒子/双子星云手机/AppDelegate/customLaunchView/customLaunchView.m

@@ -0,0 +1,27 @@
+//
+//  customLaunchView.m
+//  隐私保护
+//
+//  Created by xd h on 2023/10/12.
+//
+
+#import "customLaunchView.h"
+
+
+@implementation customLaunchView
+
+- (id)initWithFrame:(CGRect)frame{
+    self = [super initWithFrame:frame];
+    
+    [self drawAnyView];
+    
+    return self;
+}
+
+-(void)drawAnyView
+{
+    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
+    imageView.image = [UIImage imageNamed:@"customLaunch"];
+    [self addSubview:imageView];
+}
+@end

+ 6 - 0
创维盒子/双子星云手机/Assets.xcassets/customLaunch/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 22 - 0
创维盒子/双子星云手机/Assets.xcassets/customLaunch/customLaunch.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "customLaunch@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "customLaunch@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN=BIN
创维盒子/双子星云手机/Assets.xcassets/customLaunch/customLaunch.imageset/customLaunch@2x.png


BIN=BIN
创维盒子/双子星云手机/Assets.xcassets/customLaunch/customLaunch.imageset/customLaunch@3x.png


+ 17 - 3
创维盒子/双子星云手机/Class/Guide/GuideViewController.m

@@ -12,6 +12,7 @@
 #import "GuideLastView.h"
 #import "SetPWDFirstViewController.h"
 #import "connectDeviceManager.h"
+#import "inputPWDViewController.h"
 
 @interface GuideViewController ()
 {
@@ -54,9 +55,22 @@
     if (index == 4){
         /*记录已经用户引导*/
         [HWDataManager setBoolWithKey:Const_Have_Show_Guide value:YES];
-        /*设置密码*/
-        SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
-        [self.navigationController pushViewController:nextVC animated:YES];
+        
+        //是否已经有密码了 有就是输入密码 没有就是设置密码
+        NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
+
+        if(curPwd && curPwd.length > 0){
+            /*设置密码*/
+            inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
+            [self.navigationController pushViewController:nextVC animated:YES];
+        }
+        else{
+            /*设置密码*/
+            SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
+            [self.navigationController pushViewController:nextVC animated:YES];
+        }
+        
+        
     }else{
         [bgScrView setContentOffset:CGPointMake((index + 1)*self.view.width, 0) animated:YES];
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

+ 16 - 0
创维盒子/双子星云手机/Class/Guide/inputPWDViewController.h

@@ -0,0 +1,16 @@
+//
+//  inputPWDViewController.h
+//  隐私保护
+//
+//  Created by xd h on 2023/10/12.
+//
+
+#import "BaseViewController.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface inputPWDViewController : BaseViewController
+
+@end
+
+NS_ASSUME_NONNULL_END

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

@@ -0,0 +1,421 @@
+//
+//  inputPWDViewController.m
+//  隐私保护
+//
+//  Created by xd h on 2023/10/12.
+//
+
+#import "inputPWDViewController.h"
+#import "connectDeviceManager.h"
+#import "RSATool.h"
+
+@interface inputPWDViewController (){
+    NSString *pwd;
+    UILabel *pointView0;
+    UILabel *pointView1;
+    UILabel *pointView2;
+    UILabel *pointView3;
+}
+
+@property(nonatomic,strong)UILabel *pwdErrorTip;
+
+@end
+
+@implementation inputPWDViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    pwd = @"";
+    [self drawAnyView];
+}
+
+
+- (void)drawAnyView{
+    [self.navigationBar setHidden:YES];
+    [self.toolBar setHidden:YES];
+    
+    [self.view setBackgroundColor:HWF5F7FAColor];
+    
+    /*设置密码标题*/
+    UILabel *topLabel = [[UILabel alloc] init];
+    [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
+    [topLabel setTextColor:HW333333Color];
+    [topLabel setTextAlignment:(NSTextAlignmentCenter)];
+    [topLabel setText:NSLocalizedString(@"guide_input_pwd_title",nil)];
+    [self.view addSubview:topLabel];
+    [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(20);
+        make.right.mas_equalTo(-20);
+        make.top.mas_equalTo(99.f + H_STATE_BAR);
+    }];
+    
+    CGFloat w_pwd = 24.f;
+    CGFloat h_pwd = 24.f;
+    
+    CGFloat pointFont = 20.f;
+    /*密码视图*/
+    pointView0 = [[UILabel alloc] init];
+    [pointView0 setTextColor:HW0A132BColor];
+    [pointView0 setBackgroundColor:HWE3E8F1Color];
+    [pointView0 setClipsToBounds:YES];
+    [pointView0 setTextAlignment:(NSTextAlignmentCenter)];
+    [pointView0 setFont:[UIFont systemFontOfSize:pointFont]];
+    [pointView0.layer setCornerRadius:w_pwd/2.f];
+    [self.view addSubview:pointView0];
+    [pointView0 mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.equalTo(self.view.mas_centerX).offset((0-2)*(w_pwd+w_pwd) + w_pwd/2.f);
+        make.height.mas_equalTo(h_pwd);
+        make.width.mas_equalTo(w_pwd);
+        make.top.mas_equalTo(151.f + H_STATE_BAR);
+    }];
+    
+    pointView1 = [[UILabel alloc] init];
+    [pointView1 setTextColor:HW0A132BColor];
+    [pointView1 setBackgroundColor:HWE3E8F1Color];
+    [pointView1 setClipsToBounds:YES];
+    [pointView1 setTextAlignment:(NSTextAlignmentCenter)];
+    [pointView1 setFont:[UIFont systemFontOfSize:pointFont]];
+    [pointView1.layer setCornerRadius:w_pwd/2.f];
+    [self.view addSubview:pointView1];
+    [pointView1 mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.equalTo(self.view.mas_centerX).offset((1-2)*(w_pwd+w_pwd) + w_pwd/2.f);
+        make.height.mas_equalTo(h_pwd);
+        make.width.mas_equalTo(w_pwd);
+        make.top.mas_equalTo(151.f + H_STATE_BAR);
+    }];
+    
+    pointView2 = [[UILabel alloc] init];
+    [pointView2 setTextColor:HW0A132BColor];
+    [pointView2 setBackgroundColor:HWE3E8F1Color];
+    [pointView2 setClipsToBounds:YES];
+    [pointView2 setTextAlignment:(NSTextAlignmentCenter)];
+    [pointView2 setFont:[UIFont systemFontOfSize:pointFont]];
+    [pointView2.layer setCornerRadius:w_pwd/2.f];
+    [self.view addSubview:pointView2];
+    [pointView2 mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.equalTo(self.view.mas_centerX).offset((2-2)*(w_pwd+w_pwd) + w_pwd/2.f);
+        make.height.mas_equalTo(h_pwd);
+        make.width.mas_equalTo(w_pwd);
+        make.top.mas_equalTo(151.f + H_STATE_BAR);
+    }];
+    
+    pointView3 = [[UILabel alloc] init];
+    [pointView3 setTextColor:HW0A132BColor];
+    [pointView3 setBackgroundColor:HWE3E8F1Color];
+    [pointView3 setClipsToBounds:YES];
+    [pointView3 setTextAlignment:(NSTextAlignmentCenter)];
+    [pointView3 setFont:[UIFont systemFontOfSize:pointFont]];
+    [pointView3.layer setCornerRadius:w_pwd/2.f];
+    [self.view addSubview:pointView3];
+    [pointView3 mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.equalTo(self.view.mas_centerX).offset((3-2)*(w_pwd+w_pwd) + w_pwd/2.f);
+        make.height.mas_equalTo(h_pwd);
+        make.width.mas_equalTo(w_pwd);
+        make.top.mas_equalTo(151.f + H_STATE_BAR);
+    }];
+    
+    /*下方绘制键盘按钮*/
+    UIView *bgViewForNumberBoard = [[UIView alloc] init];
+    [bgViewForNumberBoard setBackgroundColor:[UIColor clearColor]];
+    CGFloat w_bgViewForNumberBoard = SCREEN_W - 2*22.f*AUTOSCALE;
+    CGFloat h_bgViewForNumberBoard = 330.f;
+    [self.view addSubview:bgViewForNumberBoard];
+    [bgViewForNumberBoard mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(22.f*AUTOSCALE);
+        make.height.mas_equalTo(h_bgViewForNumberBoard);
+        make.width.mas_equalTo(w_bgViewForNumberBoard);
+        make.bottom.mas_equalTo(-70.f);
+    }];
+    
+    CGFloat w_key_btn = w_bgViewForNumberBoard/3.f;
+    CGFloat h_key_btn = h_bgViewForNumberBoard/4.f;
+    
+    /*绘制键盘 1~9*/
+    for (NSInteger nFori = 0; nFori < 9; nFori++) {
+        CGFloat x_key_btn = (nFori%3)*w_key_btn;
+        CGFloat y_key_btn = (nFori/3)*h_key_btn;
+        
+        UIButton *keyBoardBtn = [[UIButton alloc] init];
+        [keyBoardBtn setBackgroundColor:[UIColor clearColor]];
+        [keyBoardBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
+        [keyBoardBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
+        [keyBoardBtn setTitle:[NSString stringWithFormat:@"%ld",nFori+1] forState:(UIControlStateNormal)];
+        [keyBoardBtn addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
+        [bgViewForNumberBoard addSubview:keyBoardBtn];
+        [keyBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.left.mas_equalTo(x_key_btn);
+            make.top.mas_equalTo(y_key_btn);
+            make.width.mas_equalTo(w_key_btn);
+            make.height.mas_equalTo(h_key_btn);
+        }];
+    }
+    
+    /*删除按钮*/
+    UIButton *deleteBoardBtn = [[UIButton alloc] init];
+    [deleteBoardBtn setBackgroundColor:[UIColor clearColor]];
+    [deleteBoardBtn addTarget:self action:@selector(deleteBoardBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
+    [deleteBoardBtn setImage:[UIImage imageNamed:@"key_board_delete"] forState:(UIControlStateNormal)];
+    [bgViewForNumberBoard addSubview:deleteBoardBtn];
+    [deleteBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.bottom.mas_equalTo(0);
+        make.width.mas_equalTo(w_key_btn);
+        make.height.mas_equalTo(h_key_btn);
+    }];
+    
+    /*0*/
+    UIButton *keyBoardBtn0 = [[UIButton alloc] init];
+    [keyBoardBtn0 setBackgroundColor:[UIColor clearColor]];
+    [keyBoardBtn0 setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
+    [keyBoardBtn0.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
+    [keyBoardBtn0 setTitle:@"0" forState:(UIControlStateNormal)];
+    [keyBoardBtn0 addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
+    [bgViewForNumberBoard addSubview:keyBoardBtn0];
+    [keyBoardBtn0 mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(w_key_btn);
+        make.bottom.mas_equalTo(0);
+        make.width.mas_equalTo(w_key_btn);
+        make.height.mas_equalTo(h_key_btn);
+    }];
+    
+    /*OK*/
+    UIButton *keyBoardBtnOK = [[UIButton alloc] init];
+    [keyBoardBtnOK setBackgroundColor:[UIColor clearColor]];
+    [keyBoardBtnOK setTitleColor:HW13B2EBColor forState:(UIControlStateNormal)];
+    [keyBoardBtnOK.titleLabel setFont:[UIFont boldSystemFontOfSize:30.f]];
+    [keyBoardBtnOK setTitle:@"OK" forState:(UIControlStateNormal)];
+    [keyBoardBtnOK addTarget:self action:@selector(keyBoardBtnOKPressed) forControlEvents:(UIControlEventTouchUpInside)];
+    [bgViewForNumberBoard addSubview:keyBoardBtnOK];
+    [keyBoardBtnOK mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(2*w_key_btn);
+        make.bottom.mas_equalTo(0);
+        make.width.mas_equalTo(w_key_btn);
+        make.height.mas_equalTo(h_key_btn);
+    }];
+    
+    /*绘制引导视图*/
+    //[self addGuideView];
+}
+
+- (void)addGuideView{
+    UIView *bgView = [[UIView alloc] init];
+    [bgView setBackgroundColor:HW000000Color60];
+    [self.view addSubview:bgView];
+    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.bottom.mas_equalTo(0);
+        make.right.mas_equalTo(0);
+        make.top.mas_equalTo(0);
+    }];
+    
+    /*密码背景*/
+    UIView *pwdBgView = [[UIView alloc] init];
+    [pwdBgView setBackgroundColor:HWF5F7FAColor];
+    pwdBgView.layer.cornerRadius = 26.f;
+    [bgView addSubview:pwdBgView];
+    [pwdBgView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.centerX.equalTo(bgView.mas_centerX);
+        make.top.mas_equalTo(68.f + H_STATE_BAR);
+        make.width.mas_equalTo(248);
+        make.height.mas_equalTo(138);
+    }];
+    
+    /*密码*/
+    UILabel *topLabel = [[UILabel alloc] init];
+    [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
+    [topLabel setTextColor:HW333333Color];
+    [topLabel setTextAlignment:(NSTextAlignmentCenter)];
+    [topLabel setText:NSLocalizedString(@"guide_set_pwd_title",nil)];
+    [pwdBgView addSubview:topLabel];
+    [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(20);
+        make.right.mas_equalTo(-20);
+        make.top.mas_equalTo(31.f);
+    }];
+    
+    for (NSInteger nfori = 0; nfori < 4; nfori++) {
+        CGFloat w_pwd = 24.f;
+        CGFloat h_pwd = 24.f;
+        /*密码视图*/
+        UILabel *pointView = [[UILabel alloc] init];
+        [pointView setBackgroundColor:HWE3E8F1Color];
+        [pointView setClipsToBounds:YES];
+        [pointView.layer setCornerRadius:w_pwd/2.f];
+        [pwdBgView addSubview:pointView];
+        [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.left.mas_equalTo(40.f + (w_pwd + w_pwd)*nfori);
+            make.height.mas_equalTo(h_pwd);
+            make.width.mas_equalTo(w_pwd);
+            make.top.mas_equalTo(83.f);
+        }];
+    }
+    
+    /*箭头视图*/
+    UIImageView *flagImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_set_pwd_flag"]];
+    [bgView addSubview:flagImageView];
+    [flagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.equalTo(pwdBgView.mas_left).offset(49);
+        make.height.mas_equalTo(56);
+        make.width.mas_equalTo(14);
+        make.top.equalTo(pwdBgView.mas_bottom);
+    }];
+    
+    /*不可点击btn*/
+    UIButton *unableBtn = [[UIButton alloc] init];
+    unableBtn.frame = CGRectMake(0, 0, 250, 40.f);
+
+    // gradient
+    CAGradientLayer *gl = [CAGradientLayer layer];
+    gl.frame = CGRectMake(0,0,250,40.f);
+    gl.startPoint = CGPointMake(0, 0.5);
+    gl.endPoint = CGPointMake(1, 0.5);
+    gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
+    gl.locations = @[@(0), @(1.0f)];
+    
+    [unableBtn.layer addSublayer:gl];
+    [unableBtn setUserInteractionEnabled:NO];
+    [unableBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide",nil) forState:(UIControlStateNormal)];
+    [unableBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
+    [unableBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
+    [unableBtn.layer setCornerRadius:8.f];
+    unableBtn.clipsToBounds = YES;
+    [bgView addSubview:unableBtn];
+    [unableBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.equalTo(pwdBgView.mas_left).offset(16);
+        make.width.mas_equalTo(250);
+        make.top.equalTo(flagImageView.mas_bottom);
+        make.height.mas_equalTo(40.f);
+    }];
+    
+    UIButton *knowBtn = [[UIButton alloc] init];
+    [knowBtn setBackgroundColor:[UIColor clearColor]];
+    [knowBtn.layer setCornerRadius:18.f];
+    [knowBtn.layer setBorderColor:HWFFFFFFColor.CGColor];
+    [knowBtn.layer setBorderWidth:1];
+    [knowBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:(UIControlStateNormal)];
+    [knowBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
+    [knowBtn.titleLabel setFont:[UIFont systemFontOfSize:16]];
+    [bgView addSubview:knowBtn];
+    [knowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.right.equalTo(pwdBgView.mas_right).offset(-10);
+        make.width.mas_equalTo(120);
+        make.top.equalTo(unableBtn.mas_bottom).offset(25);
+        make.height.mas_equalTo(36.f);
+    }];
+    [knowBtn addTarget:bgView
+                action:@selector(removeFromSuperview)
+      forControlEvents:(UIControlEventTouchUpInside)];
+}
+
+- (void)deleteBoardBtnPressed{
+    if (pwd.length > 0){
+        NSInteger numberLength = pwd.length;
+        if (numberLength == 1){
+            [pointView0 setText:@""];
+            [pointView0 setBackgroundColor:HWE3E8F1Color];
+        }else if (numberLength == 2){
+            [pointView1 setText:@""];
+            [pointView1 setBackgroundColor:HWE3E8F1Color];
+        }else if (numberLength == 3){
+            [pointView2 setText:@""];
+            [pointView2 setBackgroundColor:HWE3E8F1Color];
+        }else if (numberLength == 4){
+            [pointView3 setText:@""];
+            [pointView3 setBackgroundColor:HWE3E8F1Color];
+        }
+        
+        pwd = [pwd substringToIndex:numberLength-1];
+    }
+}
+
+- (void)keyBoardBtnOKPressed{
+    if (pwd.length == 4){
+        /*进入下一级推拉流界面*/
+
+        //是否已经有密码了 有就是输入密码 没有就是设置密码
+        NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
+        
+        NSString*desPwdStr  = [RSATool AES128Decrypt:curPwd key:@"fvO8gAfNSr1tbdQe"];
+        
+        if([desPwdStr isEqualToString:pwd]){
+            //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;
+            }];
+        }
+    }
+}
+
+- (void)keyBoardBtnPressed:(id)sender{
+    UIButton *btn = (UIButton *)sender;
+    NSString *selectNumberStr = btn.titleLabel.text;
+    if (pwd.length < 4){
+        NSInteger numberLength = pwd.length;
+        if (numberLength == 0){
+            [pointView0 setText:selectNumberStr];
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                [self->pointView0 setBackgroundColor:HW0A132BColor];
+            });
+        }else if (numberLength == 1){
+            [pointView1 setText:selectNumberStr];
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                [self->pointView1 setBackgroundColor:HW0A132BColor];
+            });
+        }else if (numberLength == 2){
+            [pointView2 setText:selectNumberStr];
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                [self->pointView2 setBackgroundColor:HW0A132BColor];
+            });
+        }else if (numberLength == 3){
+            [pointView3 setText:selectNumberStr];
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                [self->pointView3 setBackgroundColor:HW0A132BColor];
+            });
+        }
+        
+        pwd = [pwd stringByAppendingString:selectNumberStr];
+    }
+}
+
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+    // Get the new view controller using [segue destinationViewController].
+    // Pass the selected object to the new view controller.
+}
+*/
+
+@end

+ 26 - 0
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.m

@@ -12,6 +12,7 @@
 #import <CocoaAsyncSocket/GCDAsyncSocket.h>
 
 #import "WHPingTester.h"
+#import "RSATool.h"
 
 @interface connectDeviceManager ()<
 GCDAsyncSocketDelegate,
@@ -70,6 +71,16 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
         if(weakSelf.DeviceThirdIdMod.status == 0)
         {
             weakSelf.curConnectDeviceState = DeviceConnectGetThridOK;
+            
+            NSString*desPwdstr = [RSATool AES128Decrypt:weakSelf.DeviceThirdIdMod.data.password key:@"fvO8gAfNSr1tbdQe"];
+            
+            /*密码保持在本地*/
+            NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
+            NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
+            [dict setObject:desPwdstr forKey:Const_Have_Add_Device_PWD];
+            [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
+            
+            
             NSString *ipStr = weakSelf.DeviceThirdIdMod.data.ip;
             [weakSelf startPingDeviceIp:ipStr];
             [weakSelf initRuiyunSDKFun];
@@ -156,6 +167,21 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
 
 - (void)onConnectFun{
     
+    // 2. 监听SDN 连接状态
+    bool connected = [RaylinkProxy.sharedManager isSdnConnected];
+    
+    HLog(@"协助瑞云看日志onConnectFun isSdnConnected:%d",connected);
+    
+    if(!connected){
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            mainBlock(^{
+                [self onConnectFun];
+            });
+        });
+        
+        return;
+    }
+    
     if (self.peerConnected == YES) {
         [self disconnect];
         return;

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

@@ -23,6 +23,12 @@ NS_ASSUME_NONNULL_BEGIN
 
 /**sn*/
 @property (nonatomic,copy) NSString *sn; //
+/***/
+@property (nonatomic,copy) NSString *firstTimeUpdatePassword; //
+/***/
+@property (nonatomic,assign) bool isFirstUpdatePassword; //
+/***/
+@property (nonatomic,copy) NSString *password; //
 
 /**自定义字段 是否为局域网*/
 @property (nonatomic,assign) bool isPingOk; //

+ 1 - 0
创维盒子/双子星云手机/en.lproj/Localizable.strings

@@ -66,6 +66,7 @@
 "logo_input_pwd_again_tips" = "请再次4位数密码";
 "logo_input_pwd_no_same_tips" = "两次密码不一致,请重新输入";
 "logo_set_pwd_success" = "修改启动密码成功";
+"logo_input_pwd_fail" = "输入错误,请重新输入";
 
 "app_update_title"   = "检测更新";
 "app_update_check"   = "版本检测";

+ 2 - 0
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -74,6 +74,7 @@
 "logo_input_pwd_again_tips" = "请再次4位数密码";
 "logo_input_pwd_no_same_tips" = "两次密码不一致,请重新输入";
 "logo_set_pwd_success" = "修改启动密码成功";
+"logo_input_pwd_fail" = "输入错误,请重新输入";
 
 "mask_view_hiden_set" = "进程隐藏设置";
 "mask_view_hiden_set_hiden" = "进程隐藏";
@@ -195,6 +196,7 @@
 "guide_set_pwd_no_same" = "两次密码不一致,请重新设置";
 "guide_set_pwd_makesure_title" = "请确认密码";
 "guide_set_pwd_guide" = "为你的private-x设置一个专属密码";
+"guide_input_pwd_title" = "请输入启动密码";
 "guide_set_pwd_guide_know" = "知道了";
 "guide_set_pwd_up_step" = "上一步";
 "guide_set_open_calcula_guide_tips" = "软件会伪装成计算器。在计算器页面输入您设置的启动密码输入成功可进入私密空间";