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