/** Factory method to start query with a number */
  public static CallerInfoAsyncQuery startQuery(
      int token, Context context, String number, OnQueryCompleteListener listener, Object cookie) {
    // contruct the URI object and start Query.
    Uri contactRef = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));

    CallerInfoAsyncQuery c = new CallerInfoAsyncQuery();
    c.allocate(context, contactRef);

    if (DBG) log("starting query for number: " + number + " handler: " + c.toString());

    // create cookieWrapper, start query
    CookieWrapper cw = new CookieWrapper();
    cw.listener = listener;
    cw.cookie = cookie;
    cw.number = number;

    // check to see if these are recognized numbers, and use shortcuts if we can.
    if (PhoneNumberUtils.isEmergencyNumber(number)) {
      cw.event = EVENT_EMERGENCY_NUMBER;
    } else if (PhoneNumberUtils.isVoiceMailNumber(number)) {
      cw.event = EVENT_VOICEMAIL_NUMBER;
    } else {
      cw.event = EVENT_NEW_QUERY;
    }

    c.mHandler.startQuery(token, cw, contactRef, null, null, null, null);

    return c;
  }
Beispiel #2
0
  /**
   * getCallerInfo given a URI, look up in the call-log database for the uri unique key.
   *
   * @param context the context used to get the ContentResolver
   * @param contactRef the URI used to lookup caller id
   * @return the CallerInfo which contains the caller id for the given number. The returned
   *     CallerInfo is null if no number is supplied.
   */
  public static CallerInfo getCallerInfo(Context context, Uri contactRef) {

    return getCallerInfo(
        context,
        contactRef,
        CallerInfoAsyncQuery.getCurrentProfileContentResolver(context)
            .query(contactRef, null, null, null, null));
  }
  /** Factory method to start query with a Uri query spec */
  public static CallerInfoAsyncQuery startQuery(
      int token, Context context, Uri contactRef, OnQueryCompleteListener listener, Object cookie) {

    CallerInfoAsyncQuery c = new CallerInfoAsyncQuery();
    c.allocate(context, contactRef);

    if (DBG) log("starting query for URI: " + contactRef + " handler: " + c.toString());

    // create cookieWrapper, start query
    CookieWrapper cw = new CookieWrapper();
    cw.listener = listener;
    cw.cookie = cookie;
    cw.event = EVENT_NEW_QUERY;

    c.mHandler.startQuery(token, cw, contactRef, null, null, null, null);

    return c;
  }