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