summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Dickow <jjdickow@gmail.com>2016-03-10 16:05:10 -0500
committerJustin Dickow <jjdickow@gmail.com>2016-03-10 16:05:10 -0500
commit2936f303dad7e1b1fe5494119088eeb6d4d34fe5 (patch)
treebc83523761bd2c7e1fc68132dde790bc66064ec7
parentf92f39b7e93e9d5e8a12a8564dcbab40cd2ee406 (diff)
downloadsdl_ios-2936f303dad7e1b1fe5494119088eeb6d4d34fe5.tar.gz
Sending application state to SDL
When application registers and when application state changes we send a notification to SDL of the application state mapped to an HMI state.
-rw-r--r--SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m33
1 files changed, 33 insertions, 0 deletions
diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m
index 9475d1de8..b0054a276 100644
--- a/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m
+++ b/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m
@@ -130,6 +130,33 @@ const int POLICIES_CORRELATION_ID = 65535;
return [self.mutableProxyListeners copy];
}
+#pragma mark - Methods
+
+- (void)sendMobileHMIState {
+ UIApplicationState appState = [UIApplication sharedApplication].applicationState;
+ SDLOnHMIStatus *HMIStatusRPC = [[SDLOnHMIStatus alloc] init];
+
+ HMIStatusRPC.audioStreamingState = [SDLAudioStreamingState NOT_AUDIBLE];
+ HMIStatusRPC.systemContext = [SDLSystemContext MAIN];
+
+ switch (appState) {
+ case UIApplicationStateActive: {
+ HMIStatusRPC.hmiLevel = [SDLHMILevel FULL];
+ } break;
+ case UIApplicationStateBackground: // Fallthrough
+ case UIApplicationStateInactive: {
+ HMIStatusRPC.hmiLevel = [SDLHMILevel BACKGROUND];
+ } break;
+ default:
+ break;
+ }
+
+ NSString *log = [NSString stringWithFormat:@"Sending new mobile hmi state: %@", HMIStatusRPC.hmiLevel.value];
+ [SDLDebugTool logInfo:log withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
+
+ [self sendRPC:HMIStatusRPC];
+}
+
#pragma mark - Setters / Getters
@@ -295,6 +322,12 @@ const int POLICIES_CORRELATION_ID = 65535;
//Print Proxy Version To Console
NSString *logMessage = [NSString stringWithFormat:@"Framework Version: %@", self.proxyVersion];
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
+ if (_version >= 4) {
+ [self sendMobileHMIState];
+ // Send SDL updates to application state
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendMobileHMIState) name:UIApplicationDidBecomeActiveNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendMobileHMIState) name:UIApplicationDidEnterBackgroundNotification object:nil];
+ }
}
- (void)handleSyncPData:(SDLRPCMessage *)message {