From 7f4f95a9d1fa748d7ba644390cb3d6e58ded575b Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 5 Feb 2016 14:00:22 +0100 Subject: [PATCH] xcode: fix invalid calls to API greater than currently available fixing crashes on iOS6/iOS7 --- Classes/CallView.m | 4 +--- Classes/ChatConversationCreateTableView.m | 4 ++-- Classes/LinphoneAppDelegate.m | 4 ++++ Classes/LinphoneManager.m | 8 ++++--- Classes/LinphoneUI/UIChatBubbleTextCell.m | 2 ++ Classes/SideMenuView.m | 21 ++++++++++++------- .../IASKSpecifierValuesViewController.m | 15 ------------- Classes/Utils/Utils.h | 3 ++- Classes/Utils/Utils.m | 9 ++++++++ TestsUI/ChatTester.m | 2 +- TestsUI/LinphoneTestCase.m | 2 +- 11 files changed, 40 insertions(+), 34 deletions(-) diff --git a/Classes/CallView.m b/Classes/CallView.m index e8aa0294a..1e14d859a 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -125,12 +125,10 @@ static UICompositeViewDescription *compositeDescription = nil; [_hashButton setDtmf:true]; } -- (void)viewDidUnload { +- (void)dealloc { [PhoneMainView.instance.view removeGestureRecognizer:singleFingerTap]; // Remove all observer [NSNotificationCenter.defaultCenter removeObserver:self]; - - [super viewDidUnload]; } - (void)viewWillAppear:(BOOL)animated { diff --git a/Classes/ChatConversationCreateTableView.m b/Classes/ChatConversationCreateTableView.m index b0a0ab0ff..9c07f4a2d 100644 --- a/Classes/ChatConversationCreateTableView.m +++ b/Classes/ChatConversationCreateTableView.m @@ -37,8 +37,8 @@ NSString *address = (NSString *)key; ABRecordRef person = (__bridge ABRecordRef)(value); NSString *name = [FastAddressBook displayNameForContact:person]; - if ((filter.length == 0) || ([name.lowercaseString containsString:filter.lowercaseString]) || - ([address.lowercaseString containsString:filter.lowercaseString])) { + if ((filter.length == 0) || ([name.lowercaseString containsSubstring:filter.lowercaseString]) || + ([address.lowercaseString containsSubstring:filter.lowercaseString])) { _contacts[address] = name; } diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 7b3cecce3..81411b5b2 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -101,6 +101,7 @@ } } +#pragma deploymate push "ignored-api-availability" - (UIUserNotificationCategory *)getMessageNotificationCategory { NSArray *actions; @@ -195,6 +196,7 @@ } } } +#pragma deploymate pop - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { @@ -415,6 +417,7 @@ #pragma mark - User notifications +#pragma deploymate push "ignored-api-availability" - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { LOGI(@"%@", NSStringFromSelector(_cmd)); @@ -483,6 +486,7 @@ LOGI(@"%@", NSStringFromSelector(_cmd)); completionHandler(); } +#pragma deploymate pop #pragma mark - Remote configuration Functions (URL Handler) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 9a9004f6f..3fb1b268f 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -919,7 +919,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char NSString *chat = [UIChatBubbleTextCell TextMessageForChat:msg]; notif.repeatInterval = 0; if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) { +#pragma deploymate push "ignored-api-availability" notif.category = @"incoming_msg"; +#pragma deploymate pop } if ([LinphoneManager.instance lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES]) { notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_FULLMSG", nil), from, chat]; @@ -1250,6 +1252,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach NSNumber *number = (NSNumber *)[dataNetworkItemView valueForKey:@"dataNetworkType"]; return [number intValue]; } else { +#pragma deploymate push "ignored-api-availability" CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init]; NSString *currentRadio = info.currentRadioAccessTechnology; if ([currentRadio isEqualToString:CTRadioAccessTechnologyEdge]) { @@ -1257,6 +1260,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach } else if ([currentRadio isEqualToString:CTRadioAccessTechnologyLTE]) { return network_4g; } +#pragma deploymate pop return network_3g; } } @@ -1426,8 +1430,6 @@ static BOOL libStarted = FALSE; theLinphoneCore = linphone_core_new_with_config(&linphonec_vtable, _configDb, (__bridge void *)(self)); LOGI(@"Create linphonecore %p", theLinphoneCore); - if ([@"toto" containsString:@"o"]) - LOGE(@"lol"); // Load plugins if available in the linphone SDK - otherwise these calls will do nothing MSFactory *f = linphone_core_get_ms_factory(theLinphoneCore); @@ -1783,7 +1785,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { OSStatus lStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &lNewRouteSize, &lNewRoute); if (!lStatus && lNewRouteSize > 0) { NSString *route = (__bridge NSString *)lNewRoute; - allow = ![route containsString:@"Heads"] && ![route isEqualToString:@"Lineout"]; + allow = ![route containsSubstring:@"Heads"] && ![route isEqualToString:@"Lineout"]; CFRelease(lNewRoute); } return allow; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index a670d77e6..810b547a3 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -227,6 +227,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st if (!text || text.length == 0) return CGSizeMake(0, 0); +#pragma deploymate push "ignored-api-availability" #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7) { return [text boundingRectWithSize:size @@ -239,6 +240,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st .size; } #endif +#pragma deploymate pop { return [text sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping]; } } diff --git a/Classes/SideMenuView.m b/Classes/SideMenuView.m index bc1fcc5a6..861dc90a9 100644 --- a/Classes/SideMenuView.m +++ b/Classes/SideMenuView.m @@ -14,14 +14,17 @@ - (void)viewDidLoad { [super viewDidLoad]; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 - // it's better to detect only pan from screen edges - UIScreenEdgePanGestureRecognizer *pan = - [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(onLateralSwipe:)]; - pan.edges = UIRectEdgeRight; - [self.view addGestureRecognizer:pan]; - _swipeGestureRecognizer.enabled = NO; -#endif + +#pragma deploymate push "ignored-api-availability" + if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7) { + // it's better to detect only pan from screen edges + UIScreenEdgePanGestureRecognizer *pan = + [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(onLateralSwipe:)]; + pan.edges = UIRectEdgeRight; + [self.view addGestureRecognizer:pan]; + _swipeGestureRecognizer.enabled = NO; + } +#pragma deploymate pop } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; @@ -65,9 +68,11 @@ _avatarImage.image = [LinphoneUtils selfAvatar]; } +#pragma deploymate push "ignored-api-availability" - (void)onLateralSwipe:(UIScreenEdgePanGestureRecognizer *)pan { [PhoneMainView.instance.mainViewController hideSideMenu:YES]; } +#pragma deploymate pop - (IBAction)onHeaderClick:(id)sender { [PhoneMainView.instance changeCurrentView:SettingsView.compositeViewDescription]; diff --git a/Classes/Utils/InAppSettingsKit/Controllers/IASKSpecifierValuesViewController.m b/Classes/Utils/InAppSettingsKit/Controllers/IASKSpecifierValuesViewController.m index cda7126b4..764d14776 100755 --- a/Classes/Utils/InAppSettingsKit/Controllers/IASKSpecifierValuesViewController.m +++ b/Classes/Utils/InAppSettingsKit/Controllers/IASKSpecifierValuesViewController.m @@ -97,21 +97,6 @@ return YES; } -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; - self.tableView = nil; -} - - - (void)dealloc { _currentSpecifier = nil; _checkedItem = nil; diff --git a/Classes/Utils/Utils.h b/Classes/Utils/Utils.h index db9f7dee1..7b738d6d3 100644 --- a/Classes/Utils/Utils.h +++ b/Classes/Utils/Utils.h @@ -54,9 +54,10 @@ typedef enum { @end -@interface NSString (md5) +@interface NSString (linphoneExt) - (NSString *)md5; +- (BOOL)containsSubstring:(NSString *)str; @end diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index bc3adbe55..7d02ffd6f 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -374,6 +374,15 @@ return output; } +- (BOOL)containsSubstring:(NSString *)str { + if (UIDevice.currentDevice.systemVersion.doubleValue >= 8.0) { +#pragma deploymate push "ignored-api-availability" + return [self containsString:str]; +#pragma deploymate pop + } + return ([self rangeOfString:str].location != NSNotFound); +} + @end @implementation ContactDisplay diff --git a/TestsUI/ChatTester.m b/TestsUI/ChatTester.m index 7bad8549c..27d793a8f 100644 --- a/TestsUI/ChatTester.m +++ b/TestsUI/ChatTester.m @@ -93,7 +93,7 @@ timeout -= .5f; element = [[UIApplication sharedApplication] accessibilityElementMatchingBlock:^BOOL(UIAccessibilityElement *e) { - return [e.accessibilityLabel containsString:quality]; + return [e.accessibilityLabel containsSubstring:quality]; }]; } XCTAssertNotNil(element); diff --git a/TestsUI/LinphoneTestCase.m b/TestsUI/LinphoneTestCase.m index cb2deb163..4d73db3c5 100644 --- a/TestsUI/LinphoneTestCase.m +++ b/TestsUI/LinphoneTestCase.m @@ -22,7 +22,7 @@ [KIFTypist setKeystrokeDelay:0.05]; NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0]; - if (!([language isEqualToString:@"en"] || [language containsString:@"en-"])) { + if (!([language isEqualToString:@"en"] || [language containsSubstring:@"en-"])) { LOGF(@"Language must be 'en' (English) instead of %@", language); } }