From 41d98da17d584289767ab8186ad16d4cf8846db3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 12 Aug 2022 11:02:18 +0200 Subject: [PATCH] set immutable flags for backup notifications --- .../conversations/services/ImportBackupService.java | 6 +++++- src/main/AndroidManifest.xml | 4 ++++ .../conversations/services/ExportBackupService.java | 12 +++++++++--- .../eu/siacs/conversations/ui/util/Attachment.java | 3 +++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java index a1b5f9e77..c118d7375 100644 --- a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java +++ b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java @@ -1,5 +1,7 @@ package eu.siacs.conversations.services; +import static eu.siacs.conversations.utils.Compatibility.s; + import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -304,7 +306,9 @@ public class ImportBackupService extends Service { mBuilder.setContentTitle(getString(R.string.notification_restored_backup_title)) .setContentText(getString(R.string.notification_restored_backup_subtitle)) .setAutoCancel(true) - .setContentIntent(PendingIntent.getActivity(this, 145, new Intent(this, ManageAccountActivity.class), PendingIntent.FLAG_UPDATE_CURRENT)) + .setContentIntent(PendingIntent.getActivity(this, 145, new Intent(this, ManageAccountActivity.class), s() + ? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT + : PendingIntent.FLAG_UPDATE_CURRENT)) .setSmallIcon(R.drawable.ic_unarchive_white_24dp); notificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 8cb375870..e37b5ab36 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -60,6 +60,10 @@ + + + + diff --git a/src/main/java/eu/siacs/conversations/services/ExportBackupService.java b/src/main/java/eu/siacs/conversations/services/ExportBackupService.java index 6cbb26ad1..4e144f223 100644 --- a/src/main/java/eu/siacs/conversations/services/ExportBackupService.java +++ b/src/main/java/eu/siacs/conversations/services/ExportBackupService.java @@ -1,5 +1,7 @@ package eu.siacs.conversations.services; +import static eu.siacs.conversations.utils.Compatibility.s; + import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -344,9 +346,11 @@ public class ExportBackupService extends Service { PendingIntent openFolderIntent = null; - for (Intent intent : getPossibleFileOpenIntents(this, path)) { + for (final Intent intent : getPossibleFileOpenIntents(this, path)) { if (intent.resolveActivityInfo(getPackageManager(), 0) != null) { - openFolderIntent = PendingIntent.getActivity(this, 189, intent, PendingIntent.FLAG_UPDATE_CURRENT); + openFolderIntent = PendingIntent.getActivity(this, 189, intent, s() + ? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT + : PendingIntent.FLAG_UPDATE_CURRENT); break; } } @@ -362,7 +366,9 @@ public class ExportBackupService extends Service { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType(MIME_TYPE); final Intent chooser = Intent.createChooser(intent, getString(R.string.share_backup_files)); - shareFilesIntent = PendingIntent.getActivity(this, 190, chooser, PendingIntent.FLAG_UPDATE_CURRENT); + shareFilesIntent = PendingIntent.getActivity(this, 190, chooser, s() + ? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT + : PendingIntent.FLAG_UPDATE_CURRENT); } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext(), "backup"); diff --git a/src/main/java/eu/siacs/conversations/ui/util/Attachment.java b/src/main/java/eu/siacs/conversations/ui/util/Attachment.java index 9c6849ce6..e68bcc534 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/Attachment.java +++ b/src/main/java/eu/siacs/conversations/ui/util/Attachment.java @@ -38,6 +38,8 @@ import android.os.Parcelable; import com.google.common.base.MoreObjects; +import org.jetbrains.annotations.NotNull; + import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -89,6 +91,7 @@ public class Attachment implements Parcelable { return type; } + @NotNull @Override public String toString() { return MoreObjects.toStringHelper(this)