diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-07-26 10:21:17 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-07-26 10:21:17 -0400 |
commit | 471748ea47c1eff1a0cd48a549edf8d6c0ac4cfc (patch) | |
tree | f7d080f8240844514fa2210ce6c49fec521e590f | |
parent | 6ea90444b42a2d6691f17b7279aec34afd69ff2a (diff) | |
parent | 570d60b3d3a102477cde9d3038c50b2fd8fe23eb (diff) | |
download | sdl_ios-471748ea47c1eff1a0cd48a549edf8d6c0ac4cfc.tar.gz |
Merge branch 'master' into develop
-rw-r--r-- | .github/PULL_REQUEST_TEMPLATE.md | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | SmartDeviceLink-iOS.podspec | 2 | ||||
-rw-r--r-- | SmartDeviceLink.podspec | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLProxy.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSoftButtonManager.m | 162 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSoftButtonObject.m | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTextAndGraphicManager.m | 96 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m | 34 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m | 4 |
10 files changed, 183 insertions, 135 deletions
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index dcf9581e4..995262c63 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,7 @@ [Things to note: Pull Requests **must** fix an issue. Discussion about the feature / bug takes place in the issue, discussion of the implementation takes place in the PR. Please also see the [Contributing Guide](https://github.com/smartdevicelink/sdl_ios/blob/master/.github/CONTRIBUTING.md) for information on branch naming and the CLA. +Also, remember that all new public file headers should be added as public in the `File Inspector / Target Membership` pane, added to `SmartDeviceLink.h` and to *both* `.podspec` files. + Delete the above section when you've read it.] Fixes #[issue number] diff --git a/CHANGELOG.md b/CHANGELOG.md index 0160c9cba..f4d0bc5fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 6.0.1 + +### Bug Fixes +* Fixed a crash that could occur in development circumstances if the head unit returns "-1" for an enum +* Fixed manually sent Show RPCs causing issues when changing layouts. + # 6.0.0 (Changes since RC1) * None diff --git a/SmartDeviceLink-iOS.podspec b/SmartDeviceLink-iOS.podspec index da2389a46..082088b21 100644 --- a/SmartDeviceLink-iOS.podspec +++ b/SmartDeviceLink-iOS.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SmartDeviceLink-iOS" -s.version = "6.0.0" +s.version = "6.0.1" s.summary = "Connect your app with cars!" s.homepage = "https://github.com/smartdevicelink/SmartDeviceLink-iOS" s.license = { :type => "New BSD", :file => "LICENSE" } diff --git a/SmartDeviceLink.podspec b/SmartDeviceLink.podspec index 100f10f9f..ca1433b00 100644 --- a/SmartDeviceLink.podspec +++ b/SmartDeviceLink.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SmartDeviceLink" -s.version = "6.0.0" +s.version = "6.0.1" s.summary = "Connect your app with cars!" s.homepage = "https://github.com/smartdevicelink/SmartDeviceLink-iOS" s.license = { :type => "New BSD", :file => "LICENSE" } diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m index e5629b461..69ee0618f 100644 --- a/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink/SDLProxy.m @@ -42,7 +42,7 @@ typedef NSString SDLVehicleMake; typedef void (^URLSessionTaskCompletionHandler)(NSData *data, NSURLResponse *response, NSError *error); typedef void (^URLSessionDownloadTaskCompletionHandler)(NSURL *location, NSURLResponse *response, NSError *error); -NSString *const SDLProxyVersion = @"6.0.0"; +NSString *const SDLProxyVersion = @"6.0.1"; const float StartSessionTime = 10.0; const float NotifyProxyClosedDelay = (float)0.1; const int PoliciesCorrelationId = 65535; diff --git a/SmartDeviceLink/SDLSoftButtonManager.m b/SmartDeviceLink/SDLSoftButtonManager.m index f65acb444..e3e9278b2 100644 --- a/SmartDeviceLink/SDLSoftButtonManager.m +++ b/SmartDeviceLink/SDLSoftButtonManager.m @@ -50,7 +50,8 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic, nullable) SDLDisplayCapabilities *displayCapabilities; @property (strong, nonatomic, nullable) SDLSoftButtonCapabilities *softButtonCapabilities; -@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToSetButtons; +@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToUpdate; +@property (assign, nonatomic) BOOL isDirty; @end @@ -65,7 +66,8 @@ NS_ASSUME_NONNULL_BEGIN _softButtonObjects = @[]; _currentLevel = nil; - _waitingOnHMILevelUpdateToSetButtons = NO; + _waitingOnHMILevelUpdateToUpdate = NO; + _isDirty = NO; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_registerResponse:) name:SDLDidReceiveRegisterAppInterfaceResponse object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_displayLayoutResponse:) name:SDLDidReceiveSetDisplayLayoutResponse object:nil]; @@ -85,14 +87,16 @@ NS_ASSUME_NONNULL_BEGIN _currentLevel = nil; _displayCapabilities = nil; _softButtonCapabilities = nil; - _waitingOnHMILevelUpdateToSetButtons = NO; + _waitingOnHMILevelUpdateToUpdate = NO; + _isDirty = NO; } - (void)setSoftButtonObjects:(NSArray<SDLSoftButtonObject *> *)softButtonObjects { - if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { - _waitingOnHMILevelUpdateToSetButtons = YES; - _softButtonObjects = softButtonObjects; + // Only update if something changed. This prevents, for example, an empty array being reset + if (_softButtonObjects == softButtonObjects) { return; + } else { + self.isDirty = YES; } self.inProgressUpdate = nil; @@ -119,57 +123,13 @@ NS_ASSUME_NONNULL_BEGIN } } - _softButtonObjects = softButtonObjects; - - for (SDLSoftButtonObject *button in _softButtonObjects) { + for (SDLSoftButtonObject *button in softButtonObjects) { button.manager = self; } - NSMutableArray<SDLArtwork *> *initialStatesToBeUploaded = [NSMutableArray array]; - NSMutableArray<SDLArtwork *> *otherStatesToBeUploaded = [NSMutableArray array]; - if (self.displayCapabilities ? self.displayCapabilities.graphicSupported.boolValue : YES) { - // Upload all soft button images, the initial state images first, then the other states. We need to send updates when the initial state is ready. - for (SDLSoftButtonObject *object in self.softButtonObjects) { - if (object.currentState.artwork != nil && ![self.fileManager hasUploadedFile:object.currentState.artwork]) { - [initialStatesToBeUploaded addObject:object.currentState.artwork]; - } - } - for (SDLSoftButtonObject *object in self.softButtonObjects) { - for (SDLSoftButtonState *state in object.states) { - if ([state.name isEqualToString:object.currentState.name]) { continue; } - if (state.artwork != nil && ![self.fileManager hasUploadedFile:state.artwork]) { - [otherStatesToBeUploaded addObject:state.artwork]; - } - } - } - } - - // Upload initial images, then other state images - if (initialStatesToBeUploaded.count > 0) { - SDLLogD(@"Uploading soft button initial artworks"); - [self.fileManager uploadArtworks:[initialStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { - if (error != nil) { - SDLLogE(@"Error uploading soft button artworks: %@", error); - } - - SDLLogD(@"Soft button initial artworks uploaded"); - [self sdl_updateWithCompletionHandler:nil]; - }]; - } - if (otherStatesToBeUploaded.count > 0) { - SDLLogD(@"Uploading soft button other state artworks"); - [self.fileManager uploadArtworks:[otherStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { - if (error != nil) { - SDLLogE(@"Error uploading soft button artworks: %@", error); - } - - SDLLogD(@"Soft button other state artworks uploaded"); - // In case our soft button states have changed in the meantime - [self sdl_updateWithCompletionHandler:nil]; - }]; - } + _softButtonObjects = softButtonObjects; - [self sdl_updateWithCompletionHandler:nil]; + [self updateWithCompletionHandler:nil]; } - (nullable SDLSoftButtonObject *)softButtonObjectNamed:(NSString *)name { @@ -182,19 +142,30 @@ NS_ASSUME_NONNULL_BEGIN return nil; } -- (void)updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { - if (self.isBatchingUpdates) { return; } - - [self sdl_updateWithCompletionHandler:handler]; +- (void)sdl_transitionSoftButton:(SDLSoftButtonObject *)softButton { + self.isDirty = YES; + [self updateWithCompletionHandler:nil]; } -- (void)sdl_updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { +- (void)updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { + // Don't send if we're batching + if (self.isBatchingUpdates || !self.isDirty) { return; } + // Don't send if we're in HMI NONE if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { + self.waitingOnHMILevelUpdateToUpdate = YES; return; + } else { + self.waitingOnHMILevelUpdateToUpdate = NO; } + [self sdl_updateWithCompletionHandler:handler]; +} + +- (void)sdl_updateWithCompletionHandler:(nullable SDLSoftButtonUpdateCompletionHandler)handler { SDLLogD(@"Updating soft buttons"); + self.isDirty = NO; + if (self.inProgressUpdate != nil) { SDLLogV(@"In progress update exists, queueing update"); // If we already have a pending update, we're going to tell the old handler that it was superseded by a new update and then return @@ -217,13 +188,16 @@ NS_ASSUME_NONNULL_BEGIN self.inProgressUpdate = [[SDLShow alloc] init]; self.inProgressUpdate.mainField1 = self.currentMainField1 ?: @""; - BOOL headUnitSupportsImages = self.softButtonCapabilities ? self.softButtonCapabilities.imageSupported.boolValue : NO; + if ([self sdl_supportsSoftButtonImages]) { + [self sdl_uploadInitialStateImages]; + [self sdl_uploadOtherStateImages]; + } if (self.softButtonObjects == nil) { SDLLogV(@"Soft button objects are nil, sending an empty array"); self.inProgressUpdate.softButtons = @[]; } else if (([self sdl_currentStateHasImages] && ![self sdl_allCurrentStateImagesAreUploaded]) - || !headUnitSupportsImages) { + || ![self sdl_supportsSoftButtonImages]) { // The images don't yet exist on the head unit, or we cannot use images, send a text update, if possible. Otherwise, don't send anything yet. NSArray<SDLSoftButton *> *textOnlyButtons = [self sdl_textButtonsForCurrentState]; if (textOnlyButtons != nil) { @@ -283,6 +257,62 @@ NS_ASSUME_NONNULL_BEGIN return YES; } +- (BOOL)sdl_supportsSoftButtonImages { + BOOL supportsGraphics = self.displayCapabilities ? self.displayCapabilities.graphicSupported.boolValue : YES; + BOOL supportsSoftButtonImages = self.softButtonCapabilities ? self.softButtonCapabilities.imageSupported.boolValue : NO; + + return (supportsGraphics && supportsSoftButtonImages); +} + +- (void)sdl_uploadInitialStateImages { + NSMutableArray<SDLArtwork *> *initialStatesToBeUploaded = [NSMutableArray array]; + // Upload all soft button images, the initial state images first, then the other states. We need to send updates when the initial state is ready. + for (SDLSoftButtonObject *object in self.softButtonObjects) { + if (object.currentState.artwork != nil && ![self.fileManager hasUploadedFile:object.currentState.artwork]) { + [initialStatesToBeUploaded addObject:object.currentState.artwork]; + } + } + + // Upload initial images, then other state images + if (initialStatesToBeUploaded.count > 0) { + SDLLogD(@"Uploading soft button initial artworks"); + [self.fileManager uploadArtworks:[initialStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { + if (error != nil) { + SDLLogE(@"Error uploading soft button artworks: %@", error); + } + + SDLLogD(@"Soft button initial artworks uploaded"); + [self sdl_updateWithCompletionHandler:nil]; + }]; + } +} + +- (void)sdl_uploadOtherStateImages { + NSMutableArray<SDLArtwork *> *otherStatesToBeUploaded = [NSMutableArray array]; + // Upload all soft button images, the initial state images first, then the other states. We need to send updates when the initial state is ready. + for (SDLSoftButtonObject *object in self.softButtonObjects) { + for (SDLSoftButtonState *state in object.states) { + if ([state.name isEqualToString:object.currentState.name]) { continue; } + if (state.artwork != nil && ![self.fileManager hasUploadedFile:state.artwork]) { + [otherStatesToBeUploaded addObject:state.artwork]; + } + } + } + + if (otherStatesToBeUploaded.count > 0) { + SDLLogD(@"Uploading soft button other state artworks"); + [self.fileManager uploadArtworks:[otherStatesToBeUploaded copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) { + if (error != nil) { + SDLLogE(@"Error uploading soft button artworks: %@", error); + } + + SDLLogD(@"Soft button other state artworks uploaded"); + // In case our soft button states have changed in the meantime + [self sdl_updateWithCompletionHandler:nil]; + }]; + } +} + #pragma mark - Creating Soft Buttons /** @@ -336,7 +366,9 @@ NS_ASSUME_NONNULL_BEGIN self.displayCapabilities = response.displayCapabilities; // Auto-send an updated Show - [self updateWithCompletionHandler:nil]; + if (self.softButtonObjects.count > 0) { + [self updateWithCompletionHandler:nil]; + } } - (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification { @@ -346,12 +378,8 @@ NS_ASSUME_NONNULL_BEGIN self.currentLevel = hmiStatus.hmiLevel; // Auto-send an updated show if we were in NONE and now we are not - if ([oldHMILevel isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone]) { - if (self.waitingOnHMILevelUpdateToSetButtons) { - [self setSoftButtonObjects:_softButtonObjects]; - } else { - [self sdl_updateWithCompletionHandler:nil]; - } + if ([oldHMILevel isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone] && self.waitingOnHMILevelUpdateToUpdate) { + [self updateWithCompletionHandler:nil]; } } diff --git a/SmartDeviceLink/SDLSoftButtonObject.m b/SmartDeviceLink/SDLSoftButtonObject.m index be7915a55..427421590 100644 --- a/SmartDeviceLink/SDLSoftButtonObject.m +++ b/SmartDeviceLink/SDLSoftButtonObject.m @@ -16,6 +16,12 @@ NS_ASSUME_NONNULL_BEGIN +@interface SDLSoftButtonManager() + +- (void)sdl_transitionSoftButton:(SDLSoftButtonObject *)softButton; + +@end + @interface SDLSoftButtonObject() @property (assign, nonatomic) NSUInteger buttonId; @@ -55,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN SDLLogD(@"Transitioning button %@ to state %@", self.name, stateName); self.currentStateName = stateName; - [self.manager updateWithCompletionHandler:nil]; + [self.manager sdl_transitionSoftButton:self]; return YES; } diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m index 413aada4d..34bc8d97d 100644 --- a/SmartDeviceLink/SDLTextAndGraphicManager.m +++ b/SmartDeviceLink/SDLTextAndGraphicManager.m @@ -54,6 +54,7 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic, nullable) SDLArtwork *blankArtwork; +@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToUpdate; @property (assign, nonatomic) BOOL isDirty; @end @@ -72,6 +73,9 @@ NS_ASSUME_NONNULL_BEGIN _currentScreenData = [[SDLShow alloc] init]; _currentLevel = SDLHMILevelNone; + _waitingOnHMILevelUpdateToUpdate = NO; + _isDirty = NO; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_registerResponse:) name:SDLDidReceiveRegisterAppInterfaceResponse object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_displayLayoutResponse:) name:SDLDidReceiveSetDisplayLayoutResponse object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_hmiStatusNotification:) name:SDLDidChangeHMIStatusNotification object:nil]; @@ -102,6 +106,7 @@ NS_ASSUME_NONNULL_BEGIN _displayCapabilities = nil; _currentLevel = SDLHMILevelNone; _blankArtwork = nil; + _waitingOnHMILevelUpdateToUpdate = NO; _isDirty = NO; } @@ -110,6 +115,14 @@ NS_ASSUME_NONNULL_BEGIN - (void)updateWithCompletionHandler:(nullable SDLTextAndGraphicUpdateCompletionHandler)handler { if (self.isBatchingUpdates) { return; } + // Don't send if we're in HMI NONE + if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { + self.waitingOnHMILevelUpdateToUpdate = YES; + return; + } else { + self.waitingOnHMILevelUpdateToUpdate = NO; + } + if (self.isDirty) { self.isDirty = NO; [self sdl_updateWithCompletionHandler:handler]; @@ -117,11 +130,6 @@ NS_ASSUME_NONNULL_BEGIN } - (void)sdl_updateWithCompletionHandler:(nullable SDLTextAndGraphicUpdateCompletionHandler)handler { - // Don't send if we're in HMI NONE - if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { - return; - } - SDLLogD(@"Updating text and graphics"); if (self.inProgressUpdate != nil) { SDLLogV(@"In progress update exists, queueing update"); @@ -487,6 +495,13 @@ NS_ASSUME_NONNULL_BEGIN return [array copy]; } +- (BOOL)sdl_hasData { + BOOL hasTextFields = ([self sdl_findNonNilTextFields].count > 0); + BOOL hasImageFields = (self.primaryGraphic != nil) || (self.secondaryGraphic != nil); + + return hasTextFields || hasImageFields; +} + #pragma mark - Equality - (BOOL)sdl_showImages:(SDLShow *)show isEqualToShowImages:(SDLShow *)show2 { @@ -507,110 +522,98 @@ NS_ASSUME_NONNULL_BEGIN - (void)setTextField1:(nullable NSString *)textField1 { _textField1 = textField1; + _isDirty = YES; if (!self.isBatchingUpdates) { // If we aren't batching, send the update immediately, if we are, set ourselves as dirty (so we know we should send an update after the batch ends) - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField2:(nullable NSString *)textField2 { _textField2 = textField2; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField3:(nullable NSString *)textField3 { _textField3 = textField3; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField4:(nullable NSString *)textField4 { _textField4 = textField4; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setMediaTrackTextField:(nullable NSString *)mediaTrackTextField { _mediaTrackTextField = mediaTrackTextField; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setPrimaryGraphic:(nullable SDLArtwork *)primaryGraphic { _primaryGraphic = primaryGraphic; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setSecondaryGraphic:(nullable SDLArtwork *)secondaryGraphic { _secondaryGraphic = secondaryGraphic; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setAlignment:(nullable SDLTextAlignment)alignment { _alignment = alignment ? alignment : SDLTextAlignmentCenter; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField1Type:(nullable SDLMetadataType)textField1Type { _textField1Type = textField1Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField2Type:(nullable SDLMetadataType)textField2Type { _textField2Type = textField2Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField3Type:(nullable SDLMetadataType)textField3Type { _textField3Type = textField3Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } - (void)setTextField4Type:(nullable SDLMetadataType)textField4Type { _textField4Type = textField4Type; + _isDirty = YES; if (!self.isBatchingUpdates) { - [self sdl_updateWithCompletionHandler:nil]; - } else { - _isDirty = YES; + [self updateWithCompletionHandler:nil]; } } @@ -644,18 +647,21 @@ NS_ASSUME_NONNULL_BEGIN self.displayCapabilities = response.displayCapabilities; // Auto-send an updated show - [self sdl_updateWithCompletionHandler:nil]; + if ([self sdl_hasData]) { + [self sdl_updateWithCompletionHandler:nil]; + } } - (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification { SDLOnHMIStatus *hmiStatus = (SDLOnHMIStatus *)notification.notification; + SDLHMILevel oldLevel = self.currentLevel; + self.currentLevel = hmiStatus.hmiLevel; + // Auto-send an updated show if we were in NONE and now we are not - if ([self.currentLevel isEqualToString:SDLHMILevelNone] && ![hmiStatus.hmiLevel isEqualToString:SDLHMILevelNone]) { + if ([oldLevel isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone] && self.waitingOnHMILevelUpdateToUpdate) { [self sdl_updateWithCompletionHandler:nil]; } - - self.currentLevel = hmiStatus.hmiLevel; } @end diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index 7eaad7142..17be53b19 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -24,23 +24,23 @@ @interface SDLSoftButtonManager() +@property (strong, nonatomic) NSArray<SDLSoftButton *> *currentSoftButtons; + @property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager; @property (weak, nonatomic) SDLFileManager *fileManager; -@property (strong, nonatomic) NSArray<SDLSoftButton *> *currentSoftButtons; - @property (strong, nonatomic, nullable) SDLShow *inProgressUpdate; @property (copy, nonatomic, nullable) SDLSoftButtonUpdateCompletionHandler inProgressHandler; -@property (strong, nonatomic, nullable) SDLShow *queuedImageUpdate; @property (assign, nonatomic) BOOL hasQueuedUpdate; @property (copy, nonatomic, nullable) SDLSoftButtonUpdateCompletionHandler queuedUpdateHandler; -@property (strong, nonatomic, nullable) SDLHMILevel currentLevel; -@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToSetButtons; +@property (copy, nonatomic, nullable) SDLHMILevel currentLevel; @property (strong, nonatomic, nullable) SDLDisplayCapabilities *displayCapabilities; @property (strong, nonatomic, nullable) SDLSoftButtonCapabilities *softButtonCapabilities; +@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToUpdate; + @end QuickSpecBegin(SDLSoftButtonManagerSpec) @@ -91,22 +91,22 @@ describe(@"a soft button manager", ^{ expect(testManager.hasQueuedUpdate).to(beFalse()); expect(testManager.displayCapabilities).to(beNil()); expect(testManager.softButtonCapabilities).to(beNil()); - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beFalse()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beFalse()); }); context(@"when in HMI NONE", ^{ beforeEach(^{ testManager.currentLevel = SDLHMILevelNone; - NSString *sameName = @"Same name"; - testObject1 = [[SDLSoftButtonObject alloc] initWithName:sameName states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; - testObject2 = [[SDLSoftButtonObject alloc] initWithName:sameName state:object2State1 handler:nil]; + testObject1 = [[SDLSoftButtonObject alloc] initWithName:@"name1" states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; + testObject2 = [[SDLSoftButtonObject alloc] initWithName:@"name2" state:object2State1 handler:nil]; testManager.softButtonObjects = @[testObject1, testObject2]; }); - it(@"should not set the soft buttons", ^{ - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beTrue()); + it(@"should set the soft buttons, but not update", ^{ + expect(testManager.softButtonObjects).toNot(beEmpty()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beTrue()); expect(testManager.inProgressUpdate).to(beNil()); }); }); @@ -115,15 +115,15 @@ describe(@"a soft button manager", ^{ beforeEach(^{ testManager.currentLevel = nil; - NSString *sameName = @"Same name"; - testObject1 = [[SDLSoftButtonObject alloc] initWithName:sameName states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; - testObject2 = [[SDLSoftButtonObject alloc] initWithName:sameName state:object2State1 handler:nil]; + testObject1 = [[SDLSoftButtonObject alloc] initWithName:@"name1" states:@[object1State1, object1State2] initialStateName:object1State1Name handler:nil]; + testObject2 = [[SDLSoftButtonObject alloc] initWithName:@"name2" state:object2State1 handler:nil]; testManager.softButtonObjects = @[testObject1, testObject2]; }); - it(@"should not set the soft buttons", ^{ - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beTrue()); + it(@"should set the soft buttons, but not update", ^{ + expect(testManager.softButtonObjects).toNot(beEmpty()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beTrue()); expect(testManager.inProgressUpdate).to(beNil()); }); }); @@ -359,7 +359,7 @@ describe(@"a soft button manager", ^{ expect(testManager.currentLevel).to(beNil()); expect(testManager.displayCapabilities).to(beNil()); expect(testManager.softButtonCapabilities).to(beNil()); - expect(testManager.waitingOnHMILevelUpdateToSetButtons).to(beFalse()); + expect(testManager.waitingOnHMILevelUpdateToUpdate).to(beFalse()); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m index 5005483d0..ef5b18623 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicManagerSpec.m @@ -94,7 +94,7 @@ describe(@"text and graphic manager", ^{ expect(testManager.textField1).to(equal(testString)); expect(testManager.inProgressUpdate).to(beNil()); - expect(testManager.isDirty).to(beFalse()); + expect(testManager.isDirty).to(beTrue()); }); }); @@ -108,7 +108,7 @@ describe(@"text and graphic manager", ^{ expect(testManager.textField1).to(equal(testString)); expect(testManager.inProgressUpdate).to(beNil()); - expect(testManager.isDirty).to(beFalse()); + expect(testManager.isDirty).to(beTrue()); }); }); |