18bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio/* 28bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * Copyright (C) 2010 The Android Open Source Project 38bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * 48bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * Licensed under the Apache License, Version 2.0 (the "License"); 58bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * you may not use this file except in compliance with the License. 68bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * You may obtain a copy of the License at 78bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * 88bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * http://www.apache.org/licenses/LICENSE-2.0 98bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * 108bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * Unless required by applicable law or agreed to in writing, software 118bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * distributed under the License is distributed on an "AS IS" BASIS, 128bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * See the License for the specific language governing permissions and 148bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * limitations under the License. 158bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio */ 168bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Megliopackage com.android.providers.calendar; 178bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 188bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.app.IntentService; 198bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.content.Intent; 208bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.util.Log; 218bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 228bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Megliopublic class CalendarProviderIntentService extends IntentService { 238bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 248bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio private static final String TAG = CalendarProvider2.TAG; 258bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio private static final String REMOVE_ALARMS_VALUE = "removeAlarms"; 268bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 278bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio public CalendarProviderIntentService() { 288bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio super("CalendarProviderIntentService"); 298bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio } 308bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 318bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio @Override 328bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio protected void onHandleIntent(Intent intent) { 338bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio if (Log.isLoggable(TAG, Log.DEBUG)) { 348bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio Log.d(TAG, "Received Intent: " + intent); 358bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio } 368bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio final String action = intent.getAction(); 37420b7fb569773ae573fbe90c3a9c522d4c368863Erik if (!CalendarAlarmManager.ACTION_CHECK_NEXT_ALARM.equals(action)) { 388bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio if (Log.isLoggable(TAG, Log.DEBUG)) { 398bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio Log.d(TAG, "Invalid Intent action: " + action); 408bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio } 418bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio return; 428bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio } 438bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio final CalendarProvider2 provider = CalendarProvider2.getInstance(); 448bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio // Schedule the next alarm 458bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio final boolean removeAlarms = intent.getBooleanExtra(REMOVE_ALARMS_VALUE, false); 46420b7fb569773ae573fbe90c3a9c522d4c368863Erik provider.getOrCreateCalendarAlarmManager().runScheduleNextAlarm(removeAlarms, provider); 478bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio // Release the wake lock that was set in the Broadcast Receiver 48420b7fb569773ae573fbe90c3a9c522d4c368863Erik provider.getOrCreateCalendarAlarmManager().releaseScheduleNextAlarmWakeLock(); 498bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio } 508bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio} 51