fix passtrough of params

This commit is contained in:
Dominik Schürmann
2014-02-15 02:08:27 +01:00
parent 494a5fa414
commit 5f39cb3ec0
7 changed files with 75 additions and 94 deletions

View File

@@ -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;
}
}
}

View File

@@ -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);

View File

@@ -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";
}