CallLogReceiver.java revision d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9
1/* 2 * Copyright (C) 2011 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 17package com.android.dialer.app.calllog; 18 19import android.content.BroadcastReceiver; 20import android.content.Context; 21import android.content.Intent; 22import android.database.Cursor; 23import android.provider.VoicemailContract; 24import com.android.dialer.app.voicemail.error.VoicemailStatusCorruptionHandler; 25import com.android.dialer.app.voicemail.error.VoicemailStatusCorruptionHandler.Source; 26import com.android.dialer.common.LogUtil; 27import com.android.dialer.database.CallLogQueryHandler; 28 29/** 30 * Receiver for call log events. 31 * 32 * <p>It is currently used to handle {@link VoicemailContract#ACTION_NEW_VOICEMAIL} and {@link 33 * Intent#ACTION_BOOT_COMPLETED}. 34 */ 35public class CallLogReceiver extends BroadcastReceiver { 36 37 @Override 38 public void onReceive(Context context, Intent intent) { 39 if (VoicemailContract.ACTION_NEW_VOICEMAIL.equals(intent.getAction())) { 40 checkVoicemailStatus(context); 41 CallLogNotificationsService.updateVoicemailNotifications(context); 42 } else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { 43 CallLogNotificationsService.updateVoicemailNotifications(context); 44 } else { 45 LogUtil.w("CallLogReceiver.onReceive", "could not handle: " + intent); 46 } 47 } 48 49 private static void checkVoicemailStatus(Context context) { 50 new CallLogQueryHandler( 51 context, 52 context.getContentResolver(), 53 new CallLogQueryHandler.Listener() { 54 @Override 55 public void onVoicemailStatusFetched(Cursor statusCursor) { 56 VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus( 57 context, statusCursor, Source.Notification); 58 } 59 60 @Override 61 public void onVoicemailUnreadCountFetched(Cursor cursor) { 62 // Do nothing 63 } 64 65 @Override 66 public void onMissedCallsUnreadCountFetched(Cursor cursor) { 67 // Do nothing 68 } 69 70 @Override 71 public boolean onCallsFetched(Cursor combinedCursor) { 72 return false; 73 } 74 }) 75 .fetchVoicemailStatus(); 76 } 77} 78