PlayerViewController+AppDelegate.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // CloudPhoneViewController+RBDConnect.m
  3. // VclustersGemini
  4. //
  5. // Created by APPLE on 2021/8/16.
  6. // Copyright © 2021 APPLE. All rights reserved.
  7. //
  8. #import "PlayerViewController+AppDelegate.h"
  9. #import "AppDelegate.h"
  10. #import <SystemConfiguration/CaptiveNetwork.h>
  11. #import <RCCloudPhoneSDK/RCAudioPlayer.h>
  12. #import "ShortcutManager.h"
  13. #import <objc/runtime.h>
  14. #import "UseAccountManage.h"
  15. @interface PlayerViewController(AppDelegate)
  16. @end
  17. @implementation PlayerViewController(AppDelegate)
  18. @dynamic nowSSid;
  19. - (void)setNowSSid:(NSString *)nowSSid {
  20. objc_setAssociatedObject(self, @selector(nowSSid), nowSSid, OBJC_ASSOCIATION_COPY);
  21. }
  22. - (NSString *)nowSSid {
  23. return objc_getAssociatedObject(self, @selector(nowSSid));
  24. }
  25. #pragma mark - UIApplication Delegate
  26. - (void)applicationWillResignActive:(NSNotification *)notification
  27. {
  28. self.nowSSid = [self observeWiFi];
  29. if (USEAAC)
  30. {
  31. if (aacPlayer)
  32. {
  33. [aacPlayer stop];
  34. aacPlayer = nil;
  35. }
  36. }
  37. }
  38. - (void)applicationDidEnterBackground:(NSNotification *)notification {
  39. // 当前控制器是PlayerViewController app进入后台时 移除alert
  40. UIViewController *currentVC = [[ShortcutManager shareInstance] findCurrentShowingViewController];
  41. if ([currentVC isKindOfClass:[UIAlertController class]]) {
  42. UIAlertController *alertVC = (UIAlertController *)currentVC;
  43. NSMutableAttributedString *attriMsg = [alertVC valueForKey:@"_attributedMessage"];
  44. if ([attriMsg.string containsString:@"授权方已收回控制权,您进入观看屏幕模式。"] ||
  45. [attriMsg.string containsString:@"当前云手机正在受控,是否请求获取云手机控制权?"] ||
  46. [attriMsg.string containsString:@"当前云手机正在受控,进入云手机后,只能预览屏幕"]) {
  47. return;
  48. }
  49. [currentVC dismissViewControllerAnimated:NO completion:nil];
  50. }
  51. }
  52. - (void)applicationDidBecomeActive:(NSNotification *)notification
  53. {
  54. NSString *tempSSID = [self observeWiFi];
  55. self.nowSSid = tempSSID;
  56. if ([wattingView superview])
  57. {
  58. [self removeNewIndicator];
  59. [self showNewIndicator];
  60. }
  61. if (![tempSSID isEqualToString:self.nowSSid] && ![@"<<NONE>>" isEqualToString:tempSSID] && ![@"<<NONE>>" isEqualToString:self.nowSSid])
  62. {
  63. [self showNewIndicator];
  64. [self tryAgain];
  65. return;
  66. }
  67. [self requestIFrame];
  68. }
  69. - (void)applicationWillTerminate:(UIApplication *)application {
  70. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  71. [[UseAccountManage shareInstance] saveDviceDriftInfoWith:mPlayerView.controlBtn.frame.origin.x
  72. ponitY:mPlayerView.controlBtn.frame.origin.y
  73. hidden:mPlayerView.controlBtn.hidden
  74. deviceSN:self.deviceId];
  75. [self disconnectVideoServer];
  76. }
  77. - (NSString *)observeWiFi{
  78. NSString *currentSSID = @"Not Found";
  79. CFArrayRef myArray = CNCopySupportedInterfaces();
  80. if (myArray != nil){
  81. NSDictionary* myDict = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo((CFStringRef)CFArrayGetValueAtIndex(myArray,0));
  82. if (myDict!=nil){
  83. currentSSID=[myDict valueForKey:@"SSID"];
  84. } else {
  85. currentSSID=@"<<NONE>>";
  86. }
  87. } else {
  88. currentSSID=@"<<NONE>>";
  89. }
  90. if (myArray)
  91. {
  92. CFRelease(myArray);
  93. }
  94. return currentSSID;
  95. }
  96. @end