diff --git a/src/org/kde/kdeconnect/BackgroundService.kt b/src/org/kde/kdeconnect/BackgroundService.kt index 9961197d..5f06e422 100644 --- a/src/org/kde/kdeconnect/BackgroundService.kt +++ b/src/org/kde/kdeconnect/BackgroundService.kt @@ -163,7 +163,7 @@ class BackgroundService : Service() { intent.putExtra(MainActivity.EXTRA_DEVICE_ID, connectedDeviceIds[0]) } - val pi = PendingIntent.getActivity(this, 0, intent, UPDATE_MUTABLE_FLAGS) + val pi = PendingIntent.getActivity(this, 0, intent, UPDATE_IMMUTABLE_FLAGS) val notification = NotificationCompat.Builder(this, NotificationHelper.Channels.PERSISTENT).apply { setSmallIcon(R.drawable.ic_notification) setOngoing(true) @@ -189,7 +189,7 @@ class BackgroundService : Service() { // Adding an action button to send clipboard manually in Android 10 and later. if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_LOGS) == PackageManager.PERMISSION_DENIED) { val sendClipboard = ClipboardFloatingActivity.getIntent(this, true) - val sendPendingClipboard = PendingIntent.getActivity(this, 3, sendClipboard, UPDATE_MUTABLE_FLAGS) + val sendPendingClipboard = PendingIntent.getActivity(this, 3, sendClipboard, UPDATE_IMMUTABLE_FLAGS) notification.addAction(0, getString(R.string.foreground_notification_send_clipboard), sendPendingClipboard) } @@ -201,7 +201,7 @@ class BackgroundService : Service() { // Setting up Send File Intent. val sendFile = Intent(this, SendFileActivity::class.java) sendFile.putExtra("deviceId", deviceId) - val sendPendingFile = PendingIntent.getActivity(this, 1, sendFile, UPDATE_MUTABLE_FLAGS) + val sendPendingFile = PendingIntent.getActivity(this, 1, sendFile, UPDATE_IMMUTABLE_FLAGS) notification.addAction(0, getString(R.string.send_files), sendPendingFile) // Checking if there are registered commands and adding the button. @@ -209,7 +209,7 @@ class BackgroundService : Service() { if (plugin != null && plugin.commandList.isNotEmpty()) { val runCommand = Intent(this, RunCommandActivity::class.java) runCommand.putExtra("deviceId", connectedDeviceIds[0]) - val runPendingCommand = PendingIntent.getActivity(this, 2, runCommand, UPDATE_MUTABLE_FLAGS) + val runPendingCommand = PendingIntent.getActivity(this, 2, runCommand, UPDATE_IMMUTABLE_FLAGS) notification.addAction(0, getString(R.string.pref_plugin_runcommand), runPendingCommand) } } @@ -249,7 +249,7 @@ class BackgroundService : Service() { companion object { const val LOG_TAG = "KDE/BackgroundService" - const val UPDATE_MUTABLE_FLAGS = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE + const val UPDATE_IMMUTABLE_FLAGS = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE private const val FOREGROUND_NOTIFICATION_ID = 1 @JvmStatic diff --git a/src/org/kde/kdeconnect/Device.kt b/src/org/kde/kdeconnect/Device.kt index 2ca38796..95df6704 100644 --- a/src/org/kde/kdeconnect/Device.kt +++ b/src/org/kde/kdeconnect/Device.kt @@ -257,7 +257,7 @@ class Device : PacketReceiver { context, 1, intent, - PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE ) val acceptIntent = Intent(context, MainActivity::class.java).apply { @@ -273,13 +273,13 @@ class Device : PacketReceiver { context, 2, acceptIntent, - PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE ) val rejectedPendingIntent = PendingIntent.getActivity( context, 4, rejectIntent, - PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE ) val res = context.resources diff --git a/src/org/kde/kdeconnect/Helpers/IntentHelper.java b/src/org/kde/kdeconnect/Helpers/IntentHelper.java index 573b17c4..954be14f 100644 --- a/src/org/kde/kdeconnect/Helpers/IntentHelper.java +++ b/src/org/kde/kdeconnect/Helpers/IntentHelper.java @@ -28,7 +28,7 @@ public class IntentHelper { */ public static void startActivityFromBackgroundOrCreateNotification(Context context, Intent intent, String title) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && !LifecycleHelper.isInForeground()) { - PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE); + PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); Notification notification = new NotificationCompat .Builder(context, NotificationHelper.Channels.HIGHPRIORITY) .setContentIntent(pendingIntent) diff --git a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java index cfec36fc..fb2f6ee4 100644 --- a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java +++ b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java @@ -141,7 +141,7 @@ public class FindMyPhonePlugin extends Plugin { intent.setAction(FindMyPhoneReceiver.ACTION_FOUND_IT); intent.putExtra(FindMyPhoneReceiver.EXTRA_DEVICE_ID, getDevice().getDeviceId()); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); createNotification(pendingIntent); } @@ -150,7 +150,7 @@ public class FindMyPhonePlugin extends Plugin { Intent intent = new Intent(context, FindMyPhoneActivity.class); intent.putExtra(FindMyPhoneActivity.EXTRA_DEVICE_ID, getDevice().getDeviceId()); - PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE); + PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); createNotification(pi); } diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.kt b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.kt index fad67030..1a0aff64 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.kt +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.kt @@ -302,7 +302,7 @@ class MprisMediaSession : OnSharedPreferenceChangeListener, NotificationReceiver context, 0, iPlay, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) val aPlay = NotificationCompat.Action.Builder( R.drawable.ic_play_white, context!!.getString(R.string.mpris_play), piPlay @@ -317,7 +317,7 @@ class MprisMediaSession : OnSharedPreferenceChangeListener, NotificationReceiver context, 0, iPause, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) val aPause = NotificationCompat.Action.Builder( R.drawable.ic_pause_white, context!!.getString(R.string.mpris_pause), piPause @@ -332,7 +332,7 @@ class MprisMediaSession : OnSharedPreferenceChangeListener, NotificationReceiver context, 0, iPrevious, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) val aPrevious = NotificationCompat.Action.Builder( R.drawable.ic_previous_white, context!!.getString(R.string.mpris_previous), piPrevious @@ -347,7 +347,7 @@ class MprisMediaSession : OnSharedPreferenceChangeListener, NotificationReceiver context, 0, iNext, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) val aNext = NotificationCompat.Action.Builder( R.drawable.ic_next_white, context!!.getString(R.string.mpris_next), piNext @@ -360,7 +360,7 @@ class MprisMediaSession : OnSharedPreferenceChangeListener, NotificationReceiver val piOpenActivity = TaskStackBuilder.create(context!!) .addNextIntentWithParentStack(iOpenActivity) - .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE) + .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) val notification = NotificationCompat.Builder(context!!, NotificationHelper.Channels.MEDIA_CONTROL) @@ -398,7 +398,7 @@ class MprisMediaSession : OnSharedPreferenceChangeListener, NotificationReceiver context, 0, iCloseNotification, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) notification.setDeleteIntent(piCloseNotification) } diff --git a/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.kt b/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.kt index 85383ec6..717c01e4 100644 --- a/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.kt +++ b/src/org/kde/kdeconnect/Plugins/PingPlugin/PingPlugin.kt @@ -42,7 +42,7 @@ class PingPlugin : Plugin() { return false } - val mutableUpdateFlags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE + val mutableUpdateFlags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE val resultPendingIntent = PendingIntent.getActivity(context, 0, Intent(context, MainActivity::class.java), mutableUpdateFlags) val (id: Int, message: String) = if (np.has("message")) { diff --git a/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java b/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java index ee2fd5ef..a1037035 100644 --- a/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java +++ b/src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java @@ -77,7 +77,7 @@ public class ReceiveNotificationsPlugin extends Plugin { context, 0, new Intent(context, MainActivity.class), - PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE ); Bitmap largeIcon = null; diff --git a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetProvider.kt b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetProvider.kt index 6412867c..0e4858cf 100644 --- a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetProvider.kt +++ b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandWidgetProvider.kt @@ -187,6 +187,7 @@ private fun assignListIntent(context: Context, appWidgetId: Int, views: RemoteVi val runCommandTemplateIntent = Intent(context, RunCommandWidgetProvider::class.java) runCommandTemplateIntent.action = RUN_COMMAND_ACTION runCommandTemplateIntent.putExtra(EXTRA_APPWIDGET_ID, appWidgetId) + // Needs to be mutable because the launcher will modify it to indicate which command was selected val runCommandTemplatePendingIntent = PendingIntent.getBroadcast(context, appWidgetId, runCommandTemplateIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE) views.setPendingIntentTemplate(R.id.widget_command_list, runCommandTemplatePendingIntent) } diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java index 85d96020..a353296c 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java @@ -69,7 +69,7 @@ class ReceiveNotification { cancelIntent.setAction(SharePlugin.ACTION_CANCEL_SHARE); cancelIntent.putExtra(SharePlugin.CANCEL_SHARE_BACKGROUND_JOB_ID_EXTRA, jobId); cancelIntent.putExtra(SharePlugin.CANCEL_SHARE_DEVICE_ID_EXTRA, device.getDeviceId()); - PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(device.getContext(), 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE); + PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(device.getContext(), 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); builder.addAction(R.drawable.ic_reject_pairing_24dp, device.getContext().getString(R.string.cancel), cancelPendingIntent); } diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java index 6457c325..622229e8 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java @@ -47,7 +47,7 @@ class UploadNotification { cancelIntent.setAction(SharePlugin.ACTION_CANCEL_SHARE); cancelIntent.putExtra(SharePlugin.CANCEL_SHARE_BACKGROUND_JOB_ID_EXTRA, jobId); cancelIntent.putExtra(SharePlugin.CANCEL_SHARE_DEVICE_ID_EXTRA, device.getDeviceId()); - PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(device.getContext(), 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE); + PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(device.getContext(), 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); builder.addAction(R.drawable.ic_reject_pairing_24dp, device.getContext().getString(R.string.cancel), cancelPendingIntent); }