mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 22:29:09 +00:00
Add mandetory intent flags
Since SDK 31 for an 'PendingIntent' the intent flags 'FLAG_IMMUTABLE' or 'FLAG_IMMUTABLE' are mandetory. Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
parent
3096d90bc6
commit
f366c75f68
@ -24,6 +24,7 @@ import android.app.Notification
|
|||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
@ -168,7 +169,7 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
Log.d(NotificationWorker.TAG, "Invalid private key " + e1.localizedMessage)
|
Log.d(NotificationWorker.TAG, "Invalid private key " + e1.localizedMessage)
|
||||||
}
|
}
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Log.d(NotificationWorker.TAG, "Something went very wrong " + exception.localizedMessage)
|
Log.d(NotificationWorker.TAG, "Something went very wrong " + exception.localizedMessage, exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +218,11 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
this@MagicFirebaseMessagingService,
|
this@MagicFirebaseMessagingService,
|
||||||
0,
|
0,
|
||||||
fullScreenIntent,
|
fullScreenIntent,
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
} else {
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences!!)
|
val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences!!)
|
||||||
@ -319,6 +324,7 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
stopForeground(true)
|
stopForeground(true)
|
||||||
handler.removeCallbacksAndMessages(null)
|
handler.removeCallbacksAndMessages(null)
|
||||||
|
@ -295,7 +295,13 @@ public class NotificationWorker extends Worker {
|
|||||||
// Use unique request code to make sure that a new PendingIntent gets created for each notification
|
// Use unique request code to make sure that a new PendingIntent gets created for each notification
|
||||||
// See https://github.com/nextcloud/talk-android/issues/2111
|
// See https://github.com/nextcloud/talk-android/issues/2111
|
||||||
int requestCode = (int) System.currentTimeMillis();
|
int requestCode = (int) System.currentTimeMillis();
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, requestCode, intent, 0);
|
int intentFlag;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
intentFlag = PendingIntent.FLAG_MUTABLE;
|
||||||
|
} else {
|
||||||
|
intentFlag = 0;
|
||||||
|
}
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, requestCode, intent, intentFlag);
|
||||||
|
|
||||||
Uri uri = Uri.parse(signatureVerification.getUserEntity().getBaseUrl());
|
Uri uri = Uri.parse(signatureVerification.getUserEntity().getBaseUrl());
|
||||||
String baseUrl = uri.getHost();
|
String baseUrl = uri.getHost();
|
||||||
@ -422,8 +428,15 @@ public class NotificationWorker extends Worker {
|
|||||||
// It is NOT the same as the notification ID used in communication with the server.
|
// It is NOT the same as the notification ID used in communication with the server.
|
||||||
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_SYSTEM_NOTIFICATION_ID(), systemNotificationId);
|
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_SYSTEM_NOTIFICATION_ID(), systemNotificationId);
|
||||||
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), decryptedPushMessage.getId());
|
actualIntent.putExtra(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), decryptedPushMessage.getId());
|
||||||
|
|
||||||
|
int intentFlag;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
intentFlag = PendingIntent.FLAG_MUTABLE|PendingIntent.FLAG_UPDATE_CURRENT;
|
||||||
|
} else {
|
||||||
|
intentFlag = PendingIntent.FLAG_UPDATE_CURRENT;
|
||||||
|
}
|
||||||
PendingIntent replyPendingIntent =
|
PendingIntent replyPendingIntent =
|
||||||
PendingIntent.getBroadcast(context, systemNotificationId, actualIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent.getBroadcast(context, systemNotificationId, actualIntent, intentFlag);
|
||||||
|
|
||||||
NotificationCompat.Action replyAction =
|
NotificationCompat.Action replyAction =
|
||||||
new NotificationCompat.Action.Builder(R.drawable.ic_reply, replyLabel, replyPendingIntent)
|
new NotificationCompat.Action.Builder(R.drawable.ic_reply, replyLabel, replyPendingIntent)
|
||||||
|
Loading…
Reference in New Issue
Block a user