summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-12-11 10:21:55 -0500
committerJoel Fischer <joeljfischer@gmail.com>2017-12-11 10:21:55 -0500
commitb942e777ead28a99d4862261cefdd4c5f8958aee (patch)
tree0322596280494c3727a1f4bfc9c9b70b649f13c2
parentcf15f0675999ef3fa1e6230f2ac103fb70ab98a9 (diff)
parent127709b2b83eeea322a33e1258792f8ce367a5d2 (diff)
downloadsdl_ios-bugfix/issue_770_infinite_iAP_connection_attempts.tar.gz
Merge branch 'version/4.X' into bugfix/issue_770_infinite_iAP_connection_attemptsbugfix/issue_770_infinite_iAP_connection_attempts
# Conflicts: # SmartDeviceLink/SDLIAPTransport.m
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m42
1 files changed, 40 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index 9d82182b6..7c0dc4e31 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -239,7 +239,13 @@ int const streamOpenTimeoutSeconds = 2;
- (BOOL)sdl_connectAccessory:(EAAccessory *)accessory {
BOOL connecting = NO;
-
+
+ if ([self.class sdl_supportsRequiredProtocolStrings] != nil) {
+ NSString *failedString = [self.class sdl_supportsRequiredProtocolStrings];
+ NSAssert(NO, @"Some SDL protocol strings are not supported, check the README for all strings that must be included in your info.plist file. Missing string: %@", failedString);
+ return connecting;
+ }
+
if ([accessory supportsProtocol:multiSessionProtocolString] && SDL_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9")) {
[self sdl_createIAPDataSessionWithAccessory:accessory forProtocol:multiSessionProtocolString];
connecting = YES;
@@ -254,6 +260,32 @@ int const streamOpenTimeoutSeconds = 2;
return connecting;
}
+/**
+ Check all required protocol strings in the info.plist dictionary.
+
+ @return A missing protocol string or nil if all strings are supported.
+ */
++ (nullable NSString *)sdl_supportsRequiredProtocolStrings {
+ NSArray<NSString *> *protocolStrings = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UISupportedExternalAccessoryProtocols"];
+
+ if (![protocolStrings containsObject:multiSessionProtocolString]) {
+ return multiSessionProtocolString;
+ }
+
+ if (![protocolStrings containsObject:legacyProtocolString]) {
+ return legacyProtocolString;
+ }
+
+ for (int i = 0; i < 30; i++) {
+ NSString *indexedProtocolString = [NSString stringWithFormat:@"%@%i", indexedProtocolStringPrefix, i];
+ if (![protocolStrings containsObject:indexedProtocolString]) {
+ return indexedProtocolString;
+ }
+ }
+
+ return nil;
+}
+
- (void)sdl_establishSessionWithAccessory:(EAAccessory *)accessory {
[SDLDebugTool logInfo:@"Attempting To Connect"];
if (self.retryCounter < createSessionRetries) {
@@ -265,7 +297,13 @@ int const streamOpenTimeoutSeconds = 2;
// Connection underway, exit
return;
}
-
+
+ if ([self.class sdl_supportsRequiredProtocolStrings] != nil) {
+ NSString *failedString = [self.class sdl_supportsRequiredProtocolStrings];
+ NSAssert(NO, @"Some SDL protocol strings are not supported, check the README for all strings that must be included in your info.plist file. Missing string: %@", failedString);
+ return;
+ }
+
// Determine if we can start a multi-app session or a legacy (single-app) session
if ((sdlAccessory = [EAAccessoryManager findAccessoryForProtocol:multiSessionProtocolString]) && SDL_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9")) {
[self sdl_createIAPDataSessionWithAccessory:sdlAccessory forProtocol:multiSessionProtocolString];