• 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.app.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  * <p>This class should not be initialized directly and instead be acquired from {@link
30  * CallLogCache#getCallLogCache}.
31  */
32 class CallLogCacheLollipop extends CallLogCache {
33 
34   private String mVoicemailNumber;
35 
CallLogCacheLollipop(Context context)36   /* package */ CallLogCacheLollipop(Context context) {
37     super(context);
38   }
39 
40   @Override
isVoicemailNumber(PhoneAccountHandle accountHandle, CharSequence number)41   public boolean isVoicemailNumber(PhoneAccountHandle accountHandle, CharSequence number) {
42     if (TextUtils.isEmpty(number)) {
43       return false;
44     }
45 
46     String numberString = number.toString();
47 
48     if (!TextUtils.isEmpty(mVoicemailNumber)) {
49       return PhoneNumberUtils.compare(numberString, mVoicemailNumber);
50     }
51 
52     if (PhoneNumberUtils.isVoiceMailNumber(numberString)) {
53       mVoicemailNumber = numberString;
54       return true;
55     }
56 
57     return false;
58   }
59 
60   @Override
getAccountLabel(PhoneAccountHandle accountHandle)61   public String getAccountLabel(PhoneAccountHandle accountHandle) {
62     return null;
63   }
64 
65   @Override
getAccountColor(PhoneAccountHandle accountHandle)66   public int getAccountColor(PhoneAccountHandle accountHandle) {
67     return PhoneAccount.NO_HIGHLIGHT_COLOR;
68   }
69 
70   @Override
doesAccountSupportCallSubject(PhoneAccountHandle accountHandle)71   public boolean doesAccountSupportCallSubject(PhoneAccountHandle accountHandle) {
72     return false;
73   }
74 }
75