Exemplo n.º 1
0
  public long getSystemContactIdViaContactUri(Uri uri) {
    if (uri == null) {
      NmsLog.error(TAG, "getSystemContactIdViaContactUri is invalid!");
      return -1;
    }

    long result = -1;
    Cursor cursor = null;
    try {
      cursor =
          NmsContentResolver.query(
              mContext.getContentResolver(), uri, new String[] {Contacts._ID}, null, null, null);
      if (cursor != null && cursor.moveToFirst()) {
        result = cursor.getLong(cursor.getColumnIndex(Contacts._ID));
      }
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }
    return result;
  }
Exemplo n.º 2
0
  public String getSystemNameViaSystemContactId(long systemContactId) {
    if (systemContactId <= 0) {
      NmsLog.error(TAG, "getSystemNameViaSystemContactId: sysContactId is invalid!");
      return null;
    }

    String result = "";

    Cursor cursor = null;
    try {
      cursor =
          NmsContentResolver.query(
              mContext.getContentResolver(),
              Contacts.CONTENT_URI,
              new String[] {Contacts.DISPLAY_NAME},
              Contacts._ID + "=?",
              new String[] {String.valueOf(systemContactId)},
              null);
      if (cursor != null && cursor.moveToFirst()) {
        result = cursor.getString(cursor.getColumnIndex(Contacts.DISPLAY_NAME));
      }
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }

    return result == null ? "" : result;
  }
Exemplo n.º 3
0
 public void nmsCheckDefaultSmsAppChanged() {
   try {
     mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsCheckDefaultSmsApp, null, null);
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
 }
Exemplo n.º 4
0
 public void addPrivateContactsStatistics(int contacts) {
   try {
     Bundle param = new Bundle();
     param.putInt(FUNC_ID_addPrivateContactsStatistics + 1, contacts);
     mApiProviders.call(API_CONTENT_URI, FUNC_ID_addPrivateContactsStatistics, null, param);
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
 }
Exemplo n.º 5
0
 // M: Activation Statistics
 public void nmsAddActivatePromptStatistics(int type) {
   try {
     Bundle param = new Bundle();
     param.putInt(FUNC_ID_nmsAddActivatePromptStatistics + 1, type);
     mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsAddActivatePromptStatistics, null, param);
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
 }
Exemplo n.º 6
0
  public void nmsSaveChatHistory(long threadId[]) {
    Bundle param = new Bundle();
    param.putLongArray(FUNC_ID_nmsSaveChatHistory + 1, threadId);

    try {
      mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsSaveChatHistory, null, param);
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }
  }
Exemplo n.º 7
0
  public void nmsExitFromChatMode(String number) {
    Bundle param = new Bundle();
    param.putString(FUNC_ID_nmsExitFromChatMode + 1, number);

    try {
      mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsExitFromChatMode, null, param);
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }
  }
Exemplo n.º 8
0
  public void nmsReSendFailedMsg(long simId, long msgId) {
    try {
      Bundle param = new Bundle();
      param.putLong(FUNC_ID_nmsReSendFailedMsg + 1, simId);
      param.putLong(FUNC_ID_nmsReSendFailedMsg + 2, msgId);

      mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsReSendFailedMsg, null, param);
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }
  }
Exemplo n.º 9
0
 public String nmsGetUnifyPhoneNumber(String number) {
   Bundle param = new Bundle();
   param.putString(FUNC_ID_getUnifyPhoneNumber + 1, number);
   try {
     Bundle back = mApiProviders.call(API_CONTENT_URI, FUNC_ID_getUnifyPhoneNumber, null, param);
     if (back != null) {
       return back.getString(FUNC_ID_getUnifyPhoneNumber);
     }
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
   return null;
 }
Exemplo n.º 10
0
 public boolean nmsIsIpMsgSendable(String number) {
   Bundle param = new Bundle();
   param.putString(FUNC_ID_nmsIsIpMsgSendable + 1, number);
   try {
     Bundle back = mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsIsIpMsgSendable, null, param);
     if (back != null) {
       return back.getBoolean(FUNC_ID_nmsIsIpMsgSendable);
     }
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
   return false;
 }
Exemplo n.º 11
0
 public boolean nmsNeedShowInviteDlg(long threadId) {
   Bundle param = new Bundle();
   param.putLong(FUNC_ID_nmsNeedShowInviteDlg + 1, threadId);
   try {
     Bundle back = mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsNeedShowInviteDlg, null, param);
     if (back != null) {
       return back.getBoolean(FUNC_ID_nmsNeedShowInviteDlg);
     }
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
   return false;
 }
Exemplo n.º 12
0
  public int nmsDeleteDraftMsgInThread(long threadId) {
    try {
      Bundle param = new Bundle();
      param.putLong(FUNC_ID_nmsDeleteDraftMsgInThread + 1, threadId);
      Bundle back =
          mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsDeleteDraftMsgInThread, null, param);
      if (back != null) return back.getInt(FUNC_ID_nmsDeleteDraftMsgInThread, -1);
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }

    return 0;
  }
Exemplo n.º 13
0
 public NmsContact nmsGetContactInfoViaEngineId(int engineContactId) {
   Bundle param = new Bundle();
   param.putShort(FUNC_ID_nmsGetContactInfoViaEngineId + 1, (short) engineContactId);
   try {
     Bundle back =
         mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsGetContactInfoViaEngineId, null, param);
     if (back != null) {
       return (NmsContact) back.getSerializable(FUNC_ID_nmsGetContactInfoViaEngineId);
     }
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
   return null;
 }
Exemplo n.º 14
0
  /*
   * the value of typeFlag please refer to the class :
   * NmsIpMessageConsts::NmsIpMessageMediaTypeFlag
   */
  public int nmsGetIpMsgCountOfTypeInThread(long threadId, int typeFlag) {
    try {
      Bundle param = new Bundle();
      param.putLong(FUNC_ID_nmsGetIpMsgCountOfTypeInThread + 1, threadId);
      param.putInt(FUNC_ID_nmsGetIpMsgCountOfTypeInThread + 2, typeFlag);
      Bundle back =
          mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsGetIpMsgCountOfTypeInThread, null, param);
      if (back != null) return back.getInt(FUNC_ID_nmsGetIpMsgCountOfTypeInThread, 0);
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }

    return 0;
  }
Exemplo n.º 15
0
  public Bitmap nmsGetContactAvatarViaEngineId(int engineContactId) {
    try {
      Bundle param = new Bundle();
      param.putInt(FUNC_ID_nmsGetContactAvatarViaEngineId + 1, engineContactId);

      Bundle back =
          mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsGetContactAvatarViaEngineId, null, param);
      if (back != null) return (Bitmap) back.getParcelable(FUNC_ID_nmsGetContactAvatarViaEngineId);
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }

    return null;
  }
Exemplo n.º 16
0
  public Bitmap nmsGetContactAvatarViaNumber(String phoneNumber) {
    try {
      Bundle param = new Bundle();
      param.putString(FUNC_ID_nmsGetContactAvatarViaNumber + 1, phoneNumber);

      Bundle back =
          mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsGetContactAvatarViaNumber, null, param);
      if (back != null) return (Bitmap) back.getParcelable(FUNC_ID_nmsGetContactAvatarViaNumber);
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }

    return null;
  }
Exemplo n.º 17
0
 public NmsContact nmsGetContactInfoViaNumber(String phoneNumber) {
   Bundle param = new Bundle();
   param.putString(FUNC_ID_nmsGetContactInfoViaNumber + 1, phoneNumber);
   try {
     Bundle back =
         mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsGetContactInfoViaNumber, null, param);
     if (back != null) {
       return (NmsContact) back.getSerializable(FUNC_ID_nmsGetContactInfoViaNumber);
     }
   } catch (Exception e) {
     NmsLog.nmsPrintStackTrace(e);
   }
   return null;
 }
Exemplo n.º 18
0
  public SNmsSimInfo nmsGetSimInfoViaSimId(int simId) {
    Bundle param = new Bundle();
    param.putInt(FUNC_ID_nmsGetSimInfoViaSimId + 1, simId);

    try {
      Bundle back = mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsGetSimInfoViaSimId, null, param);
      if (back != null) {
        return (SNmsSimInfo) back.getSerializable(FUNC_ID_nmsGetSimInfoViaSimId);
      }
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }

    return null;
  }
Exemplo n.º 19
0
  private SystemContactSummary getSystemContactSummaryViaNumber(String number) {
    if (TextUtils.isEmpty(number)) {
      NmsLog.error(TAG, "getSystemContactSummaryViaNumber. number is empty!");
      return null;
    }

    String encodeNumber = Uri.encode(number);
    if (TextUtils.isEmpty(encodeNumber)) {
      NmsLog.error(TAG, "getSystemContactSummaryViaNumber. encodeNumber is empty!");
      return null;
    }

    SystemContactSummary result = null;
    Cursor cursor = null;
    try {
      Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, encodeNumber);
      cursor =
          NmsContentResolver.query(
              mContext.getContentResolver(),
              lookupUri,
              new String[] {PhoneLookup._ID, PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER},
              null,
              null,
              null);
      if (cursor != null && cursor.moveToFirst()) {
        result = new SystemContactSummary();
        result.contactId = cursor.getLong(cursor.getColumnIndex(PhoneLookup._ID));
        result.name = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
        result.number =
            NmsCommonUtils.nmsGetStandardPhoneNum(
                cursor.getString(cursor.getColumnIndex(PhoneLookup.NUMBER)));
      }

    } catch (Exception e) {
      NmsLog.error(TAG, "number: " + number + ". encodeNumber: " + encodeNumber);
      NmsLog.nmsPrintStackTrace(e);
    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }

    return result;
  }
Exemplo n.º 20
0
  public boolean isExistSystemContactViaEmail(String email) {
    if (TextUtils.isEmpty(email)) {
      NmsLog.error(TAG, "isExistSystemContactViaEmail. email is empty!");
      return false;
    }
    if (!email.contains("@")) {
      NmsLog.error(TAG, "isExistSystemContactViaEmail. email is invalid");
      return false;
    }

    String encodeEmail = Uri.encode(email);
    if (TextUtils.isEmpty(encodeEmail)) {
      NmsLog.error(TAG, "isExistSystemContactViaEmail. encodeEmail is empty!");
      return false;
    }
    Cursor cursor = null;
    boolean result = false;
    try {
      Uri lookupUri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, encodeEmail);
      cursor =
          NmsContentResolver.query(
              mContext.getContentResolver(),
              lookupUri,
              new String[] {Email.CONTACT_ID},
              null,
              null,
              null);
      if (cursor != null && cursor.moveToFirst()) {
        result = true;
      }

    } catch (Exception e) {
      NmsLog.error(TAG, "email: " + email + ". encodeEmail: " + encodeEmail);
      NmsLog.nmsPrintStackTrace(e);
    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }

    return result;
  }
Exemplo n.º 21
0
  public int[] nmsGetGroupIdList() {

    try {
      Bundle back = mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsGetGroupIdList, null, null);
      if (back != null) {
        short[] ret = back.getShortArray(FUNC_ID_nmsGetGroupIdList);
        int[] list = null;
        if (ret != null) {
          list = new int[ret.length];
          for (int i = 0; i < ret.length; ++i) {
            list[i] = ret[i];
          }
        }
        return list;
      }
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    }
    return null;
  }
Exemplo n.º 22
0
  public Bitmap getSystemAvatarViaSystemContactId(long systemContactId) {
    if (systemContactId <= 0) {
      NmsLog.error(TAG, "getSystemAvatarViaSystemContactId. sysContactId is invalid!");
      return null;
    }

    Bitmap result = null;
    Cursor cursor = null;
    try {
      cursor =
          NmsContentResolver.query(
              mContext.getContentResolver(),
              Contacts.CONTENT_URI,
              new String[] {Contacts.PHOTO_ID},
              Contacts._ID + "=?",
              new String[] {String.valueOf(systemContactId)},
              null);
      if (cursor != null && cursor.moveToFirst()) {
        long photoId = cursor.getLong(cursor.getColumnIndex(Contacts.PHOTO_ID));
        if (photoId > 0) {
          Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, systemContactId);
          InputStream input =
              Contacts.openContactPhotoInputStream(mContext.getContentResolver(), uri);
          result = BitmapFactory.decodeStream(input);
        }
      }
    } catch (Exception e) {
      NmsLog.nmsPrintStackTrace(e);
    } finally {
      if (cursor != null) {
        cursor.close();
        cursor = null;
      }
    }

    return result;
  }