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; }
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; }
public void nmsCheckDefaultSmsAppChanged() { try { mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsCheckDefaultSmsApp, null, null); } catch (Exception e) { NmsLog.nmsPrintStackTrace(e); } }
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); } }
// 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); } }
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); } }
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); } }
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); } }
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; }
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; }
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; }
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; }
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; }
/* * 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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }