From 8a780c9c492711af915a1e37d6e90a3c1df50552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 28 Aug 2015 17:46:57 +0200 Subject: Support OpenPGP API v9 --- .../keychain/remote/OpenPgpService.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index cc4a08fb4..57dd068ef 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -66,8 +66,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.HashSet; +import java.util.List; public class OpenPgpService extends RemoteService { @@ -813,19 +815,14 @@ public class OpenPgpService extends RemoteService { } // version code is required and needs to correspond to version code of service! - // History of versions in org.openintents.openpgp.util.OpenPgpApi - // we support 3, 4, 5, 6 - if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 3 - && data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 4 - && data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 5 - && data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 6 - && data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 7 - && data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 8) { + // History of versions in openpgp-api's CHANGELOG.md + List supportedVersions = Arrays.asList(3, 4, 5, 6, 7, 8, 9); + if (!supportedVersions.contains(data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1))) { Intent result = new Intent(); OpenPgpError error = new OpenPgpError (OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!\n" + "used API version: " + data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) + "\n" - + "supported API versions: 3-8"); + + "supported API versions: " + supportedVersions.toString()); result.putExtra(OpenPgpApi.RESULT_ERROR, error); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); return result; @@ -855,7 +852,6 @@ public class OpenPgpService extends RemoteService { } - protected Intent executeInternal(Intent data, ParcelFileDescriptor input, ParcelFileDescriptor output) { try { Intent errorResult = checkRequirements(data); -- cgit v1.2.3