Skip to content

Commit

Permalink
Fixes #1380
Browse files Browse the repository at this point in the history
* Add a lifecycle configuration option to disable/enable secondary transports
  • Loading branch information
joeljfischer committed Aug 12, 2019
1 parent 81e0c29 commit cce63e5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
14 changes: 14 additions & 0 deletions SmartDeviceLink/SDLLifecycleConfiguration.h
Expand Up @@ -19,6 +19,11 @@

NS_ASSUME_NONNULL_BEGIN

typedef NS_OPTIONS(NSUInteger, SDLSecondaryTransports) {
SDLSecondaryTransportsNone = 0,
SDLSecondaryTransportsTCP = 1 << 0
};

/**
* Configuration options for SDLManager
*/
Expand Down Expand Up @@ -178,6 +183,15 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (strong, nonatomic) SDLVersion *minimumRPCVersion;

/**
Which transports are permitted to be used as secondary transports. A secondary transport is a transport that is connected as an alternate, higher bandwidth transport for situations when a low-bandwidth primary transport (such as Bluetooth) will restrict certain features (such as video streaming navigation).
The only currently available secondary transport is TCP over WiFi. This is set to permit TCP by default, but it can be disabled by using SDLSecondaryTransportsNone instead.
This will only affect apps that have high-bandwidth requirements; currently that is only video streaming navigation apps.
*/
@property (assign, nonatomic) SDLSecondaryTransports allowedSecondaryTransports;

@end

NS_ASSUME_NONNULL_END
2 changes: 2 additions & 0 deletions SmartDeviceLink/SDLLifecycleConfiguration.m
Expand Up @@ -69,6 +69,7 @@ - (instancetype)initDefaultConfigurationWithAppName:(NSString *)appName fullAppI
_voiceRecognitionCommandNames = nil;
_minimumProtocolVersion = [SDLVersion versionWithString:@"1.0.0"];
_minimumRPCVersion = [SDLVersion versionWithString:@"1.0.0"];
_allowedSecondaryTransports = SDLSecondaryTransportsTCP;

_fullAppId = fullAppId;
_appId = fullAppId != nil ? [self.class sdlex_shortAppIdFromFullAppId:fullAppId] : appId;
Expand Down Expand Up @@ -156,6 +157,7 @@ - (id)copyWithZone:(nullable NSZone *)zone {
newConfig->_voiceRecognitionCommandNames = _voiceRecognitionCommandNames;
newConfig->_dayColorScheme = _dayColorScheme;
newConfig->_nightColorScheme = _nightColorScheme;
newConfig->_allowedSecondaryTransports = _allowedSecondaryTransports;

return newConfig;
}
Expand Down
13 changes: 6 additions & 7 deletions SmartDeviceLink/SDLLifecycleManager.m
Expand Up @@ -224,19 +224,18 @@ - (void)didEnterStateStarted {
// Start up the internal proxy object
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
self.secondaryTransportManager = nil;
if (self.configuration.lifecycleConfig.tcpDebugMode) {
// secondary transport manager is not used
self.secondaryTransportManager = nil;
self.proxy = [SDLProxy tcpProxyWithListener:self.notificationDispatcher
tcpIPAddress:self.configuration.lifecycleConfig.tcpDebugIPAddress
tcpPort:@(self.configuration.lifecycleConfig.tcpDebugPort).stringValue
secondaryTransportManager:self.secondaryTransportManager];
} else if (self.configuration.lifecycleConfig.allowedSecondaryTransports == SDLSecondaryTransportsNone) {
self.proxy = [SDLProxy iapProxyWithListener:self.notificationDispatcher secondaryTransportManager:nil];
} else {
// we reuse our queue to run secondary transport manager's state machine
self.secondaryTransportManager = [[SDLSecondaryTransportManager alloc] initWithStreamingProtocolDelegate:self
serialQueue:self.lifecycleQueue];
self.proxy = [SDLProxy iapProxyWithListener:self.notificationDispatcher
secondaryTransportManager:self.secondaryTransportManager];
// We reuse our queue to run secondary transport manager's state machine
self.secondaryTransportManager = [[SDLSecondaryTransportManager alloc] initWithStreamingProtocolDelegate:self serialQueue:self.lifecycleQueue];
self.proxy = [SDLProxy iapProxyWithListener:self.notificationDispatcher secondaryTransportManager:self.secondaryTransportManager];
}
#pragma clang diagnostic pop
}
Expand Down
22 changes: 22 additions & 0 deletions SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
Expand Up @@ -668,6 +668,28 @@ @interface SDLLifecycleManager ()
});
});

describe(@"configuring the lifecycle manager", ^{
__block SDLLifecycleConfiguration *lifecycleConfig = nil;
__block SDLLifecycleManager *testManager = nil;

beforeEach(^{
lifecycleConfig = [SDLLifecycleConfiguration defaultConfigurationWithAppName:@"Test app" fullAppId:@"Test ID"];
});

context(@"if no secondary transport is allowed", ^{
beforeEach(^{
lifecycleConfig.allowedSecondaryTransports = SDLSecondaryTransportsNone;

SDLConfiguration *config = [[SDLConfiguration alloc] initWithLifecycle:lifecycleConfig lockScreen:nil logging:nil fileManager:nil];
testManager = [[SDLLifecycleManager alloc] initWithConfiguration:config delegate:nil];
});

it(@"should not create a secondary transport manager", ^{
expect(testManager.secondaryTransportManager).to(beNil());
});
});
});

QuickSpecEnd

#pragma clang diagnostic pop

0 comments on commit cce63e5

Please sign in to comment.