summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2021-04-21 10:09:23 -0400
committerNicoleYarroch <nicole@livio.io>2021-04-21 10:09:23 -0400
commit8a4a02684483edaf9566ddcf6582542195588ee8 (patch)
treeae460a3719a19eb2d68e73461f65de5dc40db4a0
parent5bd0d7ceb196e3d0888f151cde9ccda6ff0f1a71 (diff)
downloadsdl_ios-8a4a02684483edaf9566ddcf6582542195588ee8.tar.gz
Added temporary fix for uploading file
Signed-off-by: NicoleYarroch <nicole@livio.io>
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj2
-rw-r--r--SmartDeviceLink/public/SDLFileManager.m9
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m16
3 files changed, 25 insertions, 2 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index 8dba00f2c..786b67dba 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -1645,6 +1645,7 @@
88D2AAE41F682BB20078D5B2 /* SDLLogConstantsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88D2AAE31F682BB20078D5B2 /* SDLLogConstantsSpec.m */; };
88D79EED255D8D5B005FACB1 /* SDLPresentAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 88D79EEB255D8D5B005FACB1 /* SDLPresentAlertOperation.h */; };
88D79EEE255D8D5B005FACB1 /* SDLPresentAlertOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 88D79EEC255D8D5B005FACB1 /* SDLPresentAlertOperation.m */; };
+ 88D930262630686100DA9E44 /* SDLFileManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9F50821BEA5C6100FEF399 /* SDLFileManagerSpec.m */; };
88DDD0F9229ECA57002F9623 /* SDLIAPConstantsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88DDD0F8229ECA57002F9623 /* SDLIAPConstantsSpec.m */; };
88DF998D22035CC600477AC1 /* EAAccessory+OCMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 88DF998C22035CC600477AC1 /* EAAccessory+OCMock.m */; };
88DF998F22035D1700477AC1 /* SDLIAPSessionSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88DF998E22035D1700477AC1 /* SDLIAPSessionSpec.m */; };
@@ -8995,6 +8996,7 @@
162E83791A9BDE8B00906325 /* SDLDeviceStatusSpec.m in Sources */,
162E83821A9BDE8B00906325 /* SDLImageSpec.m in Sources */,
162E834A1A9BDE8B00906325 /* SDLAddSubMenuResponseSpec.m in Sources */,
+ 88D930262630686100DA9E44 /* SDLFileManagerSpec.m in Sources */,
162E830C1A9BDE8B00906325 /* SDLWarningLightStatusSpec.m in Sources */,
881BBF5B255ADB8300761B7E /* SDLAlertViewSpec.m in Sources */,
1EE8C45F1F3884FF00FDC2CF /* SDLSetInteriorVehicleDataSpec.m in Sources */,
diff --git a/SmartDeviceLink/public/SDLFileManager.m b/SmartDeviceLink/public/SDLFileManager.m
index 2bd0bde31..4f90b4711 100644
--- a/SmartDeviceLink/public/SDLFileManager.m
+++ b/SmartDeviceLink/public/SDLFileManager.m
@@ -178,11 +178,16 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
// If there was an error, we'll pass the error to the startup handler and cancel out
if (error != nil) {
- // HAX: In the case we are DISALLOWED we still want to transition to a ready state. Some head units return DISALLOWED for this RPC but otherwise work.
- if([error.userInfo[@"resultCode"] isEqualToEnum:SDLResultDisallowed]) {
+ if ([error.userInfo[@"resultCode"] isEqualToEnum:SDLResultDisallowed]) {
+ // HAX: In the case we are DISALLOWED we still want to transition to a ready state. Some head units return DISALLOWED for this RPC but otherwise work.
SDLLogW(@"ListFiles is disallowed. Certain file manager APIs may not work properly.");
[weakSelf.stateMachine transitionToState:SDLFileManagerStateReady];
BLOCK_RETURN;
+ } else if ([error.userInfo[@"resultCode"] isEqualToEnum:SDLResultEncryptionNeeded]) {
+ // HAX: If the module rejects the ListFiles request because it requires the request be encrypted, we still want to transition to a ready state. Unfortunately, since we do not know what files are on the module already, we may end up doing unnecessary duplicate file uploads.
+ SDLLogW(@"ListFiles must be encrypted. We do not know which files have already been uploaded to the module. Certain file manager APIs may not work properly.");
+ [weakSelf.stateMachine transitionToState:SDLFileManagerStateReady];
+ BLOCK_RETURN;
}
[weakSelf.stateMachine transitionToState:SDLFileManagerStateStartupError];
BLOCK_RETURN;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
index 2914597d6..243b3f5ec 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
@@ -172,6 +172,22 @@ describe(@"uploading / deleting single files with the file manager", ^{
});
});
+ describe(@"after receiving a ListFiles error with a resultCode ENCRYPTION_NEEDED", ^{
+ beforeEach(^{
+ SDLListFilesOperation *operation = testFileManager.pendingTransactions.firstObject;
+ NSMutableDictionary *userInfo = [[NSError sdl_fileManager_unableToStartError].userInfo mutableCopy];
+ userInfo[@"resultCode"] = SDLResultEncryptionNeeded;
+ NSError *errorWithResultCode = [NSError errorWithDomain:[NSError sdl_fileManager_unableToStartError].domain code:[NSError sdl_fileManager_unableToStartError].code userInfo:userInfo];
+ operation.completionHandler(NO, initialSpaceAvailable, testInitialFileNames, errorWithResultCode);
+ });
+
+ it(@"should handle the error properly", ^{
+ expect(testFileManager.currentState).to(match(SDLFileManagerStateReady));
+ expect(testFileManager.remoteFileNames).to(beEmpty());
+ expect(@(testFileManager.bytesAvailable)).to(equal(initialSpaceAvailable));
+ });
+ });
+
describe(@"after receiving a ListFiles response", ^{
beforeEach(^{
SDLListFilesOperation *operation = testFileManager.pendingTransactions.firstObject;