summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-08-01 11:21:51 -0400
committerGitHub <noreply@github.com>2019-08-01 11:21:51 -0400
commit2cfac60d47843502b819f345d5202ea1893c48b2 (patch)
tree696971bc6c2b0653c800aa3058c0713decc86368
parent105de90eef357d4602c37c075193bc91627696f4 (diff)
parentce10b67322e75ad31c84fda4661a77d657387657 (diff)
downloadsdl_ios-2cfac60d47843502b819f345d5202ea1893c48b2.tar.gz
Merge pull request #1296 from SatbirTanda/feature/119/passenger_mode
Implement SDL-0119 - SDL Passenger Mode
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.h5
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.m72
-rw-r--r--SmartDeviceLink/SDLLockScreenStatus.h2
-rw-r--r--SmartDeviceLink/SDLLockScreenStatusManager.h3
-rw-r--r--SmartDeviceLink/SDLLockScreenStatusManager.m3
-rw-r--r--SmartDeviceLink/SDLLockScreenViewController.h19
-rw-r--r--SmartDeviceLink/SDLLockScreenViewController.m37
-rw-r--r--SmartDeviceLink/SDLOnDriverDistraction.h14
-rw-r--r--SmartDeviceLink/SDLOnDriverDistraction.m18
-rw-r--r--SmartDeviceLink/SDLOnLockScreenStatus.h1
-rw-r--r--SmartDeviceLink/SDLOnLockScreenStatus.m3
-rw-r--r--SmartDeviceLink/SDLProxyListener.h3
-rw-r--r--SmartDeviceLink/SDLRPCParameterNames.h2
-rw-r--r--SmartDeviceLink/SDLRPCParameterNames.m2
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m82
-rw-r--r--SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m4
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m34
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m10
18 files changed, 295 insertions, 19 deletions
diff --git a/SmartDeviceLink/SDLLockScreenManager.h b/SmartDeviceLink/SDLLockScreenManager.h
index f709c53ee..a63e42234 100644
--- a/SmartDeviceLink/SDLLockScreenManager.h
+++ b/SmartDeviceLink/SDLLockScreenManager.h
@@ -23,6 +23,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic, readonly) BOOL lockScreenPresented;
/**
+ * Whether or not the lock screen is currently dismissable
+ */
+@property (assign, nonatomic, readonly, getter=isLockScreenDismissable) BOOL lockScreenDismissable;
+
+/**
* The lock screen configuration used to set up the manager
*/
@property (strong, nonatomic, readonly) SDLLockScreenConfiguration *config;
diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m
index a8c8c3758..0ffba3f7c 100644
--- a/SmartDeviceLink/SDLLockScreenManager.m
+++ b/SmartDeviceLink/SDLLockScreenManager.m
@@ -15,6 +15,7 @@
#import "SDLLockScreenViewController.h"
#import "SDLNotificationConstants.h"
#import "SDLOnLockScreenStatus.h"
+#import "SDLOnDriverDistraction.h"
#import "SDLRPCNotificationNotification.h"
#import "SDLScreenshotViewController.h"
#import "SDLViewControllerPresentable.h"
@@ -27,7 +28,15 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) BOOL canPresent;
@property (strong, nonatomic, readwrite) SDLLockScreenConfiguration *config;
@property (strong, nonatomic) id<SDLViewControllerPresentable> presenter;
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property (strong, nonatomic, nullable) SDLOnLockScreenStatus *lastLockNotification;
+#pragma clang diagnostic pop
+
+@property (strong, nonatomic, nullable) SDLOnDriverDistraction *lastDriverDistractionNotification;
+@property (assign, nonatomic, readwrite, getter=isLockScreenDismissable) BOOL lockScreenDismissable;
+@property (assign, nonatomic) BOOL lockScreenDismissedByUser;
@end
@@ -41,12 +50,15 @@ NS_ASSUME_NONNULL_BEGIN
}
_canPresent = NO;
+ _lockScreenDismissable = NO;
_config = config;
_presenter = presenter;
-
+ _lockScreenDismissedByUser = NO;
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenStatusDidChange:) name:SDLDidChangeLockScreenStatusNotification object:dispatcher];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenIconReceived:) name:SDLDidReceiveLockScreenIcon object:dispatcher];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_driverDistractionStateDidChange:) name:SDLDidChangeDriverDistractionStateNotification object:dispatcher];
return self;
}
@@ -91,11 +103,13 @@ NS_ASSUME_NONNULL_BEGIN
return self.presenter.lockViewController;
}
-
#pragma mark - Notification Selectors
- (void)sdl_lockScreenStatusDidChange:(SDLRPCNotificationNotification *)notification {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (![notification isNotificationMemberOfClass:[SDLOnLockScreenStatus class]]) {
+#pragma clang diagnostic pop
return;
}
@@ -121,6 +135,14 @@ NS_ASSUME_NONNULL_BEGIN
[self sdl_checkLockScreen];
}
+- (void)sdl_driverDistractionStateDidChange:(SDLRPCNotificationNotification *)notification {
+ if (![notification isNotificationMemberOfClass:[SDLOnDriverDistraction class]]) {
+ return;
+ }
+
+ self.lastDriverDistractionNotification = notification.notification;
+ [self sdl_updateLockScreenDismissable];
+}
#pragma mark - Private Helpers
@@ -131,11 +153,11 @@ NS_ASSUME_NONNULL_BEGIN
// Present the VC depending on the lock screen status
if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusRequired]) {
- if (!self.presenter.presented && self.canPresent) {
+ if (!self.presenter.presented && self.canPresent && !self.lockScreenDismissedByUser) {
[self.presenter present];
}
} else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOptional]) {
- if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent) {
+ if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent && !self.lockScreenDismissedByUser) {
[self.presenter present];
} else if (!self.config.showInOptionalState && self.presenter.presented) {
[self.presenter dismiss];
@@ -147,6 +169,48 @@ NS_ASSUME_NONNULL_BEGIN
}
}
+- (void)sdl_updateLockScreenDismissable {
+ if (self.lastDriverDistractionNotification == nil ||
+ self.lastDriverDistractionNotification.lockScreenDismissalEnabled == nil ||
+ !self.lastDriverDistractionNotification.lockScreenDismissalEnabled.boolValue) {
+ self.lockScreenDismissable = NO;
+ } else {
+ self.lockScreenDismissable = YES;
+ }
+
+ if (self.lockScreenDismissedByUser &&
+ [self.lastDriverDistractionNotification.state isEqualToEnum:SDLDriverDistractionStateOn] &&
+ !self.lockScreenDismissable) {
+ self.lockScreenDismissedByUser = NO;
+ }
+
+ if (!self.lockScreenDismissedByUser) {
+ [self sdl_updateLockscreenViewControllerWithDismissableState:self.lockScreenDismissable];
+ }
+}
+
+- (void)sdl_updateLockscreenViewControllerWithDismissableState:(BOOL)enabled {
+ if (![self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]]) {
+ return;
+ }
+
+ __weak typeof(self) weakself = self;
+ dispatch_async(dispatch_get_main_queue(), ^{
+ __strong typeof(self) strongSelf = weakself;
+ SDLLockScreenViewController *lockscreenViewController = (SDLLockScreenViewController *)strongSelf.lockScreenViewController;
+ if (enabled) {
+ [lockscreenViewController addDismissGestureWithCallback:^{
+ [strongSelf.presenter dismiss];
+ strongSelf.lockScreenDismissedByUser = YES;
+ }];
+ lockscreenViewController.lockedLabelText = strongSelf.lastDriverDistractionNotification.lockScreenDismissalWarning;
+ } else {
+ [lockscreenViewController removeDismissGesture];
+ lockscreenViewController.lockedLabelText = nil;
+ }
+ });
+}
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLLockScreenStatus.h b/SmartDeviceLink/SDLLockScreenStatus.h
index 9926852c9..62f48ba05 100644
--- a/SmartDeviceLink/SDLLockScreenStatus.h
+++ b/SmartDeviceLink/SDLLockScreenStatus.h
@@ -24,6 +24,6 @@ extern SDLLockScreenStatus const SDLLockScreenStatusOff;
extern SDLLockScreenStatus const SDLLockScreenStatusOptional;
/**
- * LockScreen is Not Required
+ * LockScreen is Required
*/
extern SDLLockScreenStatus const SDLLockScreenStatusRequired;
diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.h b/SmartDeviceLink/SDLLockScreenStatusManager.h
index 2a37b9d83..90b3d85a3 100644
--- a/SmartDeviceLink/SDLLockScreenStatusManager.h
+++ b/SmartDeviceLink/SDLLockScreenStatusManager.h
@@ -18,7 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) BOOL driverDistracted;
@property (nullable, strong, nonatomic) SDLHMILevel hmiLevel;
@property (strong, nonatomic, readonly) SDLLockScreenStatus lockScreenStatus;
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property (strong, nonatomic, readonly) SDLOnLockScreenStatus *lockScreenStatusNotification;
+#pragma clang diagnostic pop
@end
diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.m b/SmartDeviceLink/SDLLockScreenStatusManager.m
index 82724eb6f..4ab22faa4 100644
--- a/SmartDeviceLink/SDLLockScreenStatusManager.m
+++ b/SmartDeviceLink/SDLLockScreenStatusManager.m
@@ -55,8 +55,11 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark Custom Getters
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (SDLOnLockScreenStatus *)lockScreenStatusNotification {
SDLOnLockScreenStatus *notification = [[SDLOnLockScreenStatus alloc] init];
+#pragma clang diagnostic pop
notification.driverDistractionStatus = @(self.driverDistracted);
notification.hmiLevel = self.hmiLevel;
notification.userSelected = @(self.userSelected);
diff --git a/SmartDeviceLink/SDLLockScreenViewController.h b/SmartDeviceLink/SDLLockScreenViewController.h
index d340db61a..2b19537b5 100644
--- a/SmartDeviceLink/SDLLockScreenViewController.h
+++ b/SmartDeviceLink/SDLLockScreenViewController.h
@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface SDLLockScreenViewController : UIViewController
+typedef void (^SwipeGestureCallbackBlock)(void);
+
/**
* The app's icon. This will be set by the lock screen configuration.
*/
@@ -27,6 +29,21 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (copy, nonatomic, nullable) UIColor *backgroundColor;
+/**
+ * The locked label string. This will be set by the lock screen manager to inform the user about the dismissable state.
+ */
+@property (copy, nonatomic, nullable) NSString *lockedLabelText;
+
+/**
+ * Adds a swipe gesture to the lock screen view controller.
+ */
+- (void)addDismissGestureWithCallback:(SwipeGestureCallbackBlock)swipeGestureCallback;
+
+/**
+ * Remove swipe gesture to the lock screen view controller.
+ */
+- (void)removeDismissGesture;
+
@end
-NS_ASSUME_NONNULL_END \ No newline at end of file
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLLockScreenViewController.m b/SmartDeviceLink/SDLLockScreenViewController.m
index 291913aaa..9c5a14c99 100644
--- a/SmartDeviceLink/SDLLockScreenViewController.m
+++ b/SmartDeviceLink/SDLLockScreenViewController.m
@@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (weak, nonatomic) IBOutlet UILabel *lockedLabel;
@property (weak, nonatomic) IBOutlet UIImageView *arrowUpImageView;
@property (weak, nonatomic) IBOutlet UIImageView *arrowDownImageView;
+@property (strong, nonatomic) SwipeGestureCallbackBlock dismissGestureCallback;
+@property (strong, nonatomic, nullable) UISwipeGestureRecognizer *swipeGesture;
@end
@@ -49,7 +51,6 @@ NS_ASSUME_NONNULL_BEGIN
return useWhiteIcon ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault;
}
-
#pragma mark - Setters
- (void)setAppIcon:(UIImage *_Nullable)appIcon {
@@ -70,6 +71,31 @@ NS_ASSUME_NONNULL_BEGIN
[self sdl_layoutViews];
}
+- (void)setLockedLabelText:(NSString *_Nullable)lockedLabelText {
+ _lockedLabelText = lockedLabelText;
+
+ [self sdl_layoutViews];
+}
+
+#pragma mark - Swipe Gesture
+
+- (void)addDismissGestureWithCallback:(SwipeGestureCallbackBlock)swipeGestureCallback {
+ if (!self.swipeGesture) {
+ self.dismissGestureCallback = swipeGestureCallback;
+ self.swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(sdl_didSwipeToDismiss:)];
+ [self.swipeGesture setDirection: UISwipeGestureRecognizerDirectionDown];
+ [self.view addGestureRecognizer:self.swipeGesture];
+ }
+}
+
+- (void)removeDismissGesture {
+ [self.view removeGestureRecognizer:self.swipeGesture];
+ self.swipeGesture = nil;
+}
+
+- (void)sdl_didSwipeToDismiss:(UISwipeGestureRecognizer *)gesture {
+ self.dismissGestureCallback();
+}
#pragma mark - Layout
@@ -87,7 +113,14 @@ NS_ASSUME_NONNULL_BEGIN
self.arrowDownImageView.tintColor = iconColor;
self.lockedLabel.textColor = iconColor;
-
+ self.lockedLabel.numberOfLines = 0;
+
+ if (self.lockedLabelText != nil) {
+ self.lockedLabel.text = self.lockedLabelText;
+ } else {
+ self.lockedLabel.text = NSLocalizedString(@"Locked for your safety", nil);
+ }
+
self.view.backgroundColor = self.backgroundColor;
if (self.vehicleIcon != nil && self.appIcon != nil) {
diff --git a/SmartDeviceLink/SDLOnDriverDistraction.h b/SmartDeviceLink/SDLOnDriverDistraction.h
index d7f369348..f7df06bd8 100644
--- a/SmartDeviceLink/SDLOnDriverDistraction.h
+++ b/SmartDeviceLink/SDLOnDriverDistraction.h
@@ -28,6 +28,20 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (strong, nonatomic) SDLDriverDistractionState state;
+/**
+ If enabled, the lock screen will be able to be dismissed while connected to SDL, allowing users the ability to interact with the app.
+
+ Optional, Boolean
+ */
+@property (strong, nonatomic) NSNumber<SDLBool> *lockScreenDismissalEnabled;
+
+/**
+ Warning message to be displayed on the lock screen when dismissal is enabled. This warning should be used to ensure that the user is not the driver of the vehicle, ex. `Swipe up to dismiss, acknowledging that you are not the driver.`. This parameter must be present if "lockScreenDismissalEnabled" is set to true.
+
+ Optional, String
+ */
+@property (strong, nonatomic) NSString *lockScreenDismissalWarning;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLOnDriverDistraction.m b/SmartDeviceLink/SDLOnDriverDistraction.m
index e65ef63d5..40fb3afa2 100644
--- a/SmartDeviceLink/SDLOnDriverDistraction.m
+++ b/SmartDeviceLink/SDLOnDriverDistraction.m
@@ -30,6 +30,24 @@ NS_ASSUME_NONNULL_BEGIN
return [self.parameters sdl_enumForName:SDLRPCParameterNameState error:&error];
}
+- (void)setLockScreenDismissalEnabled:(NSNumber<SDLBool> *)lockScreenDismissalEnabled {
+ [self.parameters sdl_setObject:lockScreenDismissalEnabled forName:SDLRPCParameterNameLockScreenDismissalEnabled];
+}
+
+- (NSNumber<SDLBool> *)lockScreenDismissalEnabled {
+ NSError *error = nil;
+ return [self.parameters sdl_objectForName:SDLRPCParameterNameLockScreenDismissalEnabled ofClass:NSNumber.class error:&error];
+}
+
+- (void)setLockScreenDismissalWarning:(NSString *)lockScreenDismissalWarning {
+ [self.parameters sdl_setObject:lockScreenDismissalWarning forName:SDLRPCParameterNameLockScreenDismissalWarning];
+}
+
+- (NSString *)lockScreenDismissalWarning {
+ NSError *error = nil;
+ return [self.parameters sdl_objectForName:SDLRPCParameterNameLockScreenDismissalWarning ofClass:NSString.class error:&error];
+}
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLOnLockScreenStatus.h b/SmartDeviceLink/SDLOnLockScreenStatus.h
index 255c0d71f..ce1b2cd62 100644
--- a/SmartDeviceLink/SDLOnLockScreenStatus.h
+++ b/SmartDeviceLink/SDLOnLockScreenStatus.h
@@ -23,6 +23,7 @@
NS_ASSUME_NONNULL_BEGIN
+__deprecated
@interface SDLOnLockScreenStatus : SDLRPCNotification
/**
diff --git a/SmartDeviceLink/SDLOnLockScreenStatus.m b/SmartDeviceLink/SDLOnLockScreenStatus.m
index 563b593bb..6264ea5fd 100644
--- a/SmartDeviceLink/SDLOnLockScreenStatus.m
+++ b/SmartDeviceLink/SDLOnLockScreenStatus.m
@@ -13,7 +13,10 @@
NS_ASSUME_NONNULL_BEGIN
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation SDLOnLockScreenStatus
+#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
diff --git a/SmartDeviceLink/SDLProxyListener.h b/SmartDeviceLink/SDLProxyListener.h
index f0c9b7a90..de1384286 100644
--- a/SmartDeviceLink/SDLProxyListener.h
+++ b/SmartDeviceLink/SDLProxyListener.h
@@ -1065,7 +1065,10 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param notification A SDLOnLockScreenStatus object
*/
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification;
+#pragma clang diagnostic pop
/**
* Called when an On Permissions Change notification is received from Core
diff --git a/SmartDeviceLink/SDLRPCParameterNames.h b/SmartDeviceLink/SDLRPCParameterNames.h
index 0fc66d8c4..50b018dbb 100644
--- a/SmartDeviceLink/SDLRPCParameterNames.h
+++ b/SmartDeviceLink/SDLRPCParameterNames.h
@@ -317,6 +317,8 @@ extern SDLRPCParameterName const SDLRPCParameterNameLocationDescription;
extern SDLRPCParameterName const SDLRPCParameterNameLocationDetails;
extern SDLRPCParameterName const SDLRPCParameterNameLocationImage;
extern SDLRPCParameterName const SDLRPCParameterNameLocationName;
+extern SDLRPCParameterName const SDLRPCParameterNameLockScreenDismissalEnabled;
+extern SDLRPCParameterName const SDLRPCParameterNameLockScreenDismissalWarning;
extern SDLRPCParameterName const SDLRPCParameterNameLongitudeDegrees;
extern SDLRPCParameterName const SDLRPCParameterNameLongPress;
extern SDLRPCParameterName const SDLRPCParameterNameLongPressAvailable;
diff --git a/SmartDeviceLink/SDLRPCParameterNames.m b/SmartDeviceLink/SDLRPCParameterNames.m
index bc6659cd4..06d6b78f5 100644
--- a/SmartDeviceLink/SDLRPCParameterNames.m
+++ b/SmartDeviceLink/SDLRPCParameterNames.m
@@ -315,6 +315,8 @@ SDLRPCParameterName const SDLRPCParameterNameLocationDescription = @"locationDes
SDLRPCParameterName const SDLRPCParameterNameLocationDetails = @"locationDetails";
SDLRPCParameterName const SDLRPCParameterNameLocationImage = @"locationImage";
SDLRPCParameterName const SDLRPCParameterNameLocationName = @"locationName";
+SDLRPCParameterName const SDLRPCParameterNameLockScreenDismissalEnabled = @"lockScreenDismissalEnabled";
+SDLRPCParameterName const SDLRPCParameterNameLockScreenDismissalWarning = @"lockScreenDismissalWarning";
SDLRPCParameterName const SDLRPCParameterNameLongitudeDegrees = @"longitudeDegrees";
SDLRPCParameterName const SDLRPCParameterNameLongPress = @"longPress";
SDLRPCParameterName const SDLRPCParameterNameLongPressAvailable = @"longPressAvailable";
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
index 489de7fb0..542ce850b 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
@@ -10,6 +10,7 @@
#import "SDLNotificationConstants.h"
#import "SDLNotificationDispatcher.h"
#import "SDLOnLockScreenStatus.h"
+#import "SDLOnDriverDistraction.h"
#import "SDLRPCNotificationNotification.h"
@@ -46,10 +47,17 @@ describe(@"a lock screen manager", ^{
});
describe(@"when the lock screen status becomes REQUIRED", ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__block SDLOnLockScreenStatus *testRequiredStatus = nil;
-
+#pragma clang diagnostic pop
+
beforeEach(^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testRequiredStatus = [[SDLOnLockScreenStatus alloc] init];
+#pragma clang diagnostic pop
+
testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired;
[testNotificationDispatcher postNotificationName:SDLDidChangeLockScreenStatusNotification infoObject:testRequiredStatus];
@@ -84,10 +92,17 @@ describe(@"a lock screen manager", ^{
});
describe(@"when the lock screen status becomes REQUIRED", ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__block SDLOnLockScreenStatus *testRequiredStatus = nil;
-
+#pragma clang diagnostic pop
+ __block SDLOnDriverDistraction *testDriverDistraction = nil;
+
beforeEach(^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testRequiredStatus = [[SDLOnLockScreenStatus alloc] init];
+#pragma clang diagnostic pop
testRequiredStatus.lockScreenStatus = SDLLockScreenStatusRequired;
SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testRequiredStatus];
@@ -116,6 +131,59 @@ describe(@"a lock screen manager", ^{
});
});
+ describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled as true", ^{
+ __block SDLRPCNotificationNotification *testDriverDistractionNotification = nil;
+
+ beforeEach(^{
+ testDriverDistraction = [[SDLOnDriverDistraction alloc] init];
+ testDriverDistraction.lockScreenDismissalEnabled = @YES;
+
+ testDriverDistractionNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeDriverDistractionStateNotification object:nil rpcNotification:testDriverDistraction];
+
+ [[NSNotificationCenter defaultCenter] postNotification:testDriverDistractionNotification];
+ });
+
+ it(@"should be able to be dismissed", ^{
+ expect(testManager.isLockScreenDismissable).toEventually(equal(YES));
+ });
+
+ });
+
+ describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled 0 bit", ^{
+ __block SDLRPCNotificationNotification *testDriverDistractionNotification = nil;
+
+ beforeEach(^{
+ testDriverDistraction = [[SDLOnDriverDistraction alloc] init];
+ testDriverDistraction.lockScreenDismissalEnabled = @0;
+
+ testDriverDistractionNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeDriverDistractionStateNotification object:nil rpcNotification:testDriverDistraction];
+
+ [[NSNotificationCenter defaultCenter] postNotification:testDriverDistractionNotification];
+ });
+
+ it(@"should not be able to be dismissed", ^{
+ expect(testManager.isLockScreenDismissable).toEventually(equal(NO));
+ });
+
+ });
+
+ describe(@"when a driver distraction notification is posted with lockScreenDismissableEnabled nil bit", ^{
+ __block SDLRPCNotificationNotification *testDriverDistractionNotification = nil;
+
+ beforeEach(^{
+ testDriverDistraction = [[SDLOnDriverDistraction alloc] init];
+
+ testDriverDistractionNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeDriverDistractionStateNotification object:nil rpcNotification:testDriverDistraction];
+
+ [[NSNotificationCenter defaultCenter] postNotification:testDriverDistractionNotification];
+ });
+
+ it(@"should not be able to be dismissed", ^{
+ expect(testManager.isLockScreenDismissable).toEventually(equal(NO));
+ });
+
+ });
+
describe(@"then the manager is stopped", ^{
beforeEach(^{
[testManager stop];
@@ -127,10 +195,16 @@ describe(@"a lock screen manager", ^{
});
describe(@"then the status becomes OFF", ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__block SDLOnLockScreenStatus *testOffStatus = nil;
+#pragma clang diagnostic pop
beforeEach(^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
testOffStatus = [[SDLOnLockScreenStatus alloc] init];
+#pragma clang diagnostic pop
testOffStatus.lockScreenStatus = SDLLockScreenStatusOff;
SDLRPCNotificationNotification *testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOffStatus];
@@ -211,8 +285,10 @@ describe(@"a lock screen manager", ^{
beforeEach(^{
mockViewControllerPresenter = OCMClassMock([SDLFakeViewControllerPresenter class]);
-
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLOnLockScreenStatus *testOptionalStatus = [[SDLOnLockScreenStatus alloc] init];
+#pragma clang diagnostic pop
testOptionalStatus.lockScreenStatus = SDLLockScreenStatusOptional;
testLockStatusNotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeLockScreenStatusNotification object:nil rpcNotification:testOptionalStatus];
diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m
index 98a574f95..acf64f0b8 100644
--- a/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m
+++ b/SmartDeviceLinkTests/ProxySpecs/SDLLockScreenStatusManagerSpec.m
@@ -227,7 +227,11 @@ describe(@"the lockscreen status manager", ^{
});
describe(@"when getting lock screen status notification", ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__block SDLOnLockScreenStatus *onLockScreenStatusNotification = nil;
+#pragma clang diagnostic pop
+
beforeEach(^{
lockScreenManager.userSelected = YES;
lockScreenManager.driverDistracted = NO;
diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m
index b242c0a3a..280e596a7 100644
--- a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m
+++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnDriverDistractionSpec.m
@@ -17,30 +17,52 @@ QuickSpecBegin(SDLOnDriverDistractionSpec)
describe(@"Getter/Setter Tests", ^ {
it(@"Should set and get correctly", ^ {
- SDLOnDriverDistraction* testNotification = [[SDLOnDriverDistraction alloc] init];
+ SDLOnDriverDistraction *testNotification = [[SDLOnDriverDistraction alloc] init];
testNotification.state = SDLDriverDistractionStateOn;
+ testNotification.lockScreenDismissalEnabled = @1;
expect(testNotification.state).to(equal(SDLDriverDistractionStateOn));
+ expect(testNotification.lockScreenDismissalEnabled).to(beTrue());
+
+ testNotification.lockScreenDismissalEnabled = @0;
+ expect(testNotification.lockScreenDismissalEnabled).to(beFalse());
});
it(@"Should get correctly when initialized", ^ {
- NSMutableDictionary* dict = [@{SDLRPCParameterNameNotification:
+ NSMutableDictionary *dictOn = [@{SDLRPCParameterNameNotification:
@{SDLRPCParameterNameParameters:
- @{SDLRPCParameterNameState:SDLDriverDistractionStateOn},
+ @{SDLRPCParameterNameState:SDLDriverDistractionStateOn,
+ SDLRPCParameterNameLockScreenDismissalEnabled: @1},
SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnDriverDistraction}} mutableCopy];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- SDLOnDriverDistraction* testNotification = [[SDLOnDriverDistraction alloc] initWithDictionary:dict];
+ SDLOnDriverDistraction* testNotificationOn = [[SDLOnDriverDistraction alloc] initWithDictionary:dictOn];
#pragma clang diagnostic pop
- expect(testNotification.state).to(equal(SDLDriverDistractionStateOn));
+ expect(testNotificationOn.state).to(equal(SDLDriverDistractionStateOn));
+ expect(testNotificationOn.lockScreenDismissalEnabled).to(beTrue());
+
+ NSMutableDictionary *dictOff = [@{SDLRPCParameterNameNotification:
+ @{SDLRPCParameterNameParameters:
+ @{SDLRPCParameterNameState:SDLDriverDistractionStateOff,
+ SDLRPCParameterNameLockScreenDismissalEnabled: @0},
+ SDLRPCParameterNameOperationName:SDLRPCFunctionNameOnDriverDistraction}} mutableCopy];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ SDLOnDriverDistraction *testNotificationOff = [[SDLOnDriverDistraction alloc] initWithDictionary:dictOff];
+#pragma clang diagnostic pop
+
+ expect(testNotificationOff.state).to(equal(SDLDriverDistractionStateOff));
+ expect(testNotificationOff.lockScreenDismissalEnabled).to(beFalse());
});
it(@"Should return nil if not set", ^ {
- SDLOnDriverDistraction* testNotification = [[SDLOnDriverDistraction alloc] init];
+ SDLOnDriverDistraction *testNotification = [[SDLOnDriverDistraction alloc] init];
expect(testNotification.state).to(beNil());
+ expect(testNotification.lockScreenDismissalEnabled).to(beNil());
+ expect(testNotification.lockScreenDismissalEnabled).to(beFalsy());
});
});
diff --git a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m
index cd12a3d46..4f4a574ee 100644
--- a/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m
+++ b/SmartDeviceLinkTests/RPCSpecs/NotificationSpecs/SDLOnLockScreenStatusSpec.m
@@ -18,8 +18,11 @@ QuickSpecBegin(SDLOnLockScreenStatusSpec)
describe(@"Getter/Setter Tests", ^ {
it(@"Should set and get correctly", ^ {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] init];
-
+#pragma clang diagnostic pop
+
testNotification.driverDistractionStatus = @NO;
testNotification.userSelected = @3;
testNotification.lockScreenStatus = SDLLockScreenStatusRequired;
@@ -51,8 +54,11 @@ describe(@"Getter/Setter Tests", ^ {
});
it(@"Should return nil if not set", ^ {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SDLOnLockScreenStatus* testNotification = [[SDLOnLockScreenStatus alloc] init];
-
+#pragma clang diagnostic pop
+
expect(testNotification.driverDistractionStatus).to(beNil());
expect(testNotification.userSelected).to(beNil());
expect(testNotification.lockScreenStatus).to(beNil());