load yubikey fragment after mMasterKeyId is available

This commit is contained in:
Vincent Breitmoser 2015-05-17 00:54:09 +02:00
parent 158263f255
commit 9a6f581400

View File

@ -131,6 +131,8 @@ public class ViewKeyActivity extends BaseNfcActivity implements
private boolean mIsRevoked = false; private boolean mIsRevoked = false;
private boolean mIsExpired = false; private boolean mIsExpired = false;
private boolean mShowYubikeyAfterCreation = false;
private MenuItem mRefreshItem; private MenuItem mRefreshItem;
private boolean mIsRefreshing; private boolean mIsRefreshing;
private Animation mRotate, mRotateSpin; private Animation mRotate, mRotateSpin;
@ -286,13 +288,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements
.replace(R.id.view_key_fragment, frag) .replace(R.id.view_key_fragment, frag)
.commit(); .commit();
if (getIntent().hasExtra(EXTRA_NFC_AID)) { // need to postpone loading of the yubikey fragment until after mMasterKeyId
Intent intent = getIntent(); // is available, but we mark here that this should be done
byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS); mShowYubikeyAfterCreation = true;
String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID);
byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID);
showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
}
} }
@ -586,7 +584,12 @@ public class ViewKeyActivity extends BaseNfcActivity implements
} }
public void showYubiKeyFragment(byte[] nfcFingerprints, String nfcUserId, byte[] nfcAid) { public void showYubiKeyFragment(
final byte[] nfcFingerprints, final String nfcUserId, final byte[] nfcAid) {
new Handler().post(new Runnable() {
@Override
public void run() {
ViewKeyYubiKeyFragment frag = ViewKeyYubiKeyFragment.newInstance( ViewKeyYubiKeyFragment frag = ViewKeyYubiKeyFragment.newInstance(
mMasterKeyId, nfcFingerprints, nfcUserId, nfcAid); mMasterKeyId, nfcFingerprints, nfcUserId, nfcAid);
@ -599,6 +602,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements
// if this is called while the activity wasn't resumed, just forget it happened // if this is called while the activity wasn't resumed, just forget it happened
.commitAllowingStateLoss(); .commitAllowingStateLoss();
} }
});
}
private void encrypt(Uri dataUri, boolean text) { private void encrypt(Uri dataUri, boolean text) {
// If there is no encryption key, don't bother. // If there is no encryption key, don't bother.
@ -813,6 +819,16 @@ public class ViewKeyActivity extends BaseNfcActivity implements
mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID); mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
mFingerprint = KeyFormattingUtils.convertFingerprintToHex(data.getBlob(INDEX_FINGERPRINT)); mFingerprint = KeyFormattingUtils.convertFingerprintToHex(data.getBlob(INDEX_FINGERPRINT));
// if it wasn't shown yet, display yubikey fragment
if (mShowYubikeyAfterCreation && getIntent().hasExtra(EXTRA_NFC_AID)) {
mShowYubikeyAfterCreation = false;
Intent intent = getIntent();
byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS);
String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID);
byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID);
showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
}
mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
mHasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0; mHasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0;
mIsRevoked = data.getInt(INDEX_IS_REVOKED) > 0; mIsRevoked = data.getInt(INDEX_IS_REVOKED) > 0;