dialog can only handle one key access request at a time
This commit is contained in:
@@ -103,10 +103,10 @@ public class ApiPendingIntentFactory {
|
||||
return createInternal(data, intent);
|
||||
}
|
||||
|
||||
PendingIntent createSelectAllowedKeysPendingIntent(Intent data, String packageName, long[] skippedDisallowedKeys) {
|
||||
PendingIntent createRequestKeyPermissionPendingIntent(Intent data, String packageName, long masterKeyId) {
|
||||
Intent intent = new Intent(mContext, RequestKeyPermissionActivity.class);
|
||||
intent.putExtra(RequestKeyPermissionActivity.EXTRA_PACKAGE_NAME, packageName);
|
||||
intent.putExtra(RequestKeyPermissionActivity.EXTRA_REQUESTED_KEY_IDS, skippedDisallowedKeys);
|
||||
intent.putExtra(RequestKeyPermissionActivity.EXTRA_REQUESTED_KEY_ID, masterKeyId);
|
||||
|
||||
return createInternal(data, intent);
|
||||
}
|
||||
|
||||
@@ -393,14 +393,16 @@ public class OpenPgpService extends Service {
|
||||
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||
return result;
|
||||
} else {
|
||||
if (pgpResult.isKeysDisallowed()) {
|
||||
long[] skippedDisallowedKeys = pgpResult.getSkippedDisallowedKeys();
|
||||
long[] skippedDisallowedKeys = pgpResult.getSkippedDisallowedKeys();
|
||||
if (pgpResult.isKeysDisallowed() && skippedDisallowedKeys.length > 0) {
|
||||
long masterKeyId = skippedDisallowedKeys[0];
|
||||
|
||||
// allow user to select allowed keys
|
||||
Intent result = new Intent();
|
||||
String packageName = mApiPermissionHelper.getCurrentCallingPackage();
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT,
|
||||
mApiPendingIntentFactory.createSelectAllowedKeysPendingIntent(
|
||||
data, packageName, skippedDisallowedKeys));
|
||||
mApiPendingIntentFactory.createRequestKeyPermissionPendingIntent(
|
||||
data, packageName, masterKeyId));
|
||||
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.remote.ui.RequestKeyPermissionPresenter.RequestKeyPermissionMvpView;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
||||
@@ -45,7 +46,7 @@ import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||
|
||||
public class RequestKeyPermissionActivity extends FragmentActivity {
|
||||
public static final String EXTRA_PACKAGE_NAME = "package_name";
|
||||
public static final String EXTRA_REQUESTED_KEY_IDS = "requested_key_ids";
|
||||
public static final String EXTRA_REQUESTED_KEY_ID = "requested_key_id";
|
||||
|
||||
|
||||
private RequestKeyPermissionPresenter presenter;
|
||||
@@ -69,9 +70,9 @@ public class RequestKeyPermissionActivity extends FragmentActivity {
|
||||
|
||||
Intent intent = getIntent();
|
||||
String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
|
||||
long[] keyIds = intent.getLongArrayExtra(EXTRA_REQUESTED_KEY_IDS);
|
||||
long masterKeyId = intent.getLongExtra(EXTRA_REQUESTED_KEY_ID, Constants.key.none);
|
||||
|
||||
presenter.setupFromIntentData(packageName, keyIds);
|
||||
presenter.setupFromIntentData(packageName, masterKeyId);
|
||||
}
|
||||
|
||||
public static class RequestKeyPermissionFragment extends DialogFragment {
|
||||
|
||||
@@ -51,13 +51,9 @@ class RequestKeyPermissionPresenter {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
void setupFromIntentData(String packageName, long[] requestedMasterKeyIds) {
|
||||
void setupFromIntentData(String packageName, long masterKeyId) {
|
||||
checkPackageAllowed(packageName);
|
||||
|
||||
if (requestedMasterKeyIds.length < 1) {
|
||||
view.finishAsCancelled();
|
||||
}
|
||||
|
||||
try {
|
||||
setPackageInfo(packageName);
|
||||
} catch (NameNotFoundException e) {
|
||||
@@ -67,7 +63,7 @@ class RequestKeyPermissionPresenter {
|
||||
}
|
||||
|
||||
this.packageName = packageName;
|
||||
this.masterKeyId = requestedMasterKeyIds[0];
|
||||
this.masterKeyId = masterKeyId;
|
||||
try {
|
||||
CachedPublicKeyRing cachedPublicKeyRing = new ProviderHelper(context).getCachedPublicKeyRing(masterKeyId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user