aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain-API
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-02-15 02:08:27 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-02-15 02:08:27 +0100
commit5f39cb3ec0d1d3f77d48fdbb428a2147dfe11d03 (patch)
tree3c180dc1627a400f487871fc4db29d14296f05ff /OpenPGP-Keychain-API
parent494a5fa414fe5962bdee0d50e761da9dc0cc1cc7 (diff)
downloadopen-keychain-5f39cb3ec0d1d3f77d48fdbb428a2147dfe11d03.tar.gz
open-keychain-5f39cb3ec0d1d3f77d48fdbb428a2147dfe11d03.tar.bz2
open-keychain-5f39cb3ec0d1d3f77d48fdbb428a2147dfe11d03.zip
fix passtrough of params
Diffstat (limited to 'OpenPGP-Keychain-API')
-rw-r--r--OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java63
-rw-r--r--OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java4
-rw-r--r--OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java5
3 files changed, 26 insertions, 46 deletions
diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
index e21b1c2a1..e578d0660 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
+++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
@@ -167,8 +167,7 @@ public class OpenPgpProviderActivity extends Activity {
PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT);
try {
OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(),
- REQUEST_CODE_SIGN, null,
- 0, 0, 0);
+ REQUEST_CODE_SIGN, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.e(Constants.TAG, "SendIntentException", e);
}
@@ -206,8 +205,7 @@ public class OpenPgpProviderActivity extends Activity {
PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT);
try {
OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(),
- REQUEST_CODE_ENCRYPT, null,
- 0, 0, 0);
+ REQUEST_CODE_ENCRYPT, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.e(Constants.TAG, "SendIntentException", e);
}
@@ -245,8 +243,7 @@ public class OpenPgpProviderActivity extends Activity {
PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT);
try {
OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(),
- REQUEST_CODE_SIGN_AND_ENCRYPT, null,
- 0, 0, 0);
+ REQUEST_CODE_SIGN_AND_ENCRYPT, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.e(Constants.TAG, "SendIntentException", e);
}
@@ -283,8 +280,7 @@ public class OpenPgpProviderActivity extends Activity {
PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT);
try {
OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(),
- REQUEST_CODE_DECRYPT_AND_VERIFY, null,
- 0, 0, 0);
+ REQUEST_CODE_DECRYPT_AND_VERIFY, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.e(Constants.TAG, "SendIntentException", e);
}
@@ -299,44 +295,29 @@ public class OpenPgpProviderActivity extends Activity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- Log.d(Constants.TAG, "onActivityResult");
- switch (requestCode) {
- case REQUEST_CODE_SIGN: {
- Log.d(Constants.TAG, "resultCode: " + resultCode);
+ Log.d(Constants.TAG, "onActivityResult resultCode: " + resultCode);
- // try to sign again after password caching
- if (resultCode == RESULT_OK) {
- sign(data.getExtras());
- }
- break;
- }
- case REQUEST_CODE_ENCRYPT: {
- Log.d(Constants.TAG, "resultCode: " + resultCode);
+ // try again after user interaction
+ if (resultCode == RESULT_OK) {
+ Bundle params = data.getBundleExtra(OpenPgpConstants.PI_RESULT_PARAMS);
- // try to sign again after password caching
- if (resultCode == RESULT_OK) {
- // use data extras now as params for call (they now include key ids!
- encrypt(data.getExtras());
+ switch (requestCode) {
+ case REQUEST_CODE_SIGN: {
+ sign(params);
+ break;
}
- break;
- }
- case REQUEST_CODE_SIGN_AND_ENCRYPT: {
- Log.d(Constants.TAG, "resultCode: " + resultCode);
-
- // try to sign again after password caching
- if (resultCode == RESULT_OK) {
- signAndEncrypt(data.getExtras());
+ case REQUEST_CODE_ENCRYPT: {
+ encrypt(params);
+ break;
}
- break;
- }
- case REQUEST_CODE_DECRYPT_AND_VERIFY: {
- Log.d(Constants.TAG, "resultCode: " + resultCode);
-
- // try to sign again after password caching
- if (resultCode == RESULT_OK) {
- decryptAndVerify(new Bundle());
+ case REQUEST_CODE_SIGN_AND_ENCRYPT: {
+ signAndEncrypt(params);
+ break;
+ }
+ case REQUEST_CODE_DECRYPT_AND_VERIFY: {
+ decryptAndVerify(params);
+ break;
}
- break;
}
}
}
diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
index 5f67ddf88..5c38d3304 100644
--- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
+++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
@@ -131,11 +131,7 @@ public class OpenPgpApi {
try {
params.putInt(OpenPgpConstants.PARAMS_API_VERSION, OpenPgpConstants.API_VERSION);
- // default result is error
Bundle result = new Bundle();
- result.putInt(OpenPgpConstants.RESULT_CODE, OpenPgpConstants.RESULT_CODE_ERROR);
- result.putParcelable(OpenPgpConstants.RESULT_ERRORS,
- new OpenPgpError(OpenPgpError.GENERIC_ERROR, "This should never happen!"));
if (operationId == OPERATION_GET_KEY_IDS) {
result = mService.getKeyIds(params);
diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java
index 64bc92fdd..229c8d42a 100644
--- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java
+++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpConstants.java
@@ -33,7 +33,7 @@ public class OpenPgpConstants {
public static final String PARAMS_USER_IDS = "user_ids";
public static final String PARAMS_KEY_IDS = "key_ids";
- /* Bundle return */
+ /* Service Bundle returns */
public static final String RESULT_CODE = "result_code";
public static final String RESULT_SIGNATURE = "signature";
public static final String RESULT_ERRORS = "error";
@@ -46,4 +46,7 @@ public class OpenPgpConstants {
// executeServiceMethod intent and do it again with params from intent
public static final int RESULT_CODE_USER_INTERACTION_REQUIRED = 2;
+ /* PendingIntent returns */
+ public static final String PI_RESULT_PARAMS = "params";
+
}