summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-10-02 14:55:50 -0400
committerJoel Fischer <joeljfischer@gmail.com>2019-10-02 14:55:50 -0400
commitdee4d892bcfc890eaa9e3a507891651bb42d500f (patch)
tree0b902c83958d353f4a0cd18ac30a0b26d38ad6fd
parentc958f09862f21c24150dfa17837bb16d154ceb7e (diff)
downloadsdl_ios-dee4d892bcfc890eaa9e3a507891651bb42d500f.tar.gz
Sub-managers unsubscribe from system capability
* Fix multiple text and graphic manager subscribes to display capability
-rw-r--r--SmartDeviceLink/SDLSoftButtonManager.m10
-rw-r--r--SmartDeviceLink/SDLTextAndGraphicManager.m8
2 files changed, 12 insertions, 6 deletions
diff --git a/SmartDeviceLink/SDLSoftButtonManager.m b/SmartDeviceLink/SDLSoftButtonManager.m
index f6320d645..a8dd84629 100644
--- a/SmartDeviceLink/SDLSoftButtonManager.m
+++ b/SmartDeviceLink/SDLSoftButtonManager.m
@@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) NSOperationQueue *transactionQueue;
-@property (strong, nonatomic, nullable, readonly) SDLWindowCapability *windowCapability;
+@property (strong, nonatomic, nullable) SDLWindowCapability *windowCapability;
@property (copy, nonatomic, nullable) SDLHMILevel currentLevel;
@property (strong, nonatomic) NSMutableArray<SDLAsynchronousOperation *> *batchQueue;
@@ -62,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
_connectionManager = connectionManager;
_fileManager = fileManager;
+ _systemCapabilityManager = systemCapabilityManager;
_softButtonObjects = @[];
_currentLevel = nil;
@@ -74,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)start {
- [_systemCapabilityManager subscribeToCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self selector:@selector(sdl_displayCapabilityDidUpdate:)];
+ [self.systemCapabilityManager subscribeToCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self selector:@selector(sdl_displayCapabilityDidUpdate:)];
}
- (void)stop {
@@ -85,6 +86,8 @@ NS_ASSUME_NONNULL_BEGIN
[_transactionQueue cancelAllOperations];
self.transactionQueue = [self sdl_newTransactionQueue];
+
+ [self.systemCapabilityManager unsubscribeFromCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self];
}
- (NSOperationQueue *)sdl_newTransactionQueue {
@@ -195,7 +198,8 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - RPC Responses
- (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability {
- _windowCapability = systemCapability.displayCapabilities[0].windowCapabilities[0];
+ self.windowCapability = self.systemCapabilityManager.defaultMainWindowCapability;
+
// Auto-send an updated Show to account for changes to the capabilities
if (self.softButtonObjects.count > 0) {
SDLSoftButtonReplaceOperation *op = [[SDLSoftButtonReplaceOperation alloc] initWithConnectionManager:self.connectionManager fileManager:self.fileManager capabilities:self.windowCapability.softButtonCapabilities.firstObject softButtonObjects:self.softButtonObjects mainField1:self.currentMainField1];
diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m
index bc8e6aa5f..fcd83432d 100644
--- a/SmartDeviceLink/SDLTextAndGraphicManager.m
+++ b/SmartDeviceLink/SDLTextAndGraphicManager.m
@@ -81,14 +81,13 @@ NS_ASSUME_NONNULL_BEGIN
_waitingOnHMILevelUpdateToUpdate = NO;
_isDirty = NO;
- [_systemCapabilityManager subscribeToCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self selector:@selector(sdl_displayCapabilityDidUpdate:)];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_hmiStatusNotification:) name:SDLDidChangeHMIStatusNotification object:nil];
return self;
}
- (void)start {
- [_systemCapabilityManager subscribeToCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self selector:@selector(sdl_displayCapabilityDidUpdate:)];
+ [self.systemCapabilityManager subscribeToCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self selector:@selector(sdl_displayCapabilityDidUpdate:)];
}
- (void)stop {
@@ -116,6 +115,8 @@ NS_ASSUME_NONNULL_BEGIN
_blankArtwork = nil;
_waitingOnHMILevelUpdateToUpdate = NO;
_isDirty = NO;
+
+ [self.systemCapabilityManager unsubscribeFromCapabilityType:SDLSystemCapabilityTypeDisplays withObserver:self];
}
#pragma mark - Upload / Send
@@ -699,7 +700,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability {
// we won't use the object in the parameter but the convenience method of the system capability manager
- self.windowCapability = _systemCapabilityManager.defaultMainWindowCapability;
+ NSLog(@"PING");
+ self.windowCapability = self.systemCapabilityManager.defaultMainWindowCapability;
// Auto-send an updated show
if ([self sdl_hasData]) {