Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration Option for Secondary Transports #1381

Merged
merged 1 commit into from Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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