summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakamitsu Yoshii <tyoshii@xevo.com>2017-12-26 10:24:44 +0900
committerTakamitsu Yoshii <tyoshii@xevo.com>2018-01-09 10:04:43 +0900
commit4cfd95d9032a2c4c7c53d244b7edb9ca71b4f411 (patch)
treec36521f4436520e4abf8cc36f19e356444f66cc8
parent273698b7deb9d20719007809a29b37f787384a47 (diff)
downloadsdl_ios-4cfd95d9032a2c4c7c53d244b7edb9ca71b4f411.tar.gz
fix: start background task when data is received from ea session
fix: start background task whenever connection is initiated
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m13
1 files changed, 12 insertions, 1 deletions
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index b24f8a12f..7ee2e5934 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -69,7 +69,7 @@ int const ProtocolIndexTimeoutSeconds = 10;
if (self.backgroundTaskId != UIBackgroundTaskInvalid) {
return;
}
-
+
SDLLogD(@"Starting background task");
self.backgroundTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithName:BackgroundTaskName expirationHandler:^{
SDLLogD(@"Background task expired");
@@ -198,6 +198,12 @@ int const ProtocolIndexTimeoutSeconds = 10;
#pragma mark - Stream Lifecycle
- (void)connect {
+ UIApplicationState state = [UIApplication sharedApplication].applicationState;
+ if (state != UIApplicationStateActive) {
+ SDLLogV(@"App inactive on connect, starting background task");
+ [self sdl_backgroundTaskStart];
+ }
+
[self sdl_connect:nil];
}
@@ -517,6 +523,8 @@ int const ProtocolIndexTimeoutSeconds = 10;
[strongSelf.protocolIndexTimer cancel];
});
}
+
+ [strongSelf sdl_backgroundTaskStart];
};
}
@@ -581,6 +589,8 @@ int const ProtocolIndexTimeoutSeconds = 10;
break;
}
}
+
+ [strongSelf sdl_backgroundTaskStart];
};
}
@@ -644,6 +654,7 @@ int const ProtocolIndexTimeoutSeconds = 10;
- (void)sdl_destructObjects {
if (!_alreadyDestructed) {
+ [self sdl_backgroundTaskEnd];
_alreadyDestructed = YES;
self.controlSession = nil;
self.session = nil;