summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Switzer <dswitzer@xevo.com>2017-04-14 10:04:06 -0700
committerDavid Switzer <dswitzer@xevo.com>2017-04-14 10:04:06 -0700
commit0c351672c542222956635b0f08988b6965276d9f (patch)
tree946e8fb33ac3daf8396a53d94b2e27ec657e6320
parente38715f2183ce3bd06767e12d9dd4aea5cf47fa3 (diff)
downloadsdl_ios-0c351672c542222956635b0f08988b6965276d9f.tar.gz
Update background task handling code based on review feedback.
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m13
1 files changed, 5 insertions, 8 deletions
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index 12b4110cb..2ba2d93e8 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -98,24 +98,21 @@ int const streamOpenTimeoutSeconds = 2;
}
- (void)sdl_backgroundTaskEnd {
- if (self.backgroundTaskId != UIBackgroundTaskInvalid) {
- [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskId];
- self.backgroundTaskId = UIBackgroundTaskInvalid;
+ if (self.backgroundTaskId == UIBackgroundTaskInvalid) {
+ return;
}
+
+ [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskId];
+ self.backgroundTaskId = UIBackgroundTaskInvalid;
}
-
#pragma mark - EAAccessory Notifications
- (void)sdl_accessoryConnected:(NSNotification *)notification {
NSMutableString *logMessage = [NSMutableString stringWithFormat:@"Accessory Connected, Opening in %0.03fs", self.retryDelay];
[self sdl_backgroundTaskStart];
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
-
self.retryCounter = 0;
- if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
- [self sdl_backgroundTaskStart];
- }
[self performSelector:@selector(connect) withObject:nil afterDelay:self.retryDelay];
}