1 package com.android.providers.calendar; 2 3 import android.accounts.Account; 4 import android.app.PendingIntent; 5 import android.content.ContentResolver; 6 import android.content.Context; 7 import android.net.Uri; 8 9 import java.util.concurrent.atomic.AtomicBoolean; 10 11 public class CalendarProvider2ForTesting extends CalendarProvider2 { 12 13 /** 14 * For testing, don't want to start the TimezoneCheckerThread, as it results 15 * in race conditions. Thus updateTimezoneDependentFields is stubbed out. 16 */ 17 @Override updateTimezoneDependentFields()18 protected void updateTimezoneDependentFields() { 19 } 20 21 /** 22 * For testing, don't want onAccountsUpdated asynchronously deleting data. 23 */ 24 @Override onAccountsUpdated(Account[] accounts)25 public void onAccountsUpdated(Account[] accounts) { 26 } 27 28 @Override doUpdateTimezoneDependentFields()29 protected void doUpdateTimezoneDependentFields() { 30 } 31 32 @Override postInitialize()33 protected void postInitialize() { 34 } 35 36 @Override initCalendarAlarm()37 protected void initCalendarAlarm() { 38 mCalendarAlarm = new MockCalendarAlarmManager(getContext()); 39 } 40 41 @Override shouldSyncFor(Uri uri)42 protected boolean shouldSyncFor(Uri uri) { 43 return true; 44 } 45 46 @Override getCallingPackageName()47 protected String getCallingPackageName() { 48 return ""; 49 } 50 51 private static class MockCalendarAlarmManager extends CalendarAlarmManager { 52 MockCalendarAlarmManager(Context context)53 public MockCalendarAlarmManager(Context context) { 54 super(context); 55 } 56 57 @Override initializeWithContext(Context context)58 protected void initializeWithContext(Context context) { 59 mContext = context; 60 mNextAlarmCheckScheduled = new AtomicBoolean(false); 61 mAlarmLock = new Object(); 62 } 63 64 @Override set(int type, long triggerAtTime, PendingIntent operation)65 public void set(int type, long triggerAtTime, PendingIntent operation) { 66 } 67 68 @Override setExact(int type, long triggerAtTime, PendingIntent operation)69 public void setExact(int type, long triggerAtTime, PendingIntent operation) { 70 } 71 72 @Override setExactAndAllowWhileIdle(int type, long triggerAtTime, PendingIntent operation)73 public void setExactAndAllowWhileIdle(int type, long triggerAtTime, 74 PendingIntent operation) { 75 } 76 77 @Override cancel(PendingIntent operation)78 public void cancel(PendingIntent operation) { 79 } 80 81 @Override scheduleAlarm(long alarmTime)82 public void scheduleAlarm(long alarmTime) { 83 } 84 85 @Override rescheduleMissedAlarms(ContentResolver cr)86 public void rescheduleMissedAlarms(ContentResolver cr) { 87 } 88 } 89 } 90