1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.providers.calendar; 17 18 import android.app.IntentService; 19 import android.content.Intent; 20 import android.util.Log; 21 22 public class CalendarProviderIntentService extends IntentService { 23 24 private static final String TAG = CalendarProvider2.TAG; 25 private static final String REMOVE_ALARMS_VALUE = "removeAlarms"; 26 27 public CalendarProviderIntentService() { 28 super("CalendarProviderIntentService"); 29 } 30 31 @Override 32 protected void onHandleIntent(Intent intent) { 33 if (Log.isLoggable(TAG, Log.DEBUG)) { 34 Log.d(TAG, "Received Intent: " + intent); 35 } 36 final String action = intent.getAction(); 37 if (!CalendarAlarmManager.ACTION_CHECK_NEXT_ALARM.equals(action)) { 38 if (Log.isLoggable(TAG, Log.DEBUG)) { 39 Log.d(TAG, "Invalid Intent action: " + action); 40 } 41 return; 42 } 43 final CalendarProvider2 provider = CalendarProvider2.getInstance(); 44 // Schedule the next alarm 45 final boolean removeAlarms = intent.getBooleanExtra(REMOVE_ALARMS_VALUE, false); 46 provider.getOrCreateCalendarAlarmManager().runScheduleNextAlarm(removeAlarms, provider); 47 // Release the wake lock that was set in the Broadcast Receiver 48 provider.getOrCreateCalendarAlarmManager().releaseScheduleNextAlarmWakeLock(); 49 } 50 } 51