Return extra values for select sign key call
This commit is contained in:
@@ -92,6 +92,16 @@ public class CachedPublicKeyRing extends KeyRing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCreationTime() throws PgpKeyNotFoundException {
|
||||||
|
try {
|
||||||
|
Object data = mKeyRepository.getGenericData(mUri,
|
||||||
|
KeychainContract.KeyRings.CREATION, KeyRepository.FIELD_TYPE_INTEGER);
|
||||||
|
return (long) data;
|
||||||
|
} catch (KeyWritableRepository.NotFoundException e) {
|
||||||
|
throw new PgpKeyNotFoundException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryUserId() throws PgpKeyNotFoundException {
|
public String getPrimaryUserId() throws PgpKeyNotFoundException {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ import org.sufficientlysecure.keychain.pgp.SecurityProblem;
|
|||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
||||||
import org.sufficientlysecure.keychain.provider.AutocryptPeerDataAccessObject;
|
import org.sufficientlysecure.keychain.provider.AutocryptPeerDataAccessObject;
|
||||||
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
@@ -683,28 +684,42 @@ public class OpenPgpService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Intent getSignKeyIdImpl(Intent data) {
|
private Intent getSignKeyIdImpl(Intent data) {
|
||||||
// if data already contains EXTRA_SIGN_KEY_ID, it has been executed again
|
Intent result = new Intent();
|
||||||
// after user interaction. Then, we just need to return the long again!
|
data.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
|
||||||
if (data.hasExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
|
|
||||||
long signKeyId = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, Constants.key.none);
|
|
||||||
|
|
||||||
Intent result = new Intent();
|
{ // return PendingIntent to be executed by client
|
||||||
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 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);
|
mApiPendingIntentFactory.createSelectSignKeyIdPendingIntent(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);
|
result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long signKeyId;
|
||||||
|
if (data.hasExtra(OpenPgpApi.RESULT_SIGN_KEY_ID)) {
|
||||||
|
signKeyId = data.getLongExtra(OpenPgpApi.RESULT_SIGN_KEY_ID, Constants.key.none);
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
|
} else {
|
||||||
|
signKeyId = data.getLongExtra(OpenPgpApi.EXTRA_PRESELECT_KEY_ID, Constants.key.none);
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED);
|
||||||
|
}
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_SIGN_KEY_ID, signKeyId);
|
||||||
|
|
||||||
|
if (signKeyId != Constants.key.none) {
|
||||||
|
try {
|
||||||
|
CachedPublicKeyRing cachedPublicKeyRing = mKeyRepository.getCachedPublicKeyRing(signKeyId);
|
||||||
|
String userId = cachedPublicKeyRing.getPrimaryUserId();
|
||||||
|
long creationTime = cachedPublicKeyRing.getCreationTime() * 1000;
|
||||||
|
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_PRIMARY_USER_ID, userId);
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_KEY_CREATION_TIME, creationTime);
|
||||||
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
Timber.e(e, "Error loading key info");
|
||||||
|
return createErrorResultIntent(OpenPgpError.GENERIC_ERROR, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent getKeyIdsImpl(Intent data) {
|
private Intent getKeyIdsImpl(Intent data) {
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent resultData = new Intent();
|
Intent resultData = new Intent();
|
||||||
resultData.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, masterKeyId);
|
resultData.putExtra(OpenPgpApi.RESULT_SIGN_KEY_ID, masterKeyId);
|
||||||
activity.setResult(RESULT_OK, resultData);
|
activity.setResult(RESULT_OK, resultData);
|
||||||
activity.finish();
|
activity.finish();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user