summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2021-09-24 11:38:51 -0400
committerJoel Fischer <joeljfischer@gmail.com>2021-09-24 11:38:51 -0400
commit7769ece279def35c1cb204c93724a9791c9ebfb5 (patch)
tree38c500e98e6a5691e232acc7c6810f0cb6e87255
parent1844b32b14121d3c2ecbb6d263fb96a7b7d30e1d (diff)
downloadsdl_ios-7769ece279def35c1cb204c93724a9791c9ebfb5.tar.gz
Additional completion handler fixes
-rw-r--r--SmartDeviceLink/private/SDLError.h3
-rw-r--r--SmartDeviceLink/private/SDLError.m24
-rw-r--r--SmartDeviceLink/private/SDLTextAndGraphicManager.m13
-rw-r--r--SmartDeviceLink/public/SDLErrorConstants.h13
-rw-r--r--SmartDeviceLink/public/SDLFileManager.m5
-rw-r--r--SmartDeviceLink/public/SDLSystemCapabilityManager.m4
6 files changed, 53 insertions, 9 deletions
diff --git a/SmartDeviceLink/private/SDLError.h b/SmartDeviceLink/private/SDLError.h
index 2829a9634..72453b06f 100644
--- a/SmartDeviceLink/private/SDLError.h
+++ b/SmartDeviceLink/private/SDLError.h
@@ -58,6 +58,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSError *)sdl_softButtonManager_pendingUpdateSuperseded;
+ (NSError *)sdl_subscribeButtonManager_notSubscribed;
+ (NSError *)sdl_textAndGraphicManager_pendingUpdateSuperseded;
++ (NSError *)sdl_textAndGraphicManager_batchingUpdate;
++ (NSError *)sdl_textAndGraphicManager_nothingToUpdate;
#pragma mark Menu Manager
@@ -91,6 +93,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSError *)sdl_systemCapabilityManager_moduleDoesNotSupportSystemCapabilities;
+ (NSError *)sdl_systemCapabilityManager_cannotUpdateInHMINONE;
+ (NSError *)sdl_systemCapabilityManager_cannotUpdateTypeDISPLAYS;
++ (NSError *)sdl_systemCapabilityManager_unknownSystemCapabilityType;
#pragma mark Transport
diff --git a/SmartDeviceLink/private/SDLError.m b/SmartDeviceLink/private/SDLError.m
index 0bbd94f21..120077f88 100644
--- a/SmartDeviceLink/private/SDLError.m
+++ b/SmartDeviceLink/private/SDLError.m
@@ -277,6 +277,22 @@ NS_ASSUME_NONNULL_BEGIN
return [NSError errorWithDomain:SDLErrorDomainSubscribeButtonManager code:SDLSubscribeButtonManagerErrorNotSubscribed userInfo:userInfo];
}
++ (NSError *)sdl_textAndGraphicManager_batchingUpdate {
+ return [NSError errorWithDomain:SDLErrorDomainTextAndGraphicManager code:SDLTextAndGraphicManagerErrorCurrentlyBatching userInfo:@{
+ NSLocalizedDescriptionKey: @"Update will not run because batching is enabled",
+ NSLocalizedFailureReasonErrorKey: @"Text and Graphic manager will not run this update and call this handler because its currently batching updates. The update will occur when batching ends.",
+ NSLocalizedRecoverySuggestionErrorKey: @"This callback shouldn't occur. Please open an issue on https://www.github.com/smartdevicelink/sdl_ios/ if it does"
+ }];
+}
+
++ (NSError *)sdl_textAndGraphicManager_nothingToUpdate {
+ return [NSError errorWithDomain:SDLErrorDomainTextAndGraphicManager code:SDLTextAndGraphicManagerErrorNothingToUpdate userInfo:@{
+ NSLocalizedDescriptionKey: @"Update will not run because there's nothing to update",
+ NSLocalizedFailureReasonErrorKey: @"This callback shouldn't occur, so there's no known reason for this failure.",
+ NSLocalizedRecoverySuggestionErrorKey: @"This callback shouldn't occur. Please open an issue on https://www.github.com/smartdevicelink/sdl_ios/ if it does"
+ }];
+}
+
#pragma mark Menu Manager
+ (NSError *)sdl_menuManager_configurationOperationLayoutsNotSupported {
@@ -454,6 +470,14 @@ NS_ASSUME_NONNULL_BEGIN
return [NSError errorWithDomain:SDLErrorDomainSystemCapabilityManager code:SDLSystemCapabilityManagerErrorCannotUpdateTypeDisplays userInfo:userInfo];
}
++ (NSError *)sdl_systemCapabilityManager_unknownSystemCapabilityType {
+ return [NSError errorWithDomain:SDLErrorDomainSystemCapabilityManager code:SDLSystemCapabilityManagerErrorUnknownType userInfo:@{
+ NSLocalizedDescriptionKey: @"An unknown system capability type was received.",
+ NSLocalizedFailureReasonErrorKey: @"Failure reason unknown. If you see this, please open an issue on https://www.github.com/smartdevicelink/sdl_ios/",
+ NSLocalizedRecoverySuggestionErrorKey: @"Ensure you are only attempting to manually subscribe to known system capability types for the version of this library. You may also want to update this library to its latest version."
+ }];
+}
+
#pragma mark Transport
+ (NSError *)sdl_transport_unknownError {
diff --git a/SmartDeviceLink/private/SDLTextAndGraphicManager.m b/SmartDeviceLink/private/SDLTextAndGraphicManager.m
index 37b9f95fa..34c4dcf54 100644
--- a/SmartDeviceLink/private/SDLTextAndGraphicManager.m
+++ b/SmartDeviceLink/private/SDLTextAndGraphicManager.m
@@ -150,11 +150,18 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Upload / Send
- (void)updateWithCompletionHandler:(nullable SDLTextAndGraphicUpdateCompletionHandler)handler {
- if (self.isBatchingUpdates) { return; }
-
- if (self.isDirty) {
+ if (self.isBatchingUpdates) {
+ if (handler != nil) {
+ // This shouldn't be possible, but just in case
+ handler([NSError sdl_textAndGraphicManager_batchingUpdate]);
+ }
+ } else if (self.isDirty) {
self.isDirty = NO;
[self sdl_updateAndCancelPreviousOperations:YES completionHandler:handler];
+ } else {
+ if (handler != nil) {
+ handler([NSError sdl_textAndGraphicManager_nothingToUpdate]);
+ }
}
}
diff --git a/SmartDeviceLink/public/SDLErrorConstants.h b/SmartDeviceLink/public/SDLErrorConstants.h
index c5e0fc88f..ce433d396 100644
--- a/SmartDeviceLink/public/SDLErrorConstants.h
+++ b/SmartDeviceLink/public/SDLErrorConstants.h
@@ -177,7 +177,13 @@ typedef NS_ENUM(NSInteger, SDLFileManagerError) {
*/
typedef NS_ENUM(NSInteger, SDLTextAndGraphicManagerError) {
/// A pending update was superseded by a newer requested update. The old update will not be sent
- SDLTextAndGraphicManagerErrorPendingUpdateSuperseded = -1
+ SDLTextAndGraphicManagerErrorPendingUpdateSuperseded = -1,
+
+ /// The manager is currently batching updates so the update will not yet be sent and the handler will not be called
+ SDLTextAndGraphicManagerErrorCurrentlyBatching = -2,
+
+ /// The manager could find nothing to update
+ SDLTextAndGraphicManagerErrorNothingToUpdate = -3,
};
/**
@@ -251,7 +257,10 @@ typedef NS_ENUM(NSInteger, SDLSystemCapabilityManagerError) {
SDLSystemCapabilityManagerErrorHMINone = -2,
/// You may not update the system capability type DISPLAYS because it is always subscribed
- SDLSystemCapabilityManagerErrorCannotUpdateTypeDisplays = -3
+ SDLSystemCapabilityManagerErrorCannotUpdateTypeDisplays = -3,
+
+ /// The module sent an unknown system capability type
+ SDLSystemCapabilityManagerErrorUnknownType = -4,
};
/**
diff --git a/SmartDeviceLink/public/SDLFileManager.m b/SmartDeviceLink/public/SDLFileManager.m
index 2acf44626..8407dd748 100644
--- a/SmartDeviceLink/public/SDLFileManager.m
+++ b/SmartDeviceLink/public/SDLFileManager.m
@@ -407,7 +407,6 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
- (void)sdl_uploadFile:(SDLFile *)file completionHandler:(nullable SDLFileManagerUploadCompletionHandler)handler {
__block NSString *fileName = file.name;
- __block SDLFileManagerUploadCompletionHandler uploadCompletion = [handler copy];
__weak typeof(self) weakSelf = self;
SDLFileWrapper *fileWrapper = [SDLFileWrapper wrapperWithFile:file completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError *_Nullable error) {
@@ -425,8 +424,8 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
}
}
- if (uploadCompletion != nil) {
- uploadCompletion(success, bytesAvailable, error);
+ if (handler != nil) {
+ handler(success, bytesAvailable, error);
}
}];
diff --git a/SmartDeviceLink/public/SDLSystemCapabilityManager.m b/SmartDeviceLink/public/SDLSystemCapabilityManager.m
index 9130cd673..849f8f2e8 100644
--- a/SmartDeviceLink/public/SDLSystemCapabilityManager.m
+++ b/SmartDeviceLink/public/SDLSystemCapabilityManager.m
@@ -450,11 +450,13 @@ typedef NSString * SDLServiceID;
[self sdl_saveDisplayCapabilityListUpdate:systemCapability.displayCapabilities];
} else {
SDLLogW(@"Received response for unknown System Capability Type: %@", systemCapabilityType);
+ if (handler != nil) {
+ handler(systemCapability, NO, [NSError sdl_systemCapabilityManager_unknownSystemCapabilityType]);
+ }
return NO;
}
SDLLogD(@"Updated system capability manager with new data: %@", systemCapability);
-
[self sdl_callObserversForUpdate:systemCapability error:error handler:handler];
return YES;
}