From cf3b059eaf98d77f93a6c335976daa820c4d85ce Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Tue, 9 Jul 2024 22:11:19 +0200 Subject: [PATCH] Use explicit PendingIntents for notification actions (#1190) Starting with Android 14, implicit intents are restricted for internal app components. This commit explicitly sets the package name for PendingIntents used as notification actions to ensure compatibility with the behavior changes outlined in: https://developer.android.com/about/versions/14/behavior-changes-14#security --- app/src/main/org/runnerup/notification/GpsBoundState.java | 1 + app/src/main/org/runnerup/notification/OngoingState.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/src/main/org/runnerup/notification/GpsBoundState.java b/app/src/main/org/runnerup/notification/GpsBoundState.java index 8fd0da341..3bc1b4357 100644 --- a/app/src/main/org/runnerup/notification/GpsBoundState.java +++ b/app/src/main/org/runnerup/notification/GpsBoundState.java @@ -28,6 +28,7 @@ public GpsBoundState(Context context) { PendingIntent pi = PendingIntent.getActivity(context, 0, i, intentFlags); Intent startIntent = new Intent() + .setPackage(context.getPackageName()) .setAction(Constants.Intents.START_ACTIVITY); PendingIntent pendingStart = PendingIntent.getBroadcast( context, 0, startIntent, PendingIntent.FLAG_UPDATE_CURRENT | intentFlags); diff --git a/app/src/main/org/runnerup/notification/OngoingState.java b/app/src/main/org/runnerup/notification/OngoingState.java index 3c5baad9e..3898d2b75 100644 --- a/app/src/main/org/runnerup/notification/OngoingState.java +++ b/app/src/main/org/runnerup/notification/OngoingState.java @@ -39,11 +39,13 @@ public OngoingState(Formatter formatter, WorkoutInfo workoutInfo, Context contex PendingIntent pi = PendingIntent.getActivity(context, 0, i, intentFlags); Intent lapIntent = new Intent() + .setPackage(context.getPackageName()) .setAction(Constants.Intents.NEW_LAP); PendingIntent pendingLap = PendingIntent.getBroadcast( context, 0, lapIntent, PendingIntent.FLAG_UPDATE_CURRENT | intentFlags); Intent pauseIntent = new Intent() + .setPackage(context.getPackageName()) .setAction(Constants.Intents.PAUSE_RESUME); PendingIntent pendingPause = PendingIntent.getBroadcast( context, 0, pauseIntent, PendingIntent.FLAG_UPDATE_CURRENT | intentFlags);