Skip to content

Commit

Permalink
Moved dealloc to BackgroundTaskManager
Browse files Browse the repository at this point in the history
* cleaned up some documentation
  • Loading branch information
NicoleYarroch committed Jun 26, 2019
1 parent 8a3f94e commit b8098be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
9 changes: 6 additions & 3 deletions SmartDeviceLink/SDLBackgroundTaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

NS_ASSUME_NONNULL_BEGIN

/**
* Class for managing a background task.
*/
@interface SDLBackgroundTaskManager : NSObject

- (instancetype)init NS_UNAVAILABLE;

/**
* Convenience init for starting a background task with a specific name
* Convenience init for starting a background task with a specific name.
*
* @param backgroundTaskName The name for the background task
* @return A SDLBackgroundTaskManager object
Expand All @@ -31,8 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Cleans up a background task when it is stopped. This should be called when:
*
* 1. The app has established a session
* 2. The system has called the `expirationHandler` for the background task. The system may kill the app if the background task is not ended.
* 1. The app has established a session.
* 2. The system has called the `expirationHandler` for the background task. The system may kill the app if the background task is not ended when `expirationHandler` is called.
*/
- (void)endBackgroundTask;

Expand Down
4 changes: 4 additions & 0 deletions SmartDeviceLink/SDLBackgroundTaskManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ - (void)endBackgroundTask {
self.currentBackgroundTaskId = UIBackgroundTaskInvalid;
}

- (void)dealloc {
[self endBackgroundTask];
}

@end

NS_ASSUME_NONNULL_END
10 changes: 2 additions & 8 deletions SmartDeviceLink/SDLLifecycleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ - (SDLState *)lifecycleState {
}

- (void)didEnterStateStarted {
// start a background task so a session can be established even when the app is backgrounded.
// Start a background task so a session can be established even when the app is backgrounded.
[self.backgroundTaskManager startBackgroundTask];

// Start up the internal proxy object
Expand All @@ -233,7 +233,7 @@ - (void)didEnterStateStarted {
self.proxy = [SDLProxy iapProxyWithListener:self.notificationDispatcher
secondaryTransportManager:self.secondaryTransportManager];
}
# pragma clang diagnostic pop
#pragma clang diagnostic pop
}

- (void)didEnterStateStopped {
Expand Down Expand Up @@ -843,12 +843,6 @@ - (void)videoServiceProtocolDidUpdateFromOldProtocol:(nullable SDLProtocol *)old
}
}

#pragma mark - Lifecycle Destruction

- (void)dealloc {
[self.backgroundTaskManager endBackgroundTask];
}

@end

NS_ASSUME_NONNULL_END

0 comments on commit b8098be

Please sign in to comment.