Split remote methods from activities for better seperation
This commit is contained in:
@@ -844,12 +844,19 @@
|
|||||||
android:name=".remote.ui.AccountSettingsActivity"
|
android:name=".remote.ui.AccountSettingsActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".remote.ui.RemotePassphraseDialogActivity"
|
||||||
|
android:theme="@style/Theme.Keychain.Transparent" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".remote.ui.RemoteSecurityTokenOperationActivity"
|
android:name=".remote.ui.RemoteSecurityTokenOperationActivity"
|
||||||
android:allowTaskReparenting="true"
|
android:allowTaskReparenting="true"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:taskAffinity=":Nfc"
|
android:taskAffinity=":Nfc"
|
||||||
android:theme="@style/Theme.Keychain.Light.Dialog" />
|
android:theme="@style/Theme.Keychain.Light.Dialog" />
|
||||||
|
<activity
|
||||||
|
android:name=".remote.ui.RemoteImportKeysActivity"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
|
android:label="@string/title_import_keys" />
|
||||||
|
|
||||||
<!-- DEPRECATED service,
|
<!-- DEPRECATED service,
|
||||||
using this service may lead to truncated data being returned to the caller -->
|
using this service may lead to truncated data being returned to the caller -->
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ import android.support.annotation.NonNull;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||||
import org.openintents.openpgp.IOpenPgpService;
|
import org.openintents.openpgp.IOpenPgpService;
|
||||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||||
import org.openintents.openpgp.OpenPgpError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.openpgp.OpenPgpMetadata;
|
import org.openintents.openpgp.OpenPgpMetadata;
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogEntryParcel;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogEntryParcel;
|
||||||
@@ -53,15 +53,14 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAccounts;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.remote.ui.RemoteImportKeysActivity;
|
||||||
|
import org.sufficientlysecure.keychain.remote.ui.RemotePassphraseDialogActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteSecurityTokenOperationActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteSecurityTokenOperationActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteSelectPubKeyActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteSelectPubKeyActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.SelectAllowedKeysActivity;
|
import org.sufficientlysecure.keychain.remote.ui.SelectAllowedKeysActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.SelectSignKeyIdActivity;
|
import org.sufficientlysecure.keychain.remote.ui.SelectSignKeyIdActivity;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.ImportKeysActivity;
|
|
||||||
import org.sufficientlysecure.keychain.ui.SecurityTokenOperationActivity;
|
|
||||||
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
|
||||||
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
||||||
import org.sufficientlysecure.keychain.util.InputData;
|
import org.sufficientlysecure.keychain.util.InputData;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@@ -194,7 +193,7 @@ public class OpenPgpService extends Service {
|
|||||||
// build PendingIntent for Security Token NFC operations
|
// build PendingIntent for Security Token NFC operations
|
||||||
Intent intent = new Intent(context, RemoteSecurityTokenOperationActivity.class);
|
Intent intent = new Intent(context, RemoteSecurityTokenOperationActivity.class);
|
||||||
// pass params through to activity that it can be returned again later to repeat pgp operation
|
// pass params through to activity that it can be returned again later to repeat pgp operation
|
||||||
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_SERVICE_INTENT, data);
|
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_DATA, data);
|
||||||
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||||
return PendingIntent.getActivity(context, 0, intent,
|
return PendingIntent.getActivity(context, 0, intent,
|
||||||
@@ -203,11 +202,11 @@ public class OpenPgpService extends Service {
|
|||||||
|
|
||||||
case PASSPHRASE: {
|
case PASSPHRASE: {
|
||||||
// build PendingIntent for Passphrase request
|
// build PendingIntent for Passphrase request
|
||||||
Intent intent = new Intent(context, PassphraseDialogActivity.class);
|
Intent intent = new Intent(context, RemotePassphraseDialogActivity.class);
|
||||||
// pass params through to activity that it can be returned again later to repeat pgp operation
|
// pass params through to activity that it can be returned again later to repeat pgp operation
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_SERVICE_INTENT, data);
|
intent.putExtra(RemotePassphraseDialogActivity.EXTRA_DATA, data);
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
intent.putExtra(RemotePassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
intent.putExtra(RemotePassphraseDialogActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||||
return PendingIntent.getActivity(context, 0, intent,
|
return PendingIntent.getActivity(context, 0, intent,
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
}
|
}
|
||||||
@@ -221,10 +220,10 @@ public class OpenPgpService extends Service {
|
|||||||
private PendingIntent getKeyserverPendingIntent(Intent data, long masterKeyId) {
|
private PendingIntent getKeyserverPendingIntent(Intent data, long masterKeyId) {
|
||||||
// If signature is unknown we return an _additional_ PendingIntent
|
// If signature is unknown we return an _additional_ PendingIntent
|
||||||
// to retrieve the missing key
|
// to retrieve the missing key
|
||||||
Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class);
|
Intent intent = new Intent(getBaseContext(), RemoteImportKeysActivity.class);
|
||||||
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE);
|
intent.setAction(RemoteImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT);
|
||||||
intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, masterKeyId);
|
intent.putExtra(RemoteImportKeysActivity.EXTRA_KEY_ID, masterKeyId);
|
||||||
intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data);
|
intent.putExtra(RemoteImportKeysActivity.EXTRA_DATA, data);
|
||||||
|
|
||||||
return PendingIntent.getActivity(getBaseContext(), 0,
|
return PendingIntent.getActivity(getBaseContext(), 0,
|
||||||
intent,
|
intent,
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.remote.ui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||||
|
import org.sufficientlysecure.keychain.remote.CryptoInputParcelCacheService;
|
||||||
|
import org.sufficientlysecure.keychain.ui.ImportKeysActivity;
|
||||||
|
import org.sufficientlysecure.keychain.ui.SecurityTokenOperationActivity;
|
||||||
|
|
||||||
|
public class RemoteImportKeysActivity extends ImportKeysActivity {
|
||||||
|
|
||||||
|
public static final String EXTRA_DATA = "data";
|
||||||
|
|
||||||
|
private Intent mPendingIntentData;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
mPendingIntentData = getIntent().getParcelableExtra(EXTRA_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleResult(ImportKeyResult result) {
|
||||||
|
setResult(RESULT_OK, mPendingIntentData);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.remote.ui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.remote.CryptoInputParcelCacheService;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
|
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
||||||
|
|
||||||
|
public class RemotePassphraseDialogActivity extends PassphraseDialogActivity {
|
||||||
|
|
||||||
|
public static final String EXTRA_DATA = "data";
|
||||||
|
|
||||||
|
private Intent mPendingIntentData;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
mPendingIntentData = getIntent().getParcelableExtra(EXTRA_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleResult(CryptoInputParcel inputParcel) {
|
||||||
|
CryptoInputParcelCacheService.addCryptoInputParcel(this, mPendingIntentData, inputParcel);
|
||||||
|
setResult(RESULT_OK, mPendingIntentData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,13 +21,14 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.remote.CryptoInputParcelCacheService;
|
import org.sufficientlysecure.keychain.remote.CryptoInputParcelCacheService;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.SecurityTokenOperationActivity;
|
import org.sufficientlysecure.keychain.ui.SecurityTokenOperationActivity;
|
||||||
|
|
||||||
public class RemoteSecurityTokenOperationActivity extends SecurityTokenOperationActivity {
|
public class RemoteSecurityTokenOperationActivity extends SecurityTokenOperationActivity {
|
||||||
|
|
||||||
public static final String EXTRA_SERVICE_INTENT = "data";
|
public static final String EXTRA_DATA = "data";
|
||||||
|
|
||||||
private Intent mServiceIntent;
|
private Intent mPendingIntentData;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -35,14 +36,14 @@ public class RemoteSecurityTokenOperationActivity extends SecurityTokenOperation
|
|||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
Bundle data = intent.getExtras();
|
Bundle data = intent.getExtras();
|
||||||
mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT);
|
mPendingIntentData = data.getParcelable(EXTRA_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void returnResult() {
|
protected void handleResult(CryptoInputParcel inputParcel) {
|
||||||
// save updated cryptoInputParcel in cache
|
// save updated cryptoInputParcel in cache
|
||||||
CryptoInputParcelCacheService.addCryptoInputParcel(this, mServiceIntent, mInputParcel);
|
CryptoInputParcelCacheService.addCryptoInputParcel(this, mPendingIntentData, inputParcel);
|
||||||
setResult(RESULT_OK, mServiceIntent);
|
setResult(RESULT_OK, mPendingIntentData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
= Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_FACEBOOK";
|
= Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_FACEBOOK";
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT =
|
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT =
|
||||||
Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN_RESULT";
|
Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN_RESULT";
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE = Constants.INTENT_PREFIX
|
|
||||||
+ "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN";
|
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN = Constants.INTENT_PREFIX
|
public static final String ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
+ "IMPORT_KEY_FROM_FILE_AND_RETURN";
|
+ "IMPORT_KEY_FROM_FILE_AND_RETURN";
|
||||||
|
|
||||||
@@ -77,10 +75,6 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
public static final String EXTRA_KEY_ID = Constants.EXTRA_PREFIX + "EXTRA_KEY_ID";
|
public static final String EXTRA_KEY_ID = Constants.EXTRA_PREFIX + "EXTRA_KEY_ID";
|
||||||
public static final String EXTRA_FINGERPRINT = OpenKeychainIntents.IMPORT_KEY_FROM_KEYSERVER_EXTRA_FINGERPRINT;
|
public static final String EXTRA_FINGERPRINT = OpenKeychainIntents.IMPORT_KEY_FROM_KEYSERVER_EXTRA_FINGERPRINT;
|
||||||
|
|
||||||
// only used by ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE when used from OpenPgpService
|
|
||||||
public static final String EXTRA_PENDING_INTENT_DATA = "data";
|
|
||||||
private Intent mPendingIntentData;
|
|
||||||
|
|
||||||
public static final String TAG_FRAG_LIST = "frag_list";
|
public static final String TAG_FRAG_LIST = "frag_list";
|
||||||
public static final String TAG_FRAG_TOP = "frag_top";
|
public static final String TAG_FRAG_TOP = "frag_top";
|
||||||
|
|
||||||
@@ -106,11 +100,6 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
importSelectedKeys();
|
importSelectedKeys();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// only used for OpenPgpService
|
|
||||||
if (getIntent().hasExtra(EXTRA_PENDING_INTENT_DATA)) {
|
|
||||||
mPendingIntentData = getIntent().getParcelableExtra(EXTRA_PENDING_INTENT_DATA);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,7 +161,6 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTION_IMPORT_KEY_FROM_KEYSERVER:
|
case ACTION_IMPORT_KEY_FROM_KEYSERVER:
|
||||||
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE:
|
|
||||||
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT: {
|
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT: {
|
||||||
|
|
||||||
if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) {
|
if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) {
|
||||||
@@ -412,7 +400,7 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleResult(ImportKeyResult result) {
|
protected void handleResult(ImportKeyResult result) {
|
||||||
String intentAction = getIntent().getAction();
|
String intentAction = getIntent().getAction();
|
||||||
|
|
||||||
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(intentAction)
|
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(intentAction)
|
||||||
@@ -424,15 +412,10 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE.equals(intentAction)) {
|
|
||||||
setResult(RESULT_OK, mPendingIntentData);
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.createNotify(ImportKeysActivity.this)
|
result.createNotify(ImportKeysActivity.this)
|
||||||
.show((ViewGroup) findViewById(R.id.import_snackbar));
|
.show((ViewGroup) findViewById(R.id.import_snackbar));
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods from CryptoOperationHelper.Callback
|
// methods from CryptoOperationHelper.Callback
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -85,9 +85,6 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
public static final String EXTRA_REQUIRED_INPUT = "required_input";
|
public static final String EXTRA_REQUIRED_INPUT = "required_input";
|
||||||
public static final String EXTRA_CRYPTO_INPUT = "crypto_input";
|
public static final String EXTRA_CRYPTO_INPUT = "crypto_input";
|
||||||
|
|
||||||
// special extra for OpenPgpService
|
|
||||||
public static final String EXTRA_SERVICE_INTENT = "data";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -393,10 +390,10 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
boolean unlockSucceeded = secretKeyToUnlock.unlock(passphrase);
|
boolean unlockSucceeded = secretKeyToUnlock.unlock(passphrase);
|
||||||
|
|
||||||
// if it didn't take that long, give the user time to appreciate the progress bar
|
// if it didn't take that long, give the user time to appreciate the progress bar
|
||||||
long operationTime = System.currentTimeMillis() -timeBeforeOperation;
|
long operationTime = System.currentTimeMillis() - timeBeforeOperation;
|
||||||
if (operationTime < 100) {
|
if (operationTime < 100) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100 -operationTime);
|
Thread.sleep(100 - operationTime);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
@@ -467,16 +464,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
// noinspection ConstantConditions, we handle the non-null case in PassphraseDialogActivity.onCreate()
|
// noinspection ConstantConditions, we handle the non-null case in PassphraseDialogActivity.onCreate()
|
||||||
inputParcel.mPassphrase = passphrase;
|
inputParcel.mPassphrase = passphrase;
|
||||||
|
|
||||||
Intent serviceIntent = getArguments().getParcelable(EXTRA_SERVICE_INTENT);
|
((PassphraseDialogActivity) getActivity()).handleResult(inputParcel);
|
||||||
if (serviceIntent != null) {
|
|
||||||
CryptoInputParcelCacheService.addCryptoInputParcel(getActivity(), serviceIntent, inputParcel);
|
|
||||||
getActivity().setResult(RESULT_OK, serviceIntent);
|
|
||||||
} else {
|
|
||||||
// also return passphrase back to activity
|
|
||||||
Intent returnIntent = new Intent();
|
|
||||||
returnIntent.putExtra(RESULT_CRYPTO_INPUT, inputParcel);
|
|
||||||
getActivity().setResult(RESULT_OK, returnIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
dismiss();
|
dismiss();
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
@@ -526,5 +514,11 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void handleResult(CryptoInputParcel inputParcel) {
|
||||||
|
// also return passphrase back to activity
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
returnIntent.putExtra(RESULT_CRYPTO_INPUT, inputParcel);
|
||||||
|
setResult(RESULT_OK, returnIntent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||||||
|
|
||||||
private static final byte[] BLANK_FINGERPRINT = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
private static final byte[] BLANK_FINGERPRINT = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
protected CryptoInputParcel mInputParcel;
|
private CryptoInputParcel mInputParcel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initTheme() {
|
protected void initTheme() {
|
||||||
@@ -268,7 +268,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNfcPostExecute() {
|
protected void onNfcPostExecute() {
|
||||||
returnResult();
|
handleResult(mInputParcel);
|
||||||
|
|
||||||
// show finish
|
// show finish
|
||||||
vAnimator.setDisplayedChild(2);
|
vAnimator.setDisplayedChild(2);
|
||||||
@@ -299,10 +299,10 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void returnResult() {
|
protected void handleResult(CryptoInputParcel inputParcel) {
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
// send back the CryptoInputParcel we received
|
// send back the CryptoInputParcel we received
|
||||||
result.putExtra(RESULT_CRYPTO_INPUT, mInputParcel);
|
result.putExtra(RESULT_CRYPTO_INPUT, inputParcel);
|
||||||
setResult(RESULT_OK, result);
|
setResult(RESULT_OK, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user