1 /* 2 * Copyright 2014, 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.server.telecom; 18 19 import android.annotation.Nullable; 20 import android.net.Uri; 21 import android.os.UserHandle; 22 import android.telecom.PhoneAccountHandle; 23 24 import android.telecom.CallerInfo; 25 26 /** 27 * Creates a notification for calls that the user missed (neither answered nor rejected). 28 */ 29 public interface MissedCallNotifier extends CallsManager.CallsManagerListener { 30 class CallInfoFactory { makeCallInfo(CallerInfo callerInfo, PhoneAccountHandle phoneAccountHandle, Uri handle, long creationTimeMillis)31 public CallInfo makeCallInfo(CallerInfo callerInfo, PhoneAccountHandle phoneAccountHandle, 32 Uri handle, long creationTimeMillis) { 33 return new CallInfo(callerInfo, phoneAccountHandle, handle, creationTimeMillis); 34 } 35 } 36 37 class CallInfo { 38 private CallerInfo mCallerInfo; 39 private PhoneAccountHandle mPhoneAccountHandle; 40 private Uri mHandle; 41 private long mCreationTimeMillis; 42 CallInfo(CallerInfo callerInfo, PhoneAccountHandle phoneAccountHandle, Uri handle, long creationTimeMillis)43 public CallInfo(CallerInfo callerInfo, PhoneAccountHandle phoneAccountHandle, Uri handle, 44 long creationTimeMillis) { 45 mCallerInfo = callerInfo; 46 mPhoneAccountHandle = phoneAccountHandle; 47 mHandle = handle; 48 mCreationTimeMillis = creationTimeMillis; 49 } 50 CallInfo(Call call)51 public CallInfo(Call call) { 52 mCallerInfo = call.getCallerInfo(); 53 mPhoneAccountHandle = call.getTargetPhoneAccount(); 54 mHandle = call.getHandle(); 55 mCreationTimeMillis = call.getCreationTimeMillis(); 56 } 57 getCallerInfo()58 public CallerInfo getCallerInfo() { 59 return mCallerInfo; 60 } 61 getPhoneAccountHandle()62 public PhoneAccountHandle getPhoneAccountHandle() { 63 return mPhoneAccountHandle; 64 } 65 getHandle()66 public Uri getHandle() { 67 return mHandle; 68 } 69 getHandleSchemeSpecificPart()70 public String getHandleSchemeSpecificPart() { 71 return mHandle == null ? null : mHandle.getSchemeSpecificPart(); 72 } 73 getCreationTimeMillis()74 public long getCreationTimeMillis() { 75 return mCreationTimeMillis; 76 } 77 getPhoneNumber()78 public String getPhoneNumber() { 79 return mCallerInfo == null ? null : mCallerInfo.getPhoneNumber(); 80 } 81 getName()82 public String getName() { 83 return mCallerInfo == null ? null : mCallerInfo.getName(); 84 } 85 } 86 clearMissedCalls(UserHandle userHandle)87 void clearMissedCalls(UserHandle userHandle); 88 showMissedCallNotification(CallInfo call, @Nullable Uri uri)89 void showMissedCallNotification(CallInfo call, @Nullable Uri uri); 90 reloadAfterBootComplete(CallerInfoLookupHelper callerInfoLookupHelper, CallInfoFactory callInfoFactory)91 void reloadAfterBootComplete(CallerInfoLookupHelper callerInfoLookupHelper, 92 CallInfoFactory callInfoFactory); 93 reloadFromDatabase(CallerInfoLookupHelper callerInfoLookupHelper, CallInfoFactory callInfoFactory, UserHandle userHandle)94 void reloadFromDatabase(CallerInfoLookupHelper callerInfoLookupHelper, 95 CallInfoFactory callInfoFactory, UserHandle userHandle); 96 setCurrentUserHandle(UserHandle userHandle)97 void setCurrentUserHandle(UserHandle userHandle); 98 } 99