194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/* 294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Copyright (C) 2011 The Android Open Source Project 394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * you may not use this file except in compliance with the License. 694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * You may obtain a copy of the License at 794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 1094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Unless required by applicable law or agreed to in writing, software 1194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 1294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * See the License for the specific language governing permissions and 1494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * limitations under the License 1594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 1694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengpackage com.android.dialer.calllog; 1894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.content.BroadcastReceiver; 2094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.content.Context; 2194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.content.Intent; 2294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.provider.VoicemailContract; 2394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.util.Log; 2494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 2594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/** 2694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Receiver for call log events. 2794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * <p> 2894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * It is currently used to handle {@link VoicemailContract#ACTION_NEW_VOICEMAIL} and 2994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * {@link Intent#ACTION_BOOT_COMPLETED}. 3094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 3194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengpublic class CallLogReceiver extends BroadcastReceiver { 3294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng private static final String TAG = "CallLogReceiver"; 3394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 3494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 3594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public void onReceive(Context context, Intent intent) { 3694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (VoicemailContract.ACTION_NEW_VOICEMAIL.equals(intent.getAction())) { 3794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng Intent serviceIntent = new Intent(context, CallLogNotificationsService.class); 3894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng serviceIntent.setAction(CallLogNotificationsService.ACTION_UPDATE_NOTIFICATIONS); 3994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng serviceIntent.putExtra( 4094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng CallLogNotificationsService.EXTRA_NEW_VOICEMAIL_URI, intent.getData()); 4194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng context.startService(serviceIntent); 4294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { 4394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng Intent serviceIntent = new Intent(context, CallLogNotificationsService.class); 4494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng serviceIntent.setAction(CallLogNotificationsService.ACTION_UPDATE_NOTIFICATIONS); 4594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng context.startService(serviceIntent); 4694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } else { 4794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng Log.w(TAG, "onReceive: could not handle: " + intent); 4894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 4994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 5094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng} 51