xcode: fix invalid calls to API greater than currently available fixing crashes on iOS6/iOS7

This commit is contained in:
Gautier Pelloux-Prayer 2016-02-05 14:00:22 +01:00
parent fa1a6f7a92
commit 7f4f95a9d1
11 changed files with 40 additions and 34 deletions

View file

@ -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 {

View file

@ -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;
}

View file

@ -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)

View file

@ -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;

View file

@ -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]; }
}

View file

@ -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];

View file

@ -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;

View file

@ -54,9 +54,10 @@ typedef enum {
@end
@interface NSString (md5)
@interface NSString (linphoneExt)
- (NSString *)md5;
- (BOOL)containsSubstring:(NSString *)str;
@end

View file

@ -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

View file

@ -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);

View file

@ -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);
}
}