123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172 |
- //
- // SceneDelegate.m
- // Private-X
- //
- // Created by 余衡武 on 2021/12/8.
- //
- #import "SceneDelegate.h"
- #import "HWWebViewController.h"
- #import "CalculatorViewController.h"
- #import "SetUsePWDViewController.h"
- #import "GuideViewController.h"
- #import "BaseNavigationController.h"
- #import "MySetViewController.h"
- #import "SafeForKey.h"
- #import "TipsQRCodeViewController.h"
- #import "SetPWDFirstViewController.h"
- #import "connectDeviceManager.h"
- #import "inputPWDViewController.h"
- #import "customLaunchView.h"
- #import "RSATool.h"
- #import "forgetPwdViewController.h"
- #import "TipsQRCodeForChangeDeviceViewController.h"
- #import "AFNetworkReachabilityManager.h"
- #import "ComontAlretViewController.h"
- #import "uploadFileManager.h"
- //#import "downloadManager.h"
- #import "nasDownloadFileManager.h"
- //#import "backupsFileManager.h"
- #import "nasBackupsManager.h"
- #import "iPhone.h"
- #import <WXApi.h>
- #import <TencentOpenAPI/QQApiInterface.h>
- #import <TencentOpenAPI/TencentOAuth.h>
- #import "NASMsgModel.h"
- #import "queryOneShareModel.h"
- #import "boxSaveFileManager.h"
- #import "boxDownloadFileManager.h"
- #import "NASViewController.h"
- #import "cloudPhoneViewController.h"
- #import "mineViewController.h"
- #import "lastFileManager.h"
- #import "customDownloadManager.h"
- #import "audioPlayListManager.h"
- #import "QRCodeScanForChangeDeviceViewController.h"
- #import "customToastVew.h"
- #import "DFPlayer.h"
- #import "UIInterface+HXRotation.h"
- #import "imageDetailsScrollViewController.h"
- #import "videoPlayByAVPlayerViewController.h"
- #import "pingManager.h"
- #import "webRtcPlayerViewController.h"
- #import "webRtcPingManager.h"
- #import "imageVersionRenewTipView.h"
- #import "HWVersionModel.h"
- #import "HaveNewVersionView.h"
- #import "newerGuideView.h"
- #import "CustomerWebViewController.h"
- #import "noticeModel.h"
- #import "HaveNoticeView.h"
- #import "UpgradeInfoModel.h"
- #import "imageVersionUpdateDoneView.h"
- #import "imageVersionUpdateFailView.h"
- #import "LoginType1ViewController.h"
- #import "privacyModeTipViewController.h"
- #import "previewFileAndFolderViewController.h"
- @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate,UITabBarControllerDelegate>
- {
- imageVersionRenewTipView * RenewTipView;
- imageVersionUpdateDoneView* imageVersionUpdateDoneV;
- imageVersionUpdateFailView* imageVersionUpdateFailV;
- }
- @property (nonatomic,strong)UpgradeInfoModel*otaUpgradeInfoModel;
- @property(nonatomic, strong) CalculatorViewController *calculatorVC;
- @property(nonatomic, strong) HWWebViewController *webVC;
- @property(nonatomic, strong) inputPWDViewController *inputVC;
- @property(nonatomic, strong) customLaunchView *customLaunchV;//
- @property(nonatomic, strong) BaseNavigationController *preRootPlayerNav;
- @property(nonatomic, assign) bool isQRCodeType;//第一次 扫码进来的
- //@property(nonatomic, assign) bool isNeedToShowSecretKey;//扫码进来的SN 没有密码 则需要显示秘钥
- @property (nonatomic, assign) BOOL isLoginAgainType;// 单点登录 点重新登录进来的
- @property (nonatomic, assign) BOOL isNeedToStopWork;// 无网络报错
- @property(nonatomic, copy) NSString *getShareStr;//拿到分享的字符串
- @property (nonatomic, assign) BOOL isFirstOpenInLaunch;//启动页停两秒
- //冷启动分享跳入用
- @property(nonatomic, strong) UISceneSession *session;
- @property(nonatomic, strong) UISceneConnectionOptions *connectionOptions;
- @end
- @implementation SceneDelegate
- - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)){
- HLog(@"willConnectToSession")
- if (scene) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(guideOk:) name:GuideOkNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLockViewFun:) name:lockBypwdNotification object:nil];
-
- //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPwdVCFun:) name:setPwdNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdFun:) name:forgetPwdNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdBackFun:) name:forgetPwdBackNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdDidSetPwdFun:) name:forgetPwdDidSetNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceFun:) name:scanChangeDeviceNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceBackFun:) name:scanChangeDeviceBackNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(firstDidLinkBoxFun) name:@"firstDidLinkBox" object:nil];
-
- UIWindowScene *windowScene = (UIWindowScene *)scene;
- self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
- self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
-
- _isFirstOpenInLaunch = YES;
-
- // 初始化数据库
- [self initBrowserWindow];
-
- //查询当前的最近webrtc机房
- NSDictionary *dict = [HWDataManager getObjectWithKey:@"Const_best_webRtc_IPRoom"];
- if(dict){
- webrtcServerModel *model = [[webrtcServerModel alloc] initWithDictionary:dict error:nil];
- if(model && model.turnIp){
- ksharedAppDelegate.bestWebrtcServerModel = model;
- }
- }
-
- // 加载主页面
- [self enterMainVCFromScene];
- //
- [self reportVersionInfoFun];
-
- [self.window makeKeyAndVisible];
-
- ksharedAppDelegate.window = self.window;
-
- //冷启动
- if(connectionOptions.URLContexts != nil){
- _session = session;
- _connectionOptions = connectionOptions;
-
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // mainBlock(^{
- // [self scene:scene openURLContexts:connectionOptions.URLContexts];
- // });
- // });
- }
- }
- }
- /** 主界面 - 内部使用 */
- - (void)enterMainVCFromScene {
- // ConnectTestViewController *qrCodeVCNav = [[ConnectTestViewController alloc] init];
- // self.window.rootViewController = qrCodeVCNav;
- // return;/*临时测试*/
-
- if(_isNeedToStopWork){
- return;
- }
-
- /*先判断本地有无设备 无设备时需要先扫码添加设备*/
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
- if (!deviceDict || ![[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
-
- //默认显示最近文件
- [HWDataManager setBoolWithKey:Const_last_file_show value:YES];
-
- /*扫码界面*/
- //TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
- LoginType1ViewController *qrCodeVC = [[LoginType1ViewController alloc] init];
- BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
- self.window.rootViewController = qrCodeVCNav;
-
- _isQRCodeType = YES;
- return;
- }
-
- NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
-
- // GuideViewController
- BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
- if (haveGuide) {
- ;
- }else {
- GuideViewController *guiDeVC = [[GuideViewController alloc] init];
- guiDeVC.delegate = self;
- guiDeVC.sn = SNStr;
- self.window.rootViewController = guiDeVC;
-
- return;
- }
-
- //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
- #ifdef developJSQ
- NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #else
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #endif
-
- //添加默认启动图片
- if(!_customLaunchV && maskModel == 0){
- _customLaunchV = [[customLaunchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
- [self.window addSubview:_customLaunchV];
- }
-
-
- if(maskModel == 0 && _isFirstOpenInLaunch){
-
- //20240612 产品觉得 启动页太快了 要停两秒
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
- customToastVew *toastview = [customToastVew makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)];
- [toastview show];
- [self->_customLaunchV addSubview:toastview];
- return;
- }
-
- [self getDeviceMsgInMainVCWith:deviceDict];
- });
-
- _isFirstOpenInLaunch = NO;
- }
- else{
- //延时等网络状态
- if(_isFirstOpenInLaunch){
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self getDeviceMsgInMainVCWith:deviceDict];
- });
- _isFirstOpenInLaunch = NO;
- }
- else{
- [self getDeviceMsgInMainVCWith:deviceDict];
- }
-
- }
-
- //[self showNetErrorAlertType2Fun];
- }
- - (void)getDeviceMsgInMainVCWith:(NSDictionary*)deviceDict
- {
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- if(!isPrivacyMode && maskModel == 0){
- return;
- }
-
- [self initMainTabbarFun];
- [self showCalculatorVC];
- return;
- }
-
- KWeakSelf
- //有设备了先去做链接准备 // 80bec9c5
- NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
- NSString *sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
- if(SNStr && !sdnId){
- //瑞云方案
- // [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
- //
- // if(didSuc == 0){
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // mainBlock(^{
- // [weakSelf showNetErrorAlertFun];
- // [weakSelf enterMainVCFromSceneSecondStepFun];
- // });
- // });
- // }
- // else if(didSuc == 2
- // ||didSuc == 201
- // ||didSuc == 202){
- // [weakSelf gotoScanAginByThridMsgErrorFun:didSuc];
- // }
- // else{
- // [weakSelf enterMainVCFromSceneSecondStepFun];
- // }
- //
- // }];
-
- //webrtc方案
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
- [paraDict setValue:SNStr forKey:@"sn"];
- KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- DeviceThirdIdModel *model = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
- if(model.status == 0
- && model.data)
- {//根据SN 获取到正确的信息
- ksharedAppDelegate.DeviceThirdIdMod = model;
-
- NSString*desPwdstr = [RSATool AES128Decrypt:model.data.password key:AESCODEKEEYY];
-
- /*密码保持在本地*/
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
- NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
- [dict setObject:desPwdstr forKey:Const_Have_Add_Device_PWD];
-
- NSString *sdnid = model.data.sdnId;
-
- if(sdnid){
- [dict setObject:sdnid forKey:Const_Have_Add_Device_sdnid];
- }
-
- [HWDataManager setObjectWithKey:Const_Have_Add_Device_Privacy_Mode value:[NSNumber numberWithBool:model.data.isPrivacyMode]];
-
- [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
-
-
- [weakSelf enterMainVCFromSceneSecondStepFun];;
-
- //ping看上是否为内网情况
- [[pingManager shareManager] startPingDeviceIpFun];
- //获取webrtc相关信息
- [weakSelf queryWebRtcMsgFun];
- }
- else{
-
- //if(model.status == 201||model.status == 202 || model.status ==2){}
- [weakSelf gotoScanAginByThridMsgErrorFun:model.status];
- }
-
-
- } failure:^(NSError * _Nonnull error) {
- HLog("网络报错");
- mainBlock(^{
- [weakSelf showNetErrorAlertFun];
- [weakSelf enterMainVCFromSceneSecondStepFun];
- });
- }];
-
- }
- else{
- //ping看上是否为内网情况
- [[pingManager shareManager] startPingDeviceIpFun];
-
- if (!ksharedAppDelegate.DeviceWebRtcMsgMod) {
- //获取webrtc相关信息
- [weakSelf queryWebRtcMsgFun];
- }
- [self enterMainVCFromSceneSecondStepFun];
- }
- }
-
- #pragma mark 获取webrct 的链接信息
- -(void)queryWebRtcMsgFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){
-
- webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
-
- if(curModel && curModel.status == 0){
- ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
-
- if(!ksharedAppDelegate.bestWebrtcServerModel){
- webrtcServerModel *model = curModel.data.webrtcServerList.firstObject;
- ksharedAppDelegate.bestWebrtcServerModel = model;
- }
-
- [[webRtcManager shareManager] beginToLinkWebRtcFun];
- [[webRtcPingManager shareManager] startPingFun];
- }
- else
- {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf queryWebRtcMsgFun];
- });
- }
-
- } failure:^(NSError * _Nonnull error) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf queryWebRtcMsgFun];
- });
- }];
- }
- - (void)enterMainVCFromSceneSecondStepFun
- {
-
- //确保通过SN号拿到密码了
- //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
- if(!ksharedAppDelegate.DeviceThirdIdMod
- &&!ksharedAppDelegate.DeviceWebRtcMsgMod){
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- mainBlock(^{
- [self enterMainVCFromScene];
- });
- });
-
- return;
- }
-
- //是否已经有密码了 有就是输入密码 没有就是设置密码
- NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
- NSString * sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
- if(!sdnId && !ksharedAppDelegate.DeviceWebRtcMsgMod){
- HLog(@"没有拿到 --sdnId:%@ --- DeviceWebRtcMsgMod:%@",sdnId,ksharedAppDelegate.DeviceWebRtcMsgMod);
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- mainBlock(^{
- [self enterMainVCFromScene];
- });
- });
-
- return;
- }
-
- if(_customLaunchV){
- [_customLaunchV removeFromSuperview];
- _customLaunchV = nil;
- }
-
- if(curPwd && curPwd.length > 0){
- /*设置密码*/
- // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
- // BaseNavigationController *nextVCNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
- // self.window.rootViewController = nextVCNav;
- }
- else{
- //1、重启、恢复出厂设备、首次设置密码 3个情况下8分钟之内不弹
- long seconds = [iTools getNowTimeStamp];
- NSNumber *secondsNum = [NSNumber numberWithLong:seconds];
- if(secondsNum){
- [HWDataManager setNumberWithKey:stringKeyAddSn(@"disenable_type2_BoxHeartbeat") value:secondsNum];
- }
-
- /*没有设置密码*/
- SetPWDFirstViewController *qrCodeVC = [[SetPWDFirstViewController alloc] init];
- BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
- self.window.rootViewController = qrCodeVCNav;
-
- return;
- }
-
- //下载配置先处理
- [boxDownloadFileManager shareInstance];
-
- [lastFileManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
- [audioPlayListManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
-
- //获取NAS相关信息
- [self getNASMsgFun];
-
- [self initMainTabbarFun];
-
- self.isLoginAgainType = NO;
- __block BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- //KWeakSelf
- if(!_isQRCodeType){
- if(isPrivacyMode)
- {
- [self showCalculatorVC];
- }
- else{
- [self HandleEnterNotPrivacyModeFun];
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- //playerRootVC.isPwdVCShow = NO;
- //[playerRootVC setShowImgAndVoiceTypeFun:YES];
- //[weakSelf shareAwakenAppBy:weakSelf.getShareStr];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
- });
- if(self->_session && self->_connectionOptions){
- [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
- }
- }
- //_isQRCodeType = NO;
- }
- else{
- if(isPrivacyMode)
- {
- [self showCalculatorVC];
- }
- else{
- [[webRtcManager shareManager] beginToLinkWebRtcFun];
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
- });
- }
- }
- _isQRCodeType = NO;
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:1 withEventValue:@"Nas"];
- }
- #pragma mark 1.4.1 新增tabbar
- - (void)initMainTabbarFun
- {
- UITabBarController *tabBarController = [[UITabBarController alloc] init];
- tabBarController.delegate = self;
-
- NASViewController *NASVC = [[NASViewController alloc] init];
- BaseNavigationController *NasNav = [[BaseNavigationController alloc] initWithRootViewController:NASVC];
-
- cloudPhoneViewController *cloudVC = [[cloudPhoneViewController alloc] init];
- BaseNavigationController *cloudPhoneNav = [[BaseNavigationController alloc] initWithRootViewController:cloudVC];
- previewFileAndFolderViewController *fileVC = [[previewFileAndFolderViewController alloc] init];
- BaseNavigationController *fileNav = [[BaseNavigationController alloc] initWithRootViewController:fileVC];
- mineViewController *mineVC = [[mineViewController alloc] init];
- BaseNavigationController *mineNav = [[BaseNavigationController alloc] initWithRootViewController:mineVC];
-
-
- NSString*phoneTitle = NSLocalizedString(@"tabbar_cloud_phone",nil);
- NSString*myTitle = NSLocalizedString(@"tabbar_my_title",nil);
- NSString*fileTitle = NSLocalizedString(@"my_set_no_file",nil);
-
- //NSArray *viewControllers = @[NasNav, cloudPhoneNav,mineNav]; // 添加更多视图控制器
- NSArray *viewControllers = @[NasNav,fileNav,mineNav]; // 添加更多视图控制器
-
- NSArray *titleArr = @[@"NAS",fileTitle,myTitle];
- NSArray *imageNArr = @[@"tabbar_nas_N", @"tabbar_file_N",@"tabbar_my_N"];
- NSArray *imageHArr = @[@"tabbar_nas_H", @"tabbar_file_H",@"tabbar_my_H"];
-
- //记录当前连接的SN
- NSString* preSN = [HWDataManager getStringWithKey:@"Const_pre_did_link_ok_sn"];
- NSString *curSN = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- if(![curSN isEqualToString:@"0333933700223110016962"]
- && ![preSN isEqualToString:@"0333933700223110016962"]
- && preSN.length > 0){
- titleArr = @[@"NAS",phoneTitle,myTitle];
- imageNArr = @[@"tabbar_nas_N", @"my_device_NO",@"tabbar_my_N"];
- imageHArr = @[@"tabbar_nas_H", @"my_device_ok",@"tabbar_my_H"];
-
- viewControllers = @[NasNav,cloudPhoneNav,mineNav];
- }
-
-
- tabBarController.viewControllers = viewControllers;
-
- for (int i=0; i<viewControllers.count; i++) {
- UITabBarItem * tabBarItem = [UITabBarItem new];
- tabBarItem.title = titleArr[i];
- tabBarItem.selectedImage = [[UIImage imageNamed:imageHArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- tabBarItem.image = [[UIImage imageNamed:imageNArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
-
- UIViewController *curVC = viewControllers[i];
- curVC.tabBarItem = tabBarItem;
- }
-
- //tabBarController.tabBar.barTintColor = [UIColor hwColor:@"#F6F8FA"]; // 设置标签栏背景色
- tabBarController.tabBar.tintColor = [UIColor hwColor:@"#01B7EA"]; // 设置选中标签项的颜色
- tabBarController.tabBar.unselectedItemTintColor = [UIColor hwColor:@"#7C8196"]; // 设置未选中标签项的颜色
- tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
- // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor hwColor:@"#01B7EA"],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateSelected];
- // //[UIColor hwColor:@"#7C8196"]
- // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateNormal];
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
- if(haveOpenMask){
-
- //非隐私模式 直接进入推拉流页
- if(ksharedAppDelegate.DeviceThirdIdMod && !ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
- ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = YES;
- [cloudVC queryWebRtcMsgFun:YES];
- }
- else{
- ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = YES;
- }
-
- tabBarController.selectedIndex = 1;
- }
- ksharedAppDelegate.mainTabBar = tabBarController;
- self.window.rootViewController = tabBarController;
- [self.window makeKeyAndVisible];
-
-
- CGFloat second = 1.0;
- //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
- if(haveOpenMask){
- second = 3;
- }
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self beginShowAlertFun];
- });
- }
- #pragma mark 第一次连接成功
- - (void)firstDidLinkBoxFun
- {
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- if (ksharedAppDelegate.mainTabBar) {
- NSArray *curArr = ksharedAppDelegate.mainTabBar.viewControllers;
- if (curArr.count >= 3) {
- BaseNavigationController *Nav = curArr[1];
- UIViewController *curVC = Nav.viewControllers.firstObject;
- if (![curVC isKindOfClass:[previewFileAndFolderViewController class]]) {
- return;
- }
- }
- }
-
- //[self initMainTabbarFun];
- [self enterMainVCFromScene];
- });
- }
- #pragma mark 处理进来是非隐私模式的情况
- - (void)HandleEnterNotPrivacyModeFun
- {
- #ifdef developJSQ
- NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #else
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #endif
- if (maskModel != 0){
- [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
- [iTools lc_setAlternateIconName:@"AppIcon1"];
- }
- }
- - (void)setPwdOk{
- [self enterMainVCFromScene];
-
- // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
- //
- // if (dataArray.count == 0) { // 浏览器没有窗口
- // // 加载首页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = Const_HomeUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- //
- // }else {
- // // 浏览器当前窗口索引ID
- // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
- // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
- // BaseModel *model = finfAlls.firstObject;
- //
- // // 加载网页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = model.webUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- // }
- }
- /** 登录界面 - 外部使用*/
- + (void)enterLoginVC {
- // SetPWDViewController *vc = [[SetPWDViewController alloc] init];
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // UIWindow *keyWindow = [iTools getKeyWindow];
- // keyWindow.rootViewController = nvc;
- }
- /** 主界面 - 外部使用 */
- + (void)enterMainVC {
- // AlbumHomeViewController *vc = [[AlbumHomeViewController alloc] init];
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // UIWindow *keyWindow = [iTools getKeyWindow];
- // keyWindow.rootViewController = nvc;
- }
- - (void)sceneDidDisconnect:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneDidDisconnect");
-
- //[[connectDeviceManager shareInstance] disconnect];
- }
- - (void)sceneDidBecomeActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneDidBecomeActive")
- }
- - (void)sceneWillResignActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneWillResignActive")
-
- }
- - (void)sceneWillEnterForeground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneWillEnterForeground")
-
- [self beginShowAlertFun];
- }
- - (void)sceneDidEnterBackground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
- HLog(@"sceneDidEnterBackground")
-
- ksharedAppDelegate.didShowBoxHeartbeatAlertType = NO;
-
- BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
-
- if(ksharedAppDelegate.DeviceThirdIdMod){
- isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- }
-
- if(isPrivacyMode){//隐私模式 需要弹密码框 转竖屏
- BOOL isNeeddelayedType = NO;
- //这里强制竖屏 处理图片详情 和视频详情的横屏情况
- BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
- if([mainNav isKindOfClass:[BaseNavigationController class]]){
- NSArray* vcArr = mainNav.viewControllers;
-
- if(vcArr.count >= 2){
- UIViewController *curVC = vcArr.lastObject;
-
- if([curVC isKindOfClass:[webRtcPlayerViewController class]]){
- webRtcPlayerViewController* vc = (webRtcPlayerViewController*)curVC;
- if(vc.isLan){
- ksharedAppDelegate.needToPushWebRtcVCType = YES;
- [vc exitCloudPhoneFun];
- }
- }
- else if([curVC isKindOfClass:[imageDetailsScrollViewController class]]
- ||[curVC isKindOfClass:[videoPlayByAVPlayerViewController class]]){
-
- //切换到竖屏
- ksharedAppDelegate.supportScreenRotateType = YES;
- [curVC hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
- //ksharedAppDelegate.supportScreenRotateType = NO;
- isNeeddelayedType = YES;
- HLog(@"sceneDidEnterBackground 旋转屏幕为竖屏")
- }
- }
- }
-
- [self showCalculatorVC];
- }
-
- }
- - (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
- HLog(@"scene continueUserActivity")
- if([TencentOAuth CanHandleUniversalLink:userActivity.webpageURL]){
- [TencentOAuth HandleUniversalLink:userActivity.webpageURL];
- }
- else{
- [WXApi handleOpenUniversalLink:userActivity delegate:self];
- }
-
- }
- - (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
- HLog(@"scene openURLContexts")
- NSEnumerator *enumerator = [URLContexts objectEnumerator];
- UIOpenURLContext *context;
- while (context = [enumerator nextObject]) {
- NSLog(@"context.URL =====%@",context.URL);
- //openprivacyxapp://page?param1=value1¶m2=value2
- NSString *curStr = context.URL.absoluteString;
- if([curStr rangeOfString:@"openprivacyxapp://page"].location != NSNotFound){
- _getShareStr = curStr;
- [self delayedHandlShareAwakenAppBy:curStr];
- break;
- }
- else{
- [WXApi handleOpenURL:context.URL delegate:self];
- }
- //NSLog(@"context.options.sourceApplication ===== %@",context.options.sourceApplication);
-
- }
-
- _session = nil;
- _connectionOptions = nil;
- }
- - (void)delayedHandlShareAwakenAppBy:(NSString*)curStr{
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self shareAwakenAppBy:curStr];
- });
-
- }
- #pragma mark 初始化数据库-DB_BrowserWindows_TableName
- - (void)initBrowserWindow {
-
- // 浏览器当前所有窗口
- NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
- // 浏览器当前窗口索引ID
- NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- NSString *IDValue = [NSString stringWithFormat:@"%ld", ID];
- NSString *where = [NSString stringWithFormat:@"where %@=%@",bg_sqlKey(@"ID"),bg_sqlValue(IDValue)];
- NSArray *modelArr = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
-
- if (dataArray.count == 0) { // 浏览器没有窗口
-
- BaseModel *model = [[BaseModel alloc] init];
- model.ID = 0;
- model.name = @"主页";
- // model.iconFile = imageUrl;
- model.webUrl = Const_HomeUrl;
-
- // 写入数据库
- model.bg_tableName = DB_BrowserWindows_TableName;
- [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
- HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
- }];
-
- // 浏览器当前窗口索引ID
- [HWDataManager setIntegerWithKey:BrowserWindowsCurrentID value:0];
-
- }else if (modelArr.count == 0) { // 新建窗口
- BaseModel *model = [[BaseModel alloc] init];
- model.ID = ID;
- model.name = @"主页";
- // model.iconFile = imageUrl;
- model.webUrl = Const_HomeUrl;
-
- // 写入数据库
- model.bg_tableName = DB_BrowserWindows_TableName;
- [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
- HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
- }];
-
- }else { // 更新窗口数据
- // 浏览器当前窗口索引ID
- // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- //
- // BaseModel *model = [[BaseModel alloc] init];
- // model.ID = ID;
- // model.name = @"主页";
- //// model.iconFile = imageUrl;
- // model.webUrl = Const_HomeUrl;
- //
- // // 更新数据库
- // model.bg_tableName = DB_BrowserWindows_TableName;
- // [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
- // HLog(@"BaseModel更新: %@", isSuccess ? @"成功":@"失败");
- // }];
- }
- }
- #pragma mark 获取当前屏幕的截图
- //- (UIImage *)getScreenShotImage {
- // CGSize size = [UIScreen mainScreen].bounds.size;
- // CGFloat scale = [UIScreen mainScreen].scale;
- // UIGraphicsBeginImageContextWithOptions(size, YES, scale);
- // [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
- // UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
- // UIGraphicsEndImageContext();
- // return image;
- //}
- #pragma mark 计算器伪装视图
- /*CalculatorViewController*/
- - (void)showCalculatorVC{
- HLog(@"showCalculatorVC 处理密码框弹出")
-
- // if(SCREEN_W > SCREEN_H){
- // HLog(@"showCalculatorVC 屏幕还是横屏状态")
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [self showCalculatorVC];
- // });
- // return;
- // }
-
- ksharedAppDelegate.supportScreenRotateType = NO;
-
-
- if(ksharedAppDelegate.getSystemPermissType){
- HLog(@"检测到获取系统全进入后台");
- return;
- }
-
- BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
- if (haveGuide) {
- ;
- }else {
-
- return;
- }
-
- BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
-
- if(ksharedAppDelegate.DeviceThirdIdMod){
- isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- }
-
- if(!isPrivacyMode){
- return;
- }
-
- //修复扫描已经有密码的合作 点击跳过因为网络弹框再次覆盖一次密码(需要输入两次密码)
- BaseNavigationController*curTopNav = (BaseNavigationController*)[iTools appRootViewController];
- if([curTopNav isKindOfClass:[BaseNavigationController class]]){
- NSArray *vcArr = [curTopNav viewControllers];
- if(vcArr && vcArr.count >0){
- UIViewController *lastVC = vcArr.lastObject;
- if([lastVC isKindOfClass:[inputPWDViewController class]]){
- return;
- }
- }
- }
-
- /*无有效时长直接返回不加载任何加密界面*/
- NSString *PwdStr = nil;
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
-
- //实时拿到的密码 (每次打开或者更换设备 通过SN重新拿)
- if(ksharedAppDelegate.DeviceThirdIdMod.data.password){
- NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
- NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
-
- if(desPwdStr){
- PwdStr = desPwdStr;
- }
- }
- else{
- //本地密码本地判断 密码改在服务器保持
- if ([[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
- PwdStr = [deviceDict objectForKey:Const_Have_Add_Device_PWD];
- }
- }
-
- if (!PwdStr || [PwdStr isEqualToString:@""])
- {
- return;
- }
-
- // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
- // if (!haveOpenMask){
- // //输入密码界面
- // [self closeCalculatorVC];
- // _inputVC = [[inputPWDViewController alloc] init];
- // [self.window addSubview:_inputVC.view];
- // return;
- // }
-
- BOOL haveVaildTime = [HWDataManager getBoolWithKey:Const_Have_No_VaildTime];
- if (haveVaildTime == YES){/*无有效时间*/
- return;
- }
-
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus != AFNetworkReachabilityStatusNotReachable)
- {
- if(!ksharedAppDelegate.DeviceThirdIdMod){
- return;
- }
-
- BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- if(!isPrivacyMode)
- {
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
- return;
- }
- }
-
- #ifdef developJSQ
- NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #else
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
- #endif
- if (maskModel == 0){
- //输入密码界面
- [self closeCalculatorVC];
- _inputVC = [[inputPWDViewController alloc] init];
- [self.window addSubview:_inputVC.view];
- ksharedAppDelegate.isDidShowPwdType = YES;
- }
- else if (maskModel == 2){
- /*浏览器*/
- [self closeCalculatorVC];
- _webVC = [[HWWebViewController alloc] init];
- _webVC.pwd = PwdStr;
- _webVC.webUrl = @"https://baidu.com";
- [self.window addSubview:_webVC.view];
- ksharedAppDelegate.isDidShowPwdType = YES;
- }else{
- /*计算器*/
- [self closeCalculatorVC];
- _calculatorVC = [[CalculatorViewController alloc] init];
- _calculatorVC.pwd = PwdStr;
- [self.window addSubview:_calculatorVC.view];
- ksharedAppDelegate.isDidShowPwdType = YES;
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:ShowPwdVCNotification object:nil];
- }
- - (void)closeCalculatorVC{
-
- ksharedAppDelegate.getSystemPermissType = NO;
-
- if (_calculatorVC){
- [_calculatorVC.view removeFromSuperview];
- }
-
- /*浏览器*/
- if (_webVC){
- [_webVC.view removeFromSuperview];
- }
-
- if(_inputVC){
- [_inputVC.view removeFromSuperview];
- }
- ksharedAppDelegate.isDidShowPwdType = NO;
-
- if(self->_session && self->_connectionOptions){
- [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
- }
- }
- - (NSString *)documentPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder {
-
- NSString *path = DocumentPath;
- if (account.length != 0) {
- path = [NSString stringWithFormat:@"%@/%@/",DocumentPath,account];
- }
-
- if ([fileFolder containsString:@"/"]) {
- NSString *path1 = [path stringByAppendingPathComponent:fileFolder];
- path1 = [path1 stringByDeletingLastPathComponent];
- NSError *error;
- if (![[NSFileManager defaultManager] fileExistsAtPath:path1]) {
- [[NSFileManager defaultManager] createDirectoryAtPath:path1 withIntermediateDirectories:YES attributes:nil error:&error];
- }
- }else{
- NSError *error;
- if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
- [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
- }
- }
-
- return [path stringByAppendingPathComponent:fileFolder];
- }
- - (void)startUseBtnBePressed{
- [self enterMainVCFromScene];
- // NSString *launchAppPWDPath = [self documentPathForAccount:@"" fileFolder:@"LaunchPWD"];
- // NSString *str = [[NSString alloc] initWithContentsOfFile:launchAppPWDPath encoding:(NSUTF8StringEncoding) error:nil];
- // if (!str || [str isEqualToString:@"0"])
- // {
- // SetUsePWDViewController *loginVC = [[SetUsePWDViewController alloc] init];
- // loginVC.delegate = self;
- // self.window.rootViewController = loginVC;
- //
- // return;
- // }
- //
- // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
- //
- // if (dataArray.count == 0) { // 浏览器没有窗口
- // // 加载首页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = Const_HomeUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- //
- // }else {
- // // 浏览器当前窗口索引ID
- // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
- // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
- // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
- // BaseModel *model = finfAlls.firstObject;
- //
- // // 加载网页
- // HWWebViewController *vc = [[HWWebViewController alloc] init];
- // vc.webUrl = model.webUrl;
- // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
- // self.window.rootViewController = nvc;
- // }
- }
- - (void)loginOk{
- [self enterMainVCFromScene];
- }
- - (void)guideOk:(NSNotification*)not{
-
- NSString *object = not.object;
- if(object && [object isEqualToString:@"isLoginAgainType"]){
- self.isLoginAgainType = YES;
- }
-
- //clear下载和上传的已经获取的数据
- // [[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
- // [uploadFileManager shareInstance].databaseArr = [NSMutableArray new];
- // [uploadFileManager shareInstance].fileModelDataArr = [NSMutableArray new];
- // [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateWait;
-
- [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
- [nasUploadFileManager shareInstance].databaseArr = nil;
-
- // [[downloadManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
- // [downloadManager shareInstance].databaseArr = [NSMutableArray new];
- // [downloadManager shareInstance].downLoadFileModelDataArr = [NSMutableArray new];
-
- [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
- [nasDownloadFileManager shareInstance].databaseArr = nil;
-
- //[[backupsFileManager shareInstance] suspendBackupsFileFun];
- [[nasBackupsManager shareInstance] suspendBackupsFileFun];
-
- //frp的下载
- [[customDownloadManager shareManager] suspendAllDownloadTask];
-
- NSString *uid =ksharedAppDelegate.DeviceThirdIdMod.data.sn;
- if(uid){
-
- }
- else{
- uid = @"";
- }
-
- [customDownloadManager shareManager].uid = uid;
-
- //盒子1音频在播放音乐,切换盒子2成功,仍在播放中
- [[DFPlayer sharedPlayer] df_deallocPlayer];
-
- [lastFileManager shareManager].uid = uid;
- [audioPlayListManager shareManager].uid = uid;
-
-
- [self enterMainVCFromScene];
- }
- #pragma mark 上报版本号信息
- -(void)reportVersionInfoFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- NSString *vers = [iPhone appVersion];
- if(vers){
- [paraDict setValue:vers forKey:@"iosClientVersionNumber"];
- }
-
- NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
- if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
- NSString*snStr = deviceDict[Const_Have_Add_Device_SN];
- if(snStr){
- [paraDict setValue:snStr forKey:@"sn"];
- }
- else{
- return;
- }
- }
- else{
- return;;
- }
-
- // KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:reportVersionInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 获取NAS相关信息
- -(void)getNASMsgFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- NSString *SNStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- if(SNStr){
- [paraDict setValue:SNStr forKey:@"sn"];
- }
- else{
- return;;
- }
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:getIpFun Parameters:paraDict success:^(id _Nonnull responseObject){
- NASMsgModel *model = [[NASMsgModel alloc] initWithDictionary:responseObject error:nil];
- if(model){
- ksharedAppDelegate.NASMsgMod = model;
- }
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 主动上锁
- - (void)showLockViewFun:(NSNotification*)not
- {
- [self showCalculatorVC];
- }
- #pragma mark 进入设置密码
- //- (void)setPwdVCFun:(NSNotification*)not
- //{
- // _isNeedToShowSecretKey = YES;
- //}
- #pragma mark 忘记密码
- - (void)forgetPwdFun:(NSNotification*)not
- {
-
- /*忘记密码*/
- forgetPwdViewController *forgetPwdVC = [[forgetPwdViewController alloc] init];
- BaseNavigationController *forgetPwdVCNav = [[BaseNavigationController alloc] initWithRootViewController:forgetPwdVC];
- self.window.rootViewController = forgetPwdVCNav;
-
- }
- #pragma mark 忘记密码返回
- - (void)forgetPwdBackFun:(NSNotification*)not
- {
- // if(_preRootPlayerNav)
- // {
- // self.window.rootViewController = _preRootPlayerNav;
- // }
- // else{
- [self enterMainVCFromScene];
- //}
-
- [self showCalculatorVC];
- }
- #pragma mark 忘记密码设置密码完成
- - (void)forgetPwdDidSetPwdFun:(NSNotification*)not
- {
- // if(_preRootPlayerNav)
- // {
- // NSArray *vcArr = _preRootPlayerNav.viewControllers;
- // if(vcArr.count > 2){
- // [_preRootPlayerNav popToViewController:vcArr[1] animated:NO];
- // }
- // self.window.rootViewController = _preRootPlayerNav;
- // }
- // else{
- [self enterMainVCFromScene];
- //}
-
- [self closeCalculatorVC];
-
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- }
- #pragma mark 扫码切换设备 scanChangeDeviceNotification
- - (void)scanChangeDeviceFun:(NSNotification*)not
- {
-
- //TipsQRCodeForChangeDeviceViewController *nextVC = [[TipsQRCodeForChangeDeviceViewController alloc] init];
- QRCodeScanForChangeDeviceViewController *nextVC = [[QRCodeScanForChangeDeviceViewController alloc] init];
- nextVC.isRootVCType = YES;
- BaseNavigationController *nextNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
- self.window.rootViewController = nextNav;
-
- }
- #pragma mark 扫码切换设备点击返回
- - (void)scanChangeDeviceBackFun:(NSNotification*)not
- {
- // if(_preRootPlayerNav)
- // {
- // self.window.rootViewController = _preRootPlayerNav;
- // }
- // else{
- [self enterMainVCFromScene];
- //}
-
- [self showCalculatorVC];
- }
- #pragma mark 网络异常弹框
- -(void)showNetErrorAlertFun
- {
- NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
-
- if(maskModel !=0 && ksharedAppDelegate.isDidShowPwdType){
- return;
- }
-
- NSString *linkErrTip = NSLocalizedString(@"player_link_fail_tip_type9",nil);
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
- //linkErrTip = NSLocalizedString(@"player_link_fail_phone_Tips",nil);
- _isNeedToStopWork = YES;
- [self showNetErrorAlertType2Fun];
- return;
- }
-
- linkErrTip = [[NSString alloc] initWithFormat:@"[9]%@",linkErrTip];
-
- ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:nil
- msg:linkErrTip
- imageStr:nil
- cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
- okTitle:NSLocalizedString(@"player_link_fail_tryAgain",nil) isOkBtnHighlight:YES
- didClickOk:^{
-
- //[self enterMainVCFromScene];
- } didClickCancel:^{
- exit(0);
- }];
-
- linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
- linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
- #pragma mark 网络异常弹框
- -(void)showNetErrorAlertType2Fun
- {
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
-
- NSString * linkErrTip = NSLocalizedString(@"netWork_error_tip_content",nil);
-
- ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"netWork_error_tip_title",nil)
- msg:linkErrTip
- imageStr:nil
- cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
- okTitle:nil isOkBtnHighlight:NO
- didClickOk:^{
-
- //[self enterMainVCFromScene];
- } didClickCancel:^{
- exit(0);
- }];
-
- linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
-
- self.window.rootViewController = [UIViewController new];
- [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
- linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
-
- }
- - (void)gotoScanAginByThridMsgErrorFun:(NSInteger)errorCode
- {
- /*扫码界面*/
- TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
- qrCodeVC.isNeedToShowAleatType = YES;
- qrCodeVC.getSNMsgcode = errorCode;
- BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
- self.window.rootViewController = qrCodeVCNav;
- }
- #pragma mark 分享页面唤醒APP
- - (void)shareAwakenAppBy:(NSString*)shareStr
- {
- //[[iToast makeText:shareStr] show];
-
- NSArray * paraArr = [shareStr componentsSeparatedByString:@"&"];
- if(!paraArr || paraArr.count==0){
- return;
- }
-
- //type=save和download
- NSString *type = nil;
- NSString *fileIds = nil;
- NSString *extractionCode = nil;
- NSString *token = nil;
-
- for (NSString*objectStr in paraArr) {
- if([objectStr rangeOfString:@"type"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- type = objectArr.lastObject;
- continue;
- }
- }
- else if([objectStr rangeOfString:@"fileIds"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- fileIds = objectArr.lastObject;
- continue;
- }
- }
- else if([objectStr rangeOfString:@"extractionCode"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- extractionCode = objectArr.lastObject;
- continue;
- }
- }
- else if([objectStr rangeOfString:@"token"].location != NSNotFound){
- NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
- if(objectArr.count == 2){
- token = objectArr.lastObject;
- continue;
- }
- }
- }
-
- if(!type || type.length ==0){
- HLog(@"分享 type 获取错误");
- return;
- }
-
- if(!fileIds || fileIds.length ==0){
- HLog(@"分享 fileIds 获取错误");
- return;
- }
-
- if(!token || token.length ==0){
- HLog(@"分享 token 获取错误");
- return;
- }
-
- [self getShareOneFileListFunByToken:token withFileIds:fileIds withExtractionCode:extractionCode withType:type];
- }
- #pragma mark 分享信息重新获取
- - (void)getShareOneFileListFunByToken:(NSString*)token withFileIds:(NSString*)fileIds withExtractionCode:(NSString*)extractionCode withType:(NSString*)type
- {
-
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
- fileIds = [fileIds stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- NSData *jsonData = [fileIds dataUsingEncoding:NSUTF8StringEncoding];;
- NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
-
- HLog(@"jsonArray:%@",jsonArray)
-
- if(!jsonArray){
- return;
- }
-
- [paraDict setValue:token forKey:@"token"];
- [paraDict setValue:jsonArray forKey:@"fileIdList"];
- [paraDict setValue:extractionCode forKey:@"extractionCode"];
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
- queryOneShareModel*model = [[queryOneShareModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.status == 0){
- weakSelf.getShareStr = nil;
- [weakSelf gotoVCByModel:model withType:type];
- }
- else{
- }
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 跳转
- - (void)gotoVCByModel:(queryOneShareModel*)model withType:(NSString*)type
- {
- if([type isEqualToString:@"save"]){
- [self saveFileToBoxFunBy:model];
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_save"];
- }
- else if([type isEqualToString:@"download"]){
- [self downloadFileToAppFunBy:model];
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_download"];
- }
-
-
- }
- #pragma mark 保存文件到盒子
- - (void)saveFileToBoxFunBy:(queryOneShareModel*)sharemodel
- {
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
-
- NSMutableArray *pathArr = [NSMutableArray new];
-
- for (ShareFileDataModel*dataModel in sharemodel.data.fileListVOS){
- [pathArr addObject:dataModel.fileUrl];
- }
-
- if (pathArr) {
- NSString *jsonStr = [iTools toJsonStrWithArray:pathArr];
- if(jsonStr){
- [paraDict setValue:jsonStr forKey:@"urls"];
- }
- }
-
-
- NSString * boxSaveDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_box_save_default_path)];
-
- if(!boxSaveDefaultPath || boxSaveDefaultPath.length == 0){
- boxSaveDefaultPath = Const_default_save_path;
- [HWDataManager setStringWithKey:stringKeyAddSn(Const_box_save_default_path) value:boxSaveDefaultPath];
- }
-
- [paraDict setValue:boxSaveDefaultPath forKey:@"savePath"];
-
- KWeakSelf
- [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"downFiles" Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.status == 0){
- [weakSelf gotoUploadFileRecordVCFunByType:2 withModel:sharemodel];
- }
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- #pragma mark 下载文件到手机
- - (void)downloadFileToAppFunBy:(queryOneShareModel*)sharemodel
- {
- [self gotoUploadFileRecordVCFunByType:1 withModel:sharemodel];
- }
- #pragma mark 跳转传输列表
- - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type withModel:(queryOneShareModel*)sharemodel
- {
- KWeakSelf
- if(type == 2){
- [[boxSaveFileManager shareInstance] addBoxSaveRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
- if(isSuccess){
- mainBlock(^{
- [weakSelf gotoUploadFileRecordVCFunByType:type];
- });
-
- }
- }];
- }
- else if (type == 1){
- if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]){
- mainBlock(^{
- [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
- });
- return;
- }
- [[boxDownloadFileManager shareInstance] addBoxDownloadRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
- if(isSuccess){
- mainBlock(^{
- [weakSelf gotoUploadFileRecordVCFunByType:type];
- });
-
- }
- }];
- }
-
-
- }
- - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type
- {
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- vc.isReceiveType = type;
-
- BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
-
- if([mainNav isKindOfClass:[BaseNavigationController class]]){
- [mainNav pushViewController:vc animated:YES];
- [[UIApplication sharedApplication] setStatusBarHidden:NO];
- }
- }
- #pragma mark UITabBarControllerDelegate
- - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
- {
- NSInteger index = tabBarController.selectedIndex;
-
- int eventType = 1;
- NSString* eventValue = @"Nas";
- if(index == 0){
- eventValue = @"Nas";
- }
- else if(index == 1){
- eventValue = @"Cloud";
- }
- else if(index == 2){
- eventValue = @"Home";
- }
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:eventType withEventValue:eventValue];
-
- }
- - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
- {
- if(ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType
- || ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType
- || ksharedAppDelegate.needToPushWebRtcVCType){
- return NO;
- }
- return YES;
- }
- #pragma mark 弹框逻辑放到这里
- //优先级:1.强制盒子更新弹窗
- // 2.APP版本更新弹窗 > 新手引导弹窗 > 通知公告弹窗
- - (void)beginShowAlertFun
- {
- //
- if (!ksharedAppDelegate.mainTabBar) {
- return;
- }
-
- //1.隐私模式密码界面 3秒检测一次是否输入完成密码了
- if(!ksharedAppDelegate.isFirstInputPwdDone){
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf beginShowAlertFun];
- });
-
- return;
- }
-
- // 强制盒子更新弹窗
- [self checkUpgradeInfoFun];
-
- }
- #pragma mark 弹框流程 1 检测盒子镜像更新弹窗->1.4.4改为从服务器请求
- - (void)checkUpgradeInfoFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:@"ota" forKey:@"type"];
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:queryUpgradeInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- UpgradeInfoModel *model = [[UpgradeInfoModel alloc] initWithDictionary:responseObject error:nil];
- if (model && model.status == 0) {
- weakSelf.otaUpgradeInfoModel = model;
- [weakSelf handelUpgradeInfoFun];
- }
- else
- {
- //2. APP版本更新弹窗
- [weakSelf checkVersionFun];
- }
- } failure:^(NSError * _Nonnull error) {
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf checkUpgradeInfoFun];
- });
- }];
- }
- #pragma mark 弹框流程 1 强制盒子更新弹窗
- - (void)handelUpgradeInfoFun
- {
- //self.otaUpgradeInfoModel.data.status = 1;
- if(self.otaUpgradeInfoModel.data.status < 1){ //-1=没有更新 0=下载中
- //2. APP版本更新弹窗
- [self checkVersionFun];
- }
- else{
-
- KWeakSelf
- if(self.otaUpgradeInfoModel.data.status < 6){
- [self showImageViewRenewTipViewFun];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf checkUpgradeInfoFun];
- });
- }
- else if(self.otaUpgradeInfoModel.data.status == 6){//升级完成
- if(RenewTipView){
- [self showImageViewRenewTipViewFun];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf OTAUpdateDoneFun];
- });
- }
- else{
- [self OTAUpdateDoneFun];
- }
- }
- else if(self.otaUpgradeInfoModel.data.status == 201){//升级失败
- //显示升级失败
- [self OTAUpdateFailFun];
- }
- else{
- //2. APP版本更新弹窗
- [self checkVersionFun];
- }
- }
-
- }
- #pragma mark 弹框流程 1 强制盒子更新弹窗
- - (void)showImageViewRenewTipViewFun
- {
- //密码框界面 拦着 不给弹出
- if(ksharedAppDelegate.isDidShowPwdType){
- //didGetSysInfoType = NO;
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf showImageViewRenewTipViewFun];
- });
-
- return;
- }
-
- if(RenewTipView){
- RenewTipView.status = _otaUpgradeInfoModel.data.status;
- return;
- }
-
- BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
- CGFloat second = 0.1;
-
- if(haveOpenMask){
- second = 1.5;
- [[NSNotificationCenter defaultCenter] postNotificationName:needToPoPCloudPhoneVCNotification object:nil];
- }
-
- KWeakSelf
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- self->RenewTipView = [[imageVersionRenewTipView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
- [ksharedAppDelegate.window addSubview:self->RenewTipView];
- self->RenewTipView.status = self->_otaUpgradeInfoModel.data.status;
- //[self.view bringSubviewToFront:RenewTipView];
-
-
- self->RenewTipView.didClickUpdateNowFun = ^{
- [weakSelf otaUpdateNowFun];
- };
-
- self->RenewTipView.didClickCloseFun = ^{
- [weakSelf didClickRenewTipViewCloseFun];
- };
- });
-
-
- }
- - (void)didClickRenewTipViewCloseFun{
- RenewTipView = nil;
- }
- #pragma mark 弹框流程 1 盒子更新弹窗 点击立即更新
- - (void)otaUpdateNowFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:@"ota" forKey:@"type"];
- [paraDict setValue:@2 forKey:@"status"];
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:upgradeDetailAdd Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if (model && model.status == 0) {
- [weakSelf checkUpgradeInfoFun];
- }
- else
- {
- [weakSelf checkVersionFun];
- }
- } failure:^(NSError * _Nonnull error) {
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf otaUpdateNowFun];
- });
- }];
-
- //1.点击更新 标志 30分别 不谈 心跳弹框
- long seconds = [iTools getNowTimeStamp];
- NSNumber *secondsNum = [NSNumber numberWithLong:seconds];
- if(secondsNum){
- [HWDataManager setNumberWithKey:stringKeyAddSn(@"disenable_type1_BoxHeartbeat") value:secondsNum];
- }
- }
- #pragma mark 弹框流程 1 OTA升级完成
- - (void)OTAUpdateDoneFun
- {
- //密码框界面 拦着 不给弹出
- if(ksharedAppDelegate.isDidShowPwdType){
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf OTAUpdateDoneFun];
- });
- return;
- }
-
- if(RenewTipView){
- [RenewTipView removeFromSuperview];
- RenewTipView = nil;
- }
-
- if (imageVersionUpdateDoneV) {
- [imageVersionUpdateDoneV removeFromSuperview];
- imageVersionUpdateDoneV = nil;
- }
-
- //显示OTA完成页面
- imageVersionUpdateDoneV = [[imageVersionUpdateDoneView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
- [ksharedAppDelegate.window addSubview:imageVersionUpdateDoneV];
- //[self.view bringSubviewToFront:curView];
-
- KWeakSelf
- imageVersionUpdateDoneV.didClickUpdateDoneFun = ^{
- [weakSelf closeOTAUpdateDoneFun];
- };
-
- }
- #pragma mark 弹框流程 1 OTA升级失败
- - (void)OTAUpdateFailFun
- {
- //密码框界面 拦着 不给弹出
- if(ksharedAppDelegate.isDidShowPwdType){
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf OTAUpdateFailFun];
- });
- return;
- }
-
- if(RenewTipView){
- [RenewTipView removeFromSuperview];
- RenewTipView = nil;
- }
-
- if (imageVersionUpdateFailV) {
- [imageVersionUpdateFailV removeFromSuperview];
- imageVersionUpdateFailV = nil;
- }
-
- //显示OTA完成页面
- imageVersionUpdateFailV = [[imageVersionUpdateFailView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
- [ksharedAppDelegate.window addSubview:imageVersionUpdateFailV];
- //[self.view bringSubviewToFront:curView];
-
- KWeakSelf
- imageVersionUpdateFailV.didClickUpdateDoneFun = ^{
- [weakSelf closeOTAUpdateDoneFun];
- };
-
- }
- #pragma mark 弹框流程 1 盒子更新弹窗 关闭弹窗
- - (void)closeOTAUpdateDoneFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:@"ota" forKey:@"type"];
- [paraDict setValue:@1 forKey:@"popButton"];
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:updateOTAPopButton Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if (model && model.status == 0) {
- }
- else
- {
- }
- [weakSelf checkVersionFun];
- } failure:^(NSError * _Nonnull error) {
- [weakSelf checkVersionFun];
- }];
- }
- #pragma mark 弹框流程 2 APP版本更新弹窗
- - (void)checkVersionFun
- {
- //[self getVersion];
-
- [self getLastNoticeFun];
- }
- #pragma mark- 网络请求
- - (void)getVersion {
-
- //密码框界面 拦着 不给弹出
- if(!ksharedAppDelegate.isFirstInputPwdDone){
- return;
- }
-
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:@"ios" forKey:@"type"];
- [paraDict setValue:@"skyworth" forKey:@"source"];
- [paraDict setValue:@"iPhone" forKey:@"iosType"];
-
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
- //HLog(@"%@", responseObject);
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if (model && model.status == 0) {
- HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
- [self checkVersion:model];
- }
- else
- {
- [self checkVersion:nil];
- }
- } failure:^(NSError * _Nonnull error) {
- HLog(@"%@", error);
- [self checkVersion:nil];
- }];
- }
- - (void)checkVersion:(HWVersionModel*)versionModel {
-
- if(!versionModel){//版本信息错误 检测新手弹框流程
- //[self showNewerGuideFun];
- [self getLastNoticeFun];
- return;
- }
-
- // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
- NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
- NSString *newVersion = [versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
- newVersion = [newVersion stringByReplacingOccurrencesOfString:@"V" withString:@""]; //去掉v
- //HLog(@"%@---%@", newVersion, currentVersion);
- if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
- //[self showNewerGuideFun];
- [self getLastNoticeFun];
- }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
- [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
- //[self showNewerGuideFun];
- [self getLastNoticeFun];
- }else { // 本地版本号 < 服务器版本号 (有新版本)
- [self showNewVersion:versionModel];
- [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
- };
- }
- - (void)showNewVersion:(HWVersionModel*)versionModel {
-
- HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
- if (haveNewVersionView.isShow) {
- return;
- }
-
- //此版本点击过稍后再试
- NSString *preVersionstr = [HWDataManager getStringWithKey:Const_did_show_version_and_click_wait];
- if(preVersionstr && [versionModel.versionNumber isEqualToString:preVersionstr]){
- //[self showNewerGuideFun];
- [self getLastNoticeFun];
- return;
- }
-
- haveNewVersionView.versionModel = versionModel;
- haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
- [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
- [ksharedAppDelegate.window addSubview:haveNewVersionView];
- haveNewVersionView.isShow = YES;
-
- if(!versionModel.necessary){
- haveNewVersionView.deleteBtn.hidden = NO;
- }
-
- [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
- haveNewVersionView.alpha = 0.0;
- [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
- haveNewVersionView.alpha = 1.0;
- KyoLog(@"in animate start");
- } completion:^(BOOL finished) {
- KyoLog(@"in animate completion");
- }];
-
- KWeakSelf
- haveNewVersionView.closeViewFun = ^{
- //[weakSelf showNewerGuideFun];
- [weakSelf getLastNoticeFun];
- };
- }
- //#pragma mark 弹框流程 3 新手引导弹窗
- //- (void)showNewerGuideFun
- //{
- // BOOL didShow = [HWDataManager getBoolWithKey:@"Const_did_show_newer_Guide"];
- //
- // if(didShow){
- // [self getLastNoticeFun];
- // return;
- // }
- //
- // //密码框界面 拦着 不给弹出
- // if(ksharedAppDelegate.isDidShowPwdType){
- // KWeakSelf
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [weakSelf showNewerGuideFun];
- // });
- // return;
- // }
- //
- // newerGuideView *guideView = [[newerGuideView alloc] init];
- // [ksharedAppDelegate.window addSubview:guideView];
- //
- // [guideView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.top.mas_equalTo(0);
- // make.left.mas_equalTo(0);
- // make.right.mas_equalTo(0);
- // make.bottom.mas_equalTo(0);
- // }];
- //
- //
- // KWeakSelf
- // guideView.didClickButtonFun = ^(NSInteger tag) {
- // [weakSelf didiClickNewerButtonFunBy:tag];
- // };
- //
- //}
- //
- //#pragma mark 新手引导点击事件
- //- (void)didiClickNewerButtonFunBy:(NSInteger)tag
- //{
- // [HWDataManager setBoolWithKey:@"Const_did_show_newer_Guide" value:YES];
- //
- // if(tag ==1){
- // [self getLastNoticeFun];
- // }
- // else if(tag ==2 || tag == 10){
- // CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
- // vc.titleStr = NSLocalizedString(@"mine_newuser_title",nil);
- //
- // NSString *url = [[NSString alloc] initWithFormat:@"%@/warrantyService/index.html#/novice?isNovice=true",CloudService];
- // if(tag == 10){
- // url = [url stringByReplacingOccurrencesOfString:@"?isNovice=true" withString:@""];
- // }
- //
- // vc.webUrl = url;
- // //[self pushViewController:vc animated:YES];
- //
- // NSArray*curVCArr = ksharedAppDelegate.mainTabBar.viewControllers;
- // NSInteger selectedIndex = ksharedAppDelegate.mainTabBar.selectedIndex;
- //
- // if(selectedIndex < curVCArr.count){
- // UIViewController * curVC = curVCArr[selectedIndex];
- // [curVC.navigationController pushViewController:curVC animated:YES];
- //
- // KWeakSelf
- // vc.didClickBackFun = ^{
- // [weakSelf getLastNoticeFun];
- // };
- // }
- //
- // }
- //}
- #pragma mark 弹框流程 4 通知公告弹窗
- - (void)getLastNoticeFun
- {
-
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:@"Private-X" forKey:@"productType"];
- [paraDict setValue:@"ios" forKey:@"type"];
-
- [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneNotice Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- noticeModel *model = [[noticeModel alloc] initWithDictionary:responseObject error:nil];
- //test code
- // model.status = 0;
- // model.data = [noticeDataModel new];
- // model.data.curNoticeId = @"1111";
- // model.data.title = @"版本升级通知公告";
- // model.data.content = @"1.偶现挤下线问题";
- // model.data.content = @"1.偶现挤下线问题\n2.本地网络弹框\n3.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n4.上传偶现UI刷新异常(数据库是正常的)\n5.偶现上传文件损坏\n6.链接不稳定问题(websock偶尔会不断重连\n7.进入设置页面读取数据偶现闪退!!!!\n8.本地网络弹框\n9.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n10.上传偶现UI刷新异常(数据库是正常的)\n11.偶现上传文件损坏\n12.链接不稳定问题(websock偶尔会不断重连)\n13.进入设置页面读取数据偶现闪退!!!!\n14.本地网络弹框\n15.访问相册权限之类的系统弹框会触发进入后台流程\n16.上传偶现UI刷新异常(数据库是正常的)";//\n17.偶现上传文件损坏\n18.链接不稳定问题(websock偶尔会不断重连\n19.进入设置页面读取数据偶现闪退!!!!\n20.本地网络弹框\n21.访问相册权限之类的系统弹框会触发进入后台流程\n22.上传偶现UI刷新异常(数据库是正常的)\n23.偶现上传文件损坏\n24.链接不稳定问题(websock偶尔会不断重连)\n25.进入设置页面读取数据偶现闪退!!!!\n26.本地网络弹框\n27.访问相册权限之类的系统弹框会触发进入后台流程\n28.上传偶现UI刷新异常(数据库是正常的)\n29.偶现上传文件损坏\n30.链接不稳定问题(websock偶尔会不断重连)\n31.进入设置页面读取数据偶现闪退!!!!";
-
- if (model && model.data && model.status == 0) {
- [self showHaveNoticeViewBy:model];
- }
- else
- {
-
- }
- } failure:^(NSError * _Nonnull error) {
- HLog(@"%@", error);
- }];
- }
- - (void)showHaveNoticeViewBy:(noticeModel*)model
- {
- //密码框界面 拦着 不给弹出
- if(ksharedAppDelegate.isDidShowPwdType){
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf showHaveNoticeViewBy:model];
- });
- return;
- }
-
- HaveNoticeView * noticeView = [HaveNoticeView shardInstance];
- NSString * preShowID = [HWDataManager getStringWithKey:Const_did_show_Notice_ID];
-
- if(noticeView.isShow
- || !model
- || [preShowID isEqualToString:model.data.curNoticeId]){
- return;
- }
-
- noticeView.curNoticeModel = model;
-
- //异常处理
- if(![iTools getKeyWindow]){
- return;
- }
-
- [[iTools getKeyWindow] addSubview:noticeView];
-
- [noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- noticeView.alpha = 0.0;
- [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
- noticeView.alpha = 1.0;
- } completion:^(BOOL finished) {
- }];
-
- }
- @end
|