summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatbir Tanda <satbirtanda@gmail.com>2019-06-04 17:43:37 -0700
committerSatbir Tanda <satbirtanda@gmail.com>2019-06-04 17:43:37 -0700
commit1a4b30f6bc43f27d6e77d0fe1cee6b11cc374ba9 (patch)
tree9142b63bf35d5be10e2de6a72ed5709697f608fe
parent7b5666be83b6cad4f905285e5a17dbb0572286a3 (diff)
downloadsdl_ios-1a4b30f6bc43f27d6e77d0fe1cee6b11cc374ba9.tar.gz
Observe SDLDidChangeDriverDistractionStateNotification
Parse lockScreenDismissalEnabled Save last notification to instance variable
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.m10
-rw-r--r--SmartDeviceLink/SDLLockScreenStatus.h2
-rw-r--r--SmartDeviceLink/SDLOnDriverDistraction.h6
-rw-r--r--SmartDeviceLink/SDLOnDriverDistraction.m9
-rw-r--r--SmartDeviceLink/SDLRPCParameterNames.h1
-rw-r--r--SmartDeviceLink/SDLRPCParameterNames.m1
6 files changed, 28 insertions, 1 deletions
diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m
index a8c8c3758..52ae85644 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"
@@ -28,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic, readwrite) SDLLockScreenConfiguration *config;
@property (strong, nonatomic) id<SDLViewControllerPresentable> presenter;
@property (strong, nonatomic, nullable) SDLOnLockScreenStatus *lastLockNotification;
+@property (strong, nonatomic, nullable) SDLOnDriverDistraction *lastDriverDistractionNotification;
@end
@@ -47,6 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
[[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;
}
@@ -121,6 +124,13 @@ NS_ASSUME_NONNULL_BEGIN
[self sdl_checkLockScreen];
}
+- (void)sdl_driverDistractionStateDidChange:(SDLRPCNotificationNotification *)notification {
+ if (![notification isNotificationMemberOfClass:[SDLOnDriverDistraction class]]) {
+ return;
+ }
+
+ self.lastDriverDistractionNotification = notification.notification;
+}
#pragma mark - Private Helpers
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/SDLOnDriverDistraction.h b/SmartDeviceLink/SDLOnDriverDistraction.h
index d7f369348..56a854d5f 100644
--- a/SmartDeviceLink/SDLOnDriverDistraction.h
+++ b/SmartDeviceLink/SDLOnDriverDistraction.h
@@ -28,6 +28,12 @@ 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.
+ */
+@property (strong, nonatomic) NSNumber<SDLBool> *lockScreenDismissalEnabled;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLOnDriverDistraction.m b/SmartDeviceLink/SDLOnDriverDistraction.m
index 147964af8..e7efabeda 100644
--- a/SmartDeviceLink/SDLOnDriverDistraction.m
+++ b/SmartDeviceLink/SDLOnDriverDistraction.m
@@ -27,6 +27,15 @@ NS_ASSUME_NONNULL_BEGIN
return [parameters sdl_enumForName:SDLRPCParameterNameState error:&error];
}
+- (void)setLockScreenDismissalEnabled:(NSNumber<SDLBool> *)lockScreenDismissalEnabled {
+ [parameters sdl_setObject:lockScreenDismissalEnabled forName:SDLRPCParameterNameLockScreenDismissalEnabled];
+}
+
+- (NSNumber<SDLBool> *)lockScreenDismissalEnabled {
+ NSError *error = nil;
+ return [parameters sdl_objectForName:SDLRPCParameterNameLockScreenDismissalEnabled ofClass:NSNumber.class error:&error];
+}
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLRPCParameterNames.h b/SmartDeviceLink/SDLRPCParameterNames.h
index 6e346e357..fac72800d 100644
--- a/SmartDeviceLink/SDLRPCParameterNames.h
+++ b/SmartDeviceLink/SDLRPCParameterNames.h
@@ -311,6 +311,7 @@ extern SDLRPCParameterName const SDLRPCParameterNameLocationDescription;
extern SDLRPCParameterName const SDLRPCParameterNameLocationDetails;
extern SDLRPCParameterName const SDLRPCParameterNameLocationImage;
extern SDLRPCParameterName const SDLRPCParameterNameLocationName;
+extern SDLRPCParameterName const SDLRPCParameterNameLockScreenDismissalEnabled;
extern SDLRPCParameterName const SDLRPCParameterNameLongitudeDegrees;
extern SDLRPCParameterName const SDLRPCParameterNameLongPress;
extern SDLRPCParameterName const SDLRPCParameterNameLongPressAvailable;
diff --git a/SmartDeviceLink/SDLRPCParameterNames.m b/SmartDeviceLink/SDLRPCParameterNames.m
index 0aae8440d..e18ccb892 100644
--- a/SmartDeviceLink/SDLRPCParameterNames.m
+++ b/SmartDeviceLink/SDLRPCParameterNames.m
@@ -309,6 +309,7 @@ SDLRPCParameterName const SDLRPCParameterNameLocationDescription = @"locationDes
SDLRPCParameterName const SDLRPCParameterNameLocationDetails = @"locationDetails";
SDLRPCParameterName const SDLRPCParameterNameLocationImage = @"locationImage";
SDLRPCParameterName const SDLRPCParameterNameLocationName = @"locationName";
+SDLRPCParameterName const SDLRPCParameterNameLockScreenDismissalEnabled = @"lockScreenDismissalEnabled";
SDLRPCParameterName const SDLRPCParameterNameLongitudeDegrees = @"longitudeDegrees";
SDLRPCParameterName const SDLRPCParameterNameLongPress = @"longPress";
SDLRPCParameterName const SDLRPCParameterNameLongPressAvailable = @"longPressAvailable";