@@ -112,21 +112,16 @@ private PendingIntent createAppLaunchIntent() {
112
112
LogWrapper .getInstance ().w (TAG , "No activity found to launch app" );
113
113
return null ;
114
114
}
115
- return PendingIntent .getActivity (
116
- context , 0 , intent , getPendingIntentFlags (PendingIntent .FLAG_ONE_SHOT ));
115
+ return getPendingIntent (intent , PendingIntent .FLAG_ONE_SHOT );
117
116
}
118
117
119
- /**
120
- * Adds {@link PendingIntent#FLAG_IMMUTABLE} to a PendingIntent's flags since any PendingIntents
121
- * used here don't need to be modified.
122
- *
123
- * <p>Specifying mutability is required starting at SDK level 31.
124
- */
125
- private static int getPendingIntentFlags (int baseFlags ) {
126
- // Only add on platform levels that support FLAG_IMMUTABLE.
127
- return Build .VERSION .SDK_INT >= Build .VERSION_CODES .M
128
- ? baseFlags | PendingIntent .FLAG_IMMUTABLE
129
- : baseFlags ;
118
+ private PendingIntent getPendingIntent (Intent intent , int extraFlags ) {
119
+ // Specify mutability because it is required starting at SDK level 31, but FLAG_IMMUTABLE is
120
+ // only supported starting at SDK level 23
121
+ int commonFlags =
122
+ Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ? PendingIntent .FLAG_IMMUTABLE : 0 ;
123
+ return PendingIntent .getActivity (
124
+ context , /* requestCode = */ 0 , intent , extraFlags | commonFlags );
130
125
}
131
126
132
127
public void showFeedbackNotification (
@@ -151,9 +146,6 @@ public void showFeedbackNotification(
151
146
Intent intent = new Intent (context , TakeScreenshotAndStartFeedbackActivity .class );
152
147
intent .addFlags (Intent .FLAG_ACTIVITY_NO_HISTORY );
153
148
intent .putExtra (TakeScreenshotAndStartFeedbackActivity .INFO_TEXT_EXTRA_KEY , infoText );
154
- PendingIntent pendingIntent =
155
- PendingIntent .getActivity (
156
- context , /* requestCode = */ 0 , intent , PendingIntent .FLAG_IMMUTABLE );
157
149
ApplicationInfo applicationInfo = context .getApplicationInfo ();
158
150
PackageManager packageManager = context .getPackageManager ();
159
151
CharSequence appLabel = packageManager .getApplicationLabel (applicationInfo );
@@ -166,7 +158,7 @@ public void showFeedbackNotification(
166
158
.setOngoing (true )
167
159
.setOnlyAlertOnce (true )
168
160
.setAutoCancel (false )
169
- .setContentIntent (pendingIntent );
161
+ .setContentIntent (getPendingIntent ( intent , /* extraFlags= */ 0 ) );
170
162
LogWrapper .getInstance ().i (TAG , "Showing feedback notification" );
171
163
notificationManager .notify (
172
164
Notification .FEEDBACK .tag , Notification .FEEDBACK .id , builder .build ());
0 commit comments