summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-11-09 09:06:01 -0500
committerJoel Fischer <joeljfischer@gmail.com>2020-11-09 09:06:01 -0500
commit92dbd732a650bb559bb4dec8a640006dc73c6a20 (patch)
tree285ff51c0c29e104d649e681d38d6927a77b54cd
parent9650ef51fc12b451cbd5fdb63e750dcf8d349640 (diff)
downloadsdl_ios-92dbd732a650bb559bb4dec8a640006dc73c6a20.tar.gz
Fixes and transaction queue updates
-rw-r--r--SmartDeviceLink/SDLVoiceCommandUpdateOperation.m2
-rw-r--r--SmartDeviceLink/private/SDLError.h1
-rw-r--r--SmartDeviceLink/private/SDLVoiceCommandManager.m34
3 files changed, 18 insertions, 19 deletions
diff --git a/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m b/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m
index 6ccd5abea..766b71206 100644
--- a/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m
+++ b/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m
@@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
return completionHandler([NSError sdl_menuManager_failedToUpdateWithDictionary:errors]);
}
- self.oldVoiceCommands = @[];
+ weakSelf.oldVoiceCommands = @[];
SDLLogD(@"Finished deleting old voice commands");
return completionHandler(nil);
}];
diff --git a/SmartDeviceLink/private/SDLError.h b/SmartDeviceLink/private/SDLError.h
index 3a20e2248..fae799fe9 100644
--- a/SmartDeviceLink/private/SDLError.h
+++ b/SmartDeviceLink/private/SDLError.h
@@ -56,7 +56,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSError *)sdl_menuManager_failedToUpdateWithDictionary:(NSDictionary *)userInfo;
+ (NSError *)sdl_voiceCommandManager_pendingUpdateSuperseded;
-+ (NSError *)sdl_voiceCommandManager_deleteFailed;
#pragma mark Choice Set Manager
diff --git a/SmartDeviceLink/private/SDLVoiceCommandManager.m b/SmartDeviceLink/private/SDLVoiceCommandManager.m
index 47182b905..073a972db 100644
--- a/SmartDeviceLink/private/SDLVoiceCommandManager.m
+++ b/SmartDeviceLink/private/SDLVoiceCommandManager.m
@@ -36,8 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager;
@property (strong, nonatomic) NSOperationQueue *transactionQueue;
-@property (assign, nonatomic) BOOL waitingOnHMIUpdate;
-@property (copy, nonatomic, nullable) SDLHMILevel currentHMILevel;
+@property (copy, nonatomic, nullable) SDLHMILevel currentLevel;
@property (assign, nonatomic) UInt32 lastVoiceCommandId;
@property (copy, nonatomic) NSArray<SDLVoiceCommand *> *currentVoiceCommands;
@@ -78,8 +77,7 @@ UInt32 const VoiceCommandIdMin = 1900000000;
_currentVoiceCommands = @[];
_transactionQueue = [self sdl_newTransactionQueue];
- _waitingOnHMIUpdate = NO;
- _currentHMILevel = nil;
+ _currentLevel = nil;
}
- (NSOperationQueue *)sdl_newTransactionQueue {
@@ -92,6 +90,18 @@ UInt32 const VoiceCommandIdMin = 1900000000;
return queue;
}
+/// Suspend the queue if the soft button capabilities are nil (we assume that soft buttons are not supported)
+/// OR if the HMI level is NONE since we want to delay sending RPCs until we're in non-NONE
+- (void)sdl_updateTransactionQueueSuspended {
+ if ([self.currentLevel isEqualToEnum:SDLHMILevelNone]) {
+ SDLLogD(@"Suspending the transaction queue. Current HMI level is NONE: %@", ([self.currentLevel isEqualToEnum:SDLHMILevelNone] ? @"YES" : @"NO"));
+ self.transactionQueue.suspended = YES;
+ } else {
+ SDLLogD(@"Starting the transaction queue");
+ self.transactionQueue.suspended = NO;
+ }
+}
+
#pragma mark - Setters
- (void)setVoiceCommands:(NSArray<SDLVoiceCommand *> *)voiceCommands {
@@ -142,22 +152,12 @@ UInt32 const VoiceCommandIdMin = 1900000000;
- (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification {
SDLOnHMIStatus *hmiStatus = (SDLOnHMIStatus *)notification.notification;
-
if (hmiStatus.windowID != nil && hmiStatus.windowID.integerValue != SDLPredefinedWindowsDefaultWindow) {
return;
}
-
- SDLHMILevel oldHMILevel = self.currentHMILevel;
- self.currentHMILevel = hmiStatus.hmiLevel;
-
- // Auto-send an updated show if we were in NONE and now we are not
- if ([oldHMILevel isEqualToEnum:SDLHMILevelNone] && ![self.currentHMILevel isEqualToEnum:SDLHMILevelNone]) {
- if (self.waitingOnHMIUpdate) {
- [self setVoiceCommands:_voiceCommands];
- } else {
- [self sdl_updateWithCompletionHandler:nil];
- }
- }
+
+ self.currentLevel = hmiStatus.hmiLevel;
+ [self sdl_updateTransactionQueueSuspended];
}
@end