PlayerViewController+AppDelegate.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. @interface PlayerViewController(AppDelegate)
  15. @end
  16. @implementation PlayerViewController(AppDelegate)
  17. @dynamic nowSSid;
  18. - (void)setNowSSid:(NSString *)nowSSid {
  19. objc_setAssociatedObject(self, @selector(nowSSid), nowSSid, OBJC_ASSOCIATION_COPY);
  20. }
  21. - (NSString *)nowSSid {
  22. return objc_getAssociatedObject(self, @selector(nowSSid));
  23. }
  24. #pragma mark - UIApplication Delegate
  25. - (void)applicationWillResignActive:(NSNotification *)notification
  26. {
  27. self.nowSSid = [self observeWiFi];
  28. if (USEAAC)
  29. {
  30. if (aacPlayer)
  31. {
  32. [aacPlayer stop];
  33. aacPlayer = nil;
  34. }
  35. }
  36. [self setShowImgAndVoiceTypeFun:NO];
  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. self.needToDissconnectType = YES;
  52. [self disconnectVideoServer];
  53. }
  54. - (void)applicationDidBecomeActive:(NSNotification *)notification
  55. {
  56. NSString *tempSSID = [self observeWiFi];
  57. self.nowSSid = tempSSID;
  58. if ([wattingView superview])
  59. {
  60. [self removeNewIndicator];
  61. [self showNewIndicator];
  62. }
  63. if (![tempSSID isEqualToString:self.nowSSid] && ![@"<<NONE>>" isEqualToString:tempSSID] && ![@"<<NONE>>" isEqualToString:self.nowSSid])
  64. {
  65. [self showNewIndicator];
  66. [self tryAgain];
  67. return;
  68. }
  69. if(self.needToDissconnectType){
  70. self.needToDissconnectType = NO;
  71. [self tryAgain];
  72. }
  73. else{
  74. [self requestIFrame];
  75. }
  76. [self setShowImgAndVoiceTypeFun:YES];
  77. }
  78. - (void)applicationWillTerminate:(UIApplication *)application {
  79. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  80. [self disconnectVideoServer];
  81. }
  82. - (NSString *)observeWiFi{
  83. NSString *currentSSID = @"Not Found";
  84. CFArrayRef myArray = CNCopySupportedInterfaces();
  85. if (myArray != nil){
  86. NSDictionary* myDict = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo((CFStringRef)CFArrayGetValueAtIndex(myArray,0));
  87. if (myDict!=nil){
  88. currentSSID=[myDict valueForKey:@"SSID"];
  89. } else {
  90. currentSSID=@"<<NONE>>";
  91. }
  92. } else {
  93. currentSSID=@"<<NONE>>";
  94. }
  95. if (myArray)
  96. {
  97. CFRelease(myArray);
  98. }
  99. return currentSSID;
  100. }
  101. @end