1package com.android.dialer.service;
2
3import android.content.Context;
4
5import com.android.dialer.calllog.ContactInfo;
6
7public interface CachedNumberLookupService {
8
9    public interface CachedContactInfo {
10        public static final int SOURCE_TYPE_DIRECTORY = 1;
11        public static final int SOURCE_TYPE_EXTENDED = 2;
12        public static final int SOURCE_TYPE_PLACES = 3;
13        public static final int SOURCE_TYPE_PROFILE = 4;
14        public static final int SOURCE_TYPE_CNAP = 5;
15
16        public ContactInfo getContactInfo();
17
18        public void setSource(int sourceType, String name, long directoryId);
19        public void setDirectorySource(String name, long directoryId);
20        public void setExtendedSource(String name, long directoryId);
21        public void setLookupKey(String lookupKey);
22    }
23
24    public CachedContactInfo buildCachedContactInfo(ContactInfo info);
25
26    /**
27     * Perform a lookup using the cached number lookup service to return contact
28     * information stored in the cache that corresponds to the given number.
29     *
30     * @param context Valid context
31     * @param number Phone number to lookup the cache for
32     * @return A {@link CachedContactInfo} containing the contact information if the phone
33     * number is found in the cache, {@link ContactInfo#EMPTY} if the phone number was
34     * not found in the cache, and null if there was an error when querying the cache.
35     */
36    public CachedContactInfo lookupCachedContactFromNumber(Context context, String number);
37
38    public void addContact(Context context, CachedContactInfo info);
39
40    public boolean isCacheUri(String uri);
41
42    public boolean isBusiness(int sourceType);
43    public boolean canReportAsInvalid(int sourceType, String objectId);
44
45    public boolean addPhoto(Context context, String number, byte[] photo);
46
47    /**
48     * Remove all cached phone number entries from the cache, regardless of how old they
49     * are.
50     *
51     * @param context Valid context
52     */
53    public void clearAllCacheEntries(Context context);
54}
55