Skip to content

Commit e39e554

Browse files
varunshah-xandroid-build-team Robot
authored andcommitted
DO NOT MERGE: Disable StrictMode VM Policy check.
Disable the VM policy violation for intents that contain a content URI but don't have FLAG_GRANT_URI_PERMISSION when scheduling alarms. Fixes: 160426113 Test: atest CalendarProvider2Test Change-Id: If6e4a03609fc3d03dde66bcaa3136b23662ccaeb (cherry picked from commit 224822ecafdf09a3a2cda11d95645f3056ab58dc) (cherry picked from commit f20d333)
1 parent b18f2f5 commit e39e554

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

core/java/android/provider/CalendarContract.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import android.database.DatabaseUtils;
4040
import android.net.Uri;
4141
import android.os.RemoteException;
42+
import android.os.StrictMode;
4243
import android.text.format.DateUtils;
4344
import android.text.format.TimeMigrationUtils;
4445
import android.util.Log;
@@ -2618,7 +2619,13 @@ public static void scheduleAlarm(Context context, AlarmManager manager, long ala
26182619
intent.setData(ContentUris.withAppendedId(CalendarContract.CONTENT_URI, alarmTime));
26192620
intent.putExtra(ALARM_TIME, alarmTime);
26202621
intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
2622+
2623+
// Disable strict mode VM policy violations temporarily for intents that contain a
2624+
// content URI but don't have FLAG_GRANT_READ_URI_PERMISSION.
2625+
StrictMode.VmPolicy oldVmPolicy = StrictMode.allowVmViolations();
26212626
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
2627+
StrictMode.setVmPolicy(oldVmPolicy);
2628+
26222629
manager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmTime, pi);
26232630
}
26242631

0 commit comments

Comments
 (0)