diff options
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.h | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.m | 22 | ||||
-rw-r--r-- | SmartDeviceLink/SDLManager.h | 12 | ||||
-rw-r--r-- | SmartDeviceLink/SDLManagerDelegate.h | 19 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m | 58 |
5 files changed, 112 insertions, 3 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.h b/SmartDeviceLink/SDLLifecycleManager.h index 7d7c3d2e1..b2666b3b3 100644 --- a/SmartDeviceLink/SDLLifecycleManager.h +++ b/SmartDeviceLink/SDLLifecycleManager.h @@ -9,8 +9,10 @@ #import "SDLNotificationConstants.h" #import <Foundation/Foundation.h> +#import "SDLAudioStreamingState.h" #import "SDLHMILevel.h" #import "SDLLanguage.h" +#import "SDLSystemContext.h" @class SDLConfiguration; @class SDLFileManager; @@ -73,6 +75,8 @@ typedef void (^SDLManagerReadyBlock)(BOOL success, NSError *_Nullable error); @property (assign, nonatomic) UInt16 lastCorrelationId; @property (copy, nonatomic, readonly) SDLLifecycleState *lifecycleState; @property (copy, nonatomic, nullable) SDLHMILevel hmiLevel; +@property (copy, nonatomic, nullable) SDLAudioStreamingState audioStreamingState; +@property (copy, nonatomic, nullable) SDLSystemContext systemContext; @property (strong, nonatomic, nullable) SDLRegisterAppInterfaceResponse *registerResponse; diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m index 66f1dfe1c..bff19c66c 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -186,7 +186,9 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; self.registerResponse = nil; self.lastCorrelationId = 0; self.hmiLevel = nil; - + self.audioStreamingState = nil; + self.systemContext = nil; + [SDLDebugTool logInfo:@"Stopping Proxy"]; self.proxy = nil; @@ -441,7 +443,13 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; SDLOnHMIStatus *hmiStatusNotification = notification.notification; SDLHMILevel oldHMILevel = self.hmiLevel; self.hmiLevel = hmiStatusNotification.hmiLevel; - + + SDLAudioStreamingState oldStreamingState = self.audioStreamingState; + self.audioStreamingState = hmiStatusNotification.audioStreamingState; + + SDLSystemContext oldSystemContext = self.systemContext; + self.systemContext = hmiStatusNotification.systemContext; + if (![self.lifecycleStateMachine isCurrentState:SDLLifecycleStateReady]) { return; } @@ -449,6 +457,16 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; if (![oldHMILevel isEqualToString:self.hmiLevel]) { [self.delegate hmiLevel:oldHMILevel didChangeToLevel:self.hmiLevel]; } + + if (![oldStreamingState isEqualToString:self.audioStreamingState] + && [self.delegate respondsToSelector:@selector(audioStreamingState:didChangeToState:)]) { + [self.delegate audioStreamingState:oldStreamingState didChangeToState:self.audioStreamingState]; + } + + if (![oldSystemContext isEqualToString:self.systemContext] + && [self.delegate respondsToSelector:@selector(systemContext:didChangeToContext:)]) { + [self.delegate systemContext:oldSystemContext didChangeToContext:self.systemContext]; + } } - (void)remoteHardwareDidUnregister:(SDLRPCNotificationNotification *)notification { diff --git a/SmartDeviceLink/SDLManager.h b/SmartDeviceLink/SDLManager.h index e42f1cd19..7e7cb8c54 100644 --- a/SmartDeviceLink/SDLManager.h +++ b/SmartDeviceLink/SDLManager.h @@ -2,8 +2,10 @@ #import "SDLNotificationConstants.h" +#import "SDLAudioStreamingState.h" #import "SDLHMILevel.h" #import "SDLLanguage.h" +#import "SDLSystemContext.h" @class SDLConfiguration; @class SDLFileManager; @@ -39,6 +41,16 @@ typedef void (^SDLManagerReadyBlock)(BOOL success, NSError *_Nullable error); @property (copy, nonatomic, readonly) SDLHMILevel hmiLevel; /** + * The current audio streaming state of the running app. + */ +@property (copy, nonatomic, readonly) SDLAudioStreamingState audioStreamingState; + +/** + * The current system context of the running app. + */ +@property (copy, nonatomic, readonly) SDLSystemContext systemContext; + +/** * The file manager to be used by the running app. */ @property (strong, nonatomic, readonly) SDLFileManager *fileManager; diff --git a/SmartDeviceLink/SDLManagerDelegate.h b/SmartDeviceLink/SDLManagerDelegate.h index 88ac86652..a3762b4e1 100644 --- a/SmartDeviceLink/SDLManagerDelegate.h +++ b/SmartDeviceLink/SDLManagerDelegate.h @@ -8,7 +8,9 @@ #import <Foundation/Foundation.h> +#import "SDLAudioStreamingState.h" #import "SDLHMILevel.h" +#import "SDLSystemContext.h" NS_ASSUME_NONNULL_BEGIN @@ -28,6 +30,23 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)hmiLevel:(SDLHMILevel)oldLevel didChangeToLevel:(SDLHMILevel)newLevel; +@optional +/** + * Called when the audio streaming state of this application changes on the remote system. This refers to when streaming audio is audible to the user. + * + * @param oldState The previous state which has now been left. + * @param newState The current state. + */ +- (void)audioStreamingState:(nullable SDLAudioStreamingState)oldState didChangeToState:(SDLAudioStreamingState)newState; + +/** + * Called when the system context of this application changes on the remote system. This refers to whether or not a user-initiated interaction is in progress, and if so, what it is. + * + * @param oldContext The previous context which has now been left. + * @param newContext The current context. + */ +- (void)systemContext:(nullable SDLSystemContext)oldContext didChangeToContext:(SDLSystemContext)newContext; + @end diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m index 0da7d2727..e5105fe6f 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m @@ -367,7 +367,63 @@ describe(@"a lifecycle manager", ^{ }); }); }); - }); + + describe(@"receiving an audio state change", ^{ + __block SDLOnHMIStatus *testHMIStatus = nil; + __block SDLAudioStreamingState testAudioStreamingState = nil; + __block SDLAudioStreamingState oldAudioStreamingState = nil; + + beforeEach(^{ + oldAudioStreamingState = testManager.audioStreamingState; + testHMIStatus = [[SDLOnHMIStatus alloc] init]; + }); + + context(@"a not audible audio state", ^{ + beforeEach(^{ + testAudioStreamingState = SDLAudioStreamingStateNotAudible; + testHMIStatus.audioStreamingState = testAudioStreamingState; + + [testManager.notificationDispatcher postRPCNotificationNotification:SDLDidChangeHMIStatusNotification notification:testHMIStatus]; + }); + + it(@"should set the audio state", ^{ + expect(testManager.audioStreamingState).toEventually(equal(testAudioStreamingState)); + }); + + it(@"should call the delegate", ^{ + OCMVerify([managerDelegateMock audioStreamingState:oldAudioStreamingState didChangeToState:testAudioStreamingState]); + }); + }); + }); + + describe(@"receiving a system context change", ^{ + __block SDLOnHMIStatus *testHMIStatus = nil; + __block SDLSystemContext testSystemContext = nil; + __block SDLSystemContext oldSystemContext = nil; + + beforeEach(^{ + oldSystemContext = testManager.systemContext; + testHMIStatus = [[SDLOnHMIStatus alloc] init]; + }); + + context(@"a alert system context state", ^{ + beforeEach(^{ + testSystemContext = SDLSystemContextAlert; + testHMIStatus.systemContext = testSystemContext; + + [testManager.notificationDispatcher postRPCNotificationNotification:SDLDidChangeHMIStatusNotification notification:testHMIStatus]; + }); + + it(@"should set the system context", ^{ + expect(testManager.systemContext).toEventually(equal(testSystemContext)); + }); + + it(@"should call the delegate", ^{ + OCMVerify([managerDelegateMock systemContext:oldSystemContext didChangeToContext:testSystemContext]); + }); + }); + }); + }); }); }); |