summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-10-03 15:58:14 -0400
committerJoel Fischer <joeljfischer@gmail.com>2017-10-03 15:58:14 -0400
commit32dcb92238092fb304c75bea60a6185efe47dde4 (patch)
tree180223d7fd01a857b86ecd46e28690d15a949af5
parent511a08c31faba735802cc47a26ffe38c34724da0 (diff)
downloadsdl_ios-32dcb92238092fb304c75bea60a6185efe47dde4.tar.gz
Lifecycle manager and state machine logs
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj2
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m72
-rw-r--r--SmartDeviceLink/SDLStateMachine.m3
3 files changed, 42 insertions, 35 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index ba8356223..b8a6bf6e9 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -4052,7 +4052,6 @@
5DA3F3511BC4477B0026F2D0 /* Developer API */ = {
isa = PBXGroup;
children = (
- 5D6F7A301BC5B7100070BF37 /* Lock Screen UI */,
5DA3F3561BC4480E0026F2D0 /* Utilities */,
5D8204171BCD80A200D0A41B /* Configurations */,
5DBAE0A61D355EF200CE00BF /* Managers */,
@@ -4239,6 +4238,7 @@
5DBAE0A51D355EE700CE00BF /* Lock Screen */ = {
isa = PBXGroup;
children = (
+ 5D6F7A301BC5B7100070BF37 /* Lock Screen UI */,
5D76E31F1D39731100647CFA /* Utilities */,
5D4D67B21D30161600468B4A /* SDLLockScreenManager.h */,
5D4D67B31D30161600468B4A /* SDLLockScreenManager.m */,
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index 6c4cd41f9..6a70e6675 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -90,7 +90,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
return nil;
}
- SDLLogV(@"Creating Lifecycle Manager");
+ SDLLogV(@"Initializing Lifecycle Manager");
// Dependencies
_configuration = [configuration copy];
@@ -134,12 +134,14 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
return;
}
+ SDLLogD(@"Starting lifecycle manager");
self.readyHandler = [readyHandler copy];
[self.lifecycleStateMachine transitionToState:SDLLifecycleStateStarted];
}
- (void)stop {
+ SDLLogD(@"Lifecycle manager stopped");
if ([self.lifecycleStateMachine isCurrentState:SDLLifecycleStateReady]) {
[self.lifecycleStateMachine transitionToState:SDLLifecycleStateUnregistering];
} else {
@@ -193,7 +195,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
}
- (void)sdl_stopManager:(BOOL)shouldRestart {
- SDLLogV(@"Stopping manager");
+ SDLLogV(@"Stopping manager, %@", (shouldRestart ? @"will restart" : @"will not restart"));
[self.fileManager stop];
[self.permissionManager stop];
@@ -224,6 +226,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
- (void)didEnterStateConnected {
// If we have security managers, add them to the proxy
if (self.configuration.streamingMediaConfig.securityManagers != nil) {
+ SDLLogD(@"Adding security managers");
[self.proxy addSecurityManagers:self.configuration.streamingMediaConfig.securityManagers forAppId:self.configuration.lifecycleConfig.appId];
}
@@ -256,7 +259,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
// Make sure there's at least one group_enter until we have synchronously run through all the startup calls
dispatch_group_enter(managerGroup);
-
+ SDLLogD(@"Setting up assistant managers");
[self.lockScreenManager start];
dispatch_group_enter(managerGroup);
@@ -288,10 +291,9 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
- (void)didEnterStateSettingUpAppIcon {
// We only want to send the app icon when the file manager is complete, and when that's done, wait for hmi status to be ready
- [self sdl_sendAppIcon:self.configuration.lifecycleConfig.appIcon
- withCompletion:^{
- [self.lifecycleStateMachine transitionToState:SDLLifecycleStateSettingUpHMI];
- }];
+ [self sdl_sendAppIcon:self.configuration.lifecycleConfig.appIcon withCompletion:^{
+ [self.lifecycleStateMachine transitionToState:SDLLifecycleStateSettingUpHMI];
+ }];
}
- (void)didEnterStateSettingUpHMI {
@@ -347,32 +349,31 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
return;
}
- [self.fileManager uploadFile:appIcon
- completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError *_Nullable error) {
- // These errors could be recoverable (particularly "cannot overwrite"), so we'll still attempt to set the app icon
- if (error != nil) {
- if (error.code == SDLFileManagerErrorCannotOverwrite) {
- SDLLogD(@"Failed to upload app icon: A file with this name already exists on the system");
- } else {
- SDLLogW(@"Unexpected error uploading app icon: %@", error);
- return;
- }
- }
-
- // Once we've tried to put the file on the remote system, try to set the app icon
- SDLSetAppIcon *setAppIcon = [[SDLSetAppIcon alloc] init];
- setAppIcon.syncFileName = appIcon.name;
-
- [self sdl_sendRequest:setAppIcon
- withResponseHandler:^(__kindof SDLRPCRequest *_Nullable request, __kindof SDLRPCResponse *_Nullable response, NSError *_Nullable error) {
- if (error != nil) {
- SDLLogW(@"Error setting up app icon: %@", error);
- }
-
- // We've succeeded or failed
- completion();
- }];
- }];
+ [self.fileManager uploadFile:appIcon completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError *_Nullable error) {
+ // These errors could be recoverable (particularly "cannot overwrite"), so we'll still attempt to set the app icon
+ if (error != nil) {
+ if (error.code == SDLFileManagerErrorCannotOverwrite) {
+ SDLLogW(@"Failed to upload app icon: A file with this name already exists on the system");
+ } else {
+ SDLLogW(@"Unexpected error uploading app icon: %@", error);
+ return;
+ }
+ }
+
+ // Once we've tried to put the file on the remote system, try to set the app icon
+ SDLSetAppIcon *setAppIcon = [[SDLSetAppIcon alloc] init];
+ setAppIcon.syncFileName = appIcon.name;
+
+ [self sdl_sendRequest:setAppIcon
+ withResponseHandler:^(__kindof SDLRPCRequest *_Nullable request, __kindof SDLRPCResponse *_Nullable response, NSError *_Nullable error) {
+ if (error != nil) {
+ SDLLogW(@"Error setting up app icon: %@", error);
+ }
+
+ // We've succeeded or failed
+ completion();
+ }];
+ }];
}
@@ -402,7 +403,6 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
- (void)sdl_sendRequest:(SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler {
// We will allow things to be sent in a "SDLLifeCycleStateConnected" state in the private method, but block it in the public method sendRequest:withCompletionHandler: so that the lifecycle manager can complete its setup without being bothered by developer error
-
NSParameterAssert(request != nil);
// If, for some reason, the request is nil we should error out.
@@ -455,10 +455,12 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
#pragma mark SDL notification observers
- (void)transportDidConnect {
+ SDLLogD(@"Transport connected");
[self.lifecycleStateMachine transitionToState:SDLLifecycleStateConnected];
}
- (void)transportDidDisconnect {
+ SDLLogD(@"Transport Disconnected");
if (self.lifecycleState == SDLLifecycleStateUnregistering || self.lifecycleState == SDLLifecycleStateStopped) {
[self.lifecycleStateMachine transitionToState:SDLLifecycleStateStopped];
} else {
@@ -481,6 +483,8 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
SDLSystemContext oldSystemContext = self.systemContext;
self.systemContext = hmiStatusNotification.systemContext;
+ SDLLogD(@"HMI level changed from %@ to %@", oldHMILevel, self.hmiLevel);
+
if (!self.firstHMINonNoneOccurred && ![self.hmiLevel isEqualToEnum:SDLHMILevelNone]) {
self.firstHMINonNoneOccurred = YES;
[self sdl_onFirstHMINonNone];
diff --git a/SmartDeviceLink/SDLStateMachine.m b/SmartDeviceLink/SDLStateMachine.m
index cc34d99e2..ffc269503 100644
--- a/SmartDeviceLink/SDLStateMachine.m
+++ b/SmartDeviceLink/SDLStateMachine.m
@@ -9,6 +9,7 @@
#import "SDLStateMachine.h"
#import "SDLError.h"
+#import "SDLLogMacros.h"
NS_ASSUME_NONNULL_BEGIN
@@ -80,6 +81,8 @@ SDLStateMachineTransitionFormat const SDLStateMachineTransitionFormatDidEnter =
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
+ SDLLogV(@"State machine for class %@ will transition from state %@ to state %@", NSStringFromClass([_target class]), oldState, state);
+
// Pre state transition calls
if ([self.target respondsToSelector:willLeave]) {
[self.target performSelector:willLeave];