summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2015-04-20 12:04:33 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2015-04-20 12:04:33 -0700
commitef2217346e099bfc47d6946f36c2138a564f42b4 (patch)
treee2a7611923381be20f718b7e29a25b63a6c3c414
parent86eb01dc0293bb0962c5b7ba94d0e520d2cc3360 (diff)
parenta85655929cfcd92000b23791c70c06f09b73bf2b (diff)
downloadpackages_apps_ContactsCommon-ef2217346e099bfc47d6946f36c2138a564f42b4.tar.gz
packages_apps_ContactsCommon-ef2217346e099bfc47d6946f36c2138a564f42b4.tar.bz2
packages_apps_ContactsCommon-ef2217346e099bfc47d6946f36c2138a564f42b4.zip
Merge "ContactsCommon: PCI RCS Patch Set 6."
-rw-r--r--src/com/android/contacts/common/list/DefaultContactListAdapter.java13
-rw-r--r--src/com/android/contacts/common/util/ContactsCommonRcsUtil.java136
-rw-r--r--src/com/android/contacts/common/vcard/NotificationImportExportListener.java4
3 files changed, 115 insertions, 38 deletions
diff --git a/src/com/android/contacts/common/list/DefaultContactListAdapter.java b/src/com/android/contacts/common/list/DefaultContactListAdapter.java
index 452e0bb7..cce1909b 100644
--- a/src/com/android/contacts/common/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/common/list/DefaultContactListAdapter.java
@@ -273,16 +273,17 @@ public class DefaultContactListAdapter extends ContactListAdapter {
if (ContactsCommonRcsUtil.getIsRcs()) {
Long contactId = cursor.getLong(ContactQuery.CONTACT_ID);
- boolean isUserProfile = cursor
- .getInt(ContactQuery.CONTACT_IS_USER_PROFILE) == 1;
- if (ContactsCommonRcsUtil.RcsCapabilityMapCache.containsKey(contactId)) {
+ boolean isUserProfile = cursor.getInt(ContactQuery.CONTACT_IS_USER_PROFILE) == 1;
+ if (ContactsCommonRcsUtil.RcsCapabilityMapCache.containsKey(contactId)
+ && ContactsCommonRcsUtil.RcsCapabilityMapCache.get(contactId) != null
+ && ContactsCommonRcsUtil.RcsCapabilityMapCache.get(contactId)) {
ContactsCommonRcsUtil.RcsCapabilityMap.put(contactId,
ContactsCommonRcsUtil.RcsCapabilityMapCache
.get(contactId));
}
- if (!isUserProfile
- && ContactsCommonRcsUtil.RcsCapabilityMap
- .containsKey(contactId)) {
+ if (!isUserProfile && ContactsCommonRcsUtil.RcsCapabilityMap.containsKey(contactId)
+ && ContactsCommonRcsUtil.RcsCapabilityMapCache.get(contactId) != null
+ && ContactsCommonRcsUtil.RcsCapabilityMapCache.get(contactId)) {
view.setRCSCapability(mContext.getDrawable(R.drawable.rcs_capacity_icon),
ContactsCommonRcsUtil.RcsCapabilityMap.get(contactId));
} else {
diff --git a/src/com/android/contacts/common/util/ContactsCommonRcsUtil.java b/src/com/android/contacts/common/util/ContactsCommonRcsUtil.java
index 4075262d..bc808fbb 100644
--- a/src/com/android/contacts/common/util/ContactsCommonRcsUtil.java
+++ b/src/com/android/contacts/common/util/ContactsCommonRcsUtil.java
@@ -27,19 +27,29 @@ import java.util.ArrayList;
import java.util.HashMap;
import com.android.contacts.common.list.DefaultContactListAdapter;
+import com.suntek.mway.rcs.client.api.voip.impl.RichScreenApi;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Contacts.Data;
+import android.text.TextUtils;
+import android.util.Log;
public class ContactsCommonRcsUtil {
+ public static final String TAG = "ContactsCommonRcsUtil";
+
+ public static final boolean DEBUG = false;
+
public static final String RCS_CAPABILITY_CHANGED = "rcs_capability_changed";
public static final String RCS_CAPABILITY_CHANGED_CONTACT_ID = "rcs_capability_changed_contact_id";
@@ -48,12 +58,19 @@ public class ContactsCommonRcsUtil {
public static final String RCS_CAPABILITY_MIMETYPE = "vnd.android.cursor.item/capability";
+ // User requst to update enhance screen
+ public static final String UPDATE_ENHANCE_SCREEN_PHONE_EVENT = "933 10 12000";
+
+ private static int DEFAULT_NUMBER_LENGTH = 11;
+
public static final HashMap<Long, Boolean> RcsCapabilityMap = new HashMap<Long, Boolean>();
public static final HashMap<Long, Boolean> RcsCapabilityMapCache = new HashMap<Long, Boolean>();
private static boolean isRcs = false;
+ private static RichScreenApi mRichScreenApi = null;
+
// private static long rcsCapabilityUpdatedContactId = -1;
/*
@@ -82,15 +99,18 @@ public class ContactsCommonRcsUtil {
@Override
protected Void doInBackground(Void... params) {
ContentResolver resolver = context.getContentResolver();
- Cursor c = resolver.query(Contacts.CONTENT_URI, new String[] {
- Contacts._ID
- }, null, null, null);
- ArrayList<Long> contactIdList = new ArrayList<Long>();
+ Cursor c = resolver.query(ContactsContract.Data.CONTENT_URI,
+ new String[] {
+ ContactsContract.Data.DATA1
+ }, Data.MIMETYPE + " = ?" + " and " +
+ ContactsContract.Data.DATA2 + " = ?", new String[] {
+ RCS_CAPABILITY_MIMETYPE, String.valueOf(1)
+ }, null);
try {
if (c != null && c.moveToFirst()) {
do {
Long contactId = c.getLong(0);
- contactIdList.add(contactId);
+ RcsCapabilityMap.put(contactId, true);
} while (c.moveToNext());
}
} finally {
@@ -98,13 +118,6 @@ public class ContactsCommonRcsUtil {
c.close();
}
}
- for (Long contactId : contactIdList) {
- if (ContactsCommonRcsUtil.isRCSUser(context, contactId)) {
- RcsCapabilityMap.put(contactId, true);
- } else {
- RcsCapabilityMap.put(contactId, false);
- }
- }
return null;
}
@@ -116,27 +129,86 @@ public class ContactsCommonRcsUtil {
}.execute();
}
- public static boolean isRCSUser(final Context context, long contactId) {
- Cursor c = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI,
- new String[] {
- ContactsContract.Data.DATA2
- }, Data.MIMETYPE + " = ? and " + ContactsContract.Data.DATA1 + " = ?",
- new String[] {
- RCS_CAPABILITY_MIMETYPE, String.valueOf(contactId)
- }, null);
- try {
- if (c != null && c.moveToFirst()) {
- do {
- if (c.getInt(0) == 1) {
- return true;
+ public static void setRichScreenApi(RichScreenApi richScreenApi) {
+ mRichScreenApi = richScreenApi;
+ }
+
+ public static RichScreenApi getRichScreenApi(Context context) {
+ if (mRichScreenApi == null) {
+ mRichScreenApi = new RichScreenApi(null);
+ mRichScreenApi.init(context, null);
+ Log.d(TAG, "_______mRichScreenApi init______");
+ }
+ return mRichScreenApi;
+ }
+
+ private static boolean isWifiEnabled(Context context) {
+ WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
+ if (wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
+ ConnectivityManager connManager = (ConnectivityManager)context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo wifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+ return wifiInfo.isConnected();
+ } else {
+ return false;
+ }
+ }
+
+ public static String getFormatNumber(String number){
+ if(null == number){
+ return "";
+ }
+ number = number.replaceAll("-", "");
+ number = number.replaceAll(" ", "");
+ number = number.replaceAll(",", "");
+ int numberLen = number.length();
+ if(numberLen > DEFAULT_NUMBER_LENGTH){
+ number = number.substring(numberLen - DEFAULT_NUMBER_LENGTH, numberLen);
+ }
+ return number;
+ }
+
+ public static void updateAllEnhanceScreeen(final Context context) {
+ if (!isWifiEnabled(context))
+ return;
+ Thread t = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ ArrayList<String> phoneNumberList = new ArrayList<String>();
+ Cursor phonecursor = context.getContentResolver().query(
+ ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[] {
+ Phone.NUMBER
+ }, null, null, null);
+ try {
+ if (phonecursor != null && phonecursor.moveToFirst()) {
+ // boolean hasTryToGet = false;
+ do {
+ String phoneNumber = phonecursor.getString(0);
+ phoneNumberList.add(getFormatNumber(phoneNumber));
+ } while (phonecursor.moveToNext());
}
- } while (c.moveToNext());
- }
- } finally {
- if(null != c){
- c.close();
+ } finally {
+ if (null != phonecursor) {
+ phonecursor.close();
+ }
+ }
+ try {
+ for (String aPhoneNumber : phoneNumberList) {
+ if (!TextUtils.isEmpty(aPhoneNumber)) {
+ if (DEBUG) {
+ Log.d(TAG, "Phone Number is: " + aPhoneNumber);
+ Log.d(TAG, "Calling downloadRichScrnObj for " + aPhoneNumber);
+ }
+ mRichScreenApi.downloadRichScrnObj(aPhoneNumber,
+ UPDATE_ENHANCE_SCREEN_PHONE_EVENT);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return;
+ }
}
- }
- return false;
+ });
+ t.start();
}
}
diff --git a/src/com/android/contacts/common/vcard/NotificationImportExportListener.java b/src/com/android/contacts/common/vcard/NotificationImportExportListener.java
index 7117f9f5..7e04ae3f 100644
--- a/src/com/android/contacts/common/vcard/NotificationImportExportListener.java
+++ b/src/com/android/contacts/common/vcard/NotificationImportExportListener.java
@@ -30,6 +30,7 @@ import android.provider.ContactsContract.RawContacts;
import android.widget.Toast;
import com.android.contacts.common.R;
+import com.android.contacts.common.util.ContactsCommonRcsUtil;
import com.android.vcard.VCardEntry;
public class NotificationImportExportListener implements VCardImportExportListener,
@@ -130,6 +131,9 @@ public class NotificationImportExportListener implements VCardImportExportListen
VCardService.TYPE_IMPORT, description, null, intent);
mNotificationManager.notify(NotificationImportExportListener.DEFAULT_NOTIFICATION_TAG,
jobId, notification);
+ if (ContactsCommonRcsUtil.getIsRcs()) {
+ ContactsCommonRcsUtil.updateAllEnhanceScreeen(mContext);
+ }
}
@Override