diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-04-27 13:49:45 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-04-27 13:49:45 -0400 |
commit | 030682e3eebeabcf9c2fc4d736da2d82332fac80 (patch) | |
tree | ca6c8ee34dd047186c77938b4749454e8177ed08 | |
parent | 0366a9a6e14c3826977ee753ceb47de39a0d1360 (diff) | |
download | sdl_ios-030682e3eebeabcf9c2fc4d736da2d82332fac80.tar.gz |
Fix attempting to update the menu while in the menu. It will now wait until the user is out of the menu.
-rw-r--r-- | SmartDeviceLink/SDLMenuManager.m | 34 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m | 14 |
2 files changed, 30 insertions, 18 deletions
diff --git a/SmartDeviceLink/SDLMenuManager.m b/SmartDeviceLink/SDLMenuManager.m index 6997e2e6c..bbb25f15e 100644 --- a/SmartDeviceLink/SDLMenuManager.m +++ b/SmartDeviceLink/SDLMenuManager.m @@ -45,12 +45,13 @@ NS_ASSUME_NONNULL_BEGIN @property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager; @property (weak, nonatomic) SDLFileManager *fileManager; -@property (copy, nonatomic, nullable) SDLHMILevel currentLevel; +@property (copy, nonatomic, nullable) SDLHMILevel currentHMILevel; +@property (copy, nonatomic, nullable) SDLSystemContext currentSystemContext; @property (strong, nonatomic, nullable) SDLDisplayCapabilities *displayCapabilities; @property (strong, nonatomic, nullable) NSArray<SDLRPCRequest *> *inProgressUpdate; @property (assign, nonatomic) BOOL hasQueuedUpdate; -@property (assign, nonatomic) BOOL waitingOnHMILevelUpdate; +@property (assign, nonatomic) BOOL waitingOnHMIUpdate; @property (assign, nonatomic) UInt32 lastMenuId; @property (copy, nonatomic) NSArray<SDLMenuCell *> *oldMenuCells; @@ -91,7 +92,7 @@ UInt32 const MenuCellIdMin = 1; #pragma mark - Updating System - (void)sdl_updateWithCompletionHandler:(nullable SDLMenuUpdateCompletionHandler)completionHandler { - if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { + if (self.currentHMILevel == nil || [self.currentHMILevel isEqualToString:SDLHMILevelNone]) { return; } @@ -132,7 +133,7 @@ UInt32 const MenuCellIdMin = 1; [self.connectionManager sendRequests:deleteMenuCommands progressHandler:nil completionHandler:^(BOOL success) { if (!success) { - SDLLogE(@"Error deleting old menu commands"); + SDLLogW(@"Unable to delete all old menu commands"); } else { SDLLogD(@"Finished deleting old menu"); } @@ -202,8 +203,10 @@ UInt32 const MenuCellIdMin = 1; #pragma mark - Setters - (void)setMenuCells:(NSArray<SDLMenuCell *> *)menuCells { - if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) { - _waitingOnHMILevelUpdate = YES; + if (self.currentHMILevel == nil + || [self.currentHMILevel isEqualToEnum:SDLHMILevelNone] + || [self.currentSystemContext isEqualToEnum:SDLSystemContextMenu]) { + _waitingOnHMIUpdate = YES; _menuCells = menuCells; return; } @@ -382,17 +385,26 @@ UInt32 const MenuCellIdMin = 1; - (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification { SDLOnHMIStatus *hmiStatus = (SDLOnHMIStatus *)notification.notification; - SDLHMILevel oldHMILevel = self.currentLevel; - self.currentLevel = hmiStatus.hmiLevel; + 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 isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone]) { - if (self.waitingOnHMILevelUpdate) { + // Auto-send an updated menu if we were in NONE and now we are not, and we need an update + if ([oldHMILevel isEqualToString:SDLHMILevelNone] && ![self.currentHMILevel isEqualToString:SDLHMILevelNone]) { + if (self.waitingOnHMIUpdate) { [self setMenuCells:_menuCells]; } else { [self sdl_updateWithCompletionHandler:nil]; } } + + SDLSystemContext oldSystemContext = self.currentSystemContext; + self.currentSystemContext = hmiStatus.systemContext; + + if ([oldSystemContext isEqualToEnum:SDLSystemContextMenu] && ![self.currentSystemContext isEqualToEnum:SDLSystemContextMenu]) { + if (self.waitingOnHMIUpdate) { + [self setMenuCells:_menuCells]; + } + } } @end diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m index 39522ef4e..8e4df67a6 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m @@ -27,12 +27,12 @@ @property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager; @property (weak, nonatomic) SDLFileManager *fileManager; -@property (copy, nonatomic, nullable) SDLHMILevel currentLevel; +@property (copy, nonatomic, nullable) SDLHMILevel currentHMILevel; @property (strong, nonatomic, nullable) SDLDisplayCapabilities *displayCapabilities; @property (strong, nonatomic, nullable) NSArray<SDLRPCRequest *> *inProgressUpdate; @property (assign, nonatomic) BOOL hasQueuedUpdate; -@property (assign, nonatomic) BOOL waitingOnHMILevelUpdate; +@property (assign, nonatomic) BOOL waitingOnHMIUpdate; @property (assign, nonatomic) UInt32 lastMenuId; @property (copy, nonatomic) NSArray<SDLMenuCell *> *oldMenuCells; @@ -62,11 +62,11 @@ describe(@"menu manager", ^{ expect(testManager.menuCells).to(beEmpty()); expect(testManager.connectionManager).to(equal(mockConnectionManager)); expect(testManager.fileManager).to(equal(mockFileManager)); - expect(testManager.currentLevel).to(beNil()); + expect(testManager.currentHMILevel).to(beNil()); expect(testManager.displayCapabilities).to(beNil()); expect(testManager.inProgressUpdate).to(beNil()); expect(testManager.hasQueuedUpdate).to(beFalse()); - expect(testManager.waitingOnHMILevelUpdate).to(beFalse()); + expect(testManager.waitingOnHMIUpdate).to(beFalse()); expect(testManager.lastMenuId).to(equal(0)); expect(testManager.oldMenuCells).to(beEmpty()); }); @@ -74,7 +74,7 @@ describe(@"menu manager", ^{ describe(@"updating menu cells before HMI is ready", ^{ context(@"when in HMI NONE", ^{ beforeEach(^{ - testManager.currentLevel = SDLHMILevelNone; + testManager.currentHMILevel = SDLHMILevelNone; }); it(@"should not update", ^{ @@ -86,7 +86,7 @@ describe(@"menu manager", ^{ context(@"when no HMI level has been received", ^{ beforeEach(^{ - testManager.currentLevel = nil; + testManager.currentHMILevel = nil; }); it(@"should not update", ^{ @@ -99,7 +99,7 @@ describe(@"menu manager", ^{ describe(@"updating menu cell", ^{ beforeEach(^{ - testManager.currentLevel = SDLHMILevelFull; + testManager.currentHMILevel = SDLHMILevelFull; testManager.displayCapabilities = [[SDLDisplayCapabilities alloc] init]; SDLImageField *commandIconField = [[SDLImageField alloc] init]; |