|
19 | 19 | import android.content.Context;
|
20 | 20 | import android.content.Intent;
|
21 | 21 | import android.net.Uri;
|
| 22 | +import android.os.Build; |
22 | 23 | import android.util.Base64;
|
23 | 24 | import androidx.annotation.VisibleForTesting;
|
24 | 25 | import com.google.android.datatransport.runtime.TransportContext;
|
@@ -74,7 +75,12 @@ public AlarmManagerScheduler(
|
74 | 75 |
|
75 | 76 | @VisibleForTesting
|
76 | 77 | boolean isJobServiceOn(Intent intent) {
|
77 |
| - return (PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_NO_CREATE) != null); |
| 78 | + int flags = |
| 79 | + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M |
| 80 | + ? PendingIntent.FLAG_NO_CREATE | PendingIntent.FLAG_IMMUTABLE |
| 81 | + : PendingIntent.FLAG_NO_CREATE; |
| 82 | + |
| 83 | + return (PendingIntent.getBroadcast(context, 0, intent, flags) != null); |
78 | 84 | }
|
79 | 85 |
|
80 | 86 | @Override
|
@@ -121,7 +127,12 @@ public void schedule(TransportContext transportContext, int attemptNumber, boole
|
121 | 127 | backendTime,
|
122 | 128 | attemptNumber);
|
123 | 129 |
|
124 |
| - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); |
| 130 | + PendingIntent pendingIntent = |
| 131 | + PendingIntent.getBroadcast( |
| 132 | + context, |
| 133 | + 0, |
| 134 | + intent, |
| 135 | + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0); |
125 | 136 | this.alarmManager.set(
|
126 | 137 | AlarmManager.ELAPSED_REALTIME, clock.getTime() + scheduleDelay, pendingIntent);
|
127 | 138 | }
|
|
0 commit comments