cloudPhoneViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. //
  2. // cloudPhoneViewController.m
  3. //
  4. //
  5. // Created David on 2024/6/20.
  6. //
  7. #import "cloudPhoneViewController.h"
  8. #import "cloudPhoneSetView.h"
  9. #import "webRtcMsgModel.h"
  10. #import "webRtcPlayerViewController.h"
  11. #import "HaveNewVersionView.h"
  12. #import "noticeModel.h"
  13. #import "HaveNoticeView.h"
  14. //#import "boxCheckStatusModel.h"
  15. #import "imageVersionRenewTipView.h"
  16. @interface cloudPhoneViewController ()
  17. {
  18. BOOL didGetSysInfoType;//是否收到过系统信息用在---用来判断是否要走弹框流程
  19. }
  20. @property (nonatomic,strong) cloudPhoneSetView *cloudPhoneSetV;
  21. @property (nonatomic,strong) webRtcMsgModel *webRtcMsgMod;
  22. @end
  23. @implementation cloudPhoneViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. //输入密码完成
  28. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didInpuPwdOkFun) name:didInputPWDNotification object:nil];
  29. //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneSysInfoFun:) name:getCouldPhoneSysInfoNotification object:nil];
  30. [self.view setBackgroundColor:HWF5F7FAColor];
  31. [self.toolBar setHidden:YES];
  32. [self.navigationBar setHidden:YES];
  33. [self.navBarBGView setHidden:YES];
  34. [self drawAnyView];
  35. }
  36. - (void)drawAnyView{
  37. //顶底底部图片
  38. UIImageView *topImageV = [UIImageView new];
  39. topImageV.userInteractionEnabled = YES;
  40. topImageV.image = [UIImage imageNamed:@"cloudPhone_bg"];
  41. [self.view addSubview:topImageV];
  42. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.top.mas_equalTo(0);
  44. make.left.mas_equalTo(0);
  45. make.right.mas_equalTo(0);
  46. make.bottom.mas_equalTo(0);
  47. }];
  48. CGFloat width = SCREEN_W;
  49. CGFloat height = SCREEN_H;
  50. BOOL isSmallPhoneType = NO;
  51. if(width == 375 && height == 667){
  52. isSmallPhoneType = YES;
  53. }
  54. CGFloat adjustSmallScale = 0.9;
  55. // if(isSmallPhoneType){
  56. // adjustSmallScale = 0.85;
  57. // }
  58. CGFloat imageTopY = 40.0;
  59. // if(isSmallPhoneType){
  60. // imageTopY = 20.0;
  61. // }
  62. //设置按钮
  63. UIButton *setButton = [[UIButton alloc] init];
  64. //[setButton setBackgroundImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  65. [setButton setImage:[UIImage imageNamed:@"cloudPhone_set"] forState:UIControlStateNormal];
  66. setButton.tag = 1;
  67. [setButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  68. [self.view addSubview:setButton];
  69. //setButton.backgroundColor = [UIColor greenColor];
  70. [setButton mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.top.mas_equalTo(imageTopY);
  72. if(isSmallPhoneType){
  73. make.right.mas_equalTo(-5);
  74. }
  75. else{
  76. make.right.mas_equalTo(-16);
  77. }
  78. make.width.mas_equalTo(50);
  79. make.height.mas_equalTo(50);
  80. // make.top.mas_equalTo(imageTopY);
  81. // make.right.mas_equalTo(-16);
  82. // make.width.mas_equalTo(24);
  83. // make.height.mas_equalTo(24);
  84. }];
  85. //中间图片
  86. UIImageView *midImageV = [UIImageView new];
  87. midImageV.userInteractionEnabled = YES;
  88. midImageV.image = [UIImage imageNamed:@"cloudPhone_mid_img"];
  89. [self.view addSubview:midImageV];
  90. [midImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.width.mas_equalTo(326*WAUTOSCALE*adjustSmallScale);
  92. make.height.mas_equalTo(608*WAUTOSCALE*adjustSmallScale);
  93. make.centerX.mas_equalTo(0);
  94. make.centerY.mas_equalTo(-10);
  95. }];
  96. NSString *midTopTip1Str = NSLocalizedString(@"cloudPhone_top_tip1",nil);
  97. NSString *midTopTip2Str = NSLocalizedString(@"cloudPhone_top_tip2",nil);
  98. //提示文字
  99. UILabel *midTopTipLab1 = [[UILabel alloc] init];
  100. midTopTipLab1.text = midTopTip1Str;
  101. midTopTipLab1.font = [UIFont systemFontOfSize:20.0];
  102. midTopTipLab1.textColor = [UIColor hwColor:@"#0A132B"];
  103. midTopTipLab1.textAlignment = NSTextAlignmentCenter;
  104. [midImageV addSubview:midTopTipLab1];
  105. [midTopTipLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.top.equalTo(midImageV.mas_top).offset(64);
  107. make.right.equalTo(midImageV.mas_right).offset(0);
  108. make.left.equalTo(midImageV.mas_left).offset(0);
  109. make.height.mas_equalTo(24);
  110. }];
  111. UILabel *midTopTipLab2 = [[UILabel alloc] init];
  112. midTopTipLab2.text = midTopTip2Str;
  113. midTopTipLab2.font = [UIFont systemFontOfSize:16.0];
  114. midTopTipLab2.textColor = [UIColor hwColor:@"#535657"];
  115. midTopTipLab2.textAlignment = NSTextAlignmentCenter;
  116. [midImageV addSubview:midTopTipLab2];
  117. [midTopTipLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.top.equalTo(midTopTipLab1.mas_bottom).offset(15);
  119. make.right.equalTo(midImageV.mas_right).offset(0);
  120. make.left.equalTo(midImageV.mas_left).offset(0);
  121. make.height.mas_equalTo(20);
  122. }];
  123. //进入云机
  124. UIButton*enterCloudPhoneButton = [[UIButton alloc] init];
  125. CGFloat w_btn = SCREEN_W - 15*2 - 50*2;
  126. // gradient
  127. CAGradientLayer *gl = [CAGradientLayer layer];
  128. gl.frame = CGRectMake(0,0,w_btn,44.f);
  129. gl.startPoint = CGPointMake(0, 0.5);
  130. gl.endPoint = CGPointMake(0.97, 0.5);
  131. gl.colors = @[(__bridge id)HWFFE10FColor.CGColor, (__bridge id)HWFFE411Color.CGColor];
  132. gl.locations = @[@(0), @(1.0f)];
  133. [enterCloudPhoneButton.layer addSublayer:gl];
  134. [enterCloudPhoneButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
  135. //[enterCloudPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
  136. [enterCloudPhoneButton setTitle:NSLocalizedString(@"cloudPhone_enter_tip",nil) forState:(UIControlStateNormal)];
  137. [enterCloudPhoneButton.titleLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
  138. [enterCloudPhoneButton.layer setCornerRadius:21.f];
  139. enterCloudPhoneButton.layer.borderWidth = 0.5;
  140. enterCloudPhoneButton.layer.borderColor = [UIColor clearColor].CGColor;
  141. enterCloudPhoneButton.clipsToBounds = YES;
  142. //enterCloudPhoneButton.tag = 2;
  143. [midImageV addSubview:enterCloudPhoneButton];
  144. [enterCloudPhoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.width.mas_equalTo(w_btn);
  146. make.height.mas_equalTo(42);
  147. make.centerX.mas_equalTo(0);
  148. make.bottom.equalTo(midImageV.mas_bottom).offset(-30);
  149. }];
  150. //扩大金融云机范围按钮
  151. UIButton *bigButton = [[UIButton alloc] init];
  152. bigButton.tag = 2;
  153. [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  154. [self.view addSubview:bigButton];
  155. //bigButton.backgroundColor = [UIColor greenColor];
  156. [bigButton mas_makeConstraints:^(MASConstraintMaker *make) {
  157. make.top.equalTo(midImageV.mas_top).offset(0);
  158. make.right.equalTo(midImageV.mas_right).offset(0);
  159. make.left.equalTo(midImageV.mas_left).offset(0);
  160. make.bottom.equalTo(midImageV.mas_bottom).offset(0);
  161. }];
  162. }
  163. #pragma mark 点击按钮
  164. - (void)didClickButtonFun:(UIButton*)but
  165. {
  166. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  167. {
  168. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  169. return;
  170. }
  171. // if (!ksharedAppDelegate.isWebSockLinkOKAginType) {//未链接
  172. // [[iToast makeText:NSLocalizedString(@"box_link_error_show_tip",nil)] show];
  173. // return;
  174. // }
  175. NSInteger tag = but.tag;
  176. HLog(@"%ld",tag);
  177. switch (tag) {
  178. case 1:
  179. {
  180. //数据埋点
  181. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_settings"];
  182. _cloudPhoneSetV = [cloudPhoneSetView new];
  183. [ksharedAppDelegate.window addSubview:_cloudPhoneSetV];
  184. [_cloudPhoneSetV mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.left.mas_equalTo(0);
  186. make.right.mas_equalTo(0);
  187. make.top.mas_equalTo(0);
  188. make.bottom.mas_equalTo(0);
  189. }];
  190. KWeakSelf
  191. _cloudPhoneSetV.didClickButtonFun = ^(NSInteger tag) {
  192. if (tag == 10) {//重启
  193. [weakSelf didClickRestartFun];
  194. }
  195. else if (tag == 11){//恢复出厂
  196. [weakSelf RestoreFactoryAleartFun];
  197. }
  198. };
  199. }
  200. break;
  201. case 2:
  202. {
  203. //[self checkFullScreenWithTVShowStateFun];
  204. // PlayerViewController *vc = [PlayerViewController new];
  205. // [self pushViewController:vc animated:YES];
  206. //
  207. // if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  208. // [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
  209. // }
  210. [self queryWebRtcMsgFun:YES];
  211. //数据埋点
  212. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Cloud_enter"];
  213. //[self checkBoxStatusFun];
  214. }
  215. break;
  216. default:
  217. break;
  218. }
  219. }
  220. #pragma mark 点击了重启空间
  221. - (void)didClickRestartFun
  222. {
  223. KWeakSelf
  224. /*弹窗提示重启*/
  225. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  226. msg:@""
  227. imageStr:@""
  228. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  229. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil) isOkBtnHighlight:NO
  230. didClickOk:^{
  231. [weakSelf sureToRestartCloudPhoneFun];
  232. } didClickCancel:^{
  233. }];
  234. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  235. [self presentViewController:nextVC animated:YES completion:^{
  236. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  237. }];
  238. }
  239. #pragma mark 确认重启云机
  240. - (void)sureToRestartCloudPhoneFun{
  241. // /*重启云手机*/
  242. // 通过指令通道发送 {"type":"reboot"}
  243. [[webRtcManager shareManager] needToRebootFun];
  244. //提示语
  245. [[iToast makeText:NSLocalizedString(@"player_link_rebooting_Tips",nil)] show];
  246. }
  247. #pragma mark 点击恢复出厂
  248. - (void)RestoreFactoryAleartFun
  249. {
  250. KWeakSelf
  251. /*弹窗提示恢复出厂*/
  252. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_tips",nil)
  253. msg:NSLocalizedString(@"my_set_no_Restore_Factory_msg",nil)
  254. imageStr:@"icon_Restore_Factory_big"
  255. cancelTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil)
  256. okTitle:NSLocalizedString(@"other_cancel",nil) isOkBtnHighlight:YES
  257. didClickOk:^{
  258. } didClickCancel:^{
  259. //点击确定
  260. [weakSelf gotoResetFun];
  261. }];
  262. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  263. [self presentViewController:nextVC animated:YES completion:^{
  264. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  265. }];
  266. }
  267. #pragma mark 点击了恢复出厂
  268. - (void)gotoResetFun
  269. {
  270. [[webRtcManager shareManager] needToResetFun];
  271. [self RestoreFactoryingFun];
  272. }
  273. #pragma mark 恢复出厂中
  274. - (void)RestoreFactoryingFun
  275. {
  276. KWeakSelf
  277. /*弹窗提示恢复出厂*/
  278. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factorying_tips",nil)
  279. msg:NSLocalizedString(@"my_set_no_Restore_Factorying_msg",nil)
  280. imageStr:@""
  281. cancelTitle:NSLocalizedString(@"my_set_no_Restore_Factorying",nil)
  282. okTitle:@""
  283. isOkBtnHighlight:NO
  284. didClickOk:^{
  285. [weakSelf RestoreFactoryCompleteFun];
  286. } didClickCancel:^{
  287. }];
  288. [nextVC setButtonCountdownFun:180];//90
  289. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  290. [self presentViewController:nextVC animated:YES completion:^{
  291. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  292. }];
  293. }
  294. #pragma mark 恢复出厂倒计时结束
  295. - (void)RestoreFactoryCompleteFun
  296. {
  297. //KWeakSelf
  298. /*弹窗提示恢复出厂*/
  299. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_Restore_Factory_ok_tips",nil)
  300. msg:@""
  301. imageStr:@""
  302. cancelTitle:NSLocalizedString(@"my_set_no_Restore_FactoryOK",nil)
  303. okTitle:@""
  304. isOkBtnHighlight:NO
  305. didClickOk:^{
  306. } didClickCancel:^{
  307. }];
  308. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  309. [self presentViewController:nextVC animated:YES completion:^{
  310. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  311. }];
  312. }
  313. - (void)viewWillAppear:(BOOL)animated{
  314. [super viewWillAppear:animated];
  315. // [self beginShowAlertFun];
  316. //
  317. // BOOL isNeedShowSecret = [HWDataManager getBoolWithKey:Const_need_show_Secret_key];
  318. // if(isNeedShowSecret){
  319. // [self showSecretkeyFun];
  320. // }
  321. }
  322. - (void)viewWillDisappear:(BOOL)animated{
  323. [super viewWillDisappear:animated];
  324. }
  325. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  326. {
  327. [self.navigationController pushViewController:vc animated:animated];
  328. }
  329. #pragma mark 获取webrct 的链接信息
  330. -(void)queryWebRtcMsgFun:(BOOL)isPlayerType
  331. {
  332. if(isPlayerType){
  333. if(ksharedAppDelegate.DeviceWebRtcMsgMod && ksharedAppDelegate.DeviceWebRtcMsgMod.data.sn){
  334. [self gotoWebRtcVcBy:ksharedAppDelegate.DeviceWebRtcMsgMod];
  335. return;
  336. }
  337. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  338. }
  339. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  340. KWeakSelf
  341. [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){
  342. if(isPlayerType){
  343. [weakSelf removeNewIndicator];
  344. }
  345. webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
  346. if(curModel && curModel.status == 0){
  347. ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
  348. if(isPlayerType){
  349. [weakSelf gotoWebRtcVcBy:curModel];
  350. }
  351. }
  352. else
  353. {
  354. if(isPlayerType && curModel.msg){
  355. [[iToast makeText:curModel.msg] show];
  356. }
  357. }
  358. } failure:^(NSError * _Nonnull error) {
  359. if(isPlayerType){
  360. [weakSelf removeNewIndicator];
  361. [[iToast makeText:NSLocalizedString(@"get_webrtcMsg_fail_tip",nil)] show];
  362. }
  363. }];
  364. }
  365. #pragma mark 跳转webrtc 页面
  366. - (void)gotoWebRtcVcBy:(webRtcMsgModel*)webRtcMsgMod
  367. {
  368. NSArray * vcArrs = self.navigationController.viewControllers;
  369. if(vcArrs.count != 1){
  370. return;
  371. }
  372. webRtcPlayerViewController *vc = [webRtcPlayerViewController new];
  373. vc.webRtcMsgMod = webRtcMsgMod;
  374. [self.navigationController pushViewController:vc animated:YES];
  375. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  376. ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = NO;
  377. ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = NO;
  378. });
  379. }
  380. #pragma mark 输入密码完成
  381. - (void)didInpuPwdOkFun
  382. {
  383. KWeakSelf
  384. mainBlock(^{
  385. if(ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType){
  386. [weakSelf queryWebRtcMsgFun:YES];
  387. }
  388. //查询掌机是否在线
  389. //[weakSelf checkBoxStatusFun];
  390. });
  391. }
  392. #pragma mark 获取到云机系统相关基本信息
  393. //- (void)getCouldPhoneSysInfoFun:(NSNotification*)not
  394. //{//弹框流程 优先级:强制盒子更新弹窗 > APP版本更新弹窗 > 通知公告弹窗
  395. //
  396. // if(didGetSysInfoType){//弹框流程已经走过
  397. // return;
  398. // }
  399. //
  400. // didGetSysInfoType = YES;
  401. //
  402. // if(ksharedAppDelegate.isNeedShowImageNewType){//强制盒子更新弹窗
  403. // mainBlock(^{
  404. // [self showImageViewRenewTipViewFun];
  405. // });
  406. //
  407. // }
  408. //}
  409. #pragma mark - 查询掌机情况
  410. //1、掌机Gbox助手干掉 - 客户端去掉容器开关机检测功能 20231119
  411. //- (void)checkBoxStatusFun
  412. //{
  413. // NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  414. // [paraDict setValue:@2 forKey:@"type"];
  415. //
  416. // KWeakSelf
  417. // [[netWorkManager shareInstance] CommonPostCallBackCode:queryBoxStatus Parameters:paraDict success:^(id _Nonnull responseObject) {
  418. //
  419. // boxCheckStatusModel *model = [[boxCheckStatusModel alloc] initWithDictionary:responseObject error:nil];
  420. //
  421. // if (model && model.data && model.status == 0) {
  422. // if(model.data.containerAgentStatus == 0){
  423. // [weakSelf showAlertByBoxCloseStateFun];
  424. // }
  425. // }
  426. // else
  427. // {
  428. //
  429. // }
  430. //
  431. // } failure:^(NSError * _Nonnull error) {
  432. // HLog(@"%@", error);
  433. // }];
  434. //}
  435. #pragma mark 显示云机系统已经关闭
  436. - (void)showAlertByBoxCloseStateFun
  437. {
  438. KWeakSelf
  439. /*弹窗提示*/
  440. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"cloudPhone_system_state_close_title",nil)
  441. msg:NSLocalizedString(@"cloudPhone_system_state_close_tip",nil)
  442. imageStr:@""
  443. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  444. okTitle:@"" isOkBtnHighlight:NO
  445. didClickOk:^{
  446. } didClickCancel:^{
  447. }];
  448. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  449. [self presentViewController:nextVC animated:YES completion:^{
  450. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  451. }];
  452. }
  453. @end