summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-11-09 11:03:08 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-15 09:48:52 +0000
commit95f1dd2f67f02c5a774e022c465e3ac4f7f9ffef (patch)
tree1902157511fe94ebd9ca3101874cbd6f9751de5c
parent42ceea002f0c2830b4e3a2159e0e1e6e7fe3c6ee (diff)
downloadqtconnectivity-95f1dd2f67f02c5a774e022c465e3ac4f7f9ffef.tar.gz
NFC: Fix PendingIntent creation for Android 12
Since Android 12 it's mandatory to specify the mutability of each pending intent. In NFC we require a mutable intent, so we need to conditionally use FLAG_MUTABLE. This was a default value for an intent before Android 12, so no adjustment is required for earlier versions. Fixes: QTBUG-98073 Change-Id: I9a478db016bf9646d84d6e458647614785005977 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 3753c53fc810c292db93fcfbafffbc097afb0ed1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java b/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java
index 4300680b..1f8c332c 100644
--- a/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java
+++ b/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java
@@ -52,6 +52,7 @@ import android.content.IntentFilter;
import android.nfc.NfcAdapter;
import android.content.IntentFilter.MalformedMimeTypeException;
import android.os.Bundle;
+import android.os.Build;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.pm.PackageManager;
@@ -82,11 +83,16 @@ public class QtNfc
return;
}
+ // Since Android 12 (API level 31) it's mandatory to specify mutability
+ // of PendingIntent. We need a mutable intent, which was a default
+ // option earlier.
+ int flags = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) ? PendingIntent.FLAG_MUTABLE
+ : 0;
m_pendingIntent = PendingIntent.getActivity(
m_activity,
0,
new Intent(m_activity, m_activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
- 0);
+ flags);
//Log.d(TAG, "Pending intent:" + m_pendingIntent);