diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2017-03-13 17:45:40 -0700 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2017-03-13 17:45:40 -0700 |
commit | 36139eb71ca33a75f96e2ad116ce95ba020fdac8 (patch) | |
tree | e6259e9d072807370b7a1f783cebcd9a923dda67 | |
parent | 707489a9f0c5a9947f867955e828bce8df1469f4 (diff) | |
parent | 14adcab8724b7b62908b13c90da35394bb44cf35 (diff) | |
download | sdl_ios-36139eb71ca33a75f96e2ad116ce95ba020fdac8.tar.gz |
Merge remote-tracking branch 'origin/develop' into feature/streaming_media_manager
* origin/develop:
Changed NSString category name from Enum to SDLEnum.
Added convenience isEqualToEnum function.
Update README.md
Removed unnecessary comments.
Update naming of notification constants
Added delegate callbacks for audio streaming state and system context changes.
Fix handler updates in example app and unit tests
Implement SDL 0027
# Conflicts:
# SmartDeviceLink-iOS.xcodeproj/project.pbxproj
# SmartDeviceLink/SDLTouchManager.m
29 files changed, 263 insertions, 147 deletions
@@ -16,7 +16,8 @@ * The [Core](https://github.com/smartdevicelink/sdl_core) component is the software which Vehicle Manufacturers (OEMs) implement in their vehicle head units. Integrating this component into their head unit and HMI based on a set of guidelines and templates enables access to various smartphone applications. * The optional [SDL Server](https://github.com/smartdevicelink/sdl_server) can be used by Vehicle OEMs to update application policies and gather usage information for connected applications. * The [iOS](https://github.com/smartdevicelink/sdl_ios) and [Android](https://github.com/smartdevicelink/sdl_android) libraries are implemented by app developers into their applications to enable command and control via the connected head unit. -* To suggest new features to SDL, including the iOS library, go to the [SDL Evolution](https://github.com/smartdevicelink/sdl_evolution) github project +* To suggest new features to SDL, including the iOS library, go to the [SDL Evolution](https://github.com/smartdevicelink/sdl_evolution) github project. +* To understand if a contribution should be entered as an iOS Pull Request or Issue, or an SDL Evolution Proposal, please reference [this document](https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals_versus_issues.md). <a href="http://www.youtube.com/watch?feature=player_embedded&v=AzdQdSCS24M" target="_blank"><img src="http://i.imgur.com/nm8UujD.png?1" alt="SmartDeviceLink" border="10" /></a> diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 28d2b31a7..2ec45ef92 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -761,7 +761,6 @@ 5D61FE141A84238C00846EE7 /* SDLWiperStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FC271A84238C00846EE7 /* SDLWiperStatus.m */; }; 5D6CC8EF1C610E660027F60A /* SDLSecurityType.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D6CC8EE1C610E660027F60A /* SDLSecurityType.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D6EB4CC1BF28DC600693731 /* NSMapTable+SubscriptingSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D6EB4CB1BF28DC600693731 /* NSMapTable+SubscriptingSpec.m */; }; - 5D6F7A2B1BC45BF70070BF37 /* SDLRequestHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D6F7A2A1BC45BF70070BF37 /* SDLRequestHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D6F7A2E1BC5650B0070BF37 /* SDLLifecycleConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D6F7A2C1BC5650B0070BF37 /* SDLLifecycleConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D6F7A2F1BC5650B0070BF37 /* SDLLifecycleConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D6F7A2D1BC5650B0070BF37 /* SDLLifecycleConfiguration.m */; }; 5D6F7A351BC5B9B60070BF37 /* SDLLockScreenViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D6F7A331BC5B9B60070BF37 /* SDLLockScreenViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -873,6 +872,7 @@ DA8966EF1E5693E300413EAB /* SDLStreamingMediaLifecycleManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8966EE1E5693E300413EAB /* SDLStreamingMediaLifecycleManagerSpec.m */; }; DA8966F21E56973700413EAB /* SDLStreamingMediaManagerConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8966F11E56973700413EAB /* SDLStreamingMediaManagerConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA8966F41E56977C00413EAB /* SDLStreamingMediaManagerConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8966F31E56977C00413EAB /* SDLStreamingMediaManagerConstants.m */; }; + DA4F47961E771AA100FC809E /* SDLEnum.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4F47951E771AA100FC809E /* SDLEnum.m */; }; DA96C0661D4D4F730022F520 /* SDLAppInfoSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA96C0651D4D4F730022F520 /* SDLAppInfoSpec.m */; }; DA9F7E631DCBFAC800ACAE48 /* SDLDateTime.h in Headers */ = {isa = PBXBuildFile; fileRef = DA9F7E611DCBFAC800ACAE48 /* SDLDateTime.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA9F7E641DCBFAC800ACAE48 /* SDLDateTime.m in Sources */ = {isa = PBXBuildFile; fileRef = DA9F7E621DCBFAC800ACAE48 /* SDLDateTime.m */; }; @@ -1776,7 +1776,6 @@ 5D61FC271A84238C00846EE7 /* SDLWiperStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLWiperStatus.m; sourceTree = "<group>"; }; 5D6CC8EE1C610E660027F60A /* SDLSecurityType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLSecurityType.h; sourceTree = "<group>"; }; 5D6EB4CB1BF28DC600693731 /* NSMapTable+SubscriptingSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSMapTable+SubscriptingSpec.m"; path = "DevAPISpecs/NSMapTable+SubscriptingSpec.m"; sourceTree = "<group>"; }; - 5D6F7A2A1BC45BF70070BF37 /* SDLRequestHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLRequestHandler.h; sourceTree = "<group>"; }; 5D6F7A2C1BC5650B0070BF37 /* SDLLifecycleConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLLifecycleConfiguration.h; sourceTree = "<group>"; }; 5D6F7A2D1BC5650B0070BF37 /* SDLLifecycleConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLLifecycleConfiguration.m; sourceTree = "<group>"; }; 5D6F7A331BC5B9B60070BF37 /* SDLLockScreenViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLLockScreenViewController.h; sourceTree = "<group>"; }; @@ -1881,6 +1880,7 @@ DA4353E71D2721680099B8C4 /* SDLTouchManagerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLTouchManagerSpec.m; path = UtilitiesSpecs/Touches/SDLTouchManagerSpec.m; sourceTree = "<group>"; }; DA4353E81D2721680099B8C4 /* SDLTouchSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLTouchSpec.m; path = UtilitiesSpecs/Touches/SDLTouchSpec.m; sourceTree = "<group>"; }; DA661E2B1E553E7E001C1345 /* SDLStreamingMediaManagerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLStreamingMediaManagerSpec.m; sourceTree = "<group>"; }; + DA4F47951E771AA100FC809E /* SDLEnum.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLEnum.m; sourceTree = "<group>"; }; DA7515981D95FAA000F29323 /* lock_arrow_down_black.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lock_arrow_down_black.png; sourceTree = "<group>"; }; DA7515991D95FAA000F29323 /* lock_arrow_down_black@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "lock_arrow_down_black@2x.png"; sourceTree = "<group>"; }; DA75159A1D95FAA000F29323 /* lock_arrow_down_black@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "lock_arrow_down_black@3x.png"; sourceTree = "<group>"; }; @@ -3119,6 +3119,7 @@ isa = PBXGroup; children = ( 5D61FABA1A84238A00846EE7 /* SDLEnum.h */, + DA4F47951E771AA100FC809E /* SDLEnum.m */, 5DB92D301AC9C8BA00C15BB0 /* SDLRPCStruct.h */, 5DB92D311AC9C8BA00C15BB0 /* SDLRPCStruct.m */, 5D61FB7C1A84238B00846EE7 /* SDLRPCMessage.h */, @@ -3436,7 +3437,6 @@ isa = PBXGroup; children = ( 5D6F7A301BC5B7100070BF37 /* Lock Screen UI */, - 5DA3F3611BC448690026F2D0 /* Handler Additions */, 5DA3F3561BC4480E0026F2D0 /* Utilities */, 5D8204171BCD80A200D0A41B /* Configurations */, 5DBAE0A61D355EF200CE00BF /* Managers */, @@ -3480,14 +3480,6 @@ name = Notifications; sourceTree = "<group>"; }; - 5DA3F3611BC448690026F2D0 /* Handler Additions */ = { - isa = PBXGroup; - children = ( - 5D6F7A2A1BC45BF70070BF37 /* SDLRequestHandler.h */, - ); - name = "Handler Additions"; - sourceTree = "<group>"; - }; 5DAE06711BDEC68700F9B498 /* Developer API Tests */ = { isa = PBXGroup; children = ( @@ -4057,7 +4049,6 @@ 5D61FE051A84238C00846EE7 /* SDLVehicleDataResultCode.h in Headers */, 5D61FD2B1A84238C00846EE7 /* SDLPerformInteractionResponse.h in Headers */, 5D61FDA11A84238C00846EE7 /* SDLSoftButtonCapabilities.h in Headers */, - 5D6F7A2B1BC45BF70070BF37 /* SDLRequestHandler.h in Headers */, 5D61FDB51A84238C00846EE7 /* SDLSyncMsgVersion.h in Headers */, 5DA102A41D4122C700C15826 /* NSMutableDictionary+SafeRemove.h in Headers */, 5D61FE031A84238C00846EE7 /* SDLVehicleDataResult.h in Headers */, @@ -4536,6 +4527,7 @@ 5D1665C51CF8CA2700CC4CA1 /* SDLListFilesOperation.m in Sources */, 5D61FE021A84238C00846EE7 /* SDLVehicleDataNotificationStatus.m in Sources */, 5D61FDD81A84238C00846EE7 /* SDLTouchType.m in Sources */, + DA4F47961E771AA100FC809E /* SDLEnum.m in Sources */, 5D61FDD61A84238C00846EE7 /* SDLTouchEventCapabilities.m in Sources */, 5DA102A51D4122C700C15826 /* NSMutableDictionary+SafeRemove.m in Sources */, 5D61FCF11A84238C00846EE7 /* SDLLockScreenStatusManager.m in Sources */, diff --git a/SmartDeviceLink/SDLAddCommand.h b/SmartDeviceLink/SDLAddCommand.h index fb7ea7498..509ea80fa 100644 --- a/SmartDeviceLink/SDLAddCommand.h +++ b/SmartDeviceLink/SDLAddCommand.h @@ -5,10 +5,9 @@ #import "SDLImageType.h" #import "SDLNotificationConstants.h" -#import "SDLRequestHandler.h" -@class SDLMenuParams; @class SDLImage; +@class SDLMenuParams; /** * This class will add a command to the application's Command Menu SDLMenuParams @@ -37,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface SDLAddCommand : SDLRPCRequest <SDLRequestHandler> +@interface SDLAddCommand : SDLRPCRequest /** * Construct a SDLAddCommand with a handler callback when an event occurs. @@ -46,20 +45,20 @@ NS_ASSUME_NONNULL_BEGIN * * @return An SDLAddCommand object */ -- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler; +- (instancetype)initWithHandler:(nullable SDLRPCCommandNotificationHandler)handler; -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands handler:(nullable SDLRPCNotificationHandler)handler; +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands handler:(nullable SDLRPCCommandNotificationHandler)handler; -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCNotificationHandler)handler; +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCCommandNotificationHandler)handler; -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(NSString *)iconValue iconType:(SDLImageType)iconType handler:(nullable SDLRPCNotificationHandler)handler; +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(NSString *)iconValue iconType:(SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler; /** * A handler that will let you know when the button you created is subscribed. * * @warning This will only work if you use SDLManager. */ -@property (nullable, copy, nonatomic) SDLRPCNotificationHandler handler; +@property (nullable, copy, nonatomic) SDLRPCCommandNotificationHandler handler; /** * @abstract A Unique Command ID that identifies the command diff --git a/SmartDeviceLink/SDLAddCommand.m b/SmartDeviceLink/SDLAddCommand.m index 8c491359b..bfec12164 100644 --- a/SmartDeviceLink/SDLAddCommand.m +++ b/SmartDeviceLink/SDLAddCommand.m @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler { +- (instancetype)initWithHandler:(nullable SDLRPCCommandNotificationHandler)handler { self = [self init]; if (!self) { return nil; @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands handler:(nullable SDLRPCNotificationHandler)handler { +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands handler:(nullable SDLRPCCommandNotificationHandler)handler { self = [self init]; if (!self) { return nil; @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCNotificationHandler)handler { +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName handler:(SDLRPCCommandNotificationHandler)handler { self = [self initWithId:commandId vrCommands:vrCommands handler:handler]; if (!self) { return nil; @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(NSString *)iconValue iconType:(SDLImageType)iconType handler:(nullable SDLRPCNotificationHandler)handler { +- (instancetype)initWithId:(UInt32)commandId vrCommands:(nullable NSArray<NSString *> *)vrCommands menuName:(NSString *)menuName parentId:(UInt32)parentId position:(UInt16)position iconValue:(NSString *)iconValue iconType:(SDLImageType)iconType handler:(nullable SDLRPCCommandNotificationHandler)handler { self = [self initWithId:commandId vrCommands:vrCommands menuName:menuName handler:handler]; if (!self) { return nil; diff --git a/SmartDeviceLink/SDLEnum.h b/SmartDeviceLink/SDLEnum.h index 7723ea2fb..f224d8ea3 100644 --- a/SmartDeviceLink/SDLEnum.h +++ b/SmartDeviceLink/SDLEnum.h @@ -5,4 +5,14 @@ #import <Foundation/Foundation.h> #import "SDLMacros.h" -typedef NSString* SDLEnum SDL_SWIFT_ENUM;
\ No newline at end of file +NS_ASSUME_NONNULL_BEGIN + +typedef NSString* SDLEnum SDL_SWIFT_ENUM; + +@interface NSString (SDLEnum) + +- (BOOL)isEqualToEnum:(SDLEnum)enumObj; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLEnum.m b/SmartDeviceLink/SDLEnum.m new file mode 100644 index 000000000..dae9c8f06 --- /dev/null +++ b/SmartDeviceLink/SDLEnum.m @@ -0,0 +1,21 @@ +// +// SDLEnum.m +// SmartDeviceLink-iOS +// +// Created by Muller, Alexander (A.) on 3/13/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +#import "SDLEnum.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation NSString (SDLEnum) + +- (BOOL)isEqualToEnum:(SDLEnum)enumObj { + return [self isEqualToString:enumObj]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLLifecycleConfiguration.m b/SmartDeviceLink/SDLLifecycleConfiguration.m index 0159e1b38..5035c4fa5 100644 --- a/SmartDeviceLink/SDLLifecycleConfiguration.m +++ b/SmartDeviceLink/SDLLifecycleConfiguration.m @@ -75,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Computed Properties - (BOOL)isMedia { - if ([self.appType isEqualToString:SDLAppHMITypeMedia]) { + if ([self.appType isEqualToEnum:SDLAppHMITypeMedia]) { return YES; } diff --git a/SmartDeviceLink/SDLLifecycleManager.h b/SmartDeviceLink/SDLLifecycleManager.h index 11fff2ec6..08b7335d2 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 cbbdac944..c7b8ee4c0 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -103,7 +103,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; _permissionManager = [[SDLPermissionManager alloc] init]; _lockScreenManager = [[SDLLockScreenManager alloc] initWithConfiguration:_configuration.lockScreenConfig notificationDispatcher:_notificationDispatcher presenter:[[SDLLockScreenPresenter alloc] init]]; - if ([configuration.lifecycleConfig.appType isEqualToString:SDLAppHMITypeNavigation]) { + if ([configuration.lifecycleConfig.appType isEqualToEnum:SDLAppHMITypeNavigation]) { _streamManager = [[SDLStreamingMediaManager alloc] initWithEncryption:configuration.lifecycleConfig.streamingEncryption videoEncoderSettings:configuration.lifecycleConfig.videoEncoderSettings]; } @@ -188,7 +188,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; @@ -296,7 +298,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; NSError *startError = nil; // If the resultCode isn't success, we got a warning. Errors were handled in `didEnterStateConnected`. - if (![registerResult isEqualToString:SDLResultSuccess]) { + if (![registerResult isEqualToEnum:SDLResultSuccess]) { startError = [NSError sdl_lifecycle_startedWithWarning:registerResult info:registerInfo]; } @@ -456,14 +458,30 @@ 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; } - if (![oldHMILevel isEqualToString:self.hmiLevel]) { + if (![oldHMILevel isEqualToEnum:self.hmiLevel]) { [self.delegate hmiLevel:oldHMILevel didChangeToLevel:self.hmiLevel]; } + + if (![oldStreamingState isEqualToEnum:self.audioStreamingState] + && [self.delegate respondsToSelector:@selector(audioStreamingState:didChangeToState:)]) { + [self.delegate audioStreamingState:oldStreamingState didChangeToState:self.audioStreamingState]; + } + + if (![oldSystemContext isEqualToEnum:self.systemContext] + && [self.delegate respondsToSelector:@selector(systemContext:didChangeToContext:)]) { + [self.delegate systemContext:oldSystemContext didChangeToContext:self.systemContext]; + } } - (void)remoteHardwareDidUnregister:(SDLRPCNotificationNotification *)notification { diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m index b582e5996..3089f6b41 100644 --- a/SmartDeviceLink/SDLLockScreenManager.m +++ b/SmartDeviceLink/SDLLockScreenManager.m @@ -128,17 +128,17 @@ NS_ASSUME_NONNULL_BEGIN } // Present the VC depending on the lock screen status - if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusRequired]) { + if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusRequired]) { if (!self.presenter.presented && self.canPresent) { [self.presenter present]; } - } else if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOptional]) { + } else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOptional]) { if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent) { [self.presenter present]; } else if (self.presenter.presented) { [self.presenter dismiss]; } - } else if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOff]) { + } else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOff]) { if (self.presenter.presented) { [self.presenter dismiss]; } diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.m b/SmartDeviceLink/SDLLockScreenStatusManager.m index 6d2deb68e..82724eb6f 100644 --- a/SmartDeviceLink/SDLLockScreenStatusManager.m +++ b/SmartDeviceLink/SDLLockScreenStatusManager.m @@ -45,9 +45,9 @@ NS_ASSUME_NONNULL_BEGIN _hmiLevel = hmiLevel; } - if ([hmiLevel isEqualToString:SDLHMILevelFull] || [hmiLevel isEqualToString:SDLHMILevelLimited]) { + if ([hmiLevel isEqualToEnum:SDLHMILevelFull] || [hmiLevel isEqualToEnum:SDLHMILevelLimited]) { self.userSelected = YES; - } else if ([hmiLevel isEqualToString:SDLHMILevelNone]) { + } else if ([hmiLevel isEqualToEnum:SDLHMILevelNone]) { self.userSelected = NO; } } @@ -66,10 +66,10 @@ NS_ASSUME_NONNULL_BEGIN } - (SDLLockScreenStatus)lockScreenStatus { - if (self.hmiLevel == nil || [self.hmiLevel isEqualToString:SDLHMILevelNone]) { + if (self.hmiLevel == nil || [self.hmiLevel isEqualToEnum:SDLHMILevelNone]) { // App is not active on the car return SDLLockScreenStatusOff; - } else if ([self.hmiLevel isEqualToString:SDLHMILevelBackground]) { + } else if ([self.hmiLevel isEqualToEnum:SDLHMILevelBackground]) { // App is in the background on the car if (self.userSelected) { // It was user selected @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN } else { return SDLLockScreenStatusOff; } - } else if ([self.hmiLevel isEqualToString:SDLHMILevelFull] || [self.hmiLevel isEqualToString:SDLHMILevelLimited]) { + } else if ([self.hmiLevel isEqualToEnum:SDLHMILevelFull] || [self.hmiLevel isEqualToEnum:SDLHMILevelLimited]) { // App is in the foreground on the car in some manner if (self.haveDriverDistractionStatus && !self.driverDistracted) { // We have the distraction status, and the driver is not distracted 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/SmartDeviceLink/SDLNotificationConstants.h b/SmartDeviceLink/SDLNotificationConstants.h index 63fad1b25..8b9c748ac 100644 --- a/SmartDeviceLink/SDLNotificationConstants.h +++ b/SmartDeviceLink/SDLNotificationConstants.h @@ -7,6 +7,10 @@ // #import <Foundation/Foundation.h> + +@class SDLOnButtonEvent; +@class SDLOnButtonPress; +@class SDLOnCommand; @class SDLRPCNotification; @class SDLRPCResponse; @class SDLRPCRequest; @@ -27,13 +31,6 @@ typedef NSString *SDLNotificationUserInfoKey; #pragma mark - Blocks /** - * A handler used on certain RPCs, primarily buttons or commands, when an event occurs. - * - * @param notification The RPC Notification that was fired. - */ -typedef void (^SDLRPCNotificationHandler)(__kindof SDLRPCNotification *notification); - -/** * A handler used on all RPC requests which fires when the response is received. * * @param request The request which was sent. @@ -42,6 +39,26 @@ typedef void (^SDLRPCNotificationHandler)(__kindof SDLRPCNotification *notificat */ typedef void (^SDLResponseHandler)(__kindof SDLRPCRequest *__nullable request, __kindof SDLRPCResponse *__nullable response, NSError *__nullable error); + +/** + A handler that may optionally be run when an SDLSubscribeButton or SDLSoftButton has a corresponding notification occur. + + @warning This only works if you send the RPC using SDLManager. + @warning Only one of the two parameters will be set for each block call. + + @param buttonPress An SDLOnButtonPress object that corresponds to this particular button. + @param buttonEvent An SDLOnButtonEvent object that corresponds to this particular button. + */ +typedef void (^SDLRPCButtonNotificationHandler)(SDLOnButtonPress *_Nullable buttonPress, SDLOnButtonEvent *_Nullable buttonEvent); +/** + A handler that may optionally be run when an SDLAddCommand has a corresponding notification occur. + + @warning This only works if you send the RPC using SDLManager. + + @param command An SDLOnCommand object that corresponds to this particular SDLAddCommand. + */ +typedef void (^SDLRPCCommandNotificationHandler)(SDLOnCommand *command); + /** * The key used in all SDL NSNotifications to extract the response or notification from the userinfo dictionary. */ diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m index 569ad7fca..b750e098c 100644 --- a/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink/SDLProxy.m @@ -383,13 +383,13 @@ static float DefaultConnectionTimeout = 45.0; SDLRequestType requestType = systemRequest.requestType; // Handle the various OnSystemRequest types - if ([requestType isEqualToString:SDLRequestTypeProprietary]) { + if ([requestType isEqualToEnum:SDLRequestTypeProprietary]) { [self handleSystemRequestProprietary:systemRequest]; - } else if ([requestType isEqualToString:SDLRequestTypeLockScreenIconURL]) { + } else if ([requestType isEqualToEnum:SDLRequestTypeLockScreenIconURL]) { [self handleSystemRequestLockScreenIconURL:systemRequest]; - } else if ([requestType isEqualToString:SDLRequestTypeHTTP]) { + } else if ([requestType isEqualToEnum:SDLRequestTypeHTTP]) { [self sdl_handleSystemRequestHTTP:systemRequest]; - } else if ([requestType isEqualToString:SDLRequestTypeLaunchApp]) { + } else if ([requestType isEqualToEnum:SDLRequestTypeLaunchApp]) { [self sdl_handleSystemRequestLaunchApp:systemRequest]; } } @@ -567,7 +567,7 @@ static float DefaultConnectionTimeout = 45.0; return nil; } - if (![fileType isEqualToString:SDLFileTypeJSON]) { + if (![fileType isEqualToEnum:SDLFileTypeJSON]) { [SDLDebugTool logInfo:@"OnSystemRequest (notification) failure: file type is not JSON" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return nil; } diff --git a/SmartDeviceLink/SDLRequestHandler.h b/SmartDeviceLink/SDLRequestHandler.h deleted file mode 100644 index 64ee67b48..000000000 --- a/SmartDeviceLink/SDLRequestHandler.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// SDLRequestHandler.h -// SmartDeviceLink-iOS -// -// Created by Joel Fischer on 10/6/15. -// Copyright © 2015 smartdevicelink. All rights reserved. -// - -#import <Foundation/Foundation.h> - -#import "SDLNotificationConstants.h" - -NS_ASSUME_NONNULL_BEGIN - -@protocol SDLRequestHandler <NSObject> - -/** - * The handler that is added to any RPC implementing this protocol. - */ -@property (nullable, copy, nonatomic) SDLRPCNotificationHandler handler; - -/** - * A special init function on any RPC implementing this protocol. - * - * @param handler The handler to be called at specified times, such as events for buttons. - * - * @return An instance of the class implementing this protocol. - */ -- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLResponseDispatcher.h b/SmartDeviceLink/SDLResponseDispatcher.h index f89c5cc59..3e31662e0 100644 --- a/SmartDeviceLink/SDLResponseDispatcher.h +++ b/SmartDeviceLink/SDLResponseDispatcher.h @@ -38,17 +38,17 @@ NS_ASSUME_NONNULL_BEGIN /** * Holds a map of command ids and their corresponding blocks. */ -@property (strong, nonatomic, readonly) NSMapTable<SDLAddCommandCommandId *, SDLRPCNotificationHandler> *commandHandlerMap; +@property (strong, nonatomic, readonly) NSMapTable<SDLAddCommandCommandId *, SDLRPCCommandNotificationHandler> *commandHandlerMap; /** * Holds a map of button names and their corresponding blocks. */ -@property (strong, nonatomic, readonly) NSMapTable<SDLSubscribeButtonName *, SDLRPCNotificationHandler> *buttonHandlerMap; +@property (strong, nonatomic, readonly) NSMapTable<SDLSubscribeButtonName *, SDLRPCButtonNotificationHandler> *buttonHandlerMap; /** * Holds a map of soft button ids and their corresponding blocks. */ -@property (strong, nonatomic, readonly) NSMapTable<SDLSoftButtonId *, SDLRPCNotificationHandler> *customButtonHandlerMap; +@property (strong, nonatomic, readonly) NSMapTable<SDLSoftButtonId *, SDLRPCButtonNotificationHandler> *customButtonHandlerMap; /** * Create a new response dispatcher. diff --git a/SmartDeviceLink/SDLResponseDispatcher.m b/SmartDeviceLink/SDLResponseDispatcher.m index 09cfab31d..4cefaf1b0 100644 --- a/SmartDeviceLink/SDLResponseDispatcher.m +++ b/SmartDeviceLink/SDLResponseDispatcher.m @@ -176,9 +176,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)sdl_runHandlerForCommand:(SDLRPCNotificationNotification *)notification { SDLOnCommand *onCommandNotification = notification.notification; - SDLRPCNotificationHandler handler = nil; + SDLRPCCommandNotificationHandler handler = self.commandHandlerMap[onCommandNotification.cmdID]; - handler = self.commandHandlerMap[onCommandNotification.cmdID]; if (handler) { handler(onCommandNotification); } @@ -189,26 +188,30 @@ NS_ASSUME_NONNULL_BEGIN - (void)sdl_runHandlerForButton:(SDLRPCNotificationNotification *)notification { __kindof SDLRPCNotification *rpcNotification = notification.notification; - SDLRPCNotificationHandler handler = nil; + SDLRPCButtonNotificationHandler handler = nil; SDLButtonName name = nil; NSNumber *customID = nil; - if ([rpcNotification isKindOfClass:[SDLOnButtonEvent class]]) { + if ([rpcNotification isMemberOfClass:[SDLOnButtonEvent class]]) { name = ((SDLOnButtonEvent *)rpcNotification).buttonName; customID = ((SDLOnButtonEvent *)rpcNotification).customButtonID; - } else if ([rpcNotification isKindOfClass:[SDLOnButtonPress class]]) { + } else if ([rpcNotification isMemberOfClass:[SDLOnButtonPress class]]) { name = ((SDLOnButtonPress *)rpcNotification).buttonName; customID = ((SDLOnButtonPress *)rpcNotification).customButtonID; } - if ([name isEqualToString:SDLButtonNameCustomButton]) { + if ([name isEqualToEnum:SDLButtonNameCustomButton]) { handler = self.customButtonHandlerMap[customID]; } else { handler = self.buttonHandlerMap[name]; } if (handler) { - handler(rpcNotification); + if ([rpcNotification isMemberOfClass:[SDLOnButtonEvent class]]) { + handler(nil, rpcNotification); + } else if ([rpcNotification isMemberOfClass:[SDLOnButtonPress class]]) { + handler(rpcNotification, nil); + } } } diff --git a/SmartDeviceLink/SDLSoftButton.h b/SmartDeviceLink/SDLSoftButton.h index a5cc9d7a4..398bf8053 100644 --- a/SmartDeviceLink/SDLSoftButton.h +++ b/SmartDeviceLink/SDLSoftButton.h @@ -4,7 +4,6 @@ #import "SDLRPCMessage.h" #import "SDLNotificationConstants.h" -#import "SDLRequestHandler.h" #import "SDLSoftButtonType.h" #import "SDLSystemAction.h" @@ -12,13 +11,13 @@ NS_ASSUME_NONNULL_BEGIN -@interface SDLSoftButton : SDLRPCStruct <SDLRequestHandler> +@interface SDLSoftButton : SDLRPCStruct -- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler; +- (instancetype)initWithHandler:(nullable SDLRPCButtonNotificationHandler)handler; -- (instancetype)initWithType:(SDLSoftButtonType)type text:(nullable NSString *)text image:(nullable SDLImage *)image highlighted:(BOOL)highlighted buttonId:(UInt16)buttonId systemAction:(nullable SDLSystemAction)systemAction handler:(nullable SDLRPCNotificationHandler)handler; +- (instancetype)initWithType:(SDLSoftButtonType)type text:(nullable NSString *)text image:(nullable SDLImage *)image highlighted:(BOOL)highlighted buttonId:(UInt16)buttonId systemAction:(nullable SDLSystemAction)systemAction handler:(nullable SDLRPCButtonNotificationHandler)handler; -@property (copy, nonatomic) SDLRPCNotificationHandler handler; +@property (copy, nonatomic) SDLRPCButtonNotificationHandler handler; @property (strong, nonatomic) SDLSoftButtonType type; @property (strong, nonatomic, nullable) NSString *text; diff --git a/SmartDeviceLink/SDLSoftButton.m b/SmartDeviceLink/SDLSoftButton.m index c33880c06..a50bb4bcd 100644 --- a/SmartDeviceLink/SDLSoftButton.m +++ b/SmartDeviceLink/SDLSoftButton.m @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN @implementation SDLSoftButton -- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler { +- (instancetype)initWithHandler:(nullable SDLRPCButtonNotificationHandler)handler { self = [self init]; if (!self) { return nil; @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithType:(SDLSoftButtonType)type text:(nullable NSString *)text image:(nullable SDLImage *)image highlighted:(BOOL)highlighted buttonId:(UInt16)buttonId systemAction:(nullable SDLSystemAction)systemAction handler:(nullable SDLRPCNotificationHandler)handler { +- (instancetype)initWithType:(SDLSoftButtonType)type text:(nullable NSString *)text image:(nullable SDLImage *)image highlighted:(BOOL)highlighted buttonId:(UInt16)buttonId systemAction:(nullable SDLSystemAction)systemAction handler:(nullable SDLRPCButtonNotificationHandler)handler { self = [self initWithHandler:handler]; if (!self) { return nil; diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index 70a9a1e10..19a232001 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -518,7 +518,7 @@ SDLAudioStreamState *const SDLAudioStreamStateShuttingDown = @"AudioStreamShutti } - (BOOL)isHmiStateVideoStreamCapable { - return [self.hmiLevel isEqualToString:SDLHMILevelLimited] || [self.hmiLevel isEqualToString:SDLHMILevelFull]; + return [self.hmiLevel isEqualToEnum:SDLHMILevelLimited] || [self.hmiLevel isEqualToEnum:SDLHMILevelFull]; } @end diff --git a/SmartDeviceLink/SDLSubscribeButton.h b/SmartDeviceLink/SDLSubscribeButton.h index 6b3465636..11f25a8ea 100644 --- a/SmartDeviceLink/SDLSubscribeButton.h +++ b/SmartDeviceLink/SDLSubscribeButton.h @@ -1,12 +1,12 @@ // SDLSubscribeButton.h // - +#import "SDLButtonName.h" +#import "SDLNotificationConstants.h" #import "SDLRPCRequest.h" -#import "SDLButtonName.h" -#import "SDLRequestHandler.h" +NS_ASSUME_NONNULL_BEGIN /** * Establishes a subscription to button notifications for HMI buttons. Buttons @@ -58,10 +58,7 @@ * Since SmartDeviceLink 1.0<br/> * See SDLUnsubscribeButton */ - -NS_ASSUME_NONNULL_BEGIN - -@interface SDLSubscribeButton : SDLRPCRequest <SDLRequestHandler> +@interface SDLSubscribeButton : SDLRPCRequest /** * Construct a SDLSubscribeButton with a handler callback when an event occurs. @@ -70,16 +67,16 @@ NS_ASSUME_NONNULL_BEGIN * * @return An SDLSubscribeButton object */ -- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler; +- (instancetype)initWithHandler:(nullable SDLRPCButtonNotificationHandler)handler; -- (instancetype)initWithButtonName:(SDLButtonName)buttonName handler:(nullable SDLRPCNotificationHandler)handler; +- (instancetype)initWithButtonName:(SDLButtonName)buttonName handler:(nullable SDLRPCButtonNotificationHandler)handler; /** * A handler that will let you know when the button you subscribed to is selected. * * @warning This will only work if you use SDLManager. */ -@property (copy, nonatomic) SDLRPCNotificationHandler handler; +@property (copy, nonatomic) SDLRPCButtonNotificationHandler handler; /** * @abstract The name of the button to subscribe to diff --git a/SmartDeviceLink/SDLSubscribeButton.m b/SmartDeviceLink/SDLSubscribeButton.m index 07a2fe65c..1a94caa37 100644 --- a/SmartDeviceLink/SDLSubscribeButton.m +++ b/SmartDeviceLink/SDLSubscribeButton.m @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler { +- (instancetype)initWithHandler:(nullable SDLRPCButtonNotificationHandler)handler { self = [self init]; if (!self) { return nil; @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (instancetype)initWithButtonName:(SDLButtonName)buttonName handler:(nullable SDLRPCNotificationHandler)handler { +- (instancetype)initWithButtonName:(SDLButtonName)buttonName handler:(nullable SDLRPCButtonNotificationHandler)handler { self = [self init]; if (!self) { return nil; diff --git a/SmartDeviceLink/SDLTouchManager.m b/SmartDeviceLink/SDLTouchManager.m index 4e17e134f..abb5a1fbd 100644 --- a/SmartDeviceLink/SDLTouchManager.m +++ b/SmartDeviceLink/SDLTouchManager.m @@ -129,11 +129,11 @@ static NSUInteger const MaximumNumberOfTouches = 2; return; } - if ([onTouchEvent.type isEqualToString:SDLTouchTypeBegin]) { + if ([onTouchEvent.type isEqualToEnum:SDLTouchTypeBegin]) { [self sdl_handleTouchBegan:touch]; - } else if ([onTouchEvent.type isEqualToString:SDLTouchTypeMove]) { + } else if ([onTouchEvent.type isEqualToEnum:SDLTouchTypeMove]) { [self sdl_handleTouchMoved:touch]; - } else if ([onTouchEvent.type isEqualToString:SDLTouchTypeEnd]) { + } else if ([onTouchEvent.type isEqualToEnum:SDLTouchTypeEnd]) { [self sdl_handleTouchEnded:touch]; } } diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h index a4799bb7a..b7447219c 100644 --- a/SmartDeviceLink/SmartDeviceLink.h +++ b/SmartDeviceLink/SmartDeviceLink.h @@ -313,7 +313,6 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[]; #import "NSNumber+NumberType.h" #import "SDLErrorConstants.h" #import "SDLNotificationConstants.h" -#import "SDLRequestHandler.h" // Notifications #import "SDLRPCNotificationNotification.h" diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m index 70d65cce9..7d02980a0 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m @@ -29,10 +29,10 @@ describe(@"a lifecycle configuration", ^{ expect(@(testConfig.tcpDebugMode)).to(beFalsy()); expect(testConfig.tcpDebugIPAddress).to(match(@"192.168.0.1")); expect(@(testConfig.tcpDebugPort)).to(equal(@12345)); - expect(@([testConfig.appType isEqualToString:SDLAppHMITypeDefault])).to(equal(@YES)); + expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeDefault])).to(equal(@YES)); expect(@(testConfig.isMedia)).to(beFalsy()); - expect(@([testConfig.language isEqualToString:SDLLanguageEnUs])).to(equal(@YES)); - expect(@([[testConfig.languagesSupported firstObject] isEqualToString:SDLLanguageEnUs])).to(equal(@YES)); + expect(@([testConfig.language isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); + expect(@([[testConfig.languagesSupported firstObject] isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); expect(testConfig.shortAppName).to(beNil()); expect(testConfig.ttsName).to(beNil()); expect(testConfig.voiceRecognitionCommandNames).to(beNil()); @@ -82,9 +82,9 @@ describe(@"a lifecycle configuration", ^{ expect(@(testConfig.tcpDebugMode)).to(beFalsy()); expect(testConfig.tcpDebugIPAddress).to(match(@"192.168.0.1")); expect(@(testConfig.tcpDebugPort)).to(equal(@12345)); - expect(@([testConfig.appType isEqualToString:SDLAppHMITypeMedia])).to(equal(@YES)); + expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeMedia])).to(equal(@YES)); expect(@(testConfig.isMedia)).to(beTruthy()); - expect(@([testConfig.language isEqualToString:SDLLanguageArSa])).to(equal(@YES)); + expect(@([testConfig.language isEqualToEnum:SDLLanguageArSa])).to(equal(@YES)); expect(testConfig.languagesSupported).to(haveCount(@3)); expect(testConfig.shortAppName).to(match(someShortAppName)); expect(testConfig.ttsName).to(contain(someTTSChunk)); @@ -119,9 +119,9 @@ describe(@"a lifecycle configuration", ^{ expect(@(testConfig.tcpDebugMode)).to(beTruthy()); expect(testConfig.tcpDebugIPAddress).to(match(someIPAddress)); expect(@(testConfig.tcpDebugPort)).to(equal(@(somePort))); - expect(@([testConfig.appType isEqualToString:SDLAppHMITypeDefault])).to(equal(@YES)); - expect(@([testConfig.language isEqualToString:SDLLanguageEnUs])).to(equal(@YES)); - expect(@([[testConfig.languagesSupported firstObject] isEqualToString:SDLLanguageEnUs])).to(equal(@YES)); + expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeDefault])).to(equal(@YES)); + expect(@([testConfig.language isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); + expect(@([[testConfig.languagesSupported firstObject] isEqualToEnum:SDLLanguageEnUs])).to(equal(@YES)); expect(testConfig.shortAppName).to(beNil()); expect(testConfig.ttsName).to(beNil()); expect(testConfig.voiceRecognitionCommandNames).to(beNil()); @@ -169,9 +169,9 @@ describe(@"a lifecycle configuration", ^{ expect(@(testConfig.tcpDebugMode)).to(beTruthy()); expect(testConfig.tcpDebugIPAddress).to(match(someIPAddress)); expect(@(testConfig.tcpDebugPort)).to(equal(@(somePort))); - expect(@([testConfig.appType isEqualToString:SDLAppHMITypeMedia])).to(equal(@YES)); + expect(@([testConfig.appType isEqualToEnum:SDLAppHMITypeMedia])).to(equal(@YES)); expect(@(testConfig.isMedia)).to(beTruthy()); - expect(@([testConfig.language isEqualToString:SDLLanguageArSa])).to(equal(@YES)); + expect(@([testConfig.language isEqualToEnum:SDLLanguageArSa])).to(equal(@YES)); expect(testConfig.languagesSupported).to(haveCount(@3)); expect(testConfig.shortAppName).to(match(someShortAppName)); expect(testConfig.ttsName).to(contain(someTTSChunk)); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m index eee8f74e6..d1863df19 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m @@ -377,7 +377,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]); + }); + }); + }); + }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m index ceb27c7d7..bcbc95631 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m @@ -126,7 +126,7 @@ describe(@"a response dispatcher", ^{ beforeEach(^{ numTimesHandlerCalled = 0; - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; testShow.softButtons = [@[testSoftButton1] mutableCopy]; @@ -199,7 +199,7 @@ describe(@"a response dispatcher", ^{ context(@"with a malformed soft button", ^{ beforeEach(^{ - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) {}]; + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:nil]; }); it(@"should throw an exception if there's no button id", ^{ @@ -355,7 +355,7 @@ describe(@"a response dispatcher", ^{ testSubscribeCorrelationId = @42; numTimesHandlerCalled = 0; - testSubscribeButton = [[SDLSubscribeButton alloc] initWithButtonName:testButtonName handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSubscribeButton = [[SDLSubscribeButton alloc] initWithButtonName:testButtonName handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; testSubscribeButton.correlationID = testSubscribeCorrelationId; @@ -485,7 +485,7 @@ describe(@"a response dispatcher", ^{ beforeEach(^{ numTimesHandlerCalled = 0; - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; @@ -558,7 +558,7 @@ describe(@"a response dispatcher", ^{ context(@"with a malformed soft button", ^{ beforeEach(^{ - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) {}]; + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:nil]; }); it(@"should throw an exception if there's no button id", ^{ @@ -596,7 +596,7 @@ describe(@"a response dispatcher", ^{ beforeEach(^{ numTimesHandlerCalled = 0; - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; @@ -669,7 +669,7 @@ describe(@"a response dispatcher", ^{ context(@"with a malformed soft button", ^{ beforeEach(^{ - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) {}]; + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:nil]; }); it(@"should throw an exception if there's no button id", ^{ diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m index 5139da20e..517f454f3 100644 --- a/SmartDeviceLink_Example/Classes/ProxyManager.m +++ b/SmartDeviceLink_Example/Classes/ProxyManager.m @@ -103,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN [weakSelf setupPermissionsCallbacks]; - if ([weakSelf.sdlManager.hmiLevel isEqualToString:SDLHMILevelFull]) { + if ([weakSelf.sdlManager.hmiLevel isEqualToEnum:SDLHMILevelFull]) { [weakSelf showInitialData]; } }]; @@ -115,7 +115,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)showInitialData { - if ((self.initialShowState != SDLHMIInitialShowStateDataAvailable) || ![self.sdlManager.hmiLevel isEqualToString:SDLHMILevelFull]) { + if ((self.initialShowState != SDLHMIInitialShowStateDataAvailable) || ![self.sdlManager.hmiLevel isEqualToEnum:SDLHMILevelFull]) { return; } @@ -272,12 +272,14 @@ NS_ASSUME_NONNULL_BEGIN } + (SDLSoftButton *)pointingSoftButtonWithManager:(SDLManager *)manager { - SDLSoftButton* softButton = [[SDLSoftButton alloc] initWithHandler:^(__kindof SDLRPCNotification *notification) { - if ([notification isKindOfClass:[SDLOnButtonPress class]]) { - SDLAlert* alert = [[SDLAlert alloc] init]; - alert.alertText1 = @"You pushed the button!"; - [manager sendRequest:alert]; + SDLSoftButton* softButton = [[SDLSoftButton alloc] initWithHandler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { + if (buttonPressNotification == nil) { + return; } + + SDLAlert* alert = [[SDLAlert alloc] init]; + alert.alertText1 = @"You pushed the button!"; + [manager sendRequest:alert]; }]; softButton.text = @"Press"; softButton.softButtonID = @100; @@ -364,7 +366,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)hmiLevel:(SDLHMILevel)oldLevel didChangeToLevel:(SDLHMILevel)newLevel { - if (![newLevel isEqualToString:SDLHMILevelNone] && (self.firstTimeState == SDLHMIFirstStateNone)) { + if (![newLevel isEqualToEnum:SDLHMILevelNone] && (self.firstTimeState == SDLHMIFirstStateNone)) { // This is our first time in a non-NONE state self.firstTimeState = SDLHMIFirstStateNonNone; @@ -372,12 +374,12 @@ NS_ASSUME_NONNULL_BEGIN [self prepareRemoteSystem]; } - if ([newLevel isEqualToString:SDLHMILevelFull] && (self.firstTimeState != SDLHMIFirstStateFull)) { + if ([newLevel isEqualToEnum:SDLHMILevelFull] && (self.firstTimeState != SDLHMIFirstStateFull)) { // This is our first time in a FULL state self.firstTimeState = SDLHMIFirstStateFull; } - if ([newLevel isEqualToString:SDLHMILevelFull]) { + if ([newLevel isEqualToEnum:SDLHMILevelFull]) { // We're always going to try to show the initial state, because if we've already shown it, it won't be shown, and we need to guard against some possible weird states [self showInitialData]; } |