• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.calllogcache;
18 
19 import android.content.Context;
20 import android.telecom.PhoneAccount;
21 import android.telecom.PhoneAccountHandle;
22 import android.telephony.PhoneNumberUtils;
23 import android.text.TextUtils;
24 
25 /**
26  * This is a compatibility class for the CallLogCache for versions of dialer before Lollipop Mr1
27  * (the introduction of phone accounts).
28  *
29  * This class should not be initialized directly and instead be acquired from
30  * {@link CallLogCache#getCallLogCache}.
31  */
32 class CallLogCacheLollipop extends CallLogCache {
33     private String mVoicemailNumber;
34 
CallLogCacheLollipop(Context context)35     /* package */ CallLogCacheLollipop(Context context) {
36         super(context);
37     }
38 
39     @Override
isVoicemailNumber(PhoneAccountHandle accountHandle, CharSequence number)40     public boolean isVoicemailNumber(PhoneAccountHandle accountHandle, CharSequence number) {
41         if (TextUtils.isEmpty(number)) {
42             return false;
43         }
44 
45         String numberString = number.toString();
46 
47         if (!TextUtils.isEmpty(mVoicemailNumber)) {
48             return PhoneNumberUtils.compare(numberString, mVoicemailNumber);
49         }
50 
51         if (PhoneNumberUtils.isVoiceMailNumber(numberString)) {
52             mVoicemailNumber = numberString;
53             return true;
54         }
55 
56         return false;
57     }
58 
59     @Override
getAccountLabel(PhoneAccountHandle accountHandle)60     public String getAccountLabel(PhoneAccountHandle accountHandle) {
61         return null;
62     }
63 
64     @Override
getAccountColor(PhoneAccountHandle accountHandle)65     public int getAccountColor(PhoneAccountHandle accountHandle) {
66         return PhoneAccount.NO_HIGHLIGHT_COLOR;
67     }
68 
69     @Override
doesAccountSupportCallSubject(PhoneAccountHandle accountHandle)70     public boolean doesAccountSupportCallSubject(PhoneAccountHandle accountHandle) {
71         return false;
72     }
73 }
74