PlayerViewController+AppDelegate.m 4.4 KB

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