summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatbir Tanda <satbirtanda@gmail.com>2019-07-29 05:14:24 -0700
committerSatbir Tanda <satbirtanda@gmail.com>2019-07-29 05:14:24 -0700
commit17f56e9d366c6007380ffb2884e702cded24961c (patch)
treef36880feafa15c44b5a5c18cf9646c18b83b3679
parent34c2a67e4c657469d2be581d8cd0c59661c50485 (diff)
downloadsdl_ios-17f56e9d366c6007380ffb2884e702cded24961c.tar.gz
Revert removing of SDLLockScreenStatusManager
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj8
-rw-r--r--SmartDeviceLink/SDLLockScreenStatusManager.h25
-rw-r--r--SmartDeviceLink/SDLLockScreenStatusManager.m103
-rw-r--r--SmartDeviceLink/SDLProxy.m39
4 files changed, 171 insertions, 4 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index 131ed2a09..4069770e8 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -711,6 +711,8 @@
5D61FCED1A84238C00846EE7 /* SDLListFiles.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB001A84238A00846EE7 /* SDLListFiles.m */; };
5D61FCEE1A84238C00846EE7 /* SDLListFilesResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB011A84238A00846EE7 /* SDLListFilesResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
5D61FCEF1A84238C00846EE7 /* SDLListFilesResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB021A84238A00846EE7 /* SDLListFilesResponse.m */; };
+ 5D61FCF01A84238C00846EE7 /* SDLLockScreenStatusManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB031A84238A00846EE7 /* SDLLockScreenStatusManager.h */; };
+ 5D61FCF11A84238C00846EE7 /* SDLLockScreenStatusManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB041A84238A00846EE7 /* SDLLockScreenStatusManager.m */; };
5D61FCF21A84238C00846EE7 /* SDLLockScreenStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB051A84238A00846EE7 /* SDLLockScreenStatus.h */; settings = {ATTRIBUTES = (Public, ); }; };
5D61FCF31A84238C00846EE7 /* SDLLockScreenStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D61FB061A84238A00846EE7 /* SDLLockScreenStatus.m */; };
5D61FCF41A84238C00846EE7 /* SDLMaintenanceModeStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D61FB071A84238A00846EE7 /* SDLMaintenanceModeStatus.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -2360,6 +2362,8 @@
5D61FB001A84238A00846EE7 /* SDLListFiles.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLListFiles.m; sourceTree = "<group>"; };
5D61FB011A84238A00846EE7 /* SDLListFilesResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLListFilesResponse.h; sourceTree = "<group>"; };
5D61FB021A84238A00846EE7 /* SDLListFilesResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLListFilesResponse.m; sourceTree = "<group>"; };
+ 5D61FB031A84238A00846EE7 /* SDLLockScreenStatusManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLLockScreenStatusManager.h; sourceTree = "<group>"; };
+ 5D61FB041A84238A00846EE7 /* SDLLockScreenStatusManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLLockScreenStatusManager.m; sourceTree = "<group>"; };
5D61FB051A84238A00846EE7 /* SDLLockScreenStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLLockScreenStatus.h; sourceTree = "<group>"; };
5D61FB061A84238A00846EE7 /* SDLLockScreenStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLLockScreenStatus.m; sourceTree = "<group>"; };
5D61FB071A84238A00846EE7 /* SDLMaintenanceModeStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLMaintenanceModeStatus.h; sourceTree = "<group>"; };
@@ -4062,6 +4066,8 @@
EE798CA2205611DC008EDE8E /* Secondary Transport */,
5D6CC8ED1C610E490027F60A /* Security */,
5D5934FE1A851B2500687FB9 /* @protocols */,
+ 5D61FB031A84238A00846EE7 /* SDLLockScreenStatusManager.h */,
+ 5D61FB041A84238A00846EE7 /* SDLLockScreenStatusManager.m */,
5D61FB441A84238B00846EE7 /* SDLPolicyDataParser.h */,
5D61FB451A84238B00846EE7 /* SDLPolicyDataParser.m */,
5D61FB631A84238B00846EE7 /* SDLProxy.h */,
@@ -6691,6 +6697,7 @@
88F89103221DE29A00E056AD /* SDLAsynchronousRPCOperation.h in Headers */,
5D61FD6F1A84238C00846EE7 /* SDLRPCPayload.h in Headers */,
5D339CF3207C0ACE000CC364 /* SDLMenuManager.h in Headers */,
+ 5D61FCF01A84238C00846EE7 /* SDLLockScreenStatusManager.h in Headers */,
5D61FD311A84238C00846EE7 /* SDLPolicyDataParser.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -7336,6 +7343,7 @@
5DA49CE61F1EA83300E65FC5 /* SDLControlFramePayloadRPCStartService.m in Sources */,
5DA102A51D4122C700C15826 /* NSMutableDictionary+SafeRemove.m in Sources */,
5DD60D99221C5D7D00A82A4F /* SDLVersion.m in Sources */,
+ 5D61FCF11A84238C00846EE7 /* SDLLockScreenStatusManager.m in Sources */,
5D61FDAC1A84238C00846EE7 /* SDLStartTime.m in Sources */,
5D61FDA01A84238C00846EE7 /* SDLSoftButton.m in Sources */,
5D61FCD21A84238C00846EE7 /* SDLImageFieldName.m in Sources */,
diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.h b/SmartDeviceLink/SDLLockScreenStatusManager.h
new file mode 100644
index 000000000..2a37b9d83
--- /dev/null
+++ b/SmartDeviceLink/SDLLockScreenStatusManager.h
@@ -0,0 +1,25 @@
+//
+// SDLLockScreenManager.h
+// SmartDeviceLink
+//
+
+#import <Foundation/Foundation.h>
+
+#import "SDLHMILevel.h"
+#import "SDLLockScreenStatus.h"
+
+@class SDLOnLockScreenStatus;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface SDLLockScreenStatusManager : NSObject
+
+@property (assign, nonatomic) BOOL userSelected;
+@property (assign, nonatomic) BOOL driverDistracted;
+@property (nullable, strong, nonatomic) SDLHMILevel hmiLevel;
+@property (strong, nonatomic, readonly) SDLLockScreenStatus lockScreenStatus;
+@property (strong, nonatomic, readonly) SDLOnLockScreenStatus *lockScreenStatusNotification;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.m b/SmartDeviceLink/SDLLockScreenStatusManager.m
new file mode 100644
index 000000000..82724eb6f
--- /dev/null
+++ b/SmartDeviceLink/SDLLockScreenStatusManager.m
@@ -0,0 +1,103 @@
+//
+// SDLLockScreenManager.m
+// SmartDeviceLink
+//
+
+#import "SDLLockScreenStatusManager.h"
+
+#import "SDLLockScreenStatus.h"
+#import "SDLOnLockScreenStatus.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface SDLLockScreenStatusManager ()
+
+@property (assign, nonatomic) BOOL haveDriverDistractionStatus;
+
+@end
+
+
+@implementation SDLLockScreenStatusManager
+
+#pragma mark - Lifecycle
+
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ _userSelected = NO;
+ _driverDistracted = NO;
+ _haveDriverDistractionStatus = NO;
+ }
+ return self;
+}
+
+
+#pragma mark - Getters / Setters
+#pragma mark Custom setters
+
+- (void)setDriverDistracted:(BOOL)driverDistracted {
+ _driverDistracted = driverDistracted;
+ _haveDriverDistractionStatus = YES;
+}
+
+- (void)setHmiLevel:(nullable SDLHMILevel)hmiLevel {
+ if (_hmiLevel != hmiLevel) {
+ _hmiLevel = hmiLevel;
+ }
+
+ if ([hmiLevel isEqualToEnum:SDLHMILevelFull] || [hmiLevel isEqualToEnum:SDLHMILevelLimited]) {
+ self.userSelected = YES;
+ } else if ([hmiLevel isEqualToEnum:SDLHMILevelNone]) {
+ self.userSelected = NO;
+ }
+}
+
+
+#pragma mark Custom Getters
+
+- (SDLOnLockScreenStatus *)lockScreenStatusNotification {
+ SDLOnLockScreenStatus *notification = [[SDLOnLockScreenStatus alloc] init];
+ notification.driverDistractionStatus = @(self.driverDistracted);
+ notification.hmiLevel = self.hmiLevel;
+ notification.userSelected = @(self.userSelected);
+ notification.lockScreenStatus = self.lockScreenStatus;
+
+ return notification;
+}
+
+- (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/SDLProxy.m b/SmartDeviceLink/SDLProxy.m
index 0bda06afb..f32b3de94 100644
--- a/SmartDeviceLink/SDLProxy.m
+++ b/SmartDeviceLink/SDLProxy.m
@@ -15,6 +15,7 @@
#import "SDLIAPTransport.h"
#import "SDLLanguage.h"
#import "SDLLayoutMode.h"
+#import "SDLLockScreenStatusManager.h"
#import "SDLOnButtonEvent.h"
#import "SDLOnButtonPress.h"
#import "SDLOnHMIStatus.h"
@@ -55,7 +56,9 @@ const float NotifyProxyClosedDelay = (float)0.1;
const int PoliciesCorrelationId = 65535;
static float DefaultConnectionTimeout = 45.0;
-@interface SDLProxy ()
+@interface SDLProxy () {
+ SDLLockScreenStatusManager *_lsm;
+}
@property (copy, nonatomic) NSString *appId;
@property (strong, nonatomic) NSMutableSet<NSObject<SDLProxyListener> *> *mutableProxyListeners;
@@ -72,8 +75,7 @@ static float DefaultConnectionTimeout = 45.0;
- (instancetype)initWithTransport:(id<SDLTransportType>)transport delegate:(id<SDLProxyListener>)delegate secondaryTransportManager:(nullable SDLSecondaryTransportManager *)secondaryTransportManager {
if (self = [super init]) {
SDLLogD(@"Framework Version: %@", self.proxyVersion);
-
- _rpcProcessingQueue = dispatch_queue_create("com.sdl.rpcProcessingQueue", DISPATCH_QUEUE_SERIAL);
+ _lsm = [[SDLLockScreenStatusManager alloc] init];
_mutableProxyListeners = [NSMutableSet setWithObject:delegate];
_securityManagers = [NSMutableDictionary dictionary];
@@ -447,7 +449,16 @@ static float DefaultConnectionTimeout = 45.0;
if ([functionName isEqualToString:SDLRPCFunctionNameOnAppInterfaceUnregistered] || [functionName isEqualToString:SDLRPCFunctionNameUnregisterAppInterface]) {
[self handleRPCUnregistered:dict];
}
-
+
+ // When an OnHMIStatus notification comes in, after passing it on (above), generate an "OnLockScreenNotification"
+ if ([functionName isEqualToString:@"OnHMIStatus"]) {
+ [self handleAfterHMIStatus:newMessage];
+ }
+
+ // When an OnDriverDistraction notification comes in, after passing it on (above), generate an "OnLockScreenNotification"
+ if ([functionName isEqualToString:@"OnDriverDistraction"]) {
+ [self handleAfterDriverDistraction:newMessage];
+ }
}
- (void)sdl_invokeDelegateMethodsWithFunction:(NSString *)functionName message:(SDLRPCMessage *)message {
@@ -604,6 +615,26 @@ static float DefaultConnectionTimeout = 45.0;
}
#pragma clang diagnostic pop
+
+#pragma mark Handle Post-Invoke of Delegate Methods
+- (void)handleAfterHMIStatus:(SDLRPCMessage *)message {
+ SDLHMILevel hmiLevel = (SDLHMILevel)message.parameters[SDLRPCParameterNameHMILevel];
+ _lsm.hmiLevel = hmiLevel;
+
+ SEL callbackSelector = NSSelectorFromString(@"onOnLockScreenNotification:");
+ [self invokeMethodOnDelegates:callbackSelector withObject:_lsm.lockScreenStatusNotification];
+}
+
+- (void)handleAfterDriverDistraction:(SDLRPCMessage *)message {
+ NSString *stateString = (NSString *)message.parameters[SDLRPCParameterNameState];
+ BOOL state = [stateString isEqualToString:@"DD_ON"] ? YES : NO;
+ _lsm.driverDistracted = state;
+
+ SEL callbackSelector = NSSelectorFromString(@"onOnLockScreenNotification:");
+ [self invokeMethodOnDelegates:callbackSelector withObject:_lsm.lockScreenStatusNotification];
+}
+
+
#pragma mark OnSystemRequest Handlers
- (void)sdl_handleSystemRequestLaunchApp:(SDLOnSystemRequest *)request {
NSURL *URLScheme = [NSURL URLWithString:request.url];