Fix deprecated methods in AppRTCMobile.

Remove warning suppressions and update code that uses deprecated methods
to the currently supported APIs.

BUG=webrtc:5549

Review-Url: https://codereview.webrtc.org/2780433006
Cr-Commit-Position: refs/heads/master@{#17472}
This commit is contained in:
kthelgason 2017-03-30 04:56:05 -07:00 committed by Commit bot
parent 18703f9583
commit b13237b9da
5 changed files with 71 additions and 81 deletions

View File

@ -150,23 +150,6 @@ if (is_android) {
}
if (is_ios || (is_mac && target_cpu != "x86")) {
config("warnings_config") {
# GN orders flags on a target before flags from configs. The default config
# adds these flags so to cancel them out they need to come from a config and
# cannot be on the target directly.
if (is_ios) {
# Suppress compiler warnings about deprecated that triggered
# when moving from ios_deployment_target 7.0 to 9.0.
# See webrtc:5549 for more details.
cflags = [ "-Wno-deprecated-declarations" ]
cflags_objc = [
# Enabled for cflags_objc in build/config/compiler/BUILD.gn.
# See webrtc:6520.
"-Wno-objc-missing-property-synthesis",
]
}
}
config("apprtc_common_config") {
include_dirs = [ "objc/AppRTCMobile/common" ]
}
@ -177,10 +160,7 @@ if (is_ios || (is_mac && target_cpu != "x86")) {
"objc/AppRTCMobile/common/ARDUtilities.h",
"objc/AppRTCMobile/common/ARDUtilities.m",
]
configs += [
":warnings_config",
"//build/config/compiler:enable_arc",
]
configs += [ "//build/config/compiler:enable_arc" ]
public_configs = [ ":apprtc_common_config" ]
deps = [
@ -245,10 +225,7 @@ if (is_ios || (is_mac && target_cpu != "x86")) {
"objc/AppRTCMobile/RTCSessionDescription+JSON.h",
"objc/AppRTCMobile/RTCSessionDescription+JSON.m",
]
configs += [
"//build/config/compiler:enable_arc",
":warnings_config",
]
configs += [ "//build/config/compiler:enable_arc" ]
public_configs = [ ":apprtc_signaling_config" ]
deps = [
":apprtc_common",
@ -281,10 +258,7 @@ if (is_ios || (is_mac && target_cpu != "x86")) {
"objc/AppRTCMobile/ios/UIImage+ARDUtilities.h",
"objc/AppRTCMobile/ios/UIImage+ARDUtilities.m",
]
configs += [
"//build/config/compiler:enable_arc",
":warnings_config",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
":apprtc_common",

View File

@ -57,29 +57,26 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
request.HTTPMethod = @"POST";
__weak ARDAppEngineClient *weakSelf = self;
[NSURLConnection sendAsyncRequest:request
completionHandler:^(NSURLResponse *response,
NSData *data,
NSError *error) {
ARDAppEngineClient *strongSelf = weakSelf;
if (error) {
if (completionHandler) {
completionHandler(nil, error);
}
return;
}
ARDJoinResponse *joinResponse =
[ARDJoinResponse responseFromJSONData:data];
if (!joinResponse) {
if (completionHandler) {
NSError *error = [[self class] badResponseError];
completionHandler(nil, error);
}
return;
}
if (completionHandler) {
completionHandler(joinResponse, nil);
}
}];
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
ARDAppEngineClient *strongSelf = weakSelf;
if (error) {
if (completionHandler) {
completionHandler(nil, error);
}
return;
}
ARDJoinResponse *joinResponse = [ARDJoinResponse responseFromJSONData:data];
if (!joinResponse) {
if (completionHandler) {
NSError *error = [[self class] badResponseError];
completionHandler(nil, error);
}
return;
}
if (completionHandler) {
completionHandler(joinResponse, nil);
}
}];
}
- (void)sendMessage:(ARDSignalingMessage *)message
@ -138,17 +135,24 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
NSURLResponse *response = nil;
NSError *error = nil;
RTCLog(@"C->RS: BYE");
__block NSError *error = nil;
// We want a synchronous request so that we know that we've left the room on
// room server before we do any further work.
RTCLog(@"C->RS: BYE");
[NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[NSURLConnection sendAsyncRequest:request
completionHandler:^(NSURLResponse *response, NSData *data, NSError *e) {
if (e) {
error = e;
}
dispatch_semaphore_signal(sem);
}];
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
if (error) {
RTCLogError(@"Error leaving room %@ on room server: %@",
roomId, error.localizedDescription);
RTCLogError(@"Error leaving room %@ on room server: %@", roomId, error.localizedDescription);
if (completionHandler) {
completionHandler(error);
}

View File

@ -47,15 +47,13 @@
NSData *data,
NSError *error))completionHandler {
// Kick off an async request which will call back on main thread.
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data,
NSError *error) {
if (completionHandler) {
completionHandler(response, data, error);
}
}];
NSURLSession *session = [NSURLSession sharedSession];
[[session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (completionHandler) {
completionHandler(response, data, error);
}
}] resume];
}
// Posts data to the specified URL.

View File

@ -255,12 +255,18 @@ static NSString *const loopbackLaunchProcessArgument = @"loopback";
}
- (void)showAlertWithMessage:(NSString*)message {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
}
@end

View File

@ -35,6 +35,8 @@
}
@synthesize videoCallView = _videoCallView;
@synthesize localVideoTrack = _localVideoTrack;
@synthesize remoteVideoTrack = _remoteVideoTrack;
@synthesize delegate = _delegate;
- (instancetype)initForRoom:(NSString *)room
@ -214,12 +216,18 @@
}
- (void)showAlertWithMessage:(NSString*)message {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
}
@end