1 /* 2 * Copyright (C) 2016 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.dialer.calllog; 17 18 import android.content.BroadcastReceiver; 19 import android.content.Context; 20 import android.content.Intent; 21 import android.telecom.TelecomManager; 22 import android.util.Log; 23 24 import com.android.dialer.calllog.CallLogNotificationsService; 25 26 /** 27 * Receives broadcasts that should trigger a refresh of the missed call notification. This includes 28 * both an explicit broadcast from Telecom and a reboot. 29 */ 30 public class MissedCallNotificationReceiver extends BroadcastReceiver { 31 //TODO: Use compat class for these methods. 32 public static final String ACTION_SHOW_MISSED_CALLS_NOTIFICATION = 33 "android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION"; 34 35 public static final String EXTRA_NOTIFICATION_COUNT = 36 "android.telecom.extra.NOTIFICATION_COUNT"; 37 38 public static final String EXTRA_NOTIFICATION_PHONE_NUMBER = 39 "android.telecom.extra.NOTIFICATION_PHONE_NUMBER"; 40 41 @Override onReceive(Context context, Intent intent)42 public void onReceive(Context context, Intent intent) { 43 String action = intent.getAction(); 44 if (!ACTION_SHOW_MISSED_CALLS_NOTIFICATION.equals(action)) { 45 return; 46 } 47 48 int count = intent.getIntExtra(EXTRA_NOTIFICATION_COUNT, 49 CallLogNotificationsService.UNKNOWN_MISSED_CALL_COUNT); 50 String number = intent.getStringExtra(EXTRA_NOTIFICATION_PHONE_NUMBER); 51 CallLogNotificationsService.updateMissedCallNotifications(context, count, number); 52 } 53 } 54