1034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Leepackage com.android.dialer.service;
2034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee
3034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Leeimport android.content.Context;
4f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Changimport android.net.Uri;
5f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Changimport android.support.annotation.Nullable;
6034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee
7034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Leeimport com.android.dialer.calllog.ContactInfo;
8034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee
9f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Changimport java.io.InputStream;
10f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Chang
11034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Leepublic interface CachedNumberLookupService {
12173ec96476278f0d6aa147d31a60aa3e419e5ca3Jay Shrauner
13c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner    public interface CachedContactInfo {
1447410b07d070db44ea897a1fdba7d584bc157881Yorke Lee        public static final int SOURCE_TYPE_DIRECTORY = 1;
1547410b07d070db44ea897a1fdba7d584bc157881Yorke Lee        public static final int SOURCE_TYPE_EXTENDED = 2;
1647410b07d070db44ea897a1fdba7d584bc157881Yorke Lee        public static final int SOURCE_TYPE_PLACES = 3;
1747410b07d070db44ea897a1fdba7d584bc157881Yorke Lee        public static final int SOURCE_TYPE_PROFILE = 4;
1847410b07d070db44ea897a1fdba7d584bc157881Yorke Lee        public static final int SOURCE_TYPE_CNAP = 5;
1947410b07d070db44ea897a1fdba7d584bc157881Yorke Lee
20c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner        public ContactInfo getContactInfo();
21c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner
2247410b07d070db44ea897a1fdba7d584bc157881Yorke Lee        public void setSource(int sourceType, String name, long directoryId);
23c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner        public void setDirectorySource(String name, long directoryId);
24c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner        public void setExtendedSource(String name, long directoryId);
25c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner        public void setLookupKey(String lookupKey);
26173ec96476278f0d6aa147d31a60aa3e419e5ca3Jay Shrauner    }
27173ec96476278f0d6aa147d31a60aa3e419e5ca3Jay Shrauner
28c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner    public CachedContactInfo buildCachedContactInfo(ContactInfo info);
29c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner
30034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee    /**
31034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     * Perform a lookup using the cached number lookup service to return contact
32034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     * information stored in the cache that corresponds to the given number.
33034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     *
34034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     * @param context Valid context
35034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     * @param number Phone number to lookup the cache for
36c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner     * @return A {@link CachedContactInfo} containing the contact information if the phone
37034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     * number is found in the cache, {@link ContactInfo#EMPTY} if the phone number was
38034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     * not found in the cache, and null if there was an error when querying the cache.
39034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee     */
40c089b0d2b1bf1bd511cd54dc51d9186b6ce41681Jay Shrauner    public CachedContactInfo lookupCachedContactFromNumber(Context context, String number);
41173ec96476278f0d6aa147d31a60aa3e419e5ca3Jay Shrauner
42173ec96476278f0d6aa147d31a60aa3e419e5ca3Jay Shrauner    public void addContact(Context context, CachedContactInfo info);
43006b5aff5f44d92a67c45881c575d692cacea8e5Jay Shrauner
44006b5aff5f44d92a67c45881c575d692cacea8e5Jay Shrauner    public boolean isCacheUri(String uri);
45006b5aff5f44d92a67c45881c575d692cacea8e5Jay Shrauner
4656cb0efa5eda1670077e66fc0e8c79478d0c1c67Yorke Lee    public boolean isBusiness(int sourceType);
4755733814f213809baaa8eaa8984ff026bdb08b4eAnthony Lee    public boolean canReportAsInvalid(int sourceType, String objectId);
48b77bf5df2b866dd40e330b7c2dedee4a1d51fc78Sai Cheemalapati
49f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Chang    /**
50f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Chang     * @return return {@link Uri} to the photo or return {@code null} when failing to add photo
51f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Chang     */
52f436fb5f5f6fd08a21beb5fb1b27478526ba1e9cVictor Chang    public @Nullable Uri addPhoto(Context context, String number, InputStream in);
53f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee
54f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee    /**
55f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee     * Remove all cached phone number entries from the cache, regardless of how old they
56f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee     * are.
57f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee     *
58f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee     * @param context Valid context
59f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee     */
60f2a0756a67d1f1ba3060ce1913cbcf87d37a8403Yorke Lee    public void clearAllCacheEntries(Context context);
61034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee}
62