123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- //
- // CloudPhoneViewController+RBDConnect.m
- // VclustersGemini
- //
- // Created by APPLE on 2021/8/16.
- // Copyright © 2021 APPLE. All rights reserved.
- //
- #import "PlayerViewController+AppDelegate.h"
- #import "AppDelegate.h"
- #import <SystemConfiguration/CaptiveNetwork.h>
- #import <RCCloudPhoneSDK/RCAudioPlayer.h>
- #import "ShortcutManager.h"
- #import <objc/runtime.h>
- #import "RCCommandHelp.h"
- #import "PlayerViewController+otherDelegate.h"
- //@interface PlayerViewController(AppDelegate)
- //
- //@end
- @implementation PlayerViewController(AppDelegate)
- @dynamic nowSSid;
- - (void)setNowSSid:(NSString *)nowSSid {
- objc_setAssociatedObject(self, @selector(nowSSid), nowSSid, OBJC_ASSOCIATION_COPY);
- }
- - (NSString *)nowSSid {
- return objc_getAssociatedObject(self, @selector(nowSSid));
- }
- #pragma mark - UIApplication Delegate
- - (void)applicationWillResignActive:(NSNotification *)notification
- {
- self.nowSSid = [self observeWiFi];
-
- if (USEAAC)
- {
- if (aacPlayer)
- {
- [aacPlayer stop];
-
- aacPlayer = nil;
- }
- }
-
- [self setShowImgAndVoiceTypeFun:NO];
- }
- - (void)applicationDidEnterBackground:(NSNotification *)notification {
- // 当前控制器是PlayerViewController app进入后台时 移除alert
- UIViewController *currentVC = [[ShortcutManager shareInstance] findCurrentShowingViewController];
- if ([currentVC isKindOfClass:[UIAlertController class]]) {
- UIAlertController *alertVC = (UIAlertController *)currentVC;
- NSMutableAttributedString *attriMsg = [alertVC valueForKey:@"_attributedMessage"];
- if ([attriMsg.string containsString:@"授权方已收回控制权,您进入观看屏幕模式。"] ||
- [attriMsg.string containsString:@"当前云手机正在受控,是否请求获取云手机控制权?"] ||
- [attriMsg.string containsString:@"当前云手机正在受控,进入云手机后,只能预览屏幕"]) {
- return;
- }
- [currentVC dismissViewControllerAnimated:NO completion:nil];
- }
-
- self.needToDissconnectType = YES;
- [self disconnectVideoServer];
-
- HLog(@"开始进入后台");
- //[cachesFileManager writeLogsWithMsg:@"EnterBackground"];
- }
- - (void)applicationDidBecomeActive:(NSNotification *)notification
- {
- NSString *tempSSID = [self observeWiFi];
-
- self.nowSSid = tempSSID;
-
-
- if ([wattingView superview])
- {
- [self removeNewIndicator];
- [self showNewIndicator];
- }
-
- if (![tempSSID isEqualToString:self.nowSSid] && ![@"<<NONE>>" isEqualToString:tempSSID] && ![@"<<NONE>>" isEqualToString:self.nowSSid])
- {
- [self showNewIndicator];
- [self tryAgain];
-
- return;
- }
-
- if(self.needToDissconnectType){
- self.needToDissconnectType = NO;
- [self tryAgain];
- }
- else{
- [self requestIFrame];
- }
-
-
- [self setShowImgAndVoiceTypeFun:YES];
- [self updateCopydata];
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self checkFullScreenWithTVShowStateFun];
- });
- }
- - (void)applicationWillTerminate:(UIApplication *)application {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
-
- [self disconnectVideoServer];
- }
- - (NSString *)observeWiFi{
- NSString *currentSSID = @"Not Found";
- CFArrayRef myArray = CNCopySupportedInterfaces();
- if (myArray != nil){
- NSDictionary* myDict = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo((CFStringRef)CFArrayGetValueAtIndex(myArray,0));
- if (myDict!=nil){
- currentSSID=[myDict valueForKey:@"SSID"];
- } else {
- currentSSID=@"<<NONE>>";
- }
- } else {
- currentSSID=@"<<NONE>>";
- }
-
- if (myArray)
- {
- CFRelease(myArray);
- }
-
- return currentSSID;
- }
- - (void)updateCopydata{
- UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
- NSString *str = [pasteboard string];
-
- HLog(@"__________%s______%@____",__func__,str);
-
- if ([str rangeOfString:@"CVLUSTERS_NOUSE_"].location != NSNotFound)
- {
- str = nil;
- }
-
- if (str && str.length >0)
- {
- //HLog(@"hxd111 cutting %@",str);
- /*发送数据*/
- NSString *dataStr = [RCCommandHelp commandCuttingWithContent:str];
- [[webSocketManager shareInstance] send_data:dataStr];
- //pasteboard.string = @"";
- }
-
- }
- #pragma mark 全面屏与TV投屏逻辑交互
- - (void)checkFullScreenWithTVShowStateFun
- {
- BOOL isTVShowType = ksharedAppDelegate.TvStatusMod.isTVShowType;
- BOOL fullscreenType = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
-
- if(isTVShowType && fullscreenType){//关闭全屏屏
- [HWDataManager setBoolWithKey:Consn_player_full_screen_show value:NO];
- fullscreenType = NO;
- //通知界面修改UI
- [[NSNotificationCenter defaultCenter] postNotificationName:setPlayerFullScreenNotification object:nil];
- }
-
- //重新设置分辨率
- if(fullscreenType){
- NSString *commandStr = [RCCommandHelp commondToSetFullScreenPhoneSize];
- [[webSocketManager shareInstance] send_data:commandStr];
- }
- else{
- if ((ksharedAppDelegate.couldPhone_W_PHONE == 720 && ksharedAppDelegate.couldPhone_H_PHONE == 1280)
- || (ksharedAppDelegate.couldPhone_W_PHONE == 1080 && ksharedAppDelegate.couldPhone_H_PHONE == 1920)) {//云机可能存在的分辨率
-
- }
- else{
- NSString *commondStr = [RCCommandHelp setPhoneSizecommandWithWidth:1080 high:1920 dpi:480];
- //NSString *commondStr = @"{\"data\":{\"height\":1920,\"width\":1080},\"type\":\"setPhoneSize\"}";
- [[webSocketManager shareInstance] send_data:commondStr];
- }
- }
- }
- @end
|