Skip to content

Commit

Permalink
Merge branch 'develop' into feature/smartdevicelink#1163/rpc_message_…
Browse files Browse the repository at this point in the history
…protection
  • Loading branch information
SatbirTanda committed Aug 16, 2019
2 parents c2523d1 + ce4ef80 commit 5560c74
Show file tree
Hide file tree
Showing 22 changed files with 283 additions and 41 deletions.
16 changes: 16 additions & 0 deletions Example Apps/Example ObjC/MenuManager.m
Expand Up @@ -23,6 +23,8 @@ @implementation MenuManager
return @[[self sdlex_menuCellSpeakNameWithManager:manager],
[self sdlex_menuCellGetAllVehicleDataWithManager:manager],
[self sdlex_menuCellShowPerformInteractionWithManager:manager performManager:performManager],
[self sdlex_sliderMenuCellWithManager:manager],
[self sdlex_scrollableMessageMenuCellWithManager:manager],
[self sdlex_menuCellRecordInCarMicrophoneAudioWithManager:manager],
[self sdlex_menuCellDialNumberWithManager:manager],
[self sdlex_menuCellChangeTemplateWithManager:manager],
Expand Down Expand Up @@ -130,6 +132,20 @@ + (SDLMenuCell *)sdlex_menuCellWithSubmenuWithManager:(SDLManager *)manager {
return [[SDLMenuCell alloc] initWithTitle:ACSubmenuMenuName icon:[SDLArtwork artworkWithImage:[[UIImage imageNamed:MenuBWIconImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] asImageFormat:SDLArtworkImageFormatPNG] subCells:[submenuItems copy]];
}

+ (SDLMenuCell *)sdlex_sliderMenuCellWithManager:(SDLManager *)manager {
return [[SDLMenuCell alloc] initWithTitle:ACSliderMenuName icon:nil voiceCommands:@[ACSliderMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) {
SDLSlider *sliderRPC = [[SDLSlider alloc] initWithNumTicks:3 position:1 sliderHeader:@"Select a letter" sliderFooters:@[@"A", @"B", @"C"] timeout:10000];
[manager sendRequest:sliderRPC];
}];
}

+ (SDLMenuCell *)sdlex_scrollableMessageMenuCellWithManager:(SDLManager *)manager {
return [[SDLMenuCell alloc] initWithTitle:ACScrollableMessageMenuName icon:nil voiceCommands:@[ACScrollableMessageMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) {
SDLScrollableMessage *messageRPC = [[SDLScrollableMessage alloc] initWithMessage:@"This is a scrollable message\nIt can contain many lines" timeout:10000 softButtons:nil];
[manager sendRequest:messageRPC];
}];
}

#pragma mark - Voice Commands

+ (SDLVoiceCommand *)sdlex_voiceCommandStartWithManager:(SDLManager *)manager {
Expand Down
16 changes: 16 additions & 0 deletions Example Apps/Example Swift/MenuManager.swift
Expand Up @@ -19,6 +19,8 @@ class MenuManager: NSObject {
return [menuCellSpeakName(with: manager),
menuCellGetAllVehicleData(with: manager),
menuCellShowPerformInteraction(with: manager, choiceSetManager: choiceSetManager),
sliderMenuCell(with: manager),
scrollableMessageMenuCell(with: manager),
menuCellRecordInCarMicrophoneAudio(with: manager),
menuCellDialNumber(with: manager),
menuCellChangeTemplate(with: manager),
Expand Down Expand Up @@ -174,6 +176,20 @@ private extension MenuManager {

return SDLMenuCell(title: ACSubmenuMenuName, icon: SDLArtwork(image: #imageLiteral(resourceName: "choice_set").withRenderingMode(.alwaysTemplate), persistent: true, as: .PNG), subCells: submenuItems)
}

private class func sliderMenuCell(with manager: SDLManager) -> SDLMenuCell {
return SDLMenuCell(title: ACSliderMenuName, icon: nil, voiceCommands: [ACSliderMenuName], handler: { _ in
let slider = SDLSlider(numTicks: 3, position: 1, sliderHeader: "Select a letter", sliderFooters: ["A", "B", "C"], timeout: 10000)
manager.send(slider)
})
}

private class func scrollableMessageMenuCell(with manager: SDLManager) -> SDLMenuCell {
return SDLMenuCell(title: ACScrollableMessageMenuName, icon: nil, voiceCommands: [ACScrollableMessageMenuName], handler: { _ in
let scrollableMessage = SDLScrollableMessage(message: "This is a scrollable message\nIt can contain many lines", timeout: 10000, softButtons: nil)
manager.send(scrollableMessage)
})
}
}

// MARK: - Menu Voice Commands
Expand Down
2 changes: 2 additions & 0 deletions Example Apps/Shared/AppConstants.h
Expand Up @@ -79,6 +79,8 @@ extern NSString * const ACDialPhoneNumberMenuName;
extern NSString * const ACSubmenuMenuName;
extern NSString * const ACSubmenuItemMenuName;
extern NSString * const ACSubmenuTemplateMenuName;
extern NSString * const ACSliderMenuName;
extern NSString * const ACScrollableMessageMenuName;

extern NSString * const ACAccelerationPedalPositionMenuName;
extern NSString * const ACAirbagStatusMenuName;
Expand Down
2 changes: 2 additions & 0 deletions Example Apps/Shared/AppConstants.m
Expand Up @@ -76,6 +76,8 @@
NSString * const ACSubmenuMenuName = @"Submenu";
NSString * const ACSubmenuItemMenuName = @"Item";
NSString * const ACSubmenuTemplateMenuName = @"Change Template";
NSString * const ACSliderMenuName = @"Show Slider";
NSString * const ACScrollableMessageMenuName = @"Show Scrollable Message";

NSString * const ACAccelerationPedalPositionMenuName = @"Acceleration Pedal Position";
NSString * const ACAirbagStatusMenuName = @"Airbag Status";
Expand Down
6 changes: 3 additions & 3 deletions SmartDeviceLink/SDLDisplayCapabilities.h
Expand Up @@ -75,11 +75,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) NSNumber<SDLBool> *graphicSupported;

/**
* Number of presets the screen supports
* An array of all predefined persistent display templates available on the head unit.
*
* @discussion The number of on-screen custom presets available (if any)
* Optional, Array of String, max string size 100, 0 - 100 objects, since SDL 3.0
*
* Optional, Array of String, max string size 100, 0 - 100 objects
* See SDLPredefinedLayout
*/
@property (nullable, strong, nonatomic) NSArray<NSString *> *templatesAvailable;

Expand Down
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
15 changes: 7 additions & 8 deletions SmartDeviceLink/SDLLifecycleManager.m
Expand Up @@ -231,21 +231,20 @@ - (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
encryptionLifecycleManager:self.encryptionLifecycleManager];
secondaryTransportManager:self.secondaryTransportManager];
} else if (self.configuration.lifecycleConfig.allowedSecondaryTransports == SDLSecondaryTransportsNone) {
self.proxy = [SDLProxy iapProxyWithListener:self.notificationDispatcher secondaryTransportManager:nil encryptionLifecycleManager:self.encryptionLifecycleManager];
} 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
encryptionLifecycleManager:self.encryptionLifecycleManager];
// 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 encryptionLifecycleManager:self.encryptionLifecycleManager];
}
#pragma clang diagnostic pop
}
Expand Down
17 changes: 14 additions & 3 deletions SmartDeviceLink/SDLLockScreenConfiguration.h
Expand Up @@ -14,9 +14,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface SDLLockScreenConfiguration : NSObject <NSCopying>

/**
* Whether or not the lock screen should be shown in the "lock screen optional" state. Defaults to false.
* Whether or not the lock screen should be shown in the "lock screen optional" state. Defaults to NO.
*
* @discussion In order for the "lock screen optional" state to occur, the following must be true:
* In order for the "lock screen optional" state to occur, the following must be true:
* 1. The app should have received at least 1 driver distraction notification (i.e. a `OnDriverDistraction` notification) from SDL Core. Older versions of Core did not send a notification immediately on connection.
* 2. The driver is not distracted (i.e. the last `OnDriverDistraction` notification received was for a driver distraction state off).
* 3. The `hmiLevel` can not be `NONE`.
Expand All @@ -25,7 +25,18 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) BOOL showInOptionalState;

/**
* If YES, the lock screen should be managed by SDL and automatically engage when necessary. If NO, then the lock screen will never be engaged.
If YES, then the lock screen can be dismissed with a downward swipe on compatible head units. Requires a connection of SDL 6.0+ and the head unit to enable the feature. Defaults to YES.
*/
@property (assign, nonatomic) BOOL enableDismissGesture;

/**
* If YES, then the lockscreen will show the vehicle's logo if the vehicle has made it available. If NO, then the lockscreen will not show the vehicle logo.
Defaults to YES.
*/
@property (assign, nonatomic) BOOL showDeviceLogo;

/**
* If YES, the lock screen should be managed by SDL and automatically engage when necessary. If NO, then the lock screen will never be engaged. Defaults to YES.
*/
@property (assign, nonatomic, readonly) BOOL enableAutomaticLockScreen;

Expand Down
18 changes: 8 additions & 10 deletions SmartDeviceLink/SDLLockScreenConfiguration.m
Expand Up @@ -20,39 +20,41 @@ @implementation SDLLockScreenConfiguration

#pragma mark - Lifecycle

- (instancetype)initWithAutoLockScreen:(BOOL)enableAutomatic enableInOptional:(BOOL)enableOptional backgroundColor:(UIColor *)backgroundColor appIcon:(nullable UIImage *)appIcon viewController:(nullable UIViewController *)customViewController {
- (instancetype)initWithAutoLockScreen:(BOOL)enableAutomatic enableInOptional:(BOOL)enableOptional enableDismissGesture:(BOOL)enableDismissGesture showDeviceLogo:(BOOL)showDeviceLogo backgroundColor:(UIColor *)backgroundColor appIcon:(nullable UIImage *)appIcon viewController:(nullable UIViewController *)customViewController {
self = [super init];
if (!self) {
return nil;
}

_enableAutomaticLockScreen = enableAutomatic;
_showInOptionalState = enableOptional;
_enableDismissGesture = enableDismissGesture;
_backgroundColor = backgroundColor;
_appIcon = appIcon;
_customViewController = customViewController;
_showDeviceLogo = showDeviceLogo;

return self;
}

+ (instancetype)disabledConfiguration {
return [[self alloc] initWithAutoLockScreen:NO enableInOptional:NO backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil];
return [[self alloc] initWithAutoLockScreen:NO enableInOptional:NO enableDismissGesture:NO showDeviceLogo:NO backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil];
}

+ (instancetype)enabledConfiguration {
return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil];
return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES showDeviceLogo:YES backgroundColor:[self sdl_defaultBackgroundColor] appIcon:nil viewController:nil];
}

+ (instancetype)enabledConfigurationWithAppIcon:(UIImage *)lockScreenAppIcon backgroundColor:(nullable UIColor *)lockScreenBackgroundColor {
if (lockScreenBackgroundColor == nil) {
lockScreenBackgroundColor = [self.class sdl_defaultBackgroundColor];
}

return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO backgroundColor:lockScreenBackgroundColor appIcon:lockScreenAppIcon viewController:nil];
return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES showDeviceLogo:YES backgroundColor:lockScreenBackgroundColor appIcon:lockScreenAppIcon viewController:nil];
}

+ (instancetype)enabledConfigurationWithViewController:(UIViewController *)viewController {
return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO backgroundColor:[self.class sdl_defaultBackgroundColor] appIcon:nil viewController:viewController];
return [[self alloc] initWithAutoLockScreen:YES enableInOptional:NO enableDismissGesture:YES showDeviceLogo:YES backgroundColor:[self.class sdl_defaultBackgroundColor] appIcon:nil viewController:viewController];
}


Expand All @@ -66,11 +68,7 @@ + (UIColor *)sdl_defaultBackgroundColor {
#pragma mark - NSCopying

- (id)copyWithZone:(nullable NSZone *)zone {
SDLLockScreenConfiguration *new = [[SDLLockScreenConfiguration allocWithZone:zone] initWithAutoLockScreen : _enableAutomaticLockScreen
enableInOptional : _showInOptionalState
backgroundColor : _backgroundColor
appIcon : _appIcon
viewController : _customViewController];
SDLLockScreenConfiguration *new = [[SDLLockScreenConfiguration allocWithZone:zone] initWithAutoLockScreen:_enableAutomaticLockScreen enableInOptional:_showInOptionalState enableDismissGesture:_enableDismissGesture showDeviceLogo:_showDeviceLogo backgroundColor:_backgroundColor appIcon:_appIcon viewController:_customViewController];

return new;
}
Expand Down
5 changes: 3 additions & 2 deletions SmartDeviceLink/SDLLockScreenManager.m
Expand Up @@ -126,7 +126,7 @@ - (void)sdl_lockScreenIconReceived:(NSNotification *)notification {
UIImage *icon = notification.userInfo[SDLNotificationUserInfoObject];

// If the VC is our special type, then add the vehicle icon. If they passed in a custom VC, there's no current way to show the vehicle icon. If they're managing it themselves, they can grab the notification themselves.
if ([self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]]) {
if ([self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]] && self.config.showDeviceLogo) {
((SDLLockScreenViewController *)self.lockScreenViewController).vehicleIcon = icon;
}
}
Expand Down Expand Up @@ -172,7 +172,8 @@ - (void)sdl_checkLockScreen {
- (void)sdl_updateLockScreenDismissable {
if (self.lastDriverDistractionNotification == nil ||
self.lastDriverDistractionNotification.lockScreenDismissalEnabled == nil ||
!self.lastDriverDistractionNotification.lockScreenDismissalEnabled.boolValue) {
!self.lastDriverDistractionNotification.lockScreenDismissalEnabled.boolValue ||
!self.config.enableDismissGesture) {
self.lockScreenDismissable = NO;
} else {
self.lockScreenDismissable = YES;
Expand Down
15 changes: 14 additions & 1 deletion SmartDeviceLink/SDLSoftButtonObject.h
Expand Up @@ -10,6 +10,7 @@

#import "SDLNotificationConstants.h"

@class SDLArtwork;
@class SDLSoftButton;
@class SDLSoftButtonObject;
@class SDLSoftButtonState;
Expand Down Expand Up @@ -58,11 +59,23 @@ NS_ASSUME_NONNULL_BEGIN
Create a single-state soft button. For example, a button that brings up a Perform Interaction menu.
@param name The name of the button
@param eventHandler The handler to be called when the button is in the current state and is pressed
@param state The single state of the button
@param eventHandler The handler to be called when the button is pressed
@return The button object
*/
- (instancetype)initWithName:(NSString *)name state:(SDLSoftButtonState *)state handler:(nullable SDLRPCButtonNotificationHandler)eventHandler;

/**
Create a single-state soft button. For example, a button that brings up a Perform Interaction menu.
@param name The name of the button
@param text The text to be displayed on the button
@param artwork The artwork to be displayed on the button
@param eventHandler The handler to be called when the button is pressed
@return The button object
*/
- (instancetype)initWithName:(NSString *)name text:(nullable NSString *)text artwork:(nullable SDLArtwork *)artwork handler:(nullable SDLRPCButtonNotificationHandler)eventHandler;

/**
Transition the soft button to another state in the `states` property. The wrapper considers all transitions valid (assuming a state with that name exists).
Expand Down
10 changes: 10 additions & 0 deletions SmartDeviceLink/SDLSoftButtonObject.m
Expand Up @@ -53,12 +53,22 @@ - (instancetype)initWithName:(NSString *)name state:(SDLSoftButtonState *)state
return [self initWithName:name states:@[state] initialStateName:state.name handler:eventHandler];
}

- (instancetype)initWithName:(NSString *)name text:(nullable NSString *)text artwork:(nullable SDLArtwork *)artwork handler:(nullable SDLRPCButtonNotificationHandler)eventHandler {
SDLSoftButtonState *implicitState = [[SDLSoftButtonState alloc] initWithStateName:name text:text artwork:artwork];
return [self initWithName:name state:implicitState handler:eventHandler];
}

- (BOOL)transitionToStateNamed:(NSString *)stateName {
if ([self stateWithName:stateName] == nil) {
SDLLogE(@"Attempted to transition to state: %@ on soft button: %@ but no state with that name was found", stateName, self.name);
return NO;
}

if (self.states.count == 1) {
SDLLogW(@"There's only one state, so no transitioning is possible!");
return NO;
}

SDLLogD(@"Transitioning button %@ to state %@", self.name, stateName);
self.currentStateName = stateName;
[self.manager sdl_transitionSoftButton:self];
Expand Down
5 changes: 5 additions & 0 deletions SmartDeviceLink/SDLStreamingMediaManager.h
Expand Up @@ -109,6 +109,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (assign, nonatomic) SDLStreamingEncryptionFlag requestedEncryptionType;

/**
When YES, the StreamingMediaManager will send a black screen with "Video Backgrounded String". Defaults to YES.
*/
@property (assign, nonatomic) BOOL showVideoBackgroundDisplay;

- (instancetype)init NS_UNAVAILABLE;

/**
Expand Down

0 comments on commit 5560c74

Please sign in to comment.