PlayerViewController+AppDelegate.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 "RCCommandHelp.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. [self setShowImgAndVoiceTypeFun:NO];
  38. }
  39. - (void)applicationDidEnterBackground:(NSNotification *)notification {
  40. // 当前控制器是PlayerViewController app进入后台时 移除alert
  41. UIViewController *currentVC = [[ShortcutManager shareInstance] findCurrentShowingViewController];
  42. if ([currentVC isKindOfClass:[UIAlertController class]]) {
  43. UIAlertController *alertVC = (UIAlertController *)currentVC;
  44. NSMutableAttributedString *attriMsg = [alertVC valueForKey:@"_attributedMessage"];
  45. if ([attriMsg.string containsString:@"授权方已收回控制权,您进入观看屏幕模式。"] ||
  46. [attriMsg.string containsString:@"当前云手机正在受控,是否请求获取云手机控制权?"] ||
  47. [attriMsg.string containsString:@"当前云手机正在受控,进入云手机后,只能预览屏幕"]) {
  48. return;
  49. }
  50. [currentVC dismissViewControllerAnimated:NO completion:nil];
  51. }
  52. self.needToDissconnectType = YES;
  53. [self disconnectVideoServer];
  54. }
  55. - (void)applicationDidBecomeActive:(NSNotification *)notification
  56. {
  57. NSString *tempSSID = [self observeWiFi];
  58. self.nowSSid = tempSSID;
  59. if(self->logoutAlertVC){
  60. return;
  61. }
  62. if ([wattingView superview])
  63. {
  64. [self removeNewIndicator];
  65. [self showNewIndicator];
  66. }
  67. if (![tempSSID isEqualToString:self.nowSSid] && ![@"<<NONE>>" isEqualToString:tempSSID] && ![@"<<NONE>>" isEqualToString:self.nowSSid])
  68. {
  69. [self showNewIndicator];
  70. [self tryAgain];
  71. return;
  72. }
  73. if(self.needToDissconnectType){
  74. self.needToDissconnectType = NO;
  75. [self tryAgain];
  76. }
  77. else{
  78. [self requestIFrame];
  79. }
  80. [self setShowImgAndVoiceTypeFun:YES];
  81. [self updateCopydata];
  82. }
  83. - (void)applicationWillTerminate:(UIApplication *)application {
  84. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  85. [self disconnectVideoServer];
  86. }
  87. - (NSString *)observeWiFi{
  88. NSString *currentSSID = @"Not Found";
  89. CFArrayRef myArray = CNCopySupportedInterfaces();
  90. if (myArray != nil){
  91. NSDictionary* myDict = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo((CFStringRef)CFArrayGetValueAtIndex(myArray,0));
  92. if (myDict!=nil){
  93. currentSSID=[myDict valueForKey:@"SSID"];
  94. } else {
  95. currentSSID=@"<<NONE>>";
  96. }
  97. } else {
  98. currentSSID=@"<<NONE>>";
  99. }
  100. if (myArray)
  101. {
  102. CFRelease(myArray);
  103. }
  104. return currentSSID;
  105. }
  106. - (void)updateCopydata{
  107. UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
  108. NSString *str = [pasteboard string];
  109. HLog(@"__________%s______%@____",__func__,str);
  110. if ([str rangeOfString:@"CVLUSTERS_NOUSE_"].location != NSNotFound)
  111. {
  112. str = nil;
  113. }
  114. if (str && str.length >0)
  115. {
  116. //HLog(@"hxd111 cutting %@",str);
  117. /*发送数据*/
  118. NSString *dataStr = [RCCommandHelp commandCuttingWithContent:str];
  119. [self.commandChannelManager rc_sendData:dataStr];
  120. //pasteboard.string = @"";
  121. }
  122. }
  123. @end