summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-03-11 15:48:56 -0400
committerJoel Fischer <joeljfischer@gmail.com>2020-03-11 15:48:56 -0400
commitb002f1e1aa0009310c1d1583948e6c4851044c93 (patch)
tree22f37faea7f77321473b3d13be18b1a675c43fb0
parent9703d765c4b3dc9f314c5a7223ca0ed871c35de9 (diff)
downloadsdl_ios-b002f1e1aa0009310c1d1583948e6c4851044c93.tar.gz
Choice set manager updates
* Add a huge number of logs * Add documentation * Don't suspend transaction queue based on system context
-rw-r--r--SmartDeviceLink/SDLChoiceSetManager.m49
1 files changed, 34 insertions, 15 deletions
diff --git a/SmartDeviceLink/SDLChoiceSetManager.m b/SmartDeviceLink/SDLChoiceSetManager.m
index 3be64c43f..55637aa5a 100644
--- a/SmartDeviceLink/SDLChoiceSetManager.m
+++ b/SmartDeviceLink/SDLChoiceSetManager.m
@@ -37,7 +37,6 @@
#import "SDLSetDisplayLayoutResponse.h"
#import "SDLStateMachine.h"
#import "SDLSystemCapability.h"
-#import "SDLSystemContext.h"
#import "SDLSystemCapabilityManager.h"
#import "SDLWindowCapability.h"
#import "SDLWindowCapability+ShowManagerExtensions.h"
@@ -67,7 +66,6 @@ typedef NSNumber * SDLChoiceId;
@property (strong, nonatomic) NSOperationQueue *transactionQueue;
@property (copy, nonatomic, nullable) SDLHMILevel currentHMILevel;
-@property (copy, nonatomic, nullable) SDLSystemContext currentSystemContext;
@property (copy, nonatomic, nullable) SDLWindowCapability *currentWindowCapability;
@property (strong, nonatomic) NSMutableSet<SDLChoiceCell *> *preloadedMutableChoices;
@@ -146,12 +144,12 @@ UInt16 const ChoiceCellCancelIdMin = 1;
return queue;
}
+/// Suspend the transaction queue if we are in HMI NONE
+/// OR if we don't know what text fields are allowed, or if the text field name "menu name" (this is the primary choice text) we assume we cannot present a PI.
- (void)sdl_updateTransactionQueueSuspended {
if ([self.currentHMILevel isEqualToEnum:SDLHMILevelNone]
- || [self.currentSystemContext isEqualToEnum:SDLSystemContextHMIObscured]
- || [self.currentSystemContext isEqualToEnum:SDLSystemContextAlert]
- || (self.currentWindowCapability.textFields != nil && ![self.currentWindowCapability hasTextFieldOfName:SDLTextFieldNameMenuName])) {
- SDLLogD(@"Suspending the transaction queue. Current HMI level is NONE: %@, current system context is HMIObscured or Alert: %@, window capability has MenuName (choice primary text): %@", ([self.currentHMILevel isEqualToEnum:SDLHMILevelNone] ? @"YES" : @"NO"), (([self.currentSystemContext isEqualToEnum:SDLSystemContextHMIObscured] || [self.currentSystemContext isEqualToEnum:SDLSystemContextAlert]) ? @"YES" : @"NO"), ([self.currentWindowCapability hasTextFieldOfName:SDLTextFieldNameMenuName] ? @"YES" : @"NO"));
+ || (![self.currentWindowCapability hasTextFieldOfName:SDLTextFieldNameMenuName])) {
+ SDLLogD(@"Suspending the transaction queue. Current HMI level is: %@, window capability has MenuName (choice primary text): %@", self.currentHMILevel, ([self.currentWindowCapability hasTextFieldOfName:SDLTextFieldNameMenuName] ? @"YES" : @"NO"));
self.transactionQueue.suspended = YES;
} else {
SDLLogD(@"Starting the transaction queue");
@@ -163,7 +161,6 @@ UInt16 const ChoiceCellCancelIdMin = 1;
- (void)didEnterStateShutdown {
_currentHMILevel = nil;
- _currentSystemContext = nil;
[self.transactionQueue cancelAllOperations];
self.transactionQueue = [self sdl_newTransactionQueue];
@@ -183,9 +180,7 @@ UInt16 const ChoiceCellCancelIdMin = 1;
__weak typeof(self) weakself = self;
__weak typeof(checkOp) weakOp = checkOp;
checkOp.completionBlock = ^{
- if ([self.currentState isEqualToString:SDLChoiceManagerStateShutdown]) {
- return;
- }
+ if ([self.currentState isEqualToString:SDLChoiceManagerStateShutdown]) { return; }
weakself.vrOptional = weakOp.isVROptional;
if (weakOp.error != nil) {
@@ -207,9 +202,11 @@ UInt16 const ChoiceCellCancelIdMin = 1;
#pragma mark Upload / Delete
- (void)preloadChoices:(NSArray<SDLChoiceCell *> *)choices withCompletionHandler:(nullable SDLPreloadChoiceCompletionHandler)handler {
+ SDLLogV(@"Request to preload choices: %@", choices);
if ([self.currentState isEqualToString:SDLChoiceManagerStateShutdown]) {
+ NSError *error = [NSError sdl_choiceSetManager_incorrectState:self.currentState];
+ SDLLogE(@"Attempted to preload choices but the choice set manager is shut down: %@", error);
if (handler != nil) {
- NSError *error = [NSError sdl_choiceSetManager_incorrectState:self.currentState];
handler(error);
}
return;
@@ -234,12 +231,15 @@ UInt16 const ChoiceCellCancelIdMin = 1;
// Upload pending preloads
// For backward compatibility with Gen38Inch display type head units
+ SDLLogD(@"Preloading choices");
+ SDLLogV(@"Choices to be uploaded: %@", choicesToUpload);
NSString *displayName = self.systemCapabilityManager.displays.firstObject.displayName;
SDLPreloadChoicesOperation *preloadOp = [[SDLPreloadChoicesOperation alloc] initWithConnectionManager:self.connectionManager fileManager:self.fileManager displayName:displayName windowCapability:self.systemCapabilityManager.defaultMainWindowCapability isVROptional:self.isVROptional cellsToPreload:choicesToUpload];
__weak typeof(self) weakSelf = self;
__weak typeof(preloadOp) weakPreloadOp = preloadOp;
preloadOp.completionBlock = ^{
+ SDLLogD(@"Choices finished preloading");
[weakSelf.preloadedMutableChoices unionSet:choicesToUpload];
[weakSelf.pendingMutablePreloadChoices minusSet:choicesToUpload];
@@ -251,7 +251,11 @@ UInt16 const ChoiceCellCancelIdMin = 1;
}
- (void)deleteChoices:(NSArray<SDLChoiceCell *> *)choices {
- if (![self.currentState isEqualToString:SDLChoiceManagerStateReady]) { return; }
+ SDLLogV(@"Request to delete choices: %@", choices);
+ if (![self.currentState isEqualToString:SDLChoiceManagerStateReady]) {
+ SDLLogE(@"Attempted to delete choices in an incorrect state: %@, they will not be deleted", self.currentState);
+ return;
+ }
// Find cells to be deleted that are already uploaded or are pending upload
NSSet<SDLChoiceCell *> *cellsToBeDeleted = [self sdl_choicesToBeDeletedWithArray:choices];
@@ -292,6 +296,7 @@ UInt16 const ChoiceCellCancelIdMin = 1;
return;
}
+ SDLLogD(@"Finished deleting choices");
[weakself.preloadedMutableChoices minusSet:cellsToBeDeleted];
};
[self.transactionQueue addOperation:deleteOp];
@@ -300,7 +305,10 @@ UInt16 const ChoiceCellCancelIdMin = 1;
#pragma mark Present
- (void)presentChoiceSet:(SDLChoiceSet *)choiceSet mode:(SDLInteractionMode)mode withKeyboardDelegate:(nullable id<SDLKeyboardDelegate>)delegate {
- if (![self.currentState isEqualToString:SDLChoiceManagerStateReady]) { return; }
+ if (![self.currentState isEqualToString:SDLChoiceManagerStateReady]) {
+ SDLLogE(@"Attempted to present choices in an incorrect state: %@, it will not be presented", self.currentState);
+ return;
+ }
if (choiceSet == nil) {
SDLLogW(@"Attempted to present a nil choice set, ignoring.");
@@ -308,9 +316,11 @@ UInt16 const ChoiceCellCancelIdMin = 1;
}
if (self.pendingPresentationSet != nil) {
+ SDLLogW(@"A choice set is pending: %@. We will try to cancel it in favor of presenting a different choice set: %@. If it's already on screen it cannot be cancelled", self.pendingPresentationSet, choiceSet);
[self.pendingPresentOperation cancel];
}
+ SDLLogD(@"Preloading and presenting choice set: %@", choiceSet);
self.pendingPresentationSet = choiceSet;
[self preloadChoices:self.pendingPresentationSet.choices withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
@@ -336,6 +346,7 @@ UInt16 const ChoiceCellCancelIdMin = 1;
self.pendingPresentOperation.completionBlock = ^{
__strong typeof(weakOp) strongOp = weakOp;
+ SDLLogD(@"Finished presenting choice set: %@", strongOp.choiceSet);
if (strongOp.error != nil && strongOp.choiceSet.delegate != nil) {
[strongOp.choiceSet.delegate choiceSet:strongOp.choiceSet didReceiveError:strongOp.error];
} else if (strongOp.selectedCell != nil && strongOp.choiceSet.delegate != nil) {
@@ -345,17 +356,23 @@ UInt16 const ChoiceCellCancelIdMin = 1;
weakself.pendingPresentationSet = nil;
weakself.pendingPresentOperation = nil;
};
+
[self.transactionQueue addOperation:presentOp];
}
- (nullable NSNumber<SDLInt> *)presentKeyboardWithInitialText:(NSString *)initialText delegate:(id<SDLKeyboardDelegate>)delegate {
- if (![self.currentState isEqualToString:SDLChoiceManagerStateReady]) { return nil; }
+ if (![self.currentState isEqualToString:SDLChoiceManagerStateReady]) {
+ SDLLogE(@"Attempted to present keyboard in an incorrect state: %@, it will not be presented", self.currentState);
+ return nil;
+ }
if (self.pendingPresentationSet != nil) {
+ SDLLogW(@"There's already a pending presentation set, cancelling it in favor of a keyboard");
[self.pendingPresentOperation cancel];
self.pendingPresentationSet = nil;
}
+ SDLLogD(@"Presenting keyboard with initial text: %@", initialText);
// Present a keyboard with the choice set that we used to test VR's optional state
UInt16 keyboardCancelId = self.nextCancelId++;
self.pendingPresentOperation = [[SDLPresentKeyboardOperation alloc] initWithConnectionManager:self.connectionManager keyboardProperties:self.keyboardConfiguration initialText:initialText keyboardDelegate:delegate cancelID:keyboardCancelId];
@@ -370,6 +387,7 @@ UInt16 const ChoiceCellCancelIdMin = 1;
SDLPresentKeyboardOperation *keyboardOperation = (SDLPresentKeyboardOperation *)op;
if (keyboardOperation.cancelId != cancelID.unsignedShortValue) { continue; }
+ SDLLogD(@"Dismissing keyboard with cancel ID: %@", cancelID);
[keyboardOperation dismissKeyboard];
break;
}
@@ -423,8 +441,10 @@ UInt16 const ChoiceCellCancelIdMin = 1;
- (void)setKeyboardConfiguration:(nullable SDLKeyboardProperties *)keyboardConfiguration {
if (keyboardConfiguration == nil) {
+ SDLLogD(@"Updating keyboard configuration to the default");
_keyboardConfiguration = [self sdl_defaultKeyboardConfiguration];
} else {
+ SDLLogD(@"Updating keyboard configuration to a new configuration: %@", keyboardConfiguration);
_keyboardConfiguration = [[SDLKeyboardProperties alloc] initWithLanguage:keyboardConfiguration.language layout:keyboardConfiguration.keyboardLayout keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:keyboardConfiguration.limitedCharacterList autoCompleteText:keyboardConfiguration.autoCompleteText autoCompleteList:keyboardConfiguration.autoCompleteList];
if (keyboardConfiguration.keypressMode != SDLKeypressModeResendCurrentEntry) {
@@ -479,7 +499,6 @@ UInt16 const ChoiceCellCancelIdMin = 1;
}
self.currentHMILevel = hmiStatus.hmiLevel;
- self.currentSystemContext = hmiStatus.systemContext;
[self sdl_updateTransactionQueueSuspended];
}