summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Gluck <justin.gluck@livio.io>2019-12-09 15:18:12 -0500
committerJustin Gluck <justin.gluck@livio.io>2019-12-09 15:18:12 -0500
commit3a0bc7652f7cd84c8b8a294394439c32a5bd8c76 (patch)
tree83d87241b88a4f3c2f8c54c2aa523b9663237d16
parent1cfa262288d751a6cf2f888edf1279bb1515db64 (diff)
downloadsdl_ios-3a0bc7652f7cd84c8b8a294394439c32a5bd8c76.tar.gz
making sure app is in ready state before connecting so security managers can be set
-rw-r--r--SmartDeviceLink/SDLSecondaryTransportManager.m15
-rw-r--r--SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m5
2 files changed, 16 insertions, 4 deletions
diff --git a/SmartDeviceLink/SDLSecondaryTransportManager.m b/SmartDeviceLink/SDLSecondaryTransportManager.m
index b9fbfee5d..b6fc75ef7 100644
--- a/SmartDeviceLink/SDLSecondaryTransportManager.m
+++ b/SmartDeviceLink/SDLSecondaryTransportManager.m
@@ -95,6 +95,8 @@ static const int TCPPortUnspecified = -1;
@property (strong, nonatomic, nullable) NSString *ipAddress;
// TCP port number of SDL Core. If the information isn't available then TCPPortUnspecified is stored.
@property (assign, nonatomic) int tcpPort;
+// App is ready to set security manager to secondary protocol
+@property (assign, nonatomic) BOOL isAppReady;
@end
@@ -120,8 +122,7 @@ static const int TCPPortUnspecified = -1;
@(SDLServiceTypeVideo):@(SDLTransportClassInvalid)} mutableCopy];
_tcpPort = TCPPortUnspecified;
- // Listen for Security Manager set event and update the security manager
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(securityManagerWasSet) name:SDLSecurityManagerSet object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeReady) name:SDLDidBecomeReady object:nil];
return self;
}
@@ -228,7 +229,7 @@ static const int TCPPortUnspecified = -1;
}
- (void)didEnterStateConfigured {
- if ((self.secondaryTransportType == SDLSecondaryTransportTypeTCP && [self sdl_isTCPReady])
+ if ((self.secondaryTransportType == SDLSecondaryTransportTypeTCP && [self sdl_isTCPReady] && self.isAppReady)
|| self.secondaryTransportType == SDLSecondaryTransportTypeIAP) {
[self.stateMachine transitionToState:SDLSecondaryTransportStateConnecting];
}
@@ -356,6 +357,7 @@ static const int TCPPortUnspecified = -1;
// this will trigger audio / video streaming if they are allowed on primary transport
[self sdl_handleTransportUpdateWithPrimaryAvailable:YES secondaryAvailable:NO];
+ self.isAppReady = true;
[self.stateMachine transitionToState:SDLSecondaryTransportStateConfigured];
}
@@ -511,6 +513,7 @@ static const int TCPPortUnspecified = -1;
transport.delegate = protocol;
protocol.transport = transport;
[protocol.protocolDelegateTable addObject:self];
+ protocol.securityManager = self.primaryProtocol.securityManager;
self.secondaryProtocol = protocol;
self.secondaryTransport = transport;
@@ -533,6 +536,7 @@ static const int TCPPortUnspecified = -1;
transport.delegate = protocol;
protocol.transport = transport;
[protocol.protocolDelegateTable addObject:self];
+ protocol.securityManager = self.primaryProtocol.securityManager;
self.secondaryProtocol = protocol;
self.secondaryTransport = transport;
@@ -709,8 +713,11 @@ static const int TCPPortUnspecified = -1;
}
}
-- (void)securityManagerWasSet {
+- (void)appDidBecomeReady {
self.secondaryProtocol.securityManager = self.primaryProtocol.securityManager;
+ if ([self.stateMachine.currentState isEqualToString:SDLSecondaryTransportStateConfigured]) {
+ [self.stateMachine transitionToState:SDLSecondaryTransportStateConnecting];
+ }
}
@end
diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m
index acc14b3c5..caf9ac048 100644
--- a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m
+++ b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m
@@ -52,6 +52,8 @@ static const int TCPPortUnspecified = -1;
@property (strong, nonatomic) NSMutableDictionary<SDLServiceTypeBox *, SDLTransportClassBox *> *streamingServiceTransportMap;
@property (strong, nonatomic, nullable) NSString *ipAddress;
@property (assign, nonatomic) int tcpPort;
+@property (assign, nonatomic) BOOL isAppReady;
+
@end
@@ -700,6 +702,7 @@ describe(@"the secondary transport manager ", ^{
manager.secondaryTransportType = SDLTransportSelectionTCP;
manager.ipAddress = @"192.168.1.1";
manager.tcpPort = 12345;
+ manager.isAppReady = true;
testTransportEventUpdateHeader = [SDLProtocolHeader headerForVersion:5];
testTransportEventUpdateHeader.frameType = SDLFrameTypeControl;
@@ -816,6 +819,7 @@ describe(@"the secondary transport manager ", ^{
manager.secondaryTransportType = SDLTransportSelectionTCP;
manager.ipAddress = @"192.168.1.1";
manager.tcpPort = 12345;
+ manager.isAppReady = true;
testTransportEventUpdateHeader = [SDLProtocolHeader headerForVersion:5];
testTransportEventUpdateHeader.frameType = SDLFrameTypeControl;
@@ -974,6 +978,7 @@ describe(@"the secondary transport manager ", ^{
manager.secondaryTransportType = SDLTransportSelectionTCP;
manager.ipAddress = @"192.168.1.1";
manager.tcpPort = 12345;
+ manager.isAppReady = true;
testTransportEventUpdateHeader = [SDLProtocolHeader headerForVersion:5];
testTransportEventUpdateHeader.frameType = SDLFrameTypeControl;