Add a way to call legacy getSignKey dialog
This commit is contained in:
@@ -144,6 +144,15 @@ public class ApiPendingIntentFactory {
|
|||||||
return createInternal(data, intent);
|
return createInternal(data, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PendingIntent createSelectSignKeyIdLegacyPendingIntent(Intent data, String packageName, String preferredUserId) {
|
||||||
|
Intent intent = new Intent(mContext, SelectSignKeyIdActivity.class);
|
||||||
|
intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(packageName));
|
||||||
|
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_PACKAGE_NAME, packageName);
|
||||||
|
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_USER_ID, preferredUserId);
|
||||||
|
|
||||||
|
return createInternal(data, intent);
|
||||||
|
}
|
||||||
|
|
||||||
PendingIntent createSelectSignKeyIdPendingIntent(Intent data, String packageName, String preferredUserId) {
|
PendingIntent createSelectSignKeyIdPendingIntent(Intent data, String packageName, String preferredUserId) {
|
||||||
Intent intent = new Intent(mContext, RemoteSelectIdKeyActivity.class);
|
Intent intent = new Intent(mContext, RemoteSelectIdKeyActivity.class);
|
||||||
intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(packageName));
|
intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(packageName));
|
||||||
|
|||||||
@@ -683,6 +683,33 @@ public class OpenPgpService extends Service {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Signing key choose dialog for older API versions. We keep it around to make sure those don't break */
|
||||||
|
private Intent getSignKeyIdImplLegacy(Intent data) {
|
||||||
|
// if data already contains EXTRA_SIGN_KEY_ID, it has been executed again
|
||||||
|
// after user interaction. Then, we just need to return the long again!
|
||||||
|
if (data.hasExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
|
||||||
|
long signKeyId = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, Constants.key.none);
|
||||||
|
|
||||||
|
Intent result = new Intent();
|
||||||
|
result.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, signKeyId);
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
String currentPkg = mApiPermissionHelper.getCurrentCallingPackage();
|
||||||
|
String preferredUserId = data.getStringExtra(OpenPgpApi.EXTRA_USER_ID);
|
||||||
|
|
||||||
|
PendingIntent pi = mApiPendingIntentFactory.createSelectSignKeyIdLegacyPendingIntent(
|
||||||
|
data, currentPkg, preferredUserId);
|
||||||
|
|
||||||
|
// return PendingIntent to be executed by client
|
||||||
|
Intent result = new Intent();
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED);
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Intent getSignKeyIdImpl(Intent data) {
|
private Intent getSignKeyIdImpl(Intent data) {
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
data.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
|
data.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
|
||||||
@@ -690,8 +717,13 @@ public class OpenPgpService extends Service {
|
|||||||
{ // return PendingIntent to be executed by client
|
{ // return PendingIntent to be executed by client
|
||||||
String currentPkg = mApiPermissionHelper.getCurrentCallingPackage();
|
String currentPkg = mApiPermissionHelper.getCurrentCallingPackage();
|
||||||
String preferredUserId = data.getStringExtra(OpenPgpApi.EXTRA_USER_ID);
|
String preferredUserId = data.getStringExtra(OpenPgpApi.EXTRA_USER_ID);
|
||||||
PendingIntent pi =
|
PendingIntent pi;
|
||||||
mApiPendingIntentFactory.createSelectSignKeyIdPendingIntent(data, currentPkg, preferredUserId);
|
// the new dialog doesn't really work if we don't have a user id to work with. just show the old...
|
||||||
|
if (preferredUserId == null) {
|
||||||
|
pi = mApiPendingIntentFactory.createSelectSignKeyIdLegacyPendingIntent(data, currentPkg, null);
|
||||||
|
} else {
|
||||||
|
pi = mApiPendingIntentFactory.createSelectSignKeyIdPendingIntent(data, currentPkg, preferredUserId);
|
||||||
|
}
|
||||||
result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
|
result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -977,6 +1009,9 @@ public class OpenPgpService extends Service {
|
|||||||
case OpenPgpApi.ACTION_GET_SIGN_KEY_ID: {
|
case OpenPgpApi.ACTION_GET_SIGN_KEY_ID: {
|
||||||
return getSignKeyIdImpl(data);
|
return getSignKeyIdImpl(data);
|
||||||
}
|
}
|
||||||
|
case OpenPgpApi.ACTION_GET_SIGN_KEY_ID_LEGACY: {
|
||||||
|
return getSignKeyIdImplLegacy(data);
|
||||||
|
}
|
||||||
case OpenPgpApi.ACTION_GET_KEY_IDS: {
|
case OpenPgpApi.ACTION_GET_KEY_IDS: {
|
||||||
return getKeyIdsImpl(data);
|
return getKeyIdsImpl(data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user