Home | History | Annotate | Download | only in calllog
      1 /*
      2  * Copyright (C) 2013 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 
     17 package com.android.dialer.calllog;
     18 
     19 import android.content.Context;
     20 import android.content.Intent;
     21 import android.os.RemoteException;
     22 import android.os.ServiceManager;
     23 import android.util.Log;
     24 
     25 import com.android.internal.telephony.ITelephony;
     26 
     27 /**
     28  * Helper class operating on call log notifications.
     29  */
     30 public class CallLogNotificationsHelper {
     31     private static final String TAG = "CallLogNotificationsHelper";
     32 
     33     /** Removes the missed call notifications. */
     34     public static void removeMissedCallNotifications() {
     35         try {
     36             ITelephony telephony =
     37                     ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
     38             if (telephony != null) {
     39                 telephony.cancelMissedCallsNotification();
     40             } else {
     41                 Log.w(TAG, "Telephony service is null, can't call " +
     42                         "cancelMissedCallsNotification");
     43             }
     44         } catch (RemoteException e) {
     45             Log.e(TAG, "Failed to clear missed calls notification due to remote exception");
     46         }
     47     }
     48 
     49     /** Update the voice mail notifications. */
     50     public static void updateVoicemailNotifications(Context context) {
     51         Intent serviceIntent = new Intent(context, CallLogNotificationsService.class);
     52         serviceIntent.setAction(CallLogNotificationsService.ACTION_UPDATE_NOTIFICATIONS);
     53         context.startService(serviceIntent);
     54     }
     55 }
     56