diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-04-04 11:38:59 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-04-04 11:38:59 +0200 |
commit | a1e13f789364a6346a1eac85adefa3660c683a63 (patch) | |
tree | 10b799193a137a1a3b629fe30f0dbce0ce5249f4 /OpenPGP-Keychain/src/main | |
parent | 2227705d650d1e9bf3e59202a093af129c272f04 (diff) | |
download | open-keychain-a1e13f789364a6346a1eac85adefa3660c683a63.tar.gz open-keychain-a1e13f789364a6346a1eac85adefa3660c683a63.tar.bz2 open-keychain-a1e13f789364a6346a1eac85adefa3660c683a63.zip |
calculate nfc packet on demand only
Diffstat (limited to 'OpenPGP-Keychain/src/main')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java index 9bbbb6c7b..6ce7d9aa8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java @@ -50,34 +50,22 @@ public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMess @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - initNfc(mDataUri); } /** * NFC: Initialize NFC sharing if OS and device supports it */ - private void initNfc(Uri dataUri) { + private void initNfc() { // check if NFC Beam is supported (>= Android 4.1) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // Check for available NFC Adapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); if (mNfcAdapter != null) { // init nfc - - // get public keyring as byte array - long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri); - try { - mSharedKeyringBytes = ProviderHelper.getPGPPublicKeyRing(this, masterKeyId).getEncoded(); - - // Register callback to set NDEF message - mNfcAdapter.setNdefPushMessageCallback(this, this); - // Register callback to listen for message-sent success - mNfcAdapter.setOnNdefPushCompleteCallback(this, this); - } catch(IOException e) { - // not much trouble, but leave a note - Log.e(Constants.TAG, "Error parsing keyring: ", e); - } + // Register callback to set NDEF message + mNfcAdapter.setNdefPushMessageCallback(this, this); + // Register callback to listen for message-sent success + mNfcAdapter.setOnNdefPushCompleteCallback(this, this); } } } @@ -93,9 +81,19 @@ public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMess * guarantee that this activity starts when receiving a beamed message. For now, this code * uses the tag dispatch system. */ - NdefMessage msg = new NdefMessage(NdefRecord.createMime(Constants.NFC_MIME, - mSharedKeyringBytes), NdefRecord.createApplicationRecord(Constants.PACKAGE_NAME)); - return msg; + // get public keyring as byte array + long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); + try { + mSharedKeyringBytes = ProviderHelper.getPGPPublicKeyRing(this, masterKeyId).getEncoded(); + + NdefMessage msg = new NdefMessage(NdefRecord.createMime(Constants.NFC_MIME, + mSharedKeyringBytes), NdefRecord.createApplicationRecord(Constants.PACKAGE_NAME)); + return msg; + } catch(IOException e) { + // not much trouble, but leave a note + Log.e(Constants.TAG, "Error parsing keyring: ", e); + return null; + } } /** |