From 473cb7bfebff0000ac7c0fbbfcc6cab6a551b8dc Mon Sep 17 00:00:00 2001 From: Alexander Bakker Date: Wed, 2 Feb 2022 21:01:15 +0100 Subject: [PATCH] Set FLAG_IMMUTABLE on the intent of the lock status notification This fixes a crash on API 31 --- .../aegis/services/NotificationService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/beemdevelopment/aegis/services/NotificationService.java b/app/src/main/java/com/beemdevelopment/aegis/services/NotificationService.java index 489d8b6b..43bb28b2 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/services/NotificationService.java +++ b/app/src/main/java/com/beemdevelopment/aegis/services/NotificationService.java @@ -1,8 +1,10 @@ package com.beemdevelopment.aegis.services; +import android.annotation.SuppressLint; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; +import android.os.Build; import android.os.IBinder; import androidx.annotation.Nullable; @@ -24,9 +26,14 @@ public class NotificationService extends Service { return Service.START_STICKY; } + @SuppressLint("LaunchActivityFromNotification") public void serviceMethod() { + int flags = 0; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + flags |= PendingIntent.FLAG_IMMUTABLE; + } Intent intentAction = new Intent(CODE_LOCK_VAULT_ACTION); - PendingIntent lockDatabaseIntent = PendingIntent.getBroadcast(this, 1, intentAction, 0); + PendingIntent lockDatabaseIntent = PendingIntent.getBroadcast(this, 1, intentAction, flags); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CODE_LOCK_STATUS_ID) .setSmallIcon(R.drawable.ic_fingerprint_black_24dp) .setContentTitle(getString(R.string.app_name_full))