set immutable flags for backup notifications

This commit is contained in:
Daniel Gultsch 2022-08-12 11:02:18 +02:00
parent 4fbe2deffc
commit 41d98da17d
4 changed files with 21 additions and 4 deletions

View file

@ -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());
}

View file

@ -60,6 +60,10 @@
<intent>
<action android:name="eu.siacs.conversations.location.show" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="resource/folder" />
</intent>
</queries>

View file

@ -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");

View file

@ -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)