PlayerViewController+AppDelegate.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. }
  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. [self setShowImgAndVoiceTypeFun:YES];
  69. }
  70. - (void)applicationWillTerminate:(UIApplication *)application {
  71. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  72. [self disconnectVideoServer];
  73. }
  74. - (NSString *)observeWiFi{
  75. NSString *currentSSID = @"Not Found";
  76. CFArrayRef myArray = CNCopySupportedInterfaces();
  77. if (myArray != nil){
  78. NSDictionary* myDict = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo((CFStringRef)CFArrayGetValueAtIndex(myArray,0));
  79. if (myDict!=nil){
  80. currentSSID=[myDict valueForKey:@"SSID"];
  81. } else {
  82. currentSSID=@"<<NONE>>";
  83. }
  84. } else {
  85. currentSSID=@"<<NONE>>";
  86. }
  87. if (myArray)
  88. {
  89. CFRelease(myArray);
  90. }
  91. return currentSSID;
  92. }
  93. @end