Fix NfcActivity task stack problem

This commit is contained in:
Dominik Schürmann 2014-09-29 21:20:01 +02:00
parent d20f657151
commit 654d98ac2a
5 changed files with 12 additions and 8 deletions

View File

@ -620,9 +620,18 @@
<activity <activity
android:name=".ui.PassphraseDialogActivity" android:name=".ui.PassphraseDialogActivity"
android:theme="@android:style/Theme.NoDisplay" /> android:theme="@android:style/Theme.NoDisplay" />
<!--
NOTE: singleTop is set to get NFC foreground dispatch to work.
Then, all NFC intents will be broadcasted to onNewIntent() of this activity!
If more than one task stack of OpenKeychain exists, the broadcast
restarts the activity with onCreate() instead of calling onNewIntent().
taskAffinity and allowTaskReparenting somehow prevents this from happening!
-->
<activity <activity
android:name=".ui.NfcActivity" android:name=".ui.NfcActivity"
android:launchMode="singleTop" /> android:launchMode="singleTop"
android:taskAffinity=":Nfc"
android:allowTaskReparenting="true" />
<activity <activity
android:name=".ui.HelpActivity" android:name=".ui.HelpActivity"
android:label="@string/title_help" /> android:label="@string/title_help" />

View File

@ -194,7 +194,6 @@ public class OpenPgpService extends RemoteService {
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_TO_SIGN, hashToSign); intent.putExtra(NfcActivity.EXTRA_NFC_HASH_TO_SIGN, hashToSign);
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_ALGO, hashAlgo); intent.putExtra(NfcActivity.EXTRA_NFC_HASH_ALGO, hashAlgo);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0, PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0,
intent, intent,
PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent.FLAG_CANCEL_CURRENT);
@ -215,7 +214,6 @@ public class OpenPgpService extends RemoteService {
intent.putExtra(NfcActivity.EXTRA_PIN, pin); intent.putExtra(NfcActivity.EXTRA_PIN, pin);
intent.putExtra(NfcActivity.EXTRA_NFC_ENC_SESSION_KEY, encryptedSessionKey); intent.putExtra(NfcActivity.EXTRA_NFC_ENC_SESSION_KEY, encryptedSessionKey);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0, PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0,
intent, intent,
PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent.FLAG_CANCEL_CURRENT);

View File

@ -97,7 +97,6 @@ public abstract class DecryptFragment extends Fragment {
intent.putExtra(NfcActivity.EXTRA_PIN, pin); intent.putExtra(NfcActivity.EXTRA_PIN, pin);
intent.putExtra(NfcActivity.EXTRA_NFC_ENC_SESSION_KEY, encryptedSessionKey); intent.putExtra(NfcActivity.EXTRA_NFC_ENC_SESSION_KEY, encryptedSessionKey);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(intent, REQUEST_CODE_NFC_DECRYPT); startActivityForResult(intent, REQUEST_CODE_NFC_DECRYPT);
} }

View File

@ -40,7 +40,6 @@ public abstract class EncryptActivity extends DrawerActivity {
intent.putExtra(NfcActivity.EXTRA_PIN, pin); intent.putExtra(NfcActivity.EXTRA_PIN, pin);
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_TO_SIGN, hashToSign); intent.putExtra(NfcActivity.EXTRA_NFC_HASH_TO_SIGN, hashToSign);
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_ALGO, hashAlgo); intent.putExtra(NfcActivity.EXTRA_NFC_HASH_ALGO, hashAlgo);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(intent, REQUEST_CODE_NFC); startActivityForResult(intent, REQUEST_CODE_NFC);
} }

View File

@ -111,9 +111,8 @@ public class NfcActivity extends ActionBarActivity {
Log.d(Constants.TAG, "NfcActivity mEncryptedSessionKey as hex: " + getHex(mEncryptedSessionKey)); Log.d(Constants.TAG, "NfcActivity mEncryptedSessionKey as hex: " + getHex(mEncryptedSessionKey));
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString()); Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
} else if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) { } else if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
Log.e(Constants.TAG, "This should not happen, but there is a bug in Android!"); Log.e(Constants.TAG, "This should not happen! NfcActivity.onCreate() is being called instead of onNewIntent()!");
toast("This should not happen! Please create a new bug report that the NFC screen is restarted!");
toast("This should not happen, but there is a bug in Android! Clear all app tasks and start app from launcher again!");
finish(); finish();
} else { } else {
Log.d(Constants.TAG, "Action not supported: " + action); Log.d(Constants.TAG, "Action not supported: " + action);