diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2021-09-24 08:53:59 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2021-09-24 08:53:59 -0400 |
commit | 60104522aad1c45cdd55fa0c5b73e4b369e79582 (patch) | |
tree | ef051bd14ff9f9c6a10c12378fffb7df19c0002e /SmartDeviceLink/public | |
parent | 7ef29ccad916ad794aa7983817a4aa3a9fc59a5e (diff) | |
parent | 4c1fe3f7b15c11763adc88b2078b609df068e031 (diff) | |
download | sdl_ios-60104522aad1c45cdd55fa0c5b73e4b369e79582.tar.gz |
Merge branch 'develop' into feature/issue-1898-menu-manager-refactor
# Conflicts:
# SmartDeviceLink-iOS.xcodeproj/project.pbxproj
# SmartDeviceLink-iOS.xcodeproj/xcshareddata/xcschemes/SmartDeviceLink-Example-Swift.xcscheme
Diffstat (limited to 'SmartDeviceLink/public')
-rw-r--r-- | SmartDeviceLink/public/SDLChoiceCell.m | 23 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLChoiceSet.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLErrorConstants.h | 12 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLMenuCell.m | 1 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLSeatControlCapabilities.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLSystemCapabilityManager.m | 92 |
6 files changed, 61 insertions, 71 deletions
diff --git a/SmartDeviceLink/public/SDLChoiceCell.m b/SmartDeviceLink/public/SDLChoiceCell.m index 8d2d767c8..afbe2e972 100644 --- a/SmartDeviceLink/public/SDLChoiceCell.m +++ b/SmartDeviceLink/public/SDLChoiceCell.m @@ -16,13 +16,14 @@ NS_ASSUME_NONNULL_BEGIN @interface SDLChoiceCell() @property (assign, nonatomic) UInt16 choiceId; -@property (nonatomic, readwrite) NSString *uniqueText; @property (copy, nonatomic, readwrite, nullable) NSString *secondaryText; @property (copy, nonatomic, readwrite, nullable) NSString *tertiaryText; @property (copy, nonatomic, readwrite, nullable) NSArray<NSString *> *voiceCommands; @property (strong, nonatomic, readwrite, nullable) SDLArtwork *artwork; @property (strong, nonatomic, readwrite, nullable) SDLArtwork *secondaryArtwork; +@property (assign, nonatomic) NSUInteger uniqueTextId; + @end @implementation SDLChoiceCell @@ -47,13 +48,23 @@ NS_ASSUME_NONNULL_BEGIN _voiceCommands = voiceCommands; _artwork = artwork; _secondaryArtwork = secondaryArtwork; - _uniqueText = text; + _uniqueTextId = 1; _choiceId = UINT16_MAX; return self; } +#pragma mark - Getters + +- (NSString *)uniqueText { + if (self.uniqueTextId != 1) { + return [NSString stringWithFormat:@"%@ (%lu)", self.text, (unsigned long)self.uniqueTextId]; + } else { + return self.text; + } +} + #pragma mark - Object Equality @@ -92,11 +103,15 @@ NSUInteger NSUIntRotate(NSUInteger val, NSUInteger howMuch) { #pragma mark - Etc. - (id)copyWithZone:(nullable NSZone *)zone { - return [[SDLChoiceCell allocWithZone:zone] initWithText:_text secondaryText:_secondaryText tertiaryText:_tertiaryText voiceCommands:_voiceCommands artwork:_artwork secondaryArtwork:_secondaryArtwork]; + SDLChoiceCell *newCell = [[SDLChoiceCell allocWithZone:zone] initWithText:_text secondaryText:_secondaryText tertiaryText:_tertiaryText voiceCommands:_voiceCommands artwork:_artwork secondaryArtwork:_secondaryArtwork]; + newCell.choiceId = _choiceId; + newCell.uniqueTextId = _uniqueTextId; + + return newCell; } - (NSString *)description { - return [NSString stringWithFormat:@"SDLChoiceCell: %u-\"%@ - %@ - %@\", artworkNames: %@ - %@, voice commands: %lu, uniqueText: %@", _choiceId, _text, _secondaryText, _tertiaryText, _artwork.name, _secondaryArtwork.name, (unsigned long)_voiceCommands.count, ([_text isEqualToString:_uniqueText] ? @"NO" : _uniqueText)]; + return [NSString stringWithFormat:@"SDLChoiceCell: %u-\"%@ - %@ - %@\", artworkNames: %@ - %@, voice commands: %lu, uniqueText: %@", _choiceId, _text, _secondaryText, _tertiaryText, _artwork.name, _secondaryArtwork.name, (unsigned long)_voiceCommands.count, ((_uniqueTextId == 1) ? @"NO" : self.uniqueText)]; } @end diff --git a/SmartDeviceLink/public/SDLChoiceSet.m b/SmartDeviceLink/public/SDLChoiceSet.m index 8baf085a6..85c22bbcd 100644 --- a/SmartDeviceLink/public/SDLChoiceSet.m +++ b/SmartDeviceLink/public/SDLChoiceSet.m @@ -145,7 +145,7 @@ static SDLChoiceSetLayout _defaultLayout = SDLChoiceSetLayoutList; @param choices The choices you will be adding @return Boolean that indicates whether choices and voice commands are unique or not */ --(BOOL)sdl_choiceCellsAreUnique:(NSArray<SDLChoiceCell *> *)choices { +- (BOOL)sdl_choiceCellsAreUnique:(NSArray<SDLChoiceCell *> *)choices { NSMutableSet<SDLChoiceCell *> *identicalCellsCheckSet = [NSMutableSet setWithCapacity:choices.count]; NSMutableSet<NSString *> *identicalVoiceCommandsCheckSet = [NSMutableSet set]; NSUInteger allVoiceCommandsCount = 0; diff --git a/SmartDeviceLink/public/SDLErrorConstants.h b/SmartDeviceLink/public/SDLErrorConstants.h index 78b81425f..a148e9f57 100644 --- a/SmartDeviceLink/public/SDLErrorConstants.h +++ b/SmartDeviceLink/public/SDLErrorConstants.h @@ -202,8 +202,8 @@ typedef NS_ENUM(NSInteger, SDLMenuManagerError) { /// Errors associated with Choice Set Manager class typedef NS_ENUM(NSInteger, SDLChoiceSetManagerError) { - /// The choice set has been deleted before it was presented - SDLChoiceSetManagerErrorPendingPresentationDeleted = -1, + /// Some needed choices for presentation are not available + SDLChoiceSetManagerErrorNeededChoicesUnavailable = -1, /// The choice set failed to delete SDLChoiceSetManagerErrorDeletionFailed = -2, @@ -215,7 +215,13 @@ typedef NS_ENUM(NSInteger, SDLChoiceSetManagerError) { SDLChoiceSetManagerErrorFailedToCreateMenuItems = -4, /// Invalid state - SDLChoiceSetManagerErrorInvalidState = -5 + SDLChoiceSetManagerErrorInvalidState = -5, + + /// An operation was cancelled and may or may not have succeeded + SDLChoiceSetManagerErrorCancelled = -6, + + /// No new choices could be loaded because the maximum number of choices are loaded (65535) + SDLChoiceSetManagerErrorNoIdsAvailable = -7, }; /// Errors associated with Alert Manager class diff --git a/SmartDeviceLink/public/SDLMenuCell.m b/SmartDeviceLink/public/SDLMenuCell.m index fb07ef49f..bbc02f2b6 100644 --- a/SmartDeviceLink/public/SDLMenuCell.m +++ b/SmartDeviceLink/public/SDLMenuCell.m @@ -63,7 +63,6 @@ NS_ASSUME_NONNULL_BEGIN } - (instancetype)initWithTitle:(NSString *)title secondaryText:(nullable NSString *)secondaryText tertiaryText:(nullable NSString *)tertiaryText icon:(nullable SDLArtwork *)icon secondaryArtwork:(nullable SDLArtwork *)secondaryArtwork submenuLayout:(nullable SDLMenuLayout)layout subCells:(NSArray<SDLMenuCell *> *)subCells { - self = [super init]; if (!self) { return nil; } diff --git a/SmartDeviceLink/public/SDLSeatControlCapabilities.h b/SmartDeviceLink/public/SDLSeatControlCapabilities.h index c20f5db5f..3895a89e1 100644 --- a/SmartDeviceLink/public/SDLSeatControlCapabilities.h +++ b/SmartDeviceLink/public/SDLSeatControlCapabilities.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN coolingEnabledAvailable:(BOOL)coolingEnabledAvail heatingLevelAvailable:(BOOL)heatingLevelAvail coolingLevelAvailable:(BOOL)coolingLevelAvail horizontalPositionAvailable:(BOOL)horizontalPositionAvail verticalPositionAvailable:(BOOL)verticalPositionAvail frontVerticalPositionAvailable:(BOOL)frontVerticalPositionAvail backVerticalPositionAvailable:(BOOL)backVerticalPositionAvail backTiltAngleAvailable:(BOOL)backTitlAngleAvail headSupportHorizontalPositionAvailable:(BOOL)headSupportHorizontalPositionAvail headSupportVerticalPositionAvailable:(BOOL)headSupportVerticalPositionAvail massageEnabledAvailable:(BOOL)massageEnabledAvail massageModeAvailable:(BOOL)massageModeAvail massageCushionFirmnessAvailable:(BOOL)massageCushionFirmnessAvail memoryAvailable:(BOOL)memoryAvail; /** - * @abstract The short friendly name of the light control module. + * @abstract The short friendly name of the seat control module. * It should not be used to identify a module by mobile application. * * Required, Max length 100 chars diff --git a/SmartDeviceLink/public/SDLSystemCapabilityManager.m b/SmartDeviceLink/public/SDLSystemCapabilityManager.m index e014bb4ca..9130cd673 100644 --- a/SmartDeviceLink/public/SDLSystemCapabilityManager.m +++ b/SmartDeviceLink/public/SDLSystemCapabilityManager.m @@ -123,7 +123,7 @@ typedef NSString * SDLServiceID; self.supportsSubscriptions = NO; - self.appServicesCapabilitiesDictionary = [NSMutableDictionary dictionary]; + [self.appServicesCapabilitiesDictionary removeAllObjects]; [self.capabilityObservers removeAllObjects]; [self.subscriptionStatus removeAllObjects]; @@ -386,7 +386,8 @@ typedef NSString * SDLServiceID; } - (void)sdl_notifyObserversOfCapabilityType:(SDLSystemCapabilityType)type capability:(nullable SDLSystemCapability *)capability error:(nullable NSError *)error { - for (SDLSystemCapabilityObserver *observer in self.capabilityObservers[type]) { + NSDictionary<SDLSystemCapabilityType, NSMutableArray<SDLSystemCapabilityObserver *> *> *capabilityObservers = [self.capabilityObservers copy]; + for (SDLSystemCapabilityObserver *observer in capabilityObservers[type]) { [self sdl_invokeObserver:observer withCapabilityType:type capability:capability error:error]; } } @@ -584,28 +585,27 @@ typedef NSString * SDLServiceID; return observerObject.observer; } -#pragma mark Unubscribing +#pragma mark Unsubscribing - (void)unsubscribeFromCapabilityType:(SDLSystemCapabilityType)type withObserver:(id)observer { SDLLogD(@"Unsubscribing from capability type: %@", type); - for (SDLSystemCapabilityObserver *capabilityObserver in self.capabilityObservers[type]) { - if ([observer isEqual:capabilityObserver.observer] && self.capabilityObservers[type] != nil) { - [SDLGlobals runSyncOnSerialSubQueue:self.readWriteQueue block:^{ + [SDLGlobals runSyncOnSerialSubQueue:self.readWriteQueue block:^{ + for (SDLSystemCapabilityObserver *capabilityObserver in self.capabilityObservers[type]) { + if ([observer isEqual:capabilityObserver.observer] && self.capabilityObservers[type] != nil) { [self.capabilityObservers[type] removeObject:capabilityObserver]; - }]; - - [self sdl_removeNilObserversAndUnsubscribeIfNecessary]; - break; + [self sdl_removeNilObserversAndUnsubscribeIfNecessary]; + break; + } } - } + }]; } - (void)sdl_removeNilObserversAndUnsubscribeIfNecessary { SDLLogV(@"Checking for nil observers and removing them, then checking for subscriptions we don't need and unsubscribing."); - // Loop through our observers - for (SDLSystemCapabilityType key in self.capabilityObservers.allKeys) { - for (SDLSystemCapabilityObserver *observer in self.capabilityObservers[key]) { - [SDLGlobals runSyncOnSerialSubQueue:self.readWriteQueue block:^{ + + [SDLGlobals runSyncOnSerialSubQueue:self.readWriteQueue block:^{ + for (SDLSystemCapabilityType key in self.capabilityObservers.allKeys) { + for (SDLSystemCapabilityObserver *observer in self.capabilityObservers[key]) { // If an observer object is nil, remove it if (observer.observer == nil) { [self.capabilityObservers[key] removeObject:observer]; @@ -615,24 +615,24 @@ typedef NSString * SDLServiceID; if (self.capabilityObservers[key].count == 0) { [self.capabilityObservers removeObjectForKey:key]; } - }]; + } } - } - // If we don't support subscriptions, we don't want to unsubscribe by sending an RPC below - if (!self.supportsSubscriptions) { - return; - } + // If we don't support subscriptions, we don't want to unsubscribe by sending an RPC below + if (!self.supportsSubscriptions) { + return; + } - // Loop through our subscription statuses, check if we're subscribed. If we are, and we do not have observers for that type, and that type is not DISPLAYS, then unsubscribe. - for (SDLSystemCapabilityType type in self.subscriptionStatus.allKeys) { - if ([self.subscriptionStatus[type] isEqualToNumber:@YES] - && self.capabilityObservers[type] == nil - && ![type isEqualToEnum:SDLSystemCapabilityTypeDisplays]) { - SDLLogD(@"Removing the last subscription to type %@, sending a GetSystemCapability with subscribe false (will unsubscribe)", type); - [self sdl_sendGetSystemCapabilityWithType:type subscribe:@NO completionHandler:nil]; + // Loop through our subscription statuses, check if we're subscribed. If we are, and we do not have observers for that type, and that type is not DISPLAYS, then unsubscribe. + for (SDLSystemCapabilityType type in self.subscriptionStatus.allKeys) { + if ([self.subscriptionStatus[type] isEqualToNumber:@YES] + && self.capabilityObservers[type] == nil + && ![type isEqualToEnum:SDLSystemCapabilityTypeDisplays]) { + SDLLogD(@"Removing the last subscription to type %@, sending a GetSystemCapability with subscribe false (will unsubscribe)", type); + [self sdl_sendGetSystemCapabilityWithType:type subscribe:@NO completionHandler:nil]; + } } - } + }]; } #pragma mark Notifying Subscribers @@ -736,9 +736,9 @@ typedef NSString * SDLServiceID; } /** - * Called when a `SetDisplayLayoutResponse` response is received from Core. If the template was set successfully, the the new capabilities for the template are saved. + * Called when a `SetDisplayLayoutResponse` response is received from Core. If the template was set successfully, the the new capabilities for the template are saved. * - * @param notification The `SetDisplayLayoutResponse` response received from Core + * @param notification The `SetDisplayLayoutResponse` response received from Core */ - (void)sdl_displayLayoutResponse:(SDLRPCResponseNotification *)notification { #pragma clang diagnostic push @@ -786,36 +786,6 @@ typedef NSString * SDLServiceID; self.currentHMILevel = onHMIStatus.hmiLevel; } - -#pragma mark Getters - -- (NSMutableDictionary<SDLSystemCapabilityType, NSMutableArray<SDLSystemCapabilityObserver *> *> *)capabilityObservers { - __block NSMutableDictionary<SDLSystemCapabilityType, NSMutableArray<SDLSystemCapabilityObserver *> *> *dict = nil; - [SDLGlobals runSyncOnSerialSubQueue:self.readWriteQueue block:^{ - dict = self->_capabilityObservers; - }]; - - return dict; -} - -- (NSMutableDictionary<SDLSystemCapabilityType, NSNumber<SDLBool> *> *)subscriptionStatus { - __block NSMutableDictionary<SDLSystemCapabilityType, NSNumber<SDLBool> *> *dict = nil; - [SDLGlobals runSyncOnSerialSubQueue:self.readWriteQueue block:^{ - dict = self->_subscriptionStatus; - }]; - - return dict; -} - -- (nullable NSMutableDictionary<SDLServiceID, SDLAppServiceCapability *> *)appServicesCapabilitiesDictionary { - __block NSMutableDictionary<SDLServiceID, SDLAppServiceCapability *> *dict = nil; - [SDLGlobals runSyncOnSerialSubQueue:self.readWriteQueue block:^{ - dict = self->_appServicesCapabilitiesDictionary; - }]; - - return dict; -} - @end NS_ASSUME_NONNULL_END |