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