summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2021-09-24 11:07:00 -0400
committerJoel Fischer <joeljfischer@gmail.com>2021-09-24 11:07:00 -0400
commit1844b32b14121d3c2ecbb6d263fb96a7b7d30e1d (patch)
tree329886ba9bbed7a59a03ab1726732b4a215e029d
parent095d0a2eaba8c7d607b28f1e78aa2af911740d27 (diff)
downloadsdl_ios-1844b32b14121d3c2ecbb6d263fb96a7b7d30e1d.tar.gz
Fix many cases of completion handlers not called
-rw-r--r--SmartDeviceLink/private/SDLCheckChoiceVROptionalOperation.m8
-rw-r--r--SmartDeviceLink/private/SDLChoiceSetManager.m11
-rw-r--r--SmartDeviceLink/private/SDLDeleteChoicesOperation.m5
-rw-r--r--SmartDeviceLink/private/SDLDeleteFileOperation.m4
-rw-r--r--SmartDeviceLink/private/SDLError.h2
-rw-r--r--SmartDeviceLink/private/SDLError.m8
-rw-r--r--SmartDeviceLink/private/SDLFileWrapper.m4
-rw-r--r--SmartDeviceLink/private/SDLListFilesOperation.m4
-rw-r--r--SmartDeviceLink/private/SDLMenuShowOperation.m7
-rw-r--r--SmartDeviceLink/private/SDLProtocolMessageAssembler.m2
-rw-r--r--SmartDeviceLink/private/SDLSequentialRPCRequestOperation.m7
-rw-r--r--SmartDeviceLink/private/SDLVoiceCommandUpdateOperation.m5
-rw-r--r--SmartDeviceLink/public/SDLErrorConstants.h9
-rw-r--r--SmartDeviceLink/public/SDLErrorConstants.m1
14 files changed, 67 insertions, 10 deletions
diff --git a/SmartDeviceLink/private/SDLCheckChoiceVROptionalOperation.m b/SmartDeviceLink/private/SDLCheckChoiceVROptionalOperation.m
index f9ee3168b..0b661c6c5 100644
--- a/SmartDeviceLink/private/SDLCheckChoiceVROptionalOperation.m
+++ b/SmartDeviceLink/private/SDLCheckChoiceVROptionalOperation.m
@@ -12,6 +12,7 @@
#import "SDLCreateInteractionChoiceSet.h"
#import "SDLConnectionManagerType.h"
#import "SDLDeleteInteractionChoiceSet.h"
+#import "SDLError.h"
#import "SDLLogMacros.h"
NS_ASSUME_NONNULL_BEGIN
@@ -28,9 +29,12 @@ NS_ASSUME_NONNULL_BEGIN
@implementation SDLCheckChoiceVROptionalOperation
-- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager completionHandler:(nonnull SDLCheckChoiceVROptionalCompletionHandler)completionHandler {
+- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager completionHandler:(SDLCheckChoiceVROptionalCompletionHandler)completionHandler {
self = [super init];
- if (!self) { return nil; }
+ if (!self) {
+ completionHandler(NO, [NSError sdl_failedToCreateObjectOfClass:[SDLCheckChoiceVROptionalOperation class]]);
+ return nil;
+ }
_connectionManager = connectionManager;
_operationId = [NSUUID UUID];
diff --git a/SmartDeviceLink/private/SDLChoiceSetManager.m b/SmartDeviceLink/private/SDLChoiceSetManager.m
index 006cff639..ae41c39c1 100644
--- a/SmartDeviceLink/private/SDLChoiceSetManager.m
+++ b/SmartDeviceLink/private/SDLChoiceSetManager.m
@@ -222,7 +222,16 @@ UInt16 const ChoiceCellCancelIdMax = 200;
- (void)preloadChoices:(NSArray<SDLChoiceCell *> *)choices withCompletionHandler:(nullable SDLPreloadChoiceCompletionHandler)handler {
SDLLogV(@"Request to preload choices: %@", choices);
- if (choices.count == 0) { return; }
+ if (choices.count == 0) {
+ if (handler != nil) {
+ handler([NSError sdl_choiceSetManager_choiceUploadFailed:@{
+ NSLocalizedDescriptionKey: @"Choice upload failed",
+ NSLocalizedFailureReasonErrorKey: @"No choices were provided for upload",
+ NSLocalizedRecoverySuggestionErrorKey: @"Provide some choice cells to upload instead of an empty list"
+ }]);
+ }
+ return;
+ }
if (![self.currentState isEqualToString:SDLChoiceManagerStateReady]) {
NSError *error = [NSError sdl_choiceSetManager_incorrectState:self.currentState];
SDLLogE(@"Cannot preload choices when the manager isn't in the ready state: %@", error);
diff --git a/SmartDeviceLink/private/SDLDeleteChoicesOperation.m b/SmartDeviceLink/private/SDLDeleteChoicesOperation.m
index 189460b34..03ca2a4ab 100644
--- a/SmartDeviceLink/private/SDLDeleteChoicesOperation.m
+++ b/SmartDeviceLink/private/SDLDeleteChoicesOperation.m
@@ -37,7 +37,10 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager cellsToDelete:(NSSet<SDLChoiceCell *> *)cellsToDelete loadedCells:(NSSet<SDLChoiceCell *> *)loadedCells completionHandler:(SDLDeleteChoicesCompletionHandler)completionHandler {
self = [super init];
- if (!self) { return nil; }
+ if (!self) {
+ completionHandler(loadedCells, [NSError sdl_failedToCreateObjectOfClass:[SDLDeleteChoicesOperation class]]);
+ return nil;
+ }
_connectionManager = connectionManager;
_cellsToDelete = cellsToDelete;
diff --git a/SmartDeviceLink/private/SDLDeleteFileOperation.m b/SmartDeviceLink/private/SDLDeleteFileOperation.m
index e7ce7e204..80efdf332 100644
--- a/SmartDeviceLink/private/SDLDeleteFileOperation.m
+++ b/SmartDeviceLink/private/SDLDeleteFileOperation.m
@@ -11,6 +11,7 @@
#import "SDLConnectionManagerType.h"
#import "SDLDeleteFile.h"
#import "SDLDeleteFileResponse.h"
+#import "SDLError.h"
NS_ASSUME_NONNULL_BEGIN
@@ -28,6 +29,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithFileName:(NSString *)fileName connectionManager:(id<SDLConnectionManagerType>)connectionManager completionHandler:(nullable SDLFileManagerDeleteCompletionHandler)completionHandler {
self = [super init];
if (!self) {
+ if (completionHandler != nil) {
+ completionHandler(NO, NSNotFound, [NSError sdl_failedToCreateObjectOfClass:[SDLDeleteFileOperation class]]);
+ }
return nil;
}
diff --git a/SmartDeviceLink/private/SDLError.h b/SmartDeviceLink/private/SDLError.h
index 7baabc7d1..2829a9634 100644
--- a/SmartDeviceLink/private/SDLError.h
+++ b/SmartDeviceLink/private/SDLError.h
@@ -20,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface NSError (SDLErrors)
++ (NSError *)sdl_failedToCreateObjectOfClass:(Class)objectClass;
+
#pragma mark SDLEncryptionLifecycleManager
+ (NSError *)sdl_encryption_lifecycle_notReadyError;
+ (NSError *)sdl_encryption_lifecycle_encryption_off;
diff --git a/SmartDeviceLink/private/SDLError.m b/SmartDeviceLink/private/SDLError.m
index a1dc6b52d..0bbd94f21 100644
--- a/SmartDeviceLink/private/SDLError.m
+++ b/SmartDeviceLink/private/SDLError.m
@@ -15,6 +15,14 @@ NS_ASSUME_NONNULL_BEGIN
@implementation NSError (SDLErrors)
++ (NSError *)sdl_failedToCreateObjectOfClass:(Class)objectClass {
+ return [NSError errorWithDomain:SDLErrorDomainSystem code:SDLSystemErrorFailedToCreateObject userInfo:@{
+ NSLocalizedDescriptionKey: [NSString stringWithFormat: @"iOS system failed to create a new object of class: %@", objectClass],
+ NSLocalizedFailureReasonErrorKey: @"An unknown error caused iOS to fail to create an object",
+ NSLocalizedRecoverySuggestionErrorKey: @"There is no known way to fix this error"
+ }];
+}
+
#pragma mark - SDLEncryptionLifecycleManager
+ (NSError *)sdl_encryption_lifecycle_notReadyError {
NSDictionary<NSString *, NSString *> *userInfo = @{
diff --git a/SmartDeviceLink/private/SDLFileWrapper.m b/SmartDeviceLink/private/SDLFileWrapper.m
index fac2b6580..c6500171d 100644
--- a/SmartDeviceLink/private/SDLFileWrapper.m
+++ b/SmartDeviceLink/private/SDLFileWrapper.m
@@ -8,6 +8,7 @@
#import "SDLFileWrapper.h"
+#import "SDLError.h"
#import "SDLFile.h"
@@ -18,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithFile:(SDLFile *)file completionHandler:(SDLFileManagerUploadCompletionHandler)completionHandler {
self = [super init];
if (!self) {
+ completionHandler(NO, NSNotFound, [NSError sdl_failedToCreateObjectOfClass:[SDLFileWrapper class]]);
return nil;
}
@@ -33,4 +35,4 @@ NS_ASSUME_NONNULL_BEGIN
@end
-NS_ASSUME_NONNULL_END \ No newline at end of file
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/private/SDLListFilesOperation.m b/SmartDeviceLink/private/SDLListFilesOperation.m
index 693d52eea..2eb3102b0 100644
--- a/SmartDeviceLink/private/SDLListFilesOperation.m
+++ b/SmartDeviceLink/private/SDLListFilesOperation.m
@@ -9,6 +9,7 @@
#import "SDLListFilesOperation.h"
#import "SDLConnectionManagerType.h"
+#import "SDLError.h"
#import "SDLListFiles.h"
#import "SDLListFilesResponse.h"
@@ -29,6 +30,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager completionHandler:(nullable SDLFileManagerListFilesCompletionHandler)completionHandler {
self = [super init];
if (!self) {
+ if (completionHandler != nil) {
+ completionHandler(NO, NSNotFound, @[], [NSError sdl_failedToCreateObjectOfClass:[SDLListFilesOperation class]]);
+ }
return nil;
}
diff --git a/SmartDeviceLink/private/SDLMenuShowOperation.m b/SmartDeviceLink/private/SDLMenuShowOperation.m
index 92fa5a971..c62bfb5c4 100644
--- a/SmartDeviceLink/private/SDLMenuShowOperation.m
+++ b/SmartDeviceLink/private/SDLMenuShowOperation.m
@@ -38,9 +38,12 @@ NS_ASSUME_NONNULL_BEGIN
@implementation SDLMenuShowOperation
-- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager toMenuCell:(nullable SDLMenuCell *)menuCell completionHandler:(nonnull SDLMenuShowCompletionBlock)completionHandler {
+- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager toMenuCell:(nullable SDLMenuCell *)menuCell completionHandler:(SDLMenuShowCompletionBlock)completionHandler {
self = [super init];
- if (!self) { return nil; }
+ if (!self) {
+ completionHandler([NSError sdl_failedToCreateObjectOfClass:[SDLMenuShowOperation class]]);
+ return nil;
+ }
_connectionManager = connectionManager;
_submenuCell = menuCell;
diff --git a/SmartDeviceLink/private/SDLProtocolMessageAssembler.m b/SmartDeviceLink/private/SDLProtocolMessageAssembler.m
index e4a07541c..6df71e5d9 100644
--- a/SmartDeviceLink/private/SDLProtocolMessageAssembler.m
+++ b/SmartDeviceLink/private/SDLProtocolMessageAssembler.m
@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
// Validate input
if (message.header.sessionID != self.sessionID) {
SDLLogE(@"Message part sent to the wrong assembler. This session id: %d, message session id: %d", self.sessionID, message.header.sessionID);
- return;
+ return completionHandler(NO, nil);
}
if (self.parts == nil) {
diff --git a/SmartDeviceLink/private/SDLSequentialRPCRequestOperation.m b/SmartDeviceLink/private/SDLSequentialRPCRequestOperation.m
index 96c44b82c..9fb348986 100644
--- a/SmartDeviceLink/private/SDLSequentialRPCRequestOperation.m
+++ b/SmartDeviceLink/private/SDLSequentialRPCRequestOperation.m
@@ -34,7 +34,12 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager requests:(NSArray<SDLRPCRequest *> *)requests progressHandler:(nullable SDLMultipleSequentialRequestProgressHandler)progressHandler completionHandler:(nullable SDLMultipleRequestCompletionHandler)completionHandler {
self = [super init];
- if (!self) { return nil; }
+ if (!self) {
+ if (completionHandler != nil) {
+ completionHandler(NO);
+ }
+ return nil;
+ }
executing = NO;
finished = NO;
diff --git a/SmartDeviceLink/private/SDLVoiceCommandUpdateOperation.m b/SmartDeviceLink/private/SDLVoiceCommandUpdateOperation.m
index 548c3fbcb..9d80ea8a3 100644
--- a/SmartDeviceLink/private/SDLVoiceCommandUpdateOperation.m
+++ b/SmartDeviceLink/private/SDLVoiceCommandUpdateOperation.m
@@ -39,7 +39,10 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager pendingVoiceCommands:(NSArray<SDLVoiceCommand *> *)pendingVoiceCommands oldVoiceCommands:(NSArray<SDLVoiceCommand *> *)oldVoiceCommands updateCompletionHandler:(SDLVoiceCommandUpdateCompletionHandler)completionHandler {
self = [self init];
- if (!self) { return nil; }
+ if (!self) {
+ completionHandler(@[], [NSError sdl_failedToCreateObjectOfClass:[SDLVoiceCommandUpdateOperation class]]);
+ return nil;
+ }
_connectionManager = connectionManager;
_pendingVoiceCommands = pendingVoiceCommands;
diff --git a/SmartDeviceLink/public/SDLErrorConstants.h b/SmartDeviceLink/public/SDLErrorConstants.h
index a148e9f57..c5e0fc88f 100644
--- a/SmartDeviceLink/public/SDLErrorConstants.h
+++ b/SmartDeviceLink/public/SDLErrorConstants.h
@@ -13,6 +13,9 @@
/// A typedef declaration of the SDL error domain
typedef NSString SDLErrorDomain;
+/// An error with the iOS system
+extern SDLErrorDomain *const SDLErrorDomainSystem;
+
/// An error in the SDLAudioStreamManager
extern SDLErrorDomain *const SDLErrorDomainAudioStreamManager;
@@ -58,6 +61,12 @@ extern SDLErrorDomain *const SDLErrorDomainTransport;
#pragma mark Error Codes
+/// Error associated with the underlying operating system
+typedef NS_ENUM(NSInteger, SDLSystemError) {
+ /// iOS failed to create an object
+ SDLSystemErrorFailedToCreateObject = -1
+};
+
/**
* Errors associated with the SDLManager class.
*/
diff --git a/SmartDeviceLink/public/SDLErrorConstants.m b/SmartDeviceLink/public/SDLErrorConstants.m
index ccfc62472..b6e77a210 100644
--- a/SmartDeviceLink/public/SDLErrorConstants.m
+++ b/SmartDeviceLink/public/SDLErrorConstants.m
@@ -10,6 +10,7 @@
#pragma mark Error Domains
+SDLErrorDomain *const SDLErrorDomainSystem = @"com.sdl.system.error";
SDLErrorDomain *const SDLErrorDomainAudioStreamManager = @"com.sdl.extension.pcmAudioStreamManager";
SDLErrorDomain *const SDLErrorDomainCacheFileManager = @"com.sdl.cachefilemanager.error";
SDLErrorDomain *const SDLErrorDomainChoiceSetManager = @"com.sdl.choicesetmanager.error";