diff options
author | Satbir Tanda <satbirtanda@gmail.com> | 2019-07-29 05:14:47 -0700 |
---|---|---|
committer | Satbir Tanda <satbirtanda@gmail.com> | 2019-07-29 05:14:47 -0700 |
commit | b952df76d93230b52803c0631e4e31b20c9870cd (patch) | |
tree | 3e439b411feacacddc293c6eca5d1d503aecc289 | |
parent | 8ee705900324d5bec4d9647b87006d466529e5da (diff) | |
download | sdl_ios-b952df76d93230b52803c0631e4e31b20c9870cd.tar.gz |
Revert "Add logic to observe the LockScreenStatus"
This reverts commit d1689a097a55b774529cc17a940edb99a873928f.
-rw-r--r-- | SmartDeviceLink-iOS.podspec | 1 | ||||
-rw-r--r-- | SmartDeviceLink-iOS.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | SmartDeviceLink.podspec | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLockScreenManager.m | 74 | ||||
-rw-r--r-- | SmartDeviceLink/SDLNotificationDispatcher.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLOnLockScreenStatus.h | 51 | ||||
-rw-r--r-- | SmartDeviceLink/SDLOnLockScreenStatus.m | 65 | ||||
-rw-r--r-- | SmartDeviceLink/SDLProxyListener.h | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SmartDeviceLink.h | 1 |
9 files changed, 151 insertions, 62 deletions
diff --git a/SmartDeviceLink-iOS.podspec b/SmartDeviceLink-iOS.podspec index 2f731398a..1b671ed98 100644 --- a/SmartDeviceLink-iOS.podspec +++ b/SmartDeviceLink-iOS.podspec @@ -235,6 +235,7 @@ ss.public_header_files = [ 'SmartDeviceLink/SDLOnHMIStatus.h', 'SmartDeviceLink/SDLOnKeyboardInput.h', 'SmartDeviceLink/SDLOnLanguageChange.h', +'SmartDeviceLink/SDLOnLockScreenStatus.h', 'SmartDeviceLink/SDLOnPermissionsChange.h', 'SmartDeviceLink/SDLOnRCStatus.h', 'SmartDeviceLink/SDLOnSyncPData.h', diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index ca5fc27fb..b4fa15d2b 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -749,6 +749,8 @@ 5D61FD121A84238C00846EE7 /* SDLOnKeyboardInput.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB251A84238B00846EE7 /* SDLOnKeyboardInput.m */; }; 5D61FD131A84238C00846EE7 /* SDLOnLanguageChange.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB261A84238B00846EE7 /* SDLOnLanguageChange.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D61FD141A84238C00846EE7 /* SDLOnLanguageChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB271A84238B00846EE7 /* SDLOnLanguageChange.m */; }; + 5D61FD151A84238C00846EE7 /* SDLOnLockScreenStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB281A84238B00846EE7 /* SDLOnLockScreenStatus.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5D61FD161A84238C00846EE7 /* SDLOnLockScreenStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB291A84238B00846EE7 /* SDLOnLockScreenStatus.m */; }; 5D61FD171A84238C00846EE7 /* SDLOnPermissionsChange.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB2A1A84238B00846EE7 /* SDLOnPermissionsChange.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D61FD181A84238C00846EE7 /* SDLOnPermissionsChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB2B1A84238B00846EE7 /* SDLOnPermissionsChange.m */; }; 5D61FD191A84238C00846EE7 /* SDLOnSyncPData.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB2C1A84238B00846EE7 /* SDLOnSyncPData.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -2401,6 +2403,8 @@ 5D61FB251A84238B00846EE7 /* SDLOnKeyboardInput.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnKeyboardInput.m; sourceTree = "<group>"; }; 5D61FB261A84238B00846EE7 /* SDLOnLanguageChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLOnLanguageChange.h; sourceTree = "<group>"; }; 5D61FB271A84238B00846EE7 /* SDLOnLanguageChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnLanguageChange.m; sourceTree = "<group>"; }; + 5D61FB281A84238B00846EE7 /* SDLOnLockScreenStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLOnLockScreenStatus.h; sourceTree = "<group>"; }; + 5D61FB291A84238B00846EE7 /* SDLOnLockScreenStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnLockScreenStatus.m; sourceTree = "<group>"; }; 5D61FB2A1A84238B00846EE7 /* SDLOnPermissionsChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLOnPermissionsChange.h; sourceTree = "<group>"; }; 5D61FB2B1A84238B00846EE7 /* SDLOnPermissionsChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLOnPermissionsChange.m; sourceTree = "<group>"; }; 5D61FB2C1A84238B00846EE7 /* SDLOnSyncPData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLOnSyncPData.h; sourceTree = "<group>"; }; @@ -4850,6 +4854,8 @@ 5D61FB251A84238B00846EE7 /* SDLOnKeyboardInput.m */, 5D61FB261A84238B00846EE7 /* SDLOnLanguageChange.h */, 5D61FB271A84238B00846EE7 /* SDLOnLanguageChange.m */, + 5D61FB281A84238B00846EE7 /* SDLOnLockScreenStatus.h */, + 5D61FB291A84238B00846EE7 /* SDLOnLockScreenStatus.m */, 5D61FB2A1A84238B00846EE7 /* SDLOnPermissionsChange.h */, 5D61FB2B1A84238B00846EE7 /* SDLOnPermissionsChange.m */, 1EAA47092032BAE5000FE74B /* SDLOnRCStatus.h */, @@ -6240,6 +6246,7 @@ 8817C2802289F4B900DB2DEC /* SDLIAPDataSessionDelegate.h in Headers */, 5D61FC841A84238C00846EE7 /* SDLDeviceLevelStatus.h in Headers */, 5DB92D321AC9C8BA00C15BB0 /* SDLRPCStruct.h in Headers */, + 5D61FD151A84238C00846EE7 /* SDLOnLockScreenStatus.h in Headers */, 5D61FD291A84238C00846EE7 /* SDLPerformInteraction.h in Headers */, 884E702321FBA952008D53BA /* SDLAppServiceType.h in Headers */, DAC572571D1067270004288B /* SDLTouchManager.h in Headers */, @@ -7219,6 +7226,7 @@ 5D00AC681F140F0A004000D9 /* SDLSystemCapabilityType.m in Sources */, E9C32B9D1AB20C5900F283AF /* EAAccessory+SDLProtocols.m in Sources */, 5D61FCC61A84238C00846EE7 /* SDLHMIZoneCapabilities.m in Sources */, + 5D61FD161A84238C00846EE7 /* SDLOnLockScreenStatus.m in Sources */, 5D61FDAE1A84238C00846EE7 /* SDLSubscribeButton.m in Sources */, DA9F7E6C1DCBFB0700ACAE48 /* SDLDeliveryMode.m in Sources */, 5D61FC581A84238C00846EE7 /* SDLButtonPressMode.m in Sources */, diff --git a/SmartDeviceLink.podspec b/SmartDeviceLink.podspec index b46913300..3270bf26a 100644 --- a/SmartDeviceLink.podspec +++ b/SmartDeviceLink.podspec @@ -236,6 +236,7 @@ sdefault.public_header_files = [ 'SmartDeviceLink/SDLOnHMIStatus.h', 'SmartDeviceLink/SDLOnKeyboardInput.h', 'SmartDeviceLink/SDLOnLanguageChange.h', +'SmartDeviceLink/SDLOnLockScreenStatus.h', 'SmartDeviceLink/SDLOnPermissionsChange.h', 'SmartDeviceLink/SDLOnRCStatus.h', 'SmartDeviceLink/SDLOnSyncPData.h', diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m index d072e80e0..083b6c136 100644 --- a/SmartDeviceLink/SDLLockScreenManager.m +++ b/SmartDeviceLink/SDLLockScreenManager.m @@ -14,12 +14,11 @@ #import "SDLLockScreenStatus.h" #import "SDLLockScreenViewController.h" #import "SDLNotificationConstants.h" +#import "SDLOnLockScreenStatus.h" #import "SDLOnDriverDistraction.h" #import "SDLRPCNotificationNotification.h" #import "SDLScreenshotViewController.h" #import "SDLViewControllerPresentable.h" -#import "SDLOnHMIStatus.h" -#import "SDLHMILevel.h" NS_ASSUME_NONNULL_BEGIN @@ -29,10 +28,7 @@ NS_ASSUME_NONNULL_BEGIN @property (assign, nonatomic) BOOL canPresent; @property (strong, nonatomic, readwrite) SDLLockScreenConfiguration *config; @property (strong, nonatomic) id<SDLViewControllerPresentable> presenter; -@property (copy, nonatomic, nullable) SDLHMILevel hmiLevel; -@property (assign, nonatomic) BOOL userSelected; -@property (assign, nonatomic) BOOL driverDistracted; -@property (assign, nonatomic) BOOL haveDriverDistractionStatus; +@property (strong, nonatomic, nullable) SDLOnLockScreenStatus *lastLockNotification; @property (strong, nonatomic, nullable) SDLOnDriverDistraction *lastDriverDistractionNotification; @property (assign, nonatomic, readwrite, getter=isLockScreenDismissable) BOOL lockScreenDismissable; @@ -48,15 +44,11 @@ NS_ASSUME_NONNULL_BEGIN } _canPresent = NO; - _hmiLevel = nil; - _userSelected = NO; - _driverDistracted = NO; - _haveDriverDistractionStatus = NO; _lockScreenDismissable = NO; _config = config; _presenter = presenter; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_hmiLevelDidChange:) name:SDLDidChangeHMIStatusNotification object:dispatcher]; + [[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]; @@ -106,19 +98,13 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Notification Selectors -- (void)sdl_hmiLevelDidChange:(SDLRPCNotificationNotification *)notification { - if (![notification isNotificationMemberOfClass:[SDLOnHMIStatus class]]) { +- (void)sdl_lockScreenStatusDidChange:(SDLRPCNotificationNotification *)notification { + if (![notification isNotificationMemberOfClass:[SDLOnLockScreenStatus class]]) { return; } - - SDLOnHMIStatus *hmiStatus = notification.notification; - - self.hmiLevel = hmiStatus.hmiLevel; - if ([self.hmiLevel isEqualToEnum:SDLHMILevelFull] || [self.hmiLevel isEqualToEnum:SDLHMILevelLimited]) { - self.userSelected = YES; - } else if ([self.hmiLevel isEqualToEnum:SDLHMILevelNone]) { - self.userSelected = NO; - } + + self.lastLockNotification = notification.notification; + [self sdl_checkLockScreen]; } - (void)sdl_lockScreenIconReceived:(NSNotification *)notification { @@ -145,32 +131,29 @@ NS_ASSUME_NONNULL_BEGIN } self.lastDriverDistractionNotification = notification.notification; - self.haveDriverDistractionStatus = YES; - self.driverDistracted = [self.lastDriverDistractionNotification.state isEqualToEnum:SDLDriverDistractionStateOn] ? YES : NO; - [self sdl_checkLockScreen]; [self sdl_updateLockScreenDismissable]; } #pragma mark - Private Helpers - (void)sdl_checkLockScreen { - if (self.lockScreenViewController == nil) { + if (self.lockScreenViewController == nil || self.lastLockNotification == nil) { return; } // Present the VC depending on the lock screen status BOOL lockScreenDismissableEnabled = [self.lastDriverDistractionNotification.lockScreenDismissalEnabled boolValue]; - if ([self.lockScreenStatus isEqualToEnum:SDLLockScreenStatusRequired]) { + if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusRequired]) { if (!self.presenter.presented && self.canPresent && !lockScreenDismissableEnabled) { [self.presenter present]; } - } else if ([self.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOptional]) { + } else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOptional]) { if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent && !lockScreenDismissableEnabled) { [self.presenter present]; } else if (!self.config.showInOptionalState && self.presenter.presented) { [self.presenter dismiss]; } - } else if ([self.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOff]) { + } else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOff]) { if (self.presenter.presented) { [self.presenter dismiss]; } @@ -212,39 +195,6 @@ NS_ASSUME_NONNULL_BEGIN }); } -- (SDLLockScreenStatus)lockScreenStatus { - if (self.hmiLevel == nil || [self.hmiLevel isEqualToEnum:SDLHMILevelNone]) { - // App is not active on the car - return SDLLockScreenStatusOff; - } else if ([self.hmiLevel isEqualToEnum:SDLHMILevelBackground]) { - // App is in the background on the car - if (self.userSelected) { - // It was user selected - if (self.haveDriverDistractionStatus && !self.driverDistracted) { - // We have the distraction status, and the driver is not distracted - return SDLLockScreenStatusOptional; - } else { - // We don't have the distraction status, and/or the driver is distracted - return SDLLockScreenStatusRequired; - } - } else { - return SDLLockScreenStatusOff; - } - } else if ([self.hmiLevel isEqualToEnum:SDLHMILevelFull] || [self.hmiLevel isEqualToEnum:SDLHMILevelLimited]) { - // App is in the foreground on the car in some manner - if (self.haveDriverDistractionStatus && !self.driverDistracted) { - // We have the distraction status, and the driver is not distracted - return SDLLockScreenStatusOptional; - } else { - // We don't have the distraction status, and/or the driver is distracted - return SDLLockScreenStatusRequired; - } - } else { - // This shouldn't be possible. - return SDLLockScreenStatusOff; - } -} - @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLNotificationDispatcher.m b/SmartDeviceLink/SDLNotificationDispatcher.m index 3114d0bbb..f5232a194 100644 --- a/SmartDeviceLink/SDLNotificationDispatcher.m +++ b/SmartDeviceLink/SDLNotificationDispatcher.m @@ -591,6 +591,10 @@ NS_ASSUME_NONNULL_BEGIN [self postRPCNotificationNotification:SDLDidChangeLanguageNotification notification:notification]; } +- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification { + [self postRPCNotificationNotification:SDLDidChangeLockScreenStatusNotification notification:notification]; +} + - (void)onOnPermissionsChange:(SDLOnPermissionsChange *)notification { [self postRPCNotificationNotification:SDLDidChangePermissionsNotification notification:notification]; } diff --git a/SmartDeviceLink/SDLOnLockScreenStatus.h b/SmartDeviceLink/SDLOnLockScreenStatus.h new file mode 100644 index 000000000..255c0d71f --- /dev/null +++ b/SmartDeviceLink/SDLOnLockScreenStatus.h @@ -0,0 +1,51 @@ +// +// SDLOnLockScreenStatus.h +// SmartDeviceLink +// + +#import "SDLRPCNotification.h" + +#import "SDLHMILevel.h" +#import "SDLLockScreenStatus.h" + + +/** + To help prevent driver distraction, any SmartDeviceLink application is required to implement a lockscreen that must be enforced while the application is active on the system while the vehicle is in motion. + + This lockscreen must perform the following: + + Limit all application control usability from the mobile device with a full-screen static image overlay or separate view. + + For simplicity, the `OnLockScreenStatus` RPC will be provided via the `onOnLockScreenNotification` call back. The call back will include the LockScreenStatus enum which indicates if the lockscreen is required, optional or not required. + + The call back also includes details regarding the current HMI_Status level, driver distraction status and user selection status of the application. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface SDLOnLockScreenStatus : SDLRPCNotification + +/** + Get the current driver distraction status(i.e. whether driver distraction rules are in effect, or not) + */ +@property (strong, nonatomic) NSNumber<SDLBool> *driverDistractionStatus; + +/** + Get user selection status for the application (has the app been selected via hmi or voice command) + */ + +@property (strong, nonatomic) NSNumber<SDLBool> *userSelected; + +/** + Indicates if the lockscreen should be required, optional or off + */ +@property (strong, nonatomic) SDLLockScreenStatus lockScreenStatus; + +/** + Get HMILevel in effect for the application + */ +@property (strong, nonatomic) SDLHMILevel hmiLevel; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLOnLockScreenStatus.m b/SmartDeviceLink/SDLOnLockScreenStatus.m new file mode 100644 index 000000000..563b593bb --- /dev/null +++ b/SmartDeviceLink/SDLOnLockScreenStatus.m @@ -0,0 +1,65 @@ +// +// SDLOnLockScreenStatus.m +// SmartDeviceLink +// + +#import "SDLOnLockScreenStatus.h" + +#import "NSMutableDictionary+Store.h" +#import "SDLHMILevel.h" +#import "SDLLockScreenStatus.h" +#import "SDLRPCParameterNames.h" +#import "SDLRPCFunctionNames.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation SDLOnLockScreenStatus + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +- (instancetype)init { + if (self = [super initWithName:SDLRPCFunctionNameOnLockScreenStatus]) { + } + return self; +} +#pragma clang diagnostic pop + +- (void)setLockScreenStatus:(SDLLockScreenStatus)lockScreenStatus { + [self.parameters sdl_setObject:lockScreenStatus forName:SDLRPCParameterNameOnLockScreenStatus]; +} + +- (SDLLockScreenStatus)lockScreenStatus { + NSError *error = nil; + return [self.parameters sdl_enumForName:SDLRPCParameterNameOnLockScreenStatus error:&error]; +} + +- (void)setHmiLevel:(SDLHMILevel)hmiLevel { + [self.parameters sdl_setObject:hmiLevel forName:SDLRPCParameterNameHMILevel]; +} + +- (SDLHMILevel)hmiLevel { + NSError *error = nil; + return [self.parameters sdl_enumForName:SDLRPCParameterNameHMILevel error:&error]; +} + +- (void)setUserSelected:(NSNumber<SDLBool> *)userSelected { + [self.parameters sdl_setObject:userSelected forName:SDLRPCParameterNameUserSelected]; +} + +- (NSNumber<SDLBool> *)userSelected { + NSError *error = nil; + return [self.parameters sdl_objectForName:SDLRPCParameterNameUserSelected ofClass:NSNumber.class error:&error]; +} + +- (void)setDriverDistractionStatus:(NSNumber<SDLBool> *)driverDistractionStatus { + [self.parameters sdl_setObject:driverDistractionStatus forName:SDLRPCParameterNameDriverDistractionStatus]; +} + +- (NSNumber<SDLBool> *)driverDistractionStatus { + NSError *error = nil; + return [self.parameters sdl_objectForName:SDLRPCParameterNameDriverDistractionStatus ofClass:NSNumber.class error:&error]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLProxyListener.h b/SmartDeviceLink/SDLProxyListener.h index 3e115b3ee..ea19fde07 100644 --- a/SmartDeviceLink/SDLProxyListener.h +++ b/SmartDeviceLink/SDLProxyListener.h @@ -67,6 +67,7 @@ @class SDLOnInteriorVehicleData; @class SDLOnKeyboardInput; @class SDLOnLanguageChange; +@class SDLOnLockScreenStatus; @class SDLOnPermissionsChange; @class SDLOnRCStatus; @class SDLOnSyncPData; @@ -1044,6 +1045,13 @@ NS_ASSUME_NONNULL_BEGIN - (void)onOnLanguageChange:(SDLOnLanguageChange *)notification; /** + * Called when an On Lock Screen notification is received from Core + * + * @param notification A SDLOnLockScreenStatus object + */ +- (void)onOnLockScreenNotification:(SDLOnLockScreenStatus *)notification; + +/** * Called when an On Permissions Change notification is received from Core * * @param notification A SDLOnPermissionsChange object diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h index 52f6809e2..3b884804f 100644 --- a/SmartDeviceLink/SmartDeviceLink.h +++ b/SmartDeviceLink/SmartDeviceLink.h @@ -148,6 +148,7 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[]; #import "SDLOnInteriorVehicleData.h" #import "SDLOnKeyboardInput.h" #import "SDLOnLanguageChange.h" +#import "SDLOnLockScreenStatus.h" #import "SDLOnPermissionsChange.h" #import "SDLOnRCStatus.h" #import "SDLOnSyncPData.h" |