diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-10-30 14:29:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 14:29:35 -0400 |
commit | 43f6367aa18724143032f3624887b0f867c5cc47 (patch) | |
tree | f4d13c8076a8fe33b0136849c1ab1001812b015e | |
parent | d16cf18dc09115ef471736bfb07ec3a535f16adc (diff) | |
parent | 9a6c1e42ddea49799db2db235ec6f26816dec230 (diff) | |
download | sdl_ios-43f6367aa18724143032f3624887b0f867c5cc47.tar.gz |
Merge pull request #782 from smartdevicelink/bug/issue_781_secure_and_insecure_streaming
Check the makes when deciding if secure or insecure should start
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaLifecycleManager.m | 17 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m | 3 |
2 files changed, 16 insertions, 4 deletions
diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index c8dd8a809..638419701 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -20,6 +20,7 @@ #import "SDLGetSystemCapabilityResponse.h" #import "SDLGlobals.h" #import "SDLFocusableItemLocator.h" +#import "SDLH264VideoEncoder.h" #import "SDLHMICapabilities.h" #import "SDLImageResolution.h" #import "SDLLogMacros.h" @@ -35,7 +36,7 @@ #import "SDLStreamingMediaManagerDataSource.h" #import "SDLSystemCapability.h" #import "SDLTouchManager.h" -#import "SDLH264VideoEncoder.h" +#import "SDLVehicleType.h" #import "SDLVideoStreamingCapability.h" #import "SDLVideoStreamingCodec.h" #import "SDLVideoStreamingFormat.h" @@ -78,6 +79,8 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N @property (strong, nonatomic, nullable) SDLH264VideoEncoder *videoEncoder; @property (copy, nonatomic) NSDictionary<NSString *, id> *videoEncoderSettings; +@property (copy, nonatomic) NSArray<NSString *> *secureMakes; +@property (copy, nonatomic) NSString *connectedVehicleMake; @property (strong, nonatomic, readwrite) SDLStateMachine *appStateMachine; @property (strong, nonatomic, readwrite) SDLStateMachine *videoStreamStateMachine; @@ -117,6 +120,12 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N _preferredFormatIndex = 0; _preferredResolutionIndex = 0; + NSMutableArray<NSString *> *tempMakeArray = [NSMutableArray array]; + for (Class securityManagerClass in configuration.securityManagers) { + [tempMakeArray addObjectsFromArray:[securityManagerClass availableMakes].allObjects]; + } + _secureMakes = [tempMakeArray copy]; + SDLAppState *initialState = SDLAppStateInactive; switch ([[UIApplication sharedApplication] applicationState]) { case UIApplicationStateActive: { @@ -405,7 +414,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N - (void)didEnterStateAudioStreamStarting { SDLLogD(@"Audio stream starting"); - if (self.requestedEncryptionType != SDLStreamingEncryptionFlagNone) { + if ((self.requestedEncryptionType != SDLStreamingEncryptionFlagNone) && ([self.secureMakes containsObject:self.connectedVehicleMake])) { [self.protocol startSecureServiceWithType:SDLServiceTypeAudio payload:nil completionHandler:^(BOOL success, NSError * _Nonnull error) { if (error) { SDLLogE(@"TLS setup error: %@", error); @@ -579,6 +588,8 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N _screenSize = SDLDefaultScreenSize; } + self.connectedVehicleMake = registerResponse.vehicleType.make; + SDLLogD(@"Determined base screen size on display capabilities: %@", NSStringFromCGSize(_screenSize)); } @@ -753,7 +764,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N SDLControlFramePayloadVideoStartService *startVideoPayload = [[SDLControlFramePayloadVideoStartService alloc] initWithVideoHeight:preferredResolution.resolutionHeight.intValue width:preferredResolution.resolutionWidth.intValue protocol:preferredFormat.protocol codec:preferredFormat.codec]; // Decide if we need to start a secure service or not - if (self.requestedEncryptionType != SDLStreamingEncryptionFlagNone) { + if ((self.requestedEncryptionType != SDLStreamingEncryptionFlagNone) && ([self.secureMakes containsObject:self.connectedVehicleMake])) { SDLLogD(@"Sending secure video start service with payload: %@", startVideoPayload); [self.protocol startSecureServiceWithType:SDLServiceTypeVideo payload:startVideoPayload.data completionHandler:^(BOOL success, NSError *error) { if (error) { diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m index 9a10d666a..17e42a750 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m @@ -26,6 +26,7 @@ #import "SDLResult.h" #import "SDLShow.h" #import "SDLStateMachine.h" +#import "SDLStreamingMediaConfiguration.h" #import "SDLStreamingMediaManager.h" #import "SDLTextAlignment.h" #import "SDLUnregisterAppInterface.h" @@ -80,7 +81,7 @@ describe(@"a lifecycle manager", ^{ testLifecycleConfig.shortAppName = @"Short Name"; testLifecycleConfig.appType = SDLAppHMITypeNavigation; - testConfig = [SDLConfiguration configurationWithLifecycle:testLifecycleConfig lockScreen:[SDLLockScreenConfiguration disabledConfiguration] logging:[SDLLogConfiguration defaultConfiguration]]; + testConfig = [SDLConfiguration configurationWithLifecycle:testLifecycleConfig lockScreen:[SDLLockScreenConfiguration disabledConfiguration] logging:[SDLLogConfiguration defaultConfiguration] streamingMedia:[SDLStreamingMediaConfiguration insecureConfiguration]]; testManager = [[SDLLifecycleManager alloc] initWithConfiguration:testConfig delegate:managerDelegateMock]; testManager.lockScreenManager = lockScreenManagerMock; testManager.fileManager = fileManagerMock; |