@@ -28,77 +28,77 @@ public class ImplicitPendingIntentsTest {
28
28
public static void testPendingIntentAsAnExtra (Context ctx )
29
29
throws PendingIntent .CanceledException {
30
30
{
31
- Intent baseIntent = new Intent ();
31
+ Intent baseIntent = new Intent (); // $ Source
32
32
PendingIntent pi = PendingIntent .getActivity (ctx , 0 , baseIntent , 0 );
33
33
Intent fwdIntent = new Intent ();
34
34
fwdIntent .putExtra ("fwdIntent" , pi );
35
- ctx .startActivities (new Intent [] {fwdIntent }); // $ MISSING: hasImplicitPendingIntent
36
- ctx .startActivity (fwdIntent ); // $hasImplicitPendingIntent
35
+ ctx .startActivities (new Intent [] {fwdIntent }); // $ MISSING: Alert
36
+ ctx .startActivity (fwdIntent ); // $ Alert
37
37
ctx .startService (fwdIntent ); // Safe
38
- ctx .sendBroadcast (fwdIntent ); // $hasImplicitPendingIntent
38
+ ctx .sendBroadcast (fwdIntent ); // $ Alert
39
39
40
40
fwdIntent .setComponent (null ); // Not a sanitizer
41
- ctx .startActivity (fwdIntent ); // $hasImplicitPendingIntent
41
+ ctx .startActivity (fwdIntent ); // $ Alert
42
42
43
43
fwdIntent .setPackage ("a.safe.package" ); // Sanitizer
44
44
ctx .startActivity (fwdIntent ); // Safe
45
45
}
46
46
47
47
{
48
- Intent baseIntent = new Intent ();
48
+ Intent baseIntent = new Intent (); // $ Source
49
49
PendingIntent pi = PendingIntent .getActivityAsUser (ctx , 0 , baseIntent , 0 , null , null );
50
50
Intent fwdIntent = new Intent ();
51
51
fwdIntent .putExtra ("fwdIntent" , pi );
52
- ctx .startActivity (fwdIntent ); // $hasImplicitPendingIntent
52
+ ctx .startActivity (fwdIntent ); // $ Alert
53
53
}
54
54
55
55
{
56
- Intent baseIntent = new Intent ();
56
+ Intent baseIntent = new Intent (); // $ Source
57
57
PendingIntent pi = PendingIntent .getActivities (ctx , 0 , new Intent [] {baseIntent }, 0 );
58
58
Intent fwdIntent = new Intent ();
59
59
fwdIntent .putExtra ("fwdIntent" , pi );
60
- ctx .startActivity (fwdIntent ); // $hasImplicitPendingIntent
60
+ ctx .startActivity (fwdIntent ); // $ Alert
61
61
}
62
62
63
63
{
64
- Intent baseIntent = new Intent ();
64
+ Intent baseIntent = new Intent (); // $ Source
65
65
PendingIntent pi = PendingIntent .getActivitiesAsUser (ctx , 0 , new Intent [] {baseIntent },
66
66
0 , null , null );
67
67
Intent fwdIntent = new Intent ();
68
68
fwdIntent .putExtra ("fwdIntent" , pi );
69
- ctx .startActivity (fwdIntent ); // $hasImplicitPendingIntent
69
+ ctx .startActivity (fwdIntent ); // $ Alert
70
70
}
71
71
72
72
{
73
- Intent baseIntent = new Intent ();
73
+ Intent baseIntent = new Intent (); // $ Source
74
74
PendingIntent pi = PendingIntent .getBroadcast (ctx , 0 , baseIntent , 0 );
75
75
Intent fwdIntent = new Intent ();
76
76
fwdIntent .putExtra ("fwdIntent" , pi );
77
- ctx .sendBroadcast (fwdIntent ); // $hasImplicitPendingIntent
77
+ ctx .sendBroadcast (fwdIntent ); // $ Alert
78
78
}
79
79
80
80
{
81
- Intent baseIntent = new Intent ();
81
+ Intent baseIntent = new Intent (); // $ Source
82
82
PendingIntent pi = PendingIntent .getBroadcastAsUser (ctx , 0 , baseIntent , 0 , null );
83
83
Intent fwdIntent = new Intent ();
84
84
fwdIntent .putExtra ("fwdIntent" , pi );
85
- ctx .sendBroadcast (fwdIntent ); // $hasImplicitPendingIntent
85
+ ctx .sendBroadcast (fwdIntent ); // $ Alert
86
86
}
87
87
88
88
{
89
- Intent baseIntent = new Intent ();
89
+ Intent baseIntent = new Intent (); // $ Source
90
90
PendingIntent pi = PendingIntent .getService (ctx , 0 , baseIntent , 0 );
91
91
Intent fwdIntent = new Intent ();
92
92
fwdIntent .putExtra ("fwdIntent" , pi );
93
- ctx .startActivity (fwdIntent ); // $hasImplicitPendingIntent
93
+ ctx .startActivity (fwdIntent ); // $ Alert
94
94
}
95
95
96
96
{
97
- Intent baseIntent = new Intent ();
97
+ Intent baseIntent = new Intent (); // $ Source
98
98
PendingIntent pi = PendingIntent .getForegroundService (ctx , 0 , baseIntent , 0 );
99
99
Intent fwdIntent = new Intent ();
100
100
fwdIntent .putExtra ("fwdIntent" , pi );
101
- ctx .startActivity (fwdIntent ); // $hasImplicitPendingIntent
101
+ ctx .startActivity (fwdIntent ); // $ Alert
102
102
}
103
103
104
104
{
@@ -163,31 +163,31 @@ public static void testPendingIntentAsAnExtra(Context ctx)
163
163
public static void testPendingIntentWrappedInAnotherPendingIntent (Context ctx ,
164
164
PendingIntent other ) throws PendingIntent .CanceledException {
165
165
{
166
- Intent baseIntent = new Intent ();
166
+ Intent baseIntent = new Intent (); // $ Source
167
167
PendingIntent pi = PendingIntent .getActivity (ctx , 0 , baseIntent , 0 );
168
168
Intent fwdIntent = new Intent ();
169
169
fwdIntent .putExtra ("fwdIntent" , pi );
170
- other .send (ctx , 0 , fwdIntent ); // $hasImplicitPendingIntent
171
- other .send (ctx , 0 , fwdIntent , null , null ); // $hasImplicitPendingIntent
172
- other .send (ctx , 0 , fwdIntent , null , null , null ); // $hasImplicitPendingIntent
173
- other .send (ctx , 0 , fwdIntent , null , null , null , null ); // $hasImplicitPendingIntent
170
+ other .send (ctx , 0 , fwdIntent ); // $ Alert
171
+ other .send (ctx , 0 , fwdIntent , null , null ); // $ Alert
172
+ other .send (ctx , 0 , fwdIntent , null , null , null ); // $ Alert
173
+ other .send (ctx , 0 , fwdIntent , null , null , null , null ); // $ Alert
174
174
}
175
175
}
176
176
177
177
public static void testPendingIntentInANotification (Context ctx )
178
178
throws PendingIntent .CanceledException {
179
179
180
180
{
181
- Intent baseIntent = new Intent ();
181
+ Intent baseIntent = new Intent (); // $ Source
182
182
PendingIntent pi = PendingIntent .getActivity (ctx , 0 , baseIntent , 0 );
183
183
Notification .Action .Builder aBuilder = new Notification .Action .Builder (0 , "" , pi );
184
184
Notification .Builder nBuilder =
185
185
new Notification .Builder (ctx ).addAction (aBuilder .build ());
186
186
Notification notification = nBuilder .build ();
187
187
NotificationManager nManager = null ;
188
- nManager .notifyAsPackage ("targetPackage" , "tag" , 0 , notification ); // $hasImplicitPendingIntent
189
- nManager .notify (0 , notification ); // $hasImplicitPendingIntent
190
- nManager .notifyAsUser ("" , 0 , notification , null ); // $hasImplicitPendingIntent
188
+ nManager .notifyAsPackage ("targetPackage" , "tag" , 0 , notification ); // $ Alert
189
+ nManager .notify (0 , notification ); // $ Alert
190
+ nManager .notifyAsUser ("" , 0 , notification , null ); // $ Alert
191
191
}
192
192
{
193
193
Intent baseIntent = new Intent ();
@@ -219,31 +219,31 @@ public static void testPendingIntentInANotification(Context ctx)
219
219
}
220
220
// Compat sinks
221
221
{
222
- Intent baseIntent = new Intent ();
222
+ Intent baseIntent = new Intent (); // $ Source
223
223
PendingIntent pi = PendingIntent .getActivity (ctx , 0 , baseIntent , 0 );
224
224
Notification .Action .Builder aBuilder = new Notification .Action .Builder (0 , "" , pi );
225
225
Notification .Builder nBuilder =
226
226
new Notification .Builder (ctx ).addAction (aBuilder .build ());
227
227
Notification notification = nBuilder .build ();
228
228
NotificationManagerCompat nManager = null ;
229
- nManager .notify (0 , notification ); // $hasImplicitPendingIntent
230
- nManager .notify ("" , 0 , notification ); // $hasImplicitPendingIntent
229
+ nManager .notify (0 , notification ); // $ Alert
230
+ nManager .notify ("" , 0 , notification ); // $ Alert
231
231
}
232
232
}
233
233
234
234
public static void testPendingIntentInAnAlarm (Context ctx ) {
235
235
AlarmManager aManager = (AlarmManager ) ctx .getSystemService (Context .ALARM_SERVICE );
236
236
{
237
- Intent baseIntent = new Intent ();
237
+ Intent baseIntent = new Intent (); // $ Source
238
238
PendingIntent pi = PendingIntent .getActivity (ctx , 0 , baseIntent , 0 );
239
- aManager .set (0 , 0 , pi ); // $hasImplicitPendingIntent
240
- aManager .setAlarmClock (null , pi ); // $hasImplicitPendingIntent
241
- aManager .setAndAllowWhileIdle (0 , 0 , pi ); // $hasImplicitPendingIntent
242
- aManager .setExact (0 , 0 , pi ); // $hasImplicitPendingIntent
243
- aManager .setExactAndAllowWhileIdle (0 , 0 , pi ); // $hasImplicitPendingIntent
244
- aManager .setInexactRepeating (0 , 0 , 0 , pi ); // $hasImplicitPendingIntent
245
- aManager .setRepeating (0 , 0 , 0 , pi ); // $hasImplicitPendingIntent
246
- aManager .setWindow (0 , 0 , 0 , pi ); // $hasImplicitPendingIntent
239
+ aManager .set (0 , 0 , pi ); // $ Alert
240
+ aManager .setAlarmClock (null , pi ); // $ Alert
241
+ aManager .setAndAllowWhileIdle (0 , 0 , pi ); // $ Alert
242
+ aManager .setExact (0 , 0 , pi ); // $ Alert
243
+ aManager .setExactAndAllowWhileIdle (0 , 0 , pi ); // $ Alert
244
+ aManager .setInexactRepeating (0 , 0 , 0 , pi ); // $ Alert
245
+ aManager .setRepeating (0 , 0 , 0 , pi ); // $ Alert
246
+ aManager .setWindow (0 , 0 , 0 , pi ); // $ Alert
247
247
}
248
248
{
249
249
Intent baseIntent = new Intent ();
@@ -253,24 +253,24 @@ public static void testPendingIntentInAnAlarm(Context ctx) {
253
253
}
254
254
// Compat sinks
255
255
{
256
- Intent baseIntent = new Intent ();
256
+ Intent baseIntent = new Intent (); // $ Source
257
257
PendingIntent pi = PendingIntent .getActivity (ctx , 0 , baseIntent , 0 );
258
- AlarmManagerCompat .setAlarmClock (aManager , 0 , pi , null ); // $hasImplicitPendingIntent
259
- AlarmManagerCompat .setAlarmClock (aManager , 0 , null , pi ); // $hasImplicitPendingIntent
260
- AlarmManagerCompat .setAndAllowWhileIdle (aManager , 0 , 0 , pi ); // $hasImplicitPendingIntent
261
- AlarmManagerCompat .setExact (aManager , 0 , 0 , pi ); // $hasImplicitPendingIntent
262
- AlarmManagerCompat .setExactAndAllowWhileIdle (aManager , 0 , 0 , pi ); // $hasImplicitPendingIntent
258
+ AlarmManagerCompat .setAlarmClock (aManager , 0 , pi , null ); // $ Alert
259
+ AlarmManagerCompat .setAlarmClock (aManager , 0 , null , pi ); // $ Alert
260
+ AlarmManagerCompat .setAndAllowWhileIdle (aManager , 0 , 0 , pi ); // $ Alert
261
+ AlarmManagerCompat .setExact (aManager , 0 , 0 , pi ); // $ Alert
262
+ AlarmManagerCompat .setExactAndAllowWhileIdle (aManager , 0 , 0 , pi ); // $ Alert
263
263
}
264
264
}
265
265
266
266
static class TestActivity extends Activity {
267
267
@ Override
268
268
public void onCreate (Bundle bundle ) {
269
- Intent baseIntent = new Intent ();
269
+ Intent baseIntent = new Intent (); // $ Source
270
270
PendingIntent pi = PendingIntent .getActivity (null , 0 , baseIntent , 0 );
271
271
Intent fwdIntent = new Intent ();
272
272
fwdIntent .putExtra ("fwdIntent" , pi );
273
- setResult (0 , fwdIntent ); // $hasImplicitPendingIntent
273
+ setResult (0 , fwdIntent ); // $ Alert
274
274
}
275
275
}
276
276
@@ -281,13 +281,13 @@ static class TestSliceProvider extends SliceProvider {
281
281
@ Override
282
282
public Slice onBindSlice (Uri sliceUri ) {
283
283
if (sliceUri .getAuthority ().equals ("1" )) {
284
- Intent baseIntent = new Intent ();
284
+ Intent baseIntent = new Intent (); // $ Source
285
285
PendingIntent pi = PendingIntent .getActivity (getContext (), 0 , baseIntent , 0 );
286
286
SliceAction activityAction = SliceAction .createDeeplink (pi , null , 0 , "Test" );
287
287
ListBuilder listBuilder = new ListBuilder (getContext (), sliceUri , null );
288
288
listBuilder .addRow (new ListBuilder .RowBuilder ().setTitle ("Title" )
289
289
.setPrimaryAction (activityAction ));
290
- return listBuilder .build (); // $hasImplicitPendingIntent
290
+ return listBuilder .build (); // $ Alert
291
291
292
292
} else if (sliceUri .getAuthority ().equals ("2" )) {
293
293
Intent baseIntent = new Intent (getContext (), Activity .class ); // Sanitizer
@@ -314,16 +314,16 @@ public Slice onBindSlice(Uri sliceUri) {
314
314
SliceAction action = SliceAction .createDeeplink (mPendingIntent , null , 0 , "" );
315
315
ListBuilder listBuilder = new ListBuilder (getContext (), sliceUri , 0 );
316
316
listBuilder .addRow (new ListBuilder .RowBuilder (sliceUri ).setPrimaryAction (action ));
317
- return listBuilder .build (); // $hasImplicitPendingIntent
317
+ return listBuilder .build (); // $ Alert
318
318
}
319
319
}
320
320
321
321
@ Override
322
322
public PendingIntent onCreatePermissionRequest (Uri sliceUri , String callingPackage ) {
323
323
if (sliceUri .getAuthority ().equals ("1" )) {
324
- Intent baseIntent = new Intent ();
324
+ Intent baseIntent = new Intent (); // $ Source
325
325
PendingIntent pi = PendingIntent .getActivity (getContext (), 0 , baseIntent , 0 );
326
- return pi ; // $hasImplicitPendingIntent
326
+ return pi ; // $ Alert
327
327
} else {
328
328
Intent baseIntent = new Intent ();
329
329
PendingIntent pi = PendingIntent .getActivity (getContext (), 0 , baseIntent ,
@@ -336,7 +336,7 @@ public PendingIntent onCreatePermissionRequest(Uri sliceUri, String callingPacka
336
336
public boolean onCreateSliceProvider () {
337
337
// Testing implicit field read flows:
338
338
// mPendingIntent is used in onBindSlice
339
- Intent baseIntent = new Intent ();
339
+ Intent baseIntent = new Intent (); // $ Source
340
340
mPendingIntent = PendingIntent .getActivity (getContext (), 0 , baseIntent , 0 );
341
341
return true ;
342
342
}
0 commit comments