summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2019-03-05 09:49:51 -0500
committerNicoleYarroch <nicole@livio.io>2019-03-05 09:49:51 -0500
commitbfcbbdb4b4d1e60a981ef4dd424bd81042b7edff (patch)
treea88a0986cc4b1c0556c13528ccd4cc0d3adfabe5
parentb6535b3d05587017b27c01f43e6d64cc0ce54d18 (diff)
parenta9cb8d52953ff841efb5210542b6992e6904987c (diff)
downloadsdl_ios-bfcbbdb4b4d1e60a981ef4dd424bd81042b7edff.tar.gz
Merge branch 'develop' into feature/issue_1166_cloud_app_transport
# Conflicts: # SmartDeviceLink/SDLProtocol.m # SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
-rw-r--r--SmartDeviceLink-iOS.podspec1
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj32
-rw-r--r--SmartDeviceLink.podspec1
-rw-r--r--SmartDeviceLink/SDLGlobals.h14
-rw-r--r--SmartDeviceLink/SDLGlobals.m32
-rw-r--r--SmartDeviceLink/SDLLifecycleConfiguration.h11
-rw-r--r--SmartDeviceLink/SDLLifecycleConfiguration.m3
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m20
-rw-r--r--SmartDeviceLink/SDLLogFileModuleMap.m5
-rw-r--r--SmartDeviceLink/SDLProtocol.m31
-rw-r--r--SmartDeviceLink/SDLProxy.m11
-rw-r--r--SmartDeviceLink/SDLStateMachine.m4
-rw-r--r--SmartDeviceLink/SDLVersion.h37
-rw-r--r--SmartDeviceLink/SDLVersion.m135
-rw-r--r--SmartDeviceLink/SmartDeviceLink.h1
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m17
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m29
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLStateMachineSpec.m1
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m3
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLVersionSpec.m104
-rw-r--r--SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m6
-rw-r--r--SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m3
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m45
23 files changed, 448 insertions, 98 deletions
diff --git a/SmartDeviceLink-iOS.podspec b/SmartDeviceLink-iOS.podspec
index cc568ee06..7a92fcfb1 100644
--- a/SmartDeviceLink-iOS.podspec
+++ b/SmartDeviceLink-iOS.podspec
@@ -369,6 +369,7 @@ ss.public_header_files = [
'SmartDeviceLink/SDLVehicleDataType.h',
'SmartDeviceLink/SDLVentilationMode.h',
'SmartDeviceLink/SDLVehicleType.h',
+'SmartDeviceLink/SDLVersion.h',
'SmartDeviceLink/SDLVideoStreamingCapability.h',
'SmartDeviceLink/SDLVideoStreamingCodec.h',
'SmartDeviceLink/SDLVideoStreamingFormat.h',
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index c39332552..5d78108f3 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -1175,6 +1175,7 @@
5DBF0D601F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DBF0D5F1F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m */; };
5DC09EDA1F2F7FEC00F4AB1D /* SDLControlFramePayloadNakSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DC09ED91F2F7FEC00F4AB1D /* SDLControlFramePayloadNakSpec.m */; };
5DC978261B7A38640012C2F1 /* SDLGlobalsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DC978251B7A38640012C2F1 /* SDLGlobalsSpec.m */; };
+ 5DCC458D221C9F6600036C2F /* SDLVersionSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DCC458C221C9F6600036C2F /* SDLVersionSpec.m */; };
5DCD7AE01FCCA8D200A0FC7F /* SDLCarWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DCD7ADC1FCCA8D100A0FC7F /* SDLCarWindow.h */; };
5DCD7AE11FCCA8D200A0FC7F /* SDLCarWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DCD7ADD1FCCA8D200A0FC7F /* SDLCarWindow.m */; };
5DCD7AF31FCCA8E400A0FC7F /* SDLScreenshotViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DCD7AE61FCCA8E400A0FC7F /* SDLScreenshotViewController.h */; };
@@ -1185,6 +1186,8 @@
5DCF76FA1ACDD7CD00BB647B /* SDLSendLocationResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DCF76F81ACDD7CD00BB647B /* SDLSendLocationResponse.m */; };
5DCF76FC1ACDDB4200BB647B /* SDLSendLocationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DCF76FB1ACDDB4200BB647B /* SDLSendLocationSpec.m */; };
5DCF76FE1ACDDB5A00BB647B /* SDLSendLocationResponseSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DCF76FD1ACDDB5A00BB647B /* SDLSendLocationResponseSpec.m */; };
+ 5DD60D98221C5D7D00A82A4F /* SDLVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD60D96221C5D7D00A82A4F /* SDLVersion.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 5DD60D99221C5D7D00A82A4F /* SDLVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DD60D97221C5D7D00A82A4F /* SDLVersion.m */; };
5DD67CB01E65DDB7009CD394 /* SDLLogTargetAppleSystemLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD67CAE1E65DDB7009CD394 /* SDLLogTargetAppleSystemLog.h */; settings = {ATTRIBUTES = (Public, ); }; };
5DD67CB11E65DDB7009CD394 /* SDLLogTargetAppleSystemLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DD67CAF1E65DDB7009CD394 /* SDLLogTargetAppleSystemLog.m */; };
5DD67CB81E661C4A009CD394 /* SDLLogTargetFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DD67CB61E661C4A009CD394 /* SDLLogTargetFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1910,7 +1913,7 @@
5D1665A41CF5D5DA00CC4CA1 /* DEPENDENCIES.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = DEPENDENCIES.md; sourceTree = SOURCE_ROOT; };
5D1665A51CF5D5DA00CC4CA1 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = SOURCE_ROOT; };
5D1665A61CF5D5DA00CC4CA1 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
- 5D1665A71CF5D5DA00CC4CA1 /* SmartDeviceLink-iOS.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = "SmartDeviceLink-iOS.podspec"; sourceTree = SOURCE_ROOT; };
+ 5D1665A71CF5D5DA00CC4CA1 /* SmartDeviceLink-iOS.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = "SmartDeviceLink-iOS.podspec"; sourceTree = SOURCE_ROOT; };
5D1665C21CF8CA2700CC4CA1 /* SDLListFilesOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLListFilesOperation.h; sourceTree = "<group>"; };
5D1665C31CF8CA2700CC4CA1 /* SDLListFilesOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLListFilesOperation.m; sourceTree = "<group>"; };
5D1665C61CF8CA3D00CC4CA1 /* SDLPermissionFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLPermissionFilter.h; sourceTree = "<group>"; };
@@ -2650,10 +2653,6 @@
5DADA7771F4E059E0084D17D /* SDLRectangleSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLRectangleSpec.m; sourceTree = "<group>"; };
5DAE06721BDEC6C000F9B498 /* SDLFileSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLFileSpec.m; path = DevAPISpecs/SDLFileSpec.m; sourceTree = "<group>"; };
5DAE06741BDEC6D600F9B498 /* SDLArtworkSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLArtworkSpec.m; path = DevAPISpecs/SDLArtworkSpec.m; sourceTree = "<group>"; };
- 5DB16142202115FC00F310DF /* SDLAsynchronousRPCRequestOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLAsynchronousRPCRequestOperation.h; sourceTree = "<group>"; };
- 5DB16143202115FC00F310DF /* SDLAsynchronousRPCRequestOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLAsynchronousRPCRequestOperation.m; sourceTree = "<group>"; };
- 5DB1616A2022276A00F310DF /* SDLSequentialRPCRequestOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLSequentialRPCRequestOperation.h; sourceTree = "<group>"; };
- 5DB1616B2022276A00F310DF /* SDLSequentialRPCRequestOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLSequentialRPCRequestOperation.m; sourceTree = "<group>"; };
5DB1BCD01D243A8E002FFC37 /* SDLDeleteFileOperationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLDeleteFileOperationSpec.m; path = DevAPISpecs/SDLDeleteFileOperationSpec.m; sourceTree = "<group>"; };
5DB1BCD11D243A8E002FFC37 /* SDLListFilesOperationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLListFilesOperationSpec.m; path = DevAPISpecs/SDLListFilesOperationSpec.m; sourceTree = "<group>"; };
5DB1BCD21D243A8E002FFC37 /* SDLUploadFileOperationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLUploadFileOperationSpec.m; path = DevAPISpecs/SDLUploadFileOperationSpec.m; sourceTree = "<group>"; };
@@ -2701,7 +2700,8 @@
5DBF0D5F1F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFrameVideoStartServiceAckSpec.m; path = ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m; sourceTree = "<group>"; };
5DC09ED91F2F7FEC00F4AB1D /* SDLControlFramePayloadNakSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFramePayloadNakSpec.m; path = ControlFramePayloadSpecs/SDLControlFramePayloadNakSpec.m; sourceTree = "<group>"; };
5DC978251B7A38640012C2F1 /* SDLGlobalsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLGlobalsSpec.m; path = UtilitiesSpecs/SDLGlobalsSpec.m; sourceTree = "<group>"; };
- 5DCA93821EE0844D0015768E /* SmartDeviceLink.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SmartDeviceLink.podspec; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
+ 5DCA93821EE0844D0015768E /* SmartDeviceLink.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = SmartDeviceLink.podspec; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
+ 5DCC458C221C9F6600036C2F /* SDLVersionSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDLVersionSpec.m; path = DevAPISpecs/SDLVersionSpec.m; sourceTree = "<group>"; };
5DCD7ADC1FCCA8D100A0FC7F /* SDLCarWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLCarWindow.h; sourceTree = "<group>"; };
5DCD7ADD1FCCA8D200A0FC7F /* SDLCarWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLCarWindow.m; sourceTree = "<group>"; };
5DCD7AE61FCCA8E400A0FC7F /* SDLScreenshotViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLScreenshotViewController.h; sourceTree = "<group>"; };
@@ -2712,6 +2712,8 @@
5DCF76F81ACDD7CD00BB647B /* SDLSendLocationResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLSendLocationResponse.m; sourceTree = "<group>"; };
5DCF76FB1ACDDB4200BB647B /* SDLSendLocationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLSendLocationSpec.m; sourceTree = "<group>"; };
5DCF76FD1ACDDB5A00BB647B /* SDLSendLocationResponseSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLSendLocationResponseSpec.m; sourceTree = "<group>"; };
+ 5DD60D96221C5D7D00A82A4F /* SDLVersion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLVersion.h; sourceTree = "<group>"; };
+ 5DD60D97221C5D7D00A82A4F /* SDLVersion.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLVersion.m; sourceTree = "<group>"; };
5DD67CAE1E65DDB7009CD394 /* SDLLogTargetAppleSystemLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLLogTargetAppleSystemLog.h; sourceTree = "<group>"; };
5DD67CAF1E65DDB7009CD394 /* SDLLogTargetAppleSystemLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLLogTargetAppleSystemLog.m; sourceTree = "<group>"; };
5DD67CB61E661C4A009CD394 /* SDLLogTargetFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLLogTargetFile.h; sourceTree = "<group>"; };
@@ -3420,17 +3422,6 @@
name = Connection;
sourceTree = "<group>";
};
- 5D07C02A2044963400D1ECDC /* Recovered References */ = {
- isa = PBXGroup;
- children = (
- 5DB1616B2022276A00F310DF /* SDLSequentialRPCRequestOperation.m */,
- 5DB16143202115FC00F310DF /* SDLAsynchronousRPCRequestOperation.m */,
- 5DB16142202115FC00F310DF /* SDLAsynchronousRPCRequestOperation.h */,
- 5DB1616A2022276A00F310DF /* SDLSequentialRPCRequestOperation.h */,
- );
- name = "Recovered References";
- sourceTree = "<group>";
- };
5D07C0342044AD1900D1ECDC /* Request Operations */ = {
isa = PBXGroup;
children = (
@@ -3622,7 +3613,6 @@
5D61FA2C1A84237100846EE7 /* SmartDeviceLinkTests */,
5D4346621E6F38E600B639C6 /* SmartDeviceLinkSwift */,
5D4019B01A76EC350006B0C2 /* Products */,
- 5D07C02A2044963400D1ECDC /* Recovered References */,
);
sourceTree = "<group>";
};
@@ -4733,6 +4723,7 @@
children = (
5DB1BCE41D245629002FFC37 /* State Machine */,
5D6EB4C71BF28D6800693731 /* Categories */,
+ 5DCC458C221C9F6600036C2F /* SDLVersionSpec.m */,
);
name = Utilities;
sourceTree = "<group>";
@@ -4967,6 +4958,8 @@
5DA3F35C1BC4484B0026F2D0 /* Notifications */,
5DA3F3571BC448160026F2D0 /* Categories */,
5D6008871BE3ED470094A505 /* State Machine */,
+ 5DD60D96221C5D7D00A82A4F /* SDLVersion.h */,
+ 5DD60D97221C5D7D00A82A4F /* SDLVersion.m */,
);
name = Utilities;
sourceTree = "<group>";
@@ -6028,6 +6021,7 @@
5D61FC721A84238C00846EE7 /* SDLDeleteCommand.h in Headers */,
8881AFB82225E5EE00EA870B /* SDLGetCloudAppProperties.h in Headers */,
5D61FC821A84238C00846EE7 /* SDLDeviceInfo.h in Headers */,
+ 5DD60D98221C5D7D00A82A4F /* SDLVersion.h in Headers */,
5D61FCA91A84238C00846EE7 /* SDLFileType.h in Headers */,
8877F5EE1F34A72200DC128A /* SDLSendHapticDataResponse.h in Headers */,
DA8966F21E56973700413EAB /* SDLStreamingMediaManagerConstants.h in Headers */,
@@ -6795,6 +6789,7 @@
5D61FDD61A84238C00846EE7 /* SDLTouchEventCapabilities.m in Sources */,
5DA49CE61F1EA83300E65FC5 /* SDLControlFramePayloadRPCStartService.m in Sources */,
5DA102A51D4122C700C15826 /* NSMutableDictionary+SafeRemove.m in Sources */,
+ 5DD60D99221C5D7D00A82A4F /* SDLVersion.m in Sources */,
5D61FCF11A84238C00846EE7 /* SDLLockScreenStatusManager.m in Sources */,
5D61FDAC1A84238C00846EE7 /* SDLStartTime.m in Sources */,
5D61FDA01A84238C00846EE7 /* SDLSoftButton.m in Sources */,
@@ -7025,6 +7020,7 @@
162E834F1A9BDE8B00906325 /* SDLDeleteCommandResponseSpec.m in Sources */,
88B848C91F462E3600DED768 /* TestFileProgressResponse.m in Sources */,
162E83231A9BDE8B00906325 /* SDLAddSubMenuSpec.m in Sources */,
+ 5DCC458D221C9F6600036C2F /* SDLVersionSpec.m in Sources */,
DA4353E91D2721680099B8C4 /* DispatchTimerSpec.m in Sources */,
1EE8C45D1F387D1C00FDC2CF /* SDLGetInteriorVehicleDataResponseSpec.m in Sources */,
162E82F21A9BDE8B00906325 /* SDLPredefinedLayoutSpec.m in Sources */,
diff --git a/SmartDeviceLink.podspec b/SmartDeviceLink.podspec
index 0ce0c73da..48a7ee29a 100644
--- a/SmartDeviceLink.podspec
+++ b/SmartDeviceLink.podspec
@@ -369,6 +369,7 @@ sdefault.public_header_files = [
'SmartDeviceLink/SDLVehicleDataType.h',
'SmartDeviceLink/SDLVentilationMode.h',
'SmartDeviceLink/SDLVehicleType.h',
+'SmartDeviceLink/SDLVersion.h',
'SmartDeviceLink/SDLVideoStreamingCapability.h',
'SmartDeviceLink/SDLVideoStreamingCodec.h',
'SmartDeviceLink/SDLVideoStreamingFormat.h',
diff --git a/SmartDeviceLink/SDLGlobals.h b/SmartDeviceLink/SDLGlobals.h
index 84407f11d..99ed61bf6 100644
--- a/SmartDeviceLink/SDLGlobals.h
+++ b/SmartDeviceLink/SDLGlobals.h
@@ -8,8 +8,11 @@
#import <Foundation/Foundation.h>
-#import "SDLProtocolHeader.h"
-#import "SDLSyncMsgVersion.h"
+#import "SDLProtocolConstants.h"
+
+@class SDLProtocolHeader;
+@class SDLSyncMsgVersion;
+@class SDLVersion;
NS_ASSUME_NONNULL_BEGIN
@@ -26,10 +29,9 @@ extern NSUInteger const SDLV3MTUSize;
@interface SDLGlobals : NSObject
-@property (copy, nonatomic, readonly) NSString *protocolVersion;
-@property (assign, nonatomic, readonly) NSInteger majorProtocolVersion;
-@property (strong, nonatomic) SDLSyncMsgVersion *rpcVersion;
-@property (copy, nonatomic) NSString *maxHeadUnitVersion;
+@property (copy, nonatomic, readonly) SDLVersion *protocolVersion;
+@property (strong, nonatomic) SDLVersion *rpcVersion;
+@property (copy, nonatomic) SDLVersion *maxHeadUnitProtocolVersion;
+ (instancetype)sharedGlobals;
diff --git a/SmartDeviceLink/SDLGlobals.m b/SmartDeviceLink/SDLGlobals.m
index dfc96f165..29c214f1e 100644
--- a/SmartDeviceLink/SDLGlobals.m
+++ b/SmartDeviceLink/SDLGlobals.m
@@ -9,6 +9,9 @@
#import "SDLGlobals.h"
#import "SDLLogMacros.h"
+#import "SDLProtocolHeader.h"
+#import "SDLSyncMsgVersion.h"
+#import "SDLVersion.h"
NS_ASSUME_NONNULL_BEGIN
@@ -28,7 +31,7 @@ typedef NSNumber *MTUBox;
@interface SDLGlobals ()
@property (strong, nonatomic) NSMutableDictionary<ServiceTypeBox, MTUBox> *dynamicMTUDict;
-@property (copy, nonatomic, readwrite) NSString *protocolVersion;
+@property (copy, nonatomic, readwrite) SDLVersion *protocolVersion;
@end
@@ -51,9 +54,9 @@ typedef NSNumber *MTUBox;
return nil;
}
- _protocolVersion = @"1.0.0";
- _maxHeadUnitVersion = @"0.0.0";
- _rpcVersion = [[SDLSyncMsgVersion alloc] initWithMajorVersion:1 minorVersion:0 patchVersion:0];
+ _protocolVersion = [[SDLVersion alloc] initWithString:@"1.0.0"];
+ _maxHeadUnitProtocolVersion = [[SDLVersion alloc] initWithString:@"0.0.0"];
+ _rpcVersion = [[SDLVersion alloc] initWithString:@"1.0.0"];
_dynamicMTUDict = [NSMutableDictionary dictionary];
return self;
@@ -62,14 +65,11 @@ typedef NSNumber *MTUBox;
#pragma mark - Custom Getters / Setters
-- (void)setMaxHeadUnitVersion:(NSString *)maxHeadUnitVersion {
- self.protocolVersion = [self sdl_isVersion:maxHeadUnitVersion greaterThanVersion:SDLMaxProxyProtocolVersion] ? SDLMaxProxyProtocolVersion : maxHeadUnitVersion;
+- (void)setMaxHeadUnitProtocolVersion:(SDLVersion *)maxHeadUnitVersion {
+ SDLVersion *maxProxyProtocolVersion = [SDLVersion versionWithString:SDLMaxProxyProtocolVersion];
+ self.protocolVersion = [maxHeadUnitVersion isGreaterThanVersion:maxProxyProtocolVersion] ? maxProxyProtocolVersion : maxHeadUnitVersion;
- _maxHeadUnitVersion = maxHeadUnitVersion;
-}
-
-- (NSInteger)majorProtocolVersion {
- return [self.protocolVersion substringWithRange:NSMakeRange(0, 1)].integerValue;
+ _maxHeadUnitProtocolVersion = maxHeadUnitVersion;
}
- (void)setDynamicMTUSize:(NSUInteger)maxMTUSize forServiceType:(SDLServiceType)serviceType {
@@ -90,13 +90,9 @@ typedef NSNumber *MTUBox;
#pragma mark - Helpers
-- (BOOL)sdl_isVersion:(NSString *)version1 greaterThanVersion:(NSString *)version2 {
- return ([version1 compare:version2 options:NSNumericSearch] == NSOrderedDescending);
-}
-
- (NSUInteger)sdl_defaultMaxMTUSize {
// VERSION DEPENDENT CODE
- switch (self.majorProtocolVersion) {
+ switch (self.protocolVersion.major) {
case 1: // fallthrough
case 2: {
// HAX: This was set to 1024 at some point, for an unknown reason. We can't change it because of backward compatibility & validation concerns. The actual MTU for v1/2 is 1500 bytes.
@@ -106,14 +102,14 @@ typedef NSNumber *MTUBox;
case 4: // fallthrough
case 5: {
// If the head unit isn't running v3/4, but that's the connection scheme we're using, then we have to know that they could be running an MTU that's not 128k, so we default back to the v1/2 MTU for safety.
- if ([self sdl_isVersion:self.maxHeadUnitVersion greaterThanVersion:SDLMaxProxyProtocolVersion]) {
+ if ([self.maxHeadUnitProtocolVersion isGreaterThanVersion:[SDLVersion versionWithString:SDLMaxProxyProtocolVersion]]) {
return SDLV1MTUSize;
} else {
return SDLV3MTUSize;
}
} break;
default: {
- NSAssert(NO, @"Unknown version number for MTU Size: %@", @(self.majorProtocolVersion));
+ NSAssert(NO, @"Unknown MTU size for protocol version: %@", self.protocolVersion);
return 0;
}
}
diff --git a/SmartDeviceLink/SDLLifecycleConfiguration.h b/SmartDeviceLink/SDLLifecycleConfiguration.h
index a558c0dea..878895416 100644
--- a/SmartDeviceLink/SDLLifecycleConfiguration.h
+++ b/SmartDeviceLink/SDLLifecycleConfiguration.h
@@ -14,6 +14,7 @@
@class SDLFile;
@class SDLTemplateColorScheme;
@class SDLTTSChunk;
+@class SDLVersion;
NS_ASSUME_NONNULL_BEGIN
@@ -167,6 +168,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (copy, nonatomic, nullable) SDLTemplateColorScheme *nightColorScheme;
+/**
+ The minimum protocol version that will be permitted to connect. This defaults to 1.0.0. If the protocol version of the head unit connected is below this version, the app will disconnect with an EndService protocol message and will not register.
+ */
+@property (strong, nonatomic) SDLVersion *minimumProtocolVersion;
+
+/**
+ The minimum RPC version that will be permitted to connect. This defaults to 1.0.0. If the RPC version of the head unit connected is below this version, an UnregisterAppInterface will be sent.
+ */
+@property (strong, nonatomic) SDLVersion *minimumRPCVersion;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLLifecycleConfiguration.m b/SmartDeviceLink/SDLLifecycleConfiguration.m
index 6c5b560c5..5f163d8e6 100644
--- a/SmartDeviceLink/SDLLifecycleConfiguration.m
+++ b/SmartDeviceLink/SDLLifecycleConfiguration.m
@@ -9,6 +9,7 @@
#import "SDLLifecycleConfiguration.h"
#import "SDLFile.h"
+#import "SDLVersion.h"
static NSString *const DefaultTCPIPAddress = @"192.168.0.1";
static UInt16 const DefaultTCPIPPort = 12345;
@@ -66,6 +67,8 @@ static NSUInteger const AppIdCharacterCount = 10;
_shortAppName = nil;
_ttsName = nil;
_voiceRecognitionCommandNames = nil;
+ _minimumProtocolVersion = [SDLVersion versionWithString:@"1.0.0"];
+ _minimumRPCVersion = [SDLVersion versionWithString:@"1.0.0"];
_fullAppId = fullAppId;
_appId = fullAppId != nil ? [self.class sdlex_shortAppIdFromFullAppId:fullAppId] : appId;
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index 8c6ebfc31..55336b522 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -54,6 +54,7 @@
#import "SDLStreamingProtocolDelegate.h"
#import "SDLSystemCapabilityManager.h"
#import "SDLUnregisterAppInterface.h"
+#import "SDLVersion.h"
NS_ASSUME_NONNULL_BEGIN
@@ -194,7 +195,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
SDLLifecycleStateStarted: @[SDLLifecycleStateConnected, SDLLifecycleStateStopped, SDLLifecycleStateReconnecting],
SDLLifecycleStateReconnecting: @[SDLLifecycleStateStarted, SDLLifecycleStateStopped],
SDLLifecycleStateConnected: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateRegistered],
- SDLLifecycleStateRegistered: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateSettingUpManagers, SDLLifecycleStateUpdatingConfiguration],
+ SDLLifecycleStateRegistered: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateUnregistering, SDLLifecycleStateSettingUpManagers, SDLLifecycleStateUpdatingConfiguration],
SDLLifecycleStateUpdatingConfiguration: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateSettingUpManagers],
SDLLifecycleStateSettingUpManagers: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateSettingUpAppIcon],
SDLLifecycleStateSettingUpAppIcon: @[SDLLifecycleStateStopped, SDLLifecycleStateReconnecting, SDLLifecycleStateSettingUpHMI],
@@ -280,6 +281,14 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
[self.proxy addSecurityManagers:self.configuration.streamingMediaConfig.securityManagers forAppId:self.configuration.lifecycleConfig.appId];
}
+ // If the negotiated protocol version is greater than the minimum allowable version, we need to end service and disconnect
+ if ([self.configuration.lifecycleConfig.minimumProtocolVersion isGreaterThanVersion:[SDLGlobals sharedGlobals].protocolVersion]) {
+ SDLLogW(@"Disconnecting from head unit, protocol version %@ is greater than configured minimum version %@", [SDLGlobals sharedGlobals].protocolVersion.stringVersion, self.configuration.lifecycleConfig.minimumProtocolVersion.stringVersion);
+ [self.proxy.protocol endServiceWithType:SDLServiceTypeRPC];
+ [self sdl_transitionToState:SDLLifecycleStateStopped];
+ return;
+ }
+
// Build a register app interface request with the configuration data
SDLRegisterAppInterface *regRequest = [[SDLRegisterAppInterface alloc] initWithLifecycleConfiguration:self.configuration.lifecycleConfig];
@@ -303,13 +312,20 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
}
weakSelf.registerResponse = (SDLRegisterAppInterfaceResponse *)response;
- [SDLGlobals sharedGlobals].rpcVersion = weakSelf.registerResponse.syncMsgVersion;
+ [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithSyncMsgVersion:weakSelf.registerResponse.syncMsgVersion];
[weakSelf sdl_transitionToState:SDLLifecycleStateRegistered];
});
}];
}
- (void)didEnterStateRegistered {
+ // If the negotiated RPC version is greater than the minimum allowable version, we need to unregister and disconnect
+ if ([self.configuration.lifecycleConfig.minimumRPCVersion isGreaterThanVersion:[SDLGlobals sharedGlobals].rpcVersion]) {
+ SDLLogW(@"Disconnecting from head unit, RPC version %@ is greater than configured minimum version %@", [SDLGlobals sharedGlobals].rpcVersion.stringVersion, self.configuration.lifecycleConfig.minimumRPCVersion.stringVersion);
+ [self sdl_transitionToState:SDLLifecycleStateUnregistering];
+ return;
+ }
+
NSArray<SDLLanguage> *supportedLanguages = self.configuration.lifecycleConfig.languagesSupported;
SDLLanguage desiredLanguage = self.configuration.lifecycleConfig.language;
SDLLanguage actualLanguage = self.registerResponse.language;
diff --git a/SmartDeviceLink/SDLLogFileModuleMap.m b/SmartDeviceLink/SDLLogFileModuleMap.m
index 1ac7615d9..c6e67e476 100644
--- a/SmartDeviceLink/SDLLogFileModuleMap.m
+++ b/SmartDeviceLink/SDLLogFileModuleMap.m
@@ -20,6 +20,7 @@
[self sdl_dispatcherModule],
[self sdl_fileManagerModule],
[self sdl_lifecycleManagerModule],
+ [self sdl_systemCapabilityModule],
[self sdl_lockscreenManagerModule],
[self sdl_streamingMediaManagerModule],
[self sdl_streamingMediaAudioTranscoderModule],
@@ -61,6 +62,10 @@
return [SDLLogFileModule moduleWithName:@"Lifecycle" files:[NSSet setWithArray:@[@"SDLLifecycleManager", @"SDLManager"]]];
}
++ (SDLLogFileModule *)sdl_systemCapabilityModule {
+ return [SDLLogFileModule moduleWithName:@"System Capability" files:[NSSet setWithArray:@[@"SDLSystemCapabilityManager"]]];
+}
+
+ (SDLLogFileModule *)sdl_lockscreenManagerModule {
return [SDLLogFileModule moduleWithName:@"Lockscreen" files:[NSSet setWithArray:@[@"SDLLockScreenManager", @"SDLLockScreenViewController", @"SDLLockScreenPresenter"]]];
}
diff --git a/SmartDeviceLink/SDLProtocol.m b/SmartDeviceLink/SDLProtocol.m
index 44b7737e9..299b40289 100644
--- a/SmartDeviceLink/SDLProtocol.m
+++ b/SmartDeviceLink/SDLProtocol.m
@@ -25,6 +25,7 @@
#import "SDLRPCResponse.h"
#import "SDLSecurityType.h"
#import "SDLTimer.h"
+#import "SDLVersion.h"
#import "SDLV2ProtocolHeader.h"
NSString *const SDLProtocolSecurityErrorDomain = @"com.sdl.protocol.security";
@@ -158,7 +159,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (SDLProtocolMessage *)sdl_createStartServiceMessageWithType:(SDLServiceType)serviceType encrypted:(BOOL)encryption payload:(nullable NSData *)payload {
- SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].majorProtocolVersion];
+ SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].protocolVersion.major];
NSData *servicePayload = payload;
switch (serviceType) {
@@ -218,7 +219,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - End Service
- (void)endServiceWithType:(SDLServiceType)serviceType {
- SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].majorProtocolVersion];
+ SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].protocolVersion.major];
header.frameType = SDLFrameTypeControl;
header.serviceType = serviceType;
header.frameData = SDLFrameInfoEndService;
@@ -227,7 +228,7 @@ NS_ASSUME_NONNULL_BEGIN
// Assemble the payload, it's a full control frame if we're on 5.0+, it's just the hash id if we are not
NSData *payload = nil;
if (self.hashId != SDLControlFrameInt32NotFound) {
- if([SDLGlobals sharedGlobals].majorProtocolVersion > 4) {
+ if([SDLGlobals sharedGlobals].protocolVersion.major > 4) {
SDLControlFramePayloadEndService *endServicePayload = [[SDLControlFramePayloadEndService alloc] initWithHashId:self.hashId];
payload = endServicePayload.data;
} else {
@@ -243,12 +244,12 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Register Secondary Transport
- (void)registerSecondaryTransport {
- SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].majorProtocolVersion];
+ SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].protocolVersion.major];
header.frameType = SDLFrameTypeControl;
header.serviceType = SDLServiceTypeControl;
header.frameData = SDLFrameInfoRegisterSecondaryTransport;
header.sessionID = [self sdl_retrieveSessionIDforServiceType:SDLServiceTypeControl];
- if ([SDLGlobals sharedGlobals].majorProtocolVersion >= 2) {
+ if ([SDLGlobals sharedGlobals].protocolVersion.major >= 2) {
[((SDLV2ProtocolHeader *)header) setMessageID:++_messageID];
}
@@ -265,7 +266,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)sendRPC:(SDLRPCMessage *)message encrypted:(BOOL)encryption error:(NSError *__autoreleasing *)error {
NSParameterAssert(message != nil);
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[message serializeAsDictionary:(Byte)[SDLGlobals sharedGlobals].majorProtocolVersion] options:kNilOptions error:error];
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[message serializeAsDictionary:(Byte)[SDLGlobals sharedGlobals].protocolVersion.major] options:kNilOptions error:error];
if (error != nil) {
SDLLogW(@"Error encoding JSON data: %@", *error);
@@ -276,7 +277,7 @@ NS_ASSUME_NONNULL_BEGIN
// Build the message payload. Include the binary header if necessary
// VERSION DEPENDENT CODE
- switch ([SDLGlobals sharedGlobals].majorProtocolVersion) {
+ switch ([SDLGlobals sharedGlobals].protocolVersion.major) {
case 1: {
// No binary header in version 1
messagePayload = jsonData;
@@ -314,12 +315,12 @@ NS_ASSUME_NONNULL_BEGIN
}
} break;
default: {
- NSAssert(NO, @"Attempting to send an RPC based on an unknown version number: %@, message: %@", @([SDLGlobals sharedGlobals].majorProtocolVersion), message);
+ NSAssert(NO, @"Attempting to send an RPC based on an unknown version number: %@, message: %@", @([SDLGlobals sharedGlobals].protocolVersion.major), message);
} break;
}
// Build the protocol level header & message
- SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].majorProtocolVersion];
+ SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].protocolVersion.major];
header.encrypted = encryption;
header.frameType = SDLFrameTypeSingle;
header.serviceType = (message.bulkData.length <= 0) ? SDLServiceTypeRPC : SDLServiceTypeBulkData;
@@ -327,7 +328,7 @@ NS_ASSUME_NONNULL_BEGIN
header.sessionID = [self sdl_retrieveSessionIDforServiceType:SDLServiceTypeRPC];
// V2+ messages need to have message ID property set.
- if ([SDLGlobals sharedGlobals].majorProtocolVersion >= 2) {
+ if ([SDLGlobals sharedGlobals].protocolVersion.major >= 2) {
[((SDLV2ProtocolHeader *)header) setMessageID:++_messageID];
}
@@ -370,7 +371,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)sdl_sendRawData:(NSData *)data onService:(SDLServiceType)service encryption:(BOOL)encryption {
- SDLV2ProtocolHeader *header = [[SDLV2ProtocolHeader alloc] initWithVersion:(UInt8)[SDLGlobals sharedGlobals].majorProtocolVersion];
+ SDLV2ProtocolHeader *header = [[SDLV2ProtocolHeader alloc] initWithVersion:(UInt8)[SDLGlobals sharedGlobals].protocolVersion.major];
header.encrypted = encryption;
header.frameType = SDLFrameTypeSingle;
header.serviceType = service;
@@ -484,11 +485,11 @@ NS_ASSUME_NONNULL_BEGIN
if (startServiceACKPayload.hashId != SDLControlFrameInt32NotFound) {
self.hashId = startServiceACKPayload.hashId;
}
- [SDLGlobals sharedGlobals].maxHeadUnitVersion = (startServiceACKPayload.protocolVersion != nil) ? startServiceACKPayload.protocolVersion : [NSString stringWithFormat:@"%u.0.0", startServiceACK.header.version];
-
+
// FIXME: Add check for protocol version 5.2 or greater
self.authToken = startServiceACKPayload.authToken;
+ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = (startServiceACKPayload.protocolVersion != nil) ? [SDLVersion versionWithString:startServiceACKPayload.protocolVersion] : [SDLVersion versionWithMajor:startServiceACK.header.version minor:0 patch:0];
// TODO: Hash id?
} break;
default:
@@ -498,7 +499,7 @@ NS_ASSUME_NONNULL_BEGIN
// V4 and below packet
switch (startServiceACK.header.serviceType) {
case SDLServiceTypeRPC: {
- [SDLGlobals sharedGlobals].maxHeadUnitVersion = [NSString stringWithFormat:@"%u.0.0", startServiceACK.header.version];
+ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = [SDLVersion versionWithMajor:startServiceACK.header.version minor:0 patch:0];
} break;
default:
break;
@@ -573,7 +574,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)handleHeartbeatForSession:(Byte)session {
// Respond with a heartbeat ACK
- SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].majorProtocolVersion];
+ SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:(UInt8)[SDLGlobals sharedGlobals].protocolVersion.major];
header.frameType = SDLFrameTypeControl;
header.serviceType = SDLServiceTypeControl;
header.frameData = SDLFrameInfoHeartbeatACK;
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m
index 5226a2023..a21057ebf 100644
--- a/SmartDeviceLink/SDLProxy.m
+++ b/SmartDeviceLink/SDLProxy.m
@@ -39,6 +39,7 @@
#import "SDLTransportType.h"
#import "SDLUnsubscribeButton.h"
#import "SDLVehicleType.h"
+#import "SDLVersion.h"
NS_ASSUME_NONNULL_BEGIN
@@ -296,7 +297,7 @@ static float DefaultConnectionTimeout = 45.0;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (BOOL)sdl_adaptButtonSubscribeMessage:(SDLSubscribeButton *)message {
- if ([SDLGlobals sharedGlobals].rpcVersion.majorVersion.intValue >= 5) {
+ if ([SDLGlobals sharedGlobals].rpcVersion.major >= 5) {
if ([message.buttonName isEqualToEnum:SDLButtonNameOk]) {
SDLSubscribeButton *playPauseMessage = [message copy];
playPauseMessage.buttonName = SDLButtonNamePlayPause;
@@ -333,7 +334,7 @@ static float DefaultConnectionTimeout = 45.0;
}
- (BOOL)sdl_adaptButtonUnsubscribeMessage:(SDLUnsubscribeButton *)message {
- if ([SDLGlobals sharedGlobals].rpcVersion.majorVersion.intValue >= 5) {
+ if ([SDLGlobals sharedGlobals].rpcVersion.major >= 5) {
if ([message.buttonName isEqualToEnum:SDLButtonNameOk]) {
SDLUnsubscribeButton *playPauseMessage = [message copy];
playPauseMessage.buttonName = SDLButtonNamePlayPause;
@@ -422,7 +423,7 @@ static float DefaultConnectionTimeout = 45.0;
if ([functionName isEqualToString:@"OnButtonPress"]) {
SDLOnButtonPress *message = (SDLOnButtonPress *)newMessage;
- if ([SDLGlobals sharedGlobals].rpcVersion.majorVersion.intValue >= 5) {
+ if ([SDLGlobals sharedGlobals].rpcVersion.major >= 5) {
BOOL handledRPC = [self sdl_handleOnButtonPressPostV5:message];
if (handledRPC) { return; }
} else { // RPC version of 4 or less (connected to an old head unit)
@@ -433,7 +434,7 @@ static float DefaultConnectionTimeout = 45.0;
if ([functionName isEqualToString:@"OnButtonEvent"]) {
SDLOnButtonEvent *message = (SDLOnButtonEvent *)newMessage;
- if ([SDLGlobals sharedGlobals].rpcVersion.majorVersion.intValue >= 5) {
+ if ([SDLGlobals sharedGlobals].rpcVersion.major >= 5) {
BOOL handledRPC = [self sdl_handleOnButtonEventPostV5:message];
if (handledRPC) { return; }
} else {
@@ -478,7 +479,7 @@ static float DefaultConnectionTimeout = 45.0;
self.protocol.securityManager.appId = self.appId;
}
- if ([SDLGlobals sharedGlobals].majorProtocolVersion >= 4) {
+ if ([SDLGlobals sharedGlobals].protocolVersion.major >= 4) {
[self sendMobileHMIState];
// Send SDL updates to application state
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendMobileHMIState) name:UIApplicationDidBecomeActiveNotification object:nil];
diff --git a/SmartDeviceLink/SDLStateMachine.m b/SmartDeviceLink/SDLStateMachine.m
index ffc269503..1819584ed 100644
--- a/SmartDeviceLink/SDLStateMachine.m
+++ b/SmartDeviceLink/SDLStateMachine.m
@@ -124,6 +124,8 @@ SDLStateMachineTransitionFormat const SDLStateMachineTransitionFormatDidEnter =
self.currentState = oldState;
}
+ self.currentState = state;
+
if (shouldCall) {
SEL didEnter = NSSelectorFromString([NSString stringWithFormat:SDLStateMachineTransitionFormatDidEnter, state]);
#pragma clang diagnostic push
@@ -133,8 +135,6 @@ SDLStateMachineTransitionFormat const SDLStateMachineTransitionFormatDidEnter =
#pragma clang diagnostic pop
}
}
-
- self.currentState = state;
}
/**
diff --git a/SmartDeviceLink/SDLVersion.h b/SmartDeviceLink/SDLVersion.h
new file mode 100644
index 000000000..f7b226206
--- /dev/null
+++ b/SmartDeviceLink/SDLVersion.h
@@ -0,0 +1,37 @@
+//
+// SDLVersion.h
+// SmartDeviceLink
+//
+// Created by Joel Fischer on 2/19/19.
+// Copyright © 2019 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@class SDLSyncMsgVersion;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface SDLVersion : NSObject <NSCopying>
+
+@property (nonatomic, assign) NSUInteger major;
+@property (nonatomic, assign) NSUInteger minor;
+@property (nonatomic, assign) NSUInteger patch;
+
+@property (nonatomic, copy, readonly) NSString *stringVersion;
+
+- (instancetype)initWithMajor:(NSUInteger)major minor:(NSUInteger)minor patch:(NSUInteger)patch;
++ (instancetype)versionWithMajor:(NSUInteger)major minor:(NSUInteger)minor patch:(NSUInteger)patch;
+- (nullable instancetype)initWithString:(NSString *)versionString;
++ (nullable instancetype)versionWithString:(NSString *)versionString;
+- (instancetype)initWithSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion;
++ (instancetype)versionWithSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion;
+
+- (NSComparisonResult)compare:(SDLVersion *)otherVersion;
+- (BOOL)isLessThanVersion:(SDLVersion *)otherVersion;
+- (BOOL)isEqualToVersion:(SDLVersion *)otherVersion;
+- (BOOL)isGreaterThanVersion:(SDLVersion *)otherVersion;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLVersion.m b/SmartDeviceLink/SDLVersion.m
new file mode 100644
index 000000000..37df25966
--- /dev/null
+++ b/SmartDeviceLink/SDLVersion.m
@@ -0,0 +1,135 @@
+//
+// SDLVersion.m
+// SmartDeviceLink
+//
+// Created by Joel Fischer on 2/19/19.
+// Copyright © 2019 smartdevicelink. All rights reserved.
+//
+
+#import "SDLVersion.h"
+
+#import "SDLSyncMsgVersion.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@implementation SDLVersion
+
+#pragma mark - Initializers
+
+- (instancetype)initWithMajor:(NSUInteger)major minor:(NSUInteger)minor patch:(NSUInteger)patch {
+ self = [super init];
+ if (!self) { return nil; }
+
+ _major = major;
+ _minor = minor;
+ _patch = patch;
+
+ return self;
+}
+
++ (instancetype)versionWithMajor:(NSUInteger)major minor:(NSUInteger)minor patch:(NSUInteger)patch {
+ return [[self alloc] initWithMajor:major minor:minor patch:patch];
+}
+
+- (nullable instancetype)initWithString:(NSString *)versionString {
+ self = [super init];
+ if (!self) { return nil; }
+
+ NSArray<NSString *> *splitVersions = [versionString componentsSeparatedByString:@"."];
+ if (splitVersions.count != 3) {
+ NSAssert(splitVersions.count == 3, @"Splitting a version string must result in major, minor, and patch. The format must be 'X.X.X'");
+ return nil;
+ }
+
+ NSInteger majorInt = splitVersions[0].integerValue;
+ NSInteger minorInt = splitVersions[1].integerValue;
+ NSInteger patchInt = splitVersions[2].integerValue;
+
+ if (majorInt < 0 || minorInt < 0 || patchInt < 0) {
+ NSAssert(NO, @"Attempted to parse invalid SDLVersion: %@", splitVersions);
+ return nil;
+ }
+
+ _major = (NSUInteger)majorInt;
+ _minor = (NSUInteger)minorInt;
+ _patch = (NSUInteger)patchInt;
+
+ return self;
+}
+
++ (nullable instancetype)versionWithString:(NSString *)versionString {
+ return [[self alloc] initWithString:versionString];
+}
+
+- (instancetype)initWithSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion {
+ self = [super init];
+ if (!self) { return nil; }
+
+ _major = syncMsgVersion.majorVersion.unsignedIntegerValue;
+ _minor = syncMsgVersion.minorVersion.unsignedIntegerValue;
+ _patch = syncMsgVersion.patchVersion.unsignedIntegerValue;
+
+ return self;
+}
+
++ (instancetype)versionWithSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion {
+ return [[self alloc] initWithSyncMsgVersion:syncMsgVersion];
+}
+
+#pragma mark - Setters / Getters
+
+- (NSString *)stringVersion {
+ return [NSString stringWithFormat:@"%lu.%lu.%lu", (unsigned long)_major, (unsigned long)_minor, (unsigned long)_patch];
+}
+
+#pragma mark - Helper functions
+
+- (NSComparisonResult)compare:(SDLVersion *)otherVersion {
+ if (self.major > otherVersion.major) {
+ return NSOrderedDescending;
+ } else if ((self.major == otherVersion.major) && (self.minor > otherVersion.minor)) {
+ return NSOrderedDescending;
+ } else if ((self.major == otherVersion.major) && (self.minor == otherVersion.minor) && (self.patch > otherVersion.patch)) {
+ return NSOrderedDescending;
+ } else if ((self.major == otherVersion.major) && (self.minor == otherVersion.minor) && (self.patch == otherVersion.patch)) {
+ return NSOrderedSame;
+ }
+
+ return NSOrderedAscending;
+}
+
+- (BOOL)isLessThanVersion:(SDLVersion *)otherVersion {
+ return ([self compare:otherVersion] == NSOrderedAscending);
+}
+
+- (BOOL)isEqualToVersion:(SDLVersion *)otherVersion {
+ return ([self compare:otherVersion] == NSOrderedSame);
+}
+
+- (BOOL)isGreaterThanVersion:(SDLVersion *)otherVersion {
+ return ([self compare:otherVersion] == NSOrderedDescending);
+}
+
+#pragma mark - NSObject overrides
+
+- (BOOL)isEqual:(id)object {
+ if (object == nil) { return NO; }
+ if (![object isMemberOfClass:self.class]) { return NO; }
+
+ SDLVersion *otherVersion = (SDLVersion *)object;
+
+ return [self isEqualToVersion:otherVersion];
+}
+
+- (NSString *)description {
+ return self.stringVersion;
+}
+
+- (id)copyWithZone:(nullable NSZone *)zone {
+ SDLVersion *new = [[SDLVersion allocWithZone:zone] initWithMajor:_major minor:_minor patch:_patch];
+ return new;
+}
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h
index f431b0c0b..4464e81ea 100644
--- a/SmartDeviceLink/SmartDeviceLink.h
+++ b/SmartDeviceLink/SmartDeviceLink.h
@@ -392,6 +392,7 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[];
#import "SDLErrorConstants.h"
#import "SDLNotificationConstants.h"
#import "SDLStreamingMediaManagerConstants.h"
+#import "SDLVersion.h"
// Notifications
#import "SDLRPCNotificationNotification.h"
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m
index 100acc9c2..9f49311f7 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m
@@ -14,6 +14,7 @@
#import "SDLLifecycleConfigurationUpdate.h"
#import "SDLSpeechCapabilities.h"
#import "SDLTTSChunk.h"
+#import "SDLVersion.h"
@interface SDLLifecycleConfiguration()
@@ -31,9 +32,11 @@ describe(@"A lifecycle configuration", ^{
__block NSString *testAppId = @"00542596";
__block NSString *testFullAppId = @"-ab--987-adfa651kj-212346h3kjkaju";
__block NSString *expectedGeneratedAppId = @"ab987adfa6";
+ __block SDLVersion *baseVersion = nil;
beforeEach(^{
testConfig = nil;
+ baseVersion = [SDLVersion versionWithMajor:1 minor:0 patch:0];
});
context(@"created with a default configuration", ^{
@@ -69,6 +72,8 @@ describe(@"A lifecycle configuration", ^{
expect(testConfig.ttsName).to(beNil());
expect(testConfig.voiceRecognitionCommandNames).to(beNil());
expect(testConfig.resumeHash).to(beNil());
+ expect(testConfig.minimumProtocolVersion).to(equal(baseVersion));
+ expect(testConfig.minimumRPCVersion).to(equal(baseVersion));
});
});
@@ -98,6 +103,8 @@ describe(@"A lifecycle configuration", ^{
testConfig.ttsName = testTTSName;
testConfig.voiceRecognitionCommandNames = testSynonyms;
testConfig.resumeHash = testResumeHashString;
+ testConfig.minimumProtocolVersion = [SDLVersion versionWithString:@"1.0.0"];
+ testConfig.minimumRPCVersion = [SDLVersion versionWithString:@"2.0.0"];
});
afterEach(^{
@@ -117,6 +124,8 @@ describe(@"A lifecycle configuration", ^{
expect(testConfig.ttsName).to(haveCount(@1));
expect(testConfig.voiceRecognitionCommandNames).to(haveCount(@(testSynonyms.count)));
expect(testConfig.resumeHash).to(match(testResumeHashString));
+ expect(testConfig.minimumProtocolVersion.stringVersion).to(equal(@"1.0.0"));
+ expect(testConfig.minimumRPCVersion.stringVersion).to(equal(@"2.0.0"));
});
});
});
@@ -161,6 +170,8 @@ describe(@"A lifecycle configuration", ^{
expect(testConfig.ttsName).to(beNil());
expect(testConfig.voiceRecognitionCommandNames).to(beNil());
expect(testConfig.resumeHash).to(beNil());
+ expect(testConfig.minimumProtocolVersion).to(equal(baseVersion));
+ expect(testConfig.minimumRPCVersion).to(equal(baseVersion));
});
});
@@ -170,6 +181,7 @@ describe(@"A lifecycle configuration", ^{
__block NSArray<SDLTTSChunk *> *testTTSName = nil;
__block NSArray<NSString *> *testSynonyms = nil;
__block NSString *testResumeHashString = nil;
+ __block SDLVersion *testVersion = nil;
beforeEach(^{
testConfig = [SDLLifecycleConfiguration debugConfigurationWithAppName:testAppName fullAppId:testFullAppId ipAddress:testIPAddress port:testPort];
@@ -181,6 +193,7 @@ describe(@"A lifecycle configuration", ^{
testTTSName = @[testTTSChunk];
testSynonyms = @[@"Test 1", @"Test 2", @"Test 3", @"Test 4"];
testResumeHashString = @"testing";
+ testVersion = [SDLVersion versionWithMajor:1 minor:0 patch:0];
testConfig.appType = SDLAppHMITypeInformation;
testConfig.additionalAppTypes = @[SDLAppHMITypeProjection];
@@ -190,6 +203,8 @@ describe(@"A lifecycle configuration", ^{
testConfig.ttsName = testTTSName;
testConfig.voiceRecognitionCommandNames = testSynonyms;
testConfig.resumeHash = testResumeHashString;
+ testConfig.minimumRPCVersion = testVersion;
+ testConfig.minimumProtocolVersion = testVersion;
});
afterEach(^{
@@ -209,6 +224,8 @@ describe(@"A lifecycle configuration", ^{
expect(testConfig.ttsName).to(haveCount(@1));
expect(testConfig.voiceRecognitionCommandNames).to(haveCount(@(testSynonyms.count)));
expect(testConfig.resumeHash).to(match(testResumeHashString));
+ expect(testConfig.minimumRPCVersion).to(equal(testVersion));
+ expect(testConfig.minimumProtocolVersion).to(equal(testVersion));
});
});
});
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
index e05f56dc3..f2429beb9 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
@@ -33,6 +33,7 @@
#import "SDLTTSChunk.h"
#import "SDLUnregisterAppInterface.h"
#import "SDLUnregisterAppInterfaceResponse.h"
+#import "SDLVersion.h"
// Ignore the deprecated proxy methods
@@ -255,6 +256,20 @@ describe(@"a lifecycle manager", ^{
});
});
});
+
+ describe(@"in the connected state when the minimum protocol version is in effect", ^{
+ beforeEach(^{
+ SDLVersion *oldVersion = [SDLVersion versionWithMajor:0 minor:0 patch:0];
+ id globalMock = OCMPartialMock([SDLGlobals sharedGlobals]);
+ OCMStub([globalMock protocolVersion]).andReturn(oldVersion);
+ OCMExpect([protocolMock endServiceWithType:SDLServiceTypeRPC]);
+ [testManager.lifecycleStateMachine setToState:SDLLifecycleStateConnected fromOldState:nil callEnterTransition:YES];
+ });
+
+ it(@"should disconnect", ^{
+ OCMVerifyAll(protocolMock);
+ });
+ });
describe(@"in the connected state", ^{
beforeEach(^{
@@ -312,6 +327,20 @@ describe(@"a lifecycle manager", ^{
});
});
});
+
+ describe(@"transitioning to the registered state when the minimum RPC version is in effect", ^{
+ beforeEach(^{
+ SDLVersion *oldVersion = [SDLVersion versionWithMajor:0 minor:0 patch:0];
+ id globalMock = OCMPartialMock([SDLGlobals sharedGlobals]);
+ OCMStub([globalMock rpcVersion]).andReturn(oldVersion);
+
+ [testManager.lifecycleStateMachine setToState:SDLLifecycleStateRegistered fromOldState:nil callEnterTransition:YES];
+ });
+
+ it(@"should disconnect", ^{
+ expect(testManager.lifecycleState).to(equal(SDLLifecycleStateUnregistering));
+ });
+ });
describe(@"transitioning to the Setting Up HMI state", ^{
context(@"before register response is a success", ^{
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStateMachineSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStateMachineSpec.m
index efb5a5f64..a9d72aa53 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLStateMachineSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStateMachineSpec.m
@@ -22,7 +22,6 @@ describe(@"A state machine", ^{
beforeEach(^{
testTarget = [[TestStateMachineTarget alloc] init];
-
testStateMachine = [[SDLStateMachine alloc] initWithTarget:testTarget initialState:initialState states:allowableStateTransitions];
});
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
index b2a83fca6..e3fb6732f 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
@@ -8,6 +8,7 @@
#import "SDLPutFile.h"
#import "SDLPutFileResponse.h"
#import "SDLUploadFileOperation.h"
+#import "SDLVersion.h"
#import "TestConnectionManager.h"
#import <zlib.h>
@@ -28,7 +29,7 @@ describe(@"Streaming upload of data", ^{
__block NSError *errorResult = nil;
beforeEach(^{
- [SDLGlobals sharedGlobals].maxHeadUnitVersion = @"2.0.0";
+ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"2.0.0"];
testFileName = nil;
testFileData = nil;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLVersionSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLVersionSpec.m
new file mode 100644
index 000000000..5e5ed662a
--- /dev/null
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLVersionSpec.m
@@ -0,0 +1,104 @@
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+
+#import "SDLSyncMsgVersion.h"
+#import "SDLVersion.h"
+
+QuickSpecBegin(SDLVersionSpec)
+
+describe(@"a version object", ^{
+ __block SDLVersion *testVersion = nil;
+ __block NSUInteger major = 5; __block NSUInteger minor = 4; __block NSUInteger patch = 0;
+
+ beforeEach(^{
+ testVersion = nil;
+ });
+
+ describe(@"initializers", ^{
+ context(@"created from numbers", ^{
+ it(@"should match the parameters", ^{
+ testVersion = [[SDLVersion alloc] initWithMajor:major minor:minor patch:patch];
+ expect(testVersion.major).to(equal(major));
+ expect(testVersion.minor).to(equal(minor));
+ expect(testVersion.patch).to(equal(patch));
+ });
+ });
+
+ context(@"created from a string", ^{
+ NSString *goodVersionString = [NSString stringWithFormat:@"%lu.%lu.%lu", major, minor, patch];
+ NSString *badVersionStringShort = @"1.";
+ NSString *badVersionStringLong = @"3.1.0.0";
+
+ it(@"should throw with a bad short string", ^{
+ expectAction(^{
+ testVersion = [[SDLVersion alloc] initWithString:badVersionStringShort];
+ }).to(raiseException());
+ });
+
+ it(@"should throw with a bad long string", ^{
+ expectAction(^{
+ testVersion = [[SDLVersion alloc] initWithString:badVersionStringLong];
+ }).to(raiseException());
+ });
+
+ it(@"should match the good string", ^{
+ testVersion = [[SDLVersion alloc] initWithString:goodVersionString];
+ expect(testVersion.major).to(equal(major));
+ expect(testVersion.minor).to(equal(minor));
+ expect(testVersion.patch).to(equal(patch));
+ });
+
+ it(@"should fail with negative numbers", ^{
+ expectAction(^{
+ testVersion = [[SDLVersion alloc] initWithString:@"-1.-2.-3"];
+ }).to(raiseException());
+ });
+ });
+
+ context(@"created from a SyncMsgVersion object", ^{
+ beforeEach(^{
+ SDLSyncMsgVersion *msgVersion = [[SDLSyncMsgVersion alloc] initWithMajorVersion:major minorVersion:minor patchVersion:patch];
+ testVersion = [[SDLVersion alloc] initWithSyncMsgVersion:msgVersion];
+ });
+
+ it(@"should match the parameters", ^{
+ expect(testVersion.major).to(equal(major));
+ expect(testVersion.minor).to(equal(minor));
+ expect(testVersion.patch).to(equal(patch));
+ });
+ });
+ });
+
+ describe(@"comparing versions", ^{
+ __block SDLVersion *lowerVersion = nil;
+ __block SDLVersion *equalVersion = nil;
+ __block SDLVersion *higherVersion = nil;
+
+ beforeEach(^{
+ testVersion = [[SDLVersion alloc] initWithMajor:major minor:minor patch:patch];
+
+ lowerVersion = [[SDLVersion alloc] initWithMajor:4 minor:1 patch:0];
+ equalVersion = [[SDLVersion alloc] initWithMajor:major minor:minor patch:patch];
+ higherVersion = [[SDLVersion alloc] initWithMajor:7 minor:2 patch:4];
+ });
+
+ it(@"should correctly check comparison methods", ^{
+ expect([testVersion isGreaterThanVersion:lowerVersion]).to(equal(YES));
+ expect([testVersion isGreaterThanVersion:equalVersion]).to(equal(NO));
+ expect([testVersion isGreaterThanVersion:higherVersion]).to(equal(NO));
+ expect([testVersion isEqualToVersion:lowerVersion]).to(equal(NO));
+ expect([testVersion isEqualToVersion:equalVersion]).to(equal(YES));
+ expect([testVersion isEqualToVersion:higherVersion]).to(equal(NO));
+ expect([testVersion isLessThanVersion:lowerVersion]).to(equal(NO));
+ expect([testVersion isLessThanVersion:equalVersion]).to(equal(NO));
+ expect([testVersion isLessThanVersion:higherVersion]).to(equal(YES));
+ });
+ });
+
+ it(@"should correctly turn into a string", ^{
+ testVersion = [[SDLVersion alloc] initWithMajor:major minor:minor patch:patch];
+ expect(testVersion.stringVersion).to(equal(@"5.4.0"));
+ });
+});
+
+QuickSpecEnd
diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
index 0fc3ed3db..656a5d6f2 100644
--- a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
+++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
@@ -23,7 +23,7 @@
#import "SDLV2ProtocolMessage.h"
#import "SDLV1ProtocolHeader.h"
#import "SDLV2ProtocolHeader.h"
-
+#import "SDLVersion.h"
QuickSpecBegin(SDLProtocolSpec)
//Test dictionaries
@@ -39,7 +39,7 @@ describe(@"Send StartService Tests", ^ {
it(@"Should send the correct data", ^ {
// Reset max protocol version before test. (This test case expects V1 header. If other test ran
// prior to this one, SDLGlobals would keep the max protocol version and this test case would fail.)
- [[SDLGlobals sharedGlobals] setMaxHeadUnitVersion:@"1.0.0"];
+ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"1.0.0"];
SDLProtocol* testProtocol = [[SDLProtocol alloc] init];
@@ -65,7 +65,7 @@ describe(@"Send StartService Tests", ^ {
it(@"Should reuse stored header of RPC service when starting other service", ^{
// reset max protocol version before test
- [[SDLGlobals sharedGlobals] setMaxHeadUnitVersion:@"2.0.0"];
+ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"2.0.0"];
SDLServiceType serviceTypeToStart = SDLServiceTypeVideo;
diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m
index 9dfc2c32f..ad662b47b 100644
--- a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m
+++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolMessageDisassemblerSpec.m
@@ -14,6 +14,7 @@
#import "SDLV2ProtocolHeader.h"
#import "SDLV2ProtocolMessage.h"
#import "SDLNames.h"
+#import "SDLVersion.h"
QuickSpecBegin(SDLProtocolMessageDisassemblerSpec)
@@ -24,7 +25,7 @@ describe(@"Disassemble Tests", ^ {
char dummyBytes[dataLength];
SDLGlobals *globals = [[SDLGlobals alloc] init];
- globals.maxHeadUnitVersion = @"2.0.0";
+ globals.maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"2.0.0"];
const char testPayloadHeader[12] = {0x20, 0x55, 0x64, 0x73, 0x12, 0x34, 0x43, 0x21, (dataLength >> 24) & 0xFF, (dataLength >> 16) & 0xFF, (dataLength >> 8) & 0xFF, dataLength & 0xFF};
diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m
index b09d1b4e5..f730c17c1 100644
--- a/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m
@@ -2,6 +2,7 @@
#import <Nimble/Nimble.h>
#import "SDLGlobals.h"
+#import "SDLVersion.h"
QuickSpecBegin(SDLGlobalsSpec)
@@ -14,68 +15,60 @@ describe(@"The SDLGlobals class", ^{
describe(@"when just initialized", ^{
it(@"should properly set parameters", ^{
- expect(testGlobals.protocolVersion).to(equal(@"1.0.0"));
- expect(testGlobals.majorProtocolVersion).to(equal(1));
- expect(testGlobals.maxHeadUnitVersion).to(equal(@"0.0.0"));
+ expect(testGlobals.protocolVersion.stringVersion).to(equal(@"1.0.0"));
+ expect(testGlobals.protocolVersion.major).to(equal(1));
+ expect(testGlobals.maxHeadUnitProtocolVersion.stringVersion).to(equal(@"0.0.0"));
expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV1MTUSize));
- expect(testGlobals.rpcVersion).to(equal([[SDLSyncMsgVersion alloc] initWithMajorVersion:1 minorVersion:0 patchVersion:0]));
- });
- });
-
- describe(@"setting the RPC version", ^{
- it(@"should properly set", ^{
- testGlobals.rpcVersion = [[SDLSyncMsgVersion alloc] initWithMajorVersion:4 minorVersion:2 patchVersion:3];
-
- expect(testGlobals.rpcVersion).to(equal([[SDLSyncMsgVersion alloc] initWithMajorVersion:4 minorVersion:2 patchVersion:3]));
+ expect(testGlobals.rpcVersion).to(equal([[SDLVersion alloc] initWithMajor:1 minor:0 patch:0]));
});
});
describe(@"setting maxHeadUnitVersion should alter negotiated protocol version", ^{
it(@"should use the max head unit version when lower than max proxy version", ^{
- NSString *someVersionLowerThanMaxProxyVersion = @"2.0.0";
- testGlobals.maxHeadUnitVersion = someVersionLowerThanMaxProxyVersion;
+ SDLVersion *someVersionLowerThanMaxProxyVersion = [SDLVersion versionWithString:@"2.0.0"];
+ testGlobals.maxHeadUnitProtocolVersion = someVersionLowerThanMaxProxyVersion;
expect(testGlobals.protocolVersion).to(equal(someVersionLowerThanMaxProxyVersion));
- expect(testGlobals.maxHeadUnitVersion).to(equal(someVersionLowerThanMaxProxyVersion));
+ expect(testGlobals.maxHeadUnitProtocolVersion).to(equal(someVersionLowerThanMaxProxyVersion));
});
it(@"should use the max proxy version when lower than max head unit version", ^{
- NSString *someVersionHigherThanMaxProxyVersion = @"1000.0.0";
- testGlobals.maxHeadUnitVersion = someVersionHigherThanMaxProxyVersion;
+ SDLVersion *someVersionHigherThanMaxProxyVersion = [SDLVersion versionWithString:@"1000.0.0"];
+ testGlobals.maxHeadUnitProtocolVersion = someVersionHigherThanMaxProxyVersion;
- expect(([testGlobals.protocolVersion compare:someVersionHigherThanMaxProxyVersion options:NSNumericSearch] == NSOrderedDescending)).to(beFalsy());
- expect(testGlobals.maxHeadUnitVersion).to(equal(someVersionHigherThanMaxProxyVersion));
+ expect([testGlobals.protocolVersion isGreaterThanVersion:someVersionHigherThanMaxProxyVersion]).to(beFalse());
+ expect(testGlobals.maxHeadUnitProtocolVersion).to(equal(someVersionHigherThanMaxProxyVersion));
});
});
describe(@"getting the max MTU version", ^{
context(@"when protocol version is 1 - 2", ^{
it(@"should return the correct value when protocol version is 1", ^{
- testGlobals.maxHeadUnitVersion = @"1.0.0";
+ testGlobals.maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"1.0.0"];
expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV1MTUSize));
});
it(@"should return the correct value when protocol version is 2", ^{
- testGlobals.maxHeadUnitVersion = @"2.0.0";
+ testGlobals.maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"2.0.0"];
expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV1MTUSize));
});
});
context(@"when protocol version is 3 - 4", ^{
it(@"should return the correct value when protocol version is 3", ^{
- testGlobals.maxHeadUnitVersion = @"3.0.0";
+ testGlobals.maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"3.0.0"];
expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV3MTUSize));
});
it(@"should return the correct value when protocol version is 4", ^{
- testGlobals.maxHeadUnitVersion = @"4.0.0";
+ testGlobals.maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"4.0.0"];
expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV3MTUSize));
});
describe(@"when the max proxy version is lower than max head unit version", ^{
beforeEach(^{
- NSString *someVersionHigherThanMaxProxyVersion = @"1000.0.0";
- testGlobals.maxHeadUnitVersion = someVersionHigherThanMaxProxyVersion;
+ SDLVersion *someVersionHigherThanMaxProxyVersion = [SDLVersion versionWithString:@"1000.0.0"];
+ testGlobals.maxHeadUnitProtocolVersion = someVersionHigherThanMaxProxyVersion;
});
it(@"should return the v1 - 2 value", ^{
@@ -91,7 +84,7 @@ describe(@"The SDLGlobals class", ^{
__block NSUInteger dynamicMTUSize2 = 54321;
beforeEach(^{
- testGlobals.maxHeadUnitVersion = @"5.0.0";
+ testGlobals.maxHeadUnitProtocolVersion = [SDLVersion versionWithString:@"5.0.0"];
});
context(@"Setting the RPC service MTU", ^{