零距离 v1.0版本的 MD5 值为:250cd43fb2f0f5dc8d41b0026cf86adf
以下内容为反编译后的 ContactAccessorImpl.java 源代码,内容仅作参考
package io.dcloud.feature.contacts;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.net.Uri;
import android.os.RemoteException;
import android.provider.ContactsContract;
import android.util.Base64;
import android.util.Log;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.util.JSONUtil;
import io.dcloud.common.util.JSUtil;
import io.dcloud.feature.contacts.ContactAccessor;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class ContactAccessorImpl extends ContactAccessor {
private static final String EMAIL_REGEXP = ".+@.+\\.+.+";
private static final long MAX_PHOTO_SIZE = 1048576;
private static final String Tag = "contacts";
private static final Map<String, String> dbMap;
private String getAddressType(int i) {
return i != 1 ? i != 2 ? "other" : "work" : "home";
}
private String getContactType(int i) {
return i != 0 ? i != 1 ? i != 2 ? i != 4 ? "other" : "mobile" : "work" : "home" : "custom";
}
private String getOrgType(int i) {
return i != 0 ? i != 1 ? "other" : "work" : "custom";
}
private String getPhoneType(int i) {
switch (i) {
case 0:
return "custom";
case 1:
return "home";
case 2:
return "mobile";
case 3:
return "work";
case 4:
return "work fax";
case 5:
return "home fax";
case 6:
return "pager";
case 7:
case 12:
default:
return "other";
case 8:
return "callback";
case 9:
return "car";
case 10:
return "company main";
case 11:
return "isdn";
case 13:
return "other fax";
case 14:
return "radio";
case 15:
return "telex";
case 16:
return "tty tdd";
case 17:
return "work mobile";
case 18:
return "work pager";
case 19:
return "assistant";
case 20:
return "mms";
}
}
static {
HashMap hashMap = new HashMap();
dbMap = hashMap;
hashMap.put("id", "raw_contact_id");
hashMap.put("displayName", "display_name");
hashMap.put("name", "data1");
hashMap.put("name.formatted", "data1");
hashMap.put("name.familyName", "data3");
hashMap.put("name.givenName", "data2");
hashMap.put("name.middleName", "data5");
hashMap.put("name.honorificPrefix", "data4");
hashMap.put("name.honorificSuffix", "data6");
hashMap.put("nickname", "data1");
hashMap.put("phoneNumbers", "data1");
hashMap.put("phoneNumbers.value", "data1");
hashMap.put("emails", "data1");
hashMap.put("emails.value", "data1");
hashMap.put("addresses", "data1");
hashMap.put("addresses.formatted", "data1");
hashMap.put("addresses.streetAddress", "data4");
hashMap.put("addresses.locality", "data7");
hashMap.put("addresses.region", "data8");
hashMap.put("addresses.postalCode", "data9");
hashMap.put("addresses.country", "data10");
hashMap.put("ims", "data1");
hashMap.put("ims.value", "data1");
hashMap.put("organizations", "data1");
hashMap.put("organizations.name", "data1");
hashMap.put("organizations.department", "data5");
hashMap.put("organizations.title", "data4");
hashMap.put("birthday", "vnd.android.cursor.item/contact_event");
hashMap.put("note", "data1");
hashMap.put("photos.value", "vnd.android.cursor.item/photo");
hashMap.put("urls", "data1");
hashMap.put("urls.value", "data1");
}
public ContactAccessorImpl(Context context) {
this.mApp = context;
}
@Override
public JSONArray search(JSONArray jSONArray, JSONObject jSONObject) {
JSONArray jSONArray2;
String[] selectionArgs;
String str;
int i = Integer.MAX_VALUE;
boolean z = true;
if (jSONObject != null) {
jSONArray2 = JSONUtil.getJSONArray(jSONObject, "filter");
if (!jSONObject.optBoolean("multiple", true)) {
i = 1;
}
} else {
jSONArray2 = null;
}
if (jSONArray2 != null && jSONArray2.length() != 0 && (jSONArray2.length() != 1 || !jSONArray2.optJSONObject(0).isNull("field"))) {
z = false;
}
if (z) {
str = null;
selectionArgs = null;
} else {
ContactAccessor.WhereOptions buildWhereClause = buildWhereClause(jSONArray2);
String selection = buildWhereClause.getSelection();
selectionArgs = buildWhereClause.getSelectionArgs();
str = selection;
}
Cursor query = this.mApp.getContentResolver().query(ContactsContract.Data.CONTENT_URI, new String[]{"raw_contact_id"}, str, selectionArgs, "raw_contact_id ASC");
ArrayList<String> arrayList = new ArrayList<>();
while (query.moveToNext()) {
arrayList.add(query.getString(query.getColumnIndex("raw_contact_id")));
}
query.close();
if (arrayList.size() == 0) {
return new JSONArray();
}
ContactAccessor.WhereOptions buildIdClause = buildIdClause(arrayList);
return populateContactArray(i, buildPopulationSet(jSONArray), this.mApp.getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, buildIdClause.getSelection(), buildIdClause.getSelectionArgs(), "raw_contact_id ASC"));
}
private org.json.JSONArray populateContactArray(int r34, java.util.HashMap<java.lang.String, java.lang.Boolean> r35, android.database.Cursor r36) {
throw new UnsupportedOperationException("Method not decompiled: io.dcloud.feature.contacts.ContactAccessorImpl.populateContactArray(int, java.util.HashMap, android.database.Cursor):org.json.JSONArray");
}
private ContactAccessor.WhereOptions buildIdClause(ArrayList<String> arrayList) {
ContactAccessor.WhereOptions whereOptions = new ContactAccessor.WhereOptions();
Iterator<String> it = arrayList.iterator();
StringBuffer stringBuffer = new StringBuffer("(");
while (it.hasNext()) {
stringBuffer.append("'" + it.next() + "'");
if (it.hasNext()) {
stringBuffer.append(JSUtil.COMMA);
}
}
stringBuffer.append(")");
whereOptions.setSelection("raw_contact_id IN " + stringBuffer.toString());
whereOptions.setSelectionArgs(null);
return whereOptions;
}
private JSONObject populateContact(HashMap<String, Boolean> hashMap, JSONObject jSONObject, JSONArray jSONArray, JSONArray jSONArray2, JSONArray jSONArray3, JSONArray jSONArray4, JSONArray jSONArray5, JSONArray jSONArray6, JSONArray jSONArray7) {
try {
if (jSONArray3.length() > 0 || isRequired("phoneNumbers", hashMap)) {
jSONObject.put("phoneNumbers", jSONArray3);
}
if (jSONArray4.length() > 0 || isRequired("emails", hashMap)) {
jSONObject.put("emails", jSONArray4);
}
if (jSONArray2.length() > 0 || isRequired("addresses", hashMap)) {
jSONObject.put("addresses", jSONArray2);
}
if (jSONArray5.length() > 0 || isRequired("ims", hashMap)) {
jSONObject.put("ims", jSONArray5);
}
if (jSONArray.length() > 0 || isRequired("organizations", hashMap)) {
jSONObject.put("organizations", jSONArray);
}
if (jSONArray6.length() > 0 || isRequired("urls", hashMap)) {
jSONObject.put("urls", jSONArray6);
}
if (jSONArray7.length() > 0 || isRequired("photos", hashMap)) {
jSONObject.put("photos", jSONArray7);
}
} catch (JSONException e) {
Log.e("ContactsAccessor", "e.getMessage()==" + e.getMessage(), e);
}
return jSONObject;
}
private ContactAccessor.WhereOptions buildWhereClause(JSONArray jSONArray) {
int length;
ContactAccessor.WhereOptions whereOptions = new ContactAccessor.WhereOptions();
if (jSONArray != null && (length = jSONArray.length()) > 0) {
StringBuffer stringBuffer = new StringBuffer();
ArrayList arrayList = new ArrayList();
boolean z = false;
for (int i = 0; i < length; i++) {
JSONObject jSONObject = JSONUtil.getJSONObject(jSONArray, i);
String string = JSONUtil.getString(jSONObject, "field");
String formatLogic = formatLogic(JSONUtil.getString(jSONObject, "logic"));
String string2 = JSONUtil.getString(jSONObject, IApp.ConfigProperty.CONFIG_VALUE);
if (string != null) {
Map<String, String> map = dbMap;
if (map.containsKey(string) && string2 != null && !string2.equals("")) {
String replace = string2.replace('?', '_').replace('*', '%');
stringBuffer.append("(" + map.get(string) + " LIKE ? )");
if (i != length - 1) {
stringBuffer.append(" " + formatLogic + " ");
}
arrayList.add(replace);
z = true;
}
}
}
if (z) {
whereOptions.setSelection(stringBuffer.toString());
String[] strArr = new String[arrayList.size()];
arrayList.toArray(strArr);
whereOptions.setSelectionArgs(strArr);
}
}
return whereOptions;
}
private String formatLogic(String str) {
String lowerCase = str != null ? str.toLowerCase() : "or";
return (lowerCase.equals("not") || lowerCase.equals("and")) ? lowerCase : "or";
}
private boolean isSearchAll(JSONArray jSONArray) {
if (jSONArray.length() == 1) {
try {
if ("*".equals(jSONArray.getString(0))) {
return true;
}
} catch (JSONException unused) {
}
}
return false;
}
private JSONObject organizationQuery(Cursor cursor) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", cursor.getString(cursor.getColumnIndex("_id")));
jSONObject.put("pref", false);
jSONObject.put("type", getOrgType(cursor.getInt(cursor.getColumnIndex("data2"))));
jSONObject.put("department", cursor.getString(cursor.getColumnIndex("data5")));
jSONObject.put("name", cursor.getString(cursor.getColumnIndex("data1")));
jSONObject.put(AbsoluteConst.JSON_KEY_TITLE, cursor.getString(cursor.getColumnIndex("data4")));
} catch (JSONException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
}
return jSONObject;
}
private JSONObject addressQuery(Cursor cursor) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", cursor.getString(cursor.getColumnIndex("_id")));
jSONObject.put("pref", false);
jSONObject.put("type", getAddressType(cursor.getInt(cursor.getColumnIndex("data2"))));
jSONObject.put("formatted", cursor.getString(cursor.getColumnIndex("data1")));
jSONObject.put("streetAddress", cursor.getString(cursor.getColumnIndex("data4")));
jSONObject.put("locality", cursor.getString(cursor.getColumnIndex("data7")));
jSONObject.put("region", cursor.getString(cursor.getColumnIndex("data8")));
jSONObject.put("postalCode", cursor.getString(cursor.getColumnIndex("data9")));
jSONObject.put("country", cursor.getString(cursor.getColumnIndex("data10")));
} catch (JSONException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
}
return jSONObject;
}
private JSONObject nameQuery(Cursor cursor) {
JSONObject jSONObject = new JSONObject();
try {
String string = cursor.getString(cursor.getColumnIndex("data3"));
String string2 = cursor.getString(cursor.getColumnIndex("data2"));
String string3 = cursor.getString(cursor.getColumnIndex("data5"));
String string4 = cursor.getString(cursor.getColumnIndex("data4"));
String string5 = cursor.getString(cursor.getColumnIndex("data6"));
StringBuffer stringBuffer = new StringBuffer("");
if (string4 != null) {
stringBuffer.append(string4 + " ");
}
if (string2 != null) {
stringBuffer.append(string2 + " ");
}
if (string3 != null) {
stringBuffer.append(string3 + " ");
}
if (string != null) {
stringBuffer.append(string + " ");
}
if (string5 != null) {
stringBuffer.append(string5 + " ");
}
jSONObject.put("familyName", string);
jSONObject.put("givenName", string2);
jSONObject.put("middleName", string3);
jSONObject.put("honorificPrefix", string4);
jSONObject.put("honorificSuffix", string5);
jSONObject.put("formatted", stringBuffer);
} catch (JSONException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
}
return jSONObject;
}
private JSONObject phoneQuery(Cursor cursor) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", cursor.getString(cursor.getColumnIndex("_id")));
jSONObject.put("pref", false);
jSONObject.put(IApp.ConfigProperty.CONFIG_VALUE, cursor.getString(cursor.getColumnIndex("data1")));
jSONObject.put("type", getPhoneType(cursor.getInt(cursor.getColumnIndex("data2"))));
} catch (JSONException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
} catch (Exception e2) {
Log.e("ContactsAccessor", e2.getMessage(), e2);
}
return jSONObject;
}
private JSONObject emailQuery(Cursor cursor) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", cursor.getString(cursor.getColumnIndex("_id")));
jSONObject.put("pref", false);
jSONObject.put(IApp.ConfigProperty.CONFIG_VALUE, cursor.getString(cursor.getColumnIndex("data1")));
jSONObject.put("type", getContactType(cursor.getInt(cursor.getColumnIndex("data2"))));
} catch (JSONException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
}
return jSONObject;
}
private JSONObject imQuery(Cursor cursor) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", cursor.getString(cursor.getColumnIndex("_id")));
jSONObject.put("pref", false);
jSONObject.put(IApp.ConfigProperty.CONFIG_VALUE, cursor.getString(cursor.getColumnIndex("data1")));
jSONObject.put("type", getContactType(cursor.getInt(cursor.getColumnIndex("data2"))));
} catch (JSONException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
}
return jSONObject;
}
private JSONObject urlQuery(Cursor cursor) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", cursor.getString(cursor.getColumnIndex("_id")));
jSONObject.put("pref", false);
jSONObject.put(IApp.ConfigProperty.CONFIG_VALUE, cursor.getString(cursor.getColumnIndex("data1")));
jSONObject.put("type", getContactType(cursor.getInt(cursor.getColumnIndex("data2"))));
} catch (JSONException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
}
return jSONObject;
}
private JSONObject photoQuery(Cursor cursor, long j) {
byte[] bArr;
String str;
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", cursor.getString(cursor.getColumnIndex("_id")));
jSONObject.put("pref", false);
jSONObject.put("type", "url");
InputStream openContactPhotoInputStream = ContactsContract.Contacts.openContactPhotoInputStream(this.mApp.getContentResolver(), ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, j));
try {
openContactPhotoInputStream.read(new byte[openContactPhotoInputStream.available()]);
str = "data:image/png;base64," + Base64.encodeToString(bArr, 2);
} catch (Exception e) {
e.printStackTrace();
}
jSONObject.put(IApp.ConfigProperty.CONFIG_VALUE, str);
} catch (JSONException e2) {
Log.e("ContactsAccessor", e2.getMessage(), e2);
}
return jSONObject;
}
@Override
public boolean save(JSONObject jSONObject) {
Account[] accounts = AccountManager.get(this.mApp).getAccounts();
Account account = null;
if (accounts.length == 1) {
account = accounts[0];
} else if (accounts.length > 1) {
int length = accounts.length;
int i = 0;
while (true) {
if (i >= length) {
break;
}
Account account2 = accounts[i];
if (account2.type.contains("eas") && account2.name.matches(EMAIL_REGEXP)) {
account = account2;
break;
}
i++;
}
if (account == null) {
int length2 = accounts.length;
int i2 = 0;
while (true) {
if (i2 >= length2) {
break;
}
Account account3 = accounts[i2];
if (account3.type.contains("com.google") && account3.name.matches(EMAIL_REGEXP)) {
account = account3;
break;
}
i2++;
}
}
if (account == null) {
int length3 = accounts.length;
int i3 = 0;
while (true) {
if (i3 >= length3) {
break;
}
Account account4 = accounts[i3];
if (account4.name.matches(EMAIL_REGEXP)) {
account = account4;
break;
}
i3++;
}
}
if (account == null) {
account = accounts[0];
}
}
String jsonString = getJsonString(jSONObject, "id");
if (jsonString == null || "null".equals(jsonString)) {
return createNewContact(jSONObject, account);
}
return modifyContact(jSONObject, account, jsonString);
}
private void modifyContactOption(ArrayList<ContentProviderOperation> arrayList, JSONArray jSONArray, String str, String str2, String str3, String str4) {
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? and mimetype=?", new String[]{String.valueOf(str), str2}).build());
if (jSONArray != null) {
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject optJSONObject = jSONArray.optJSONObject(i);
if (optJSONObject != null) {
ContentValues contentValues = new ContentValues();
contentValues.put("raw_contact_id", str);
contentValues.put("mimetype", str2);
contentValues.put(str3, getJsonString(optJSONObject, IApp.ConfigProperty.CONFIG_VALUE));
contentValues.put(str4, Integer.valueOf(getContactType(getJsonString(optJSONObject, "type"))));
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValues(contentValues).build());
}
}
}
}
private boolean modifyContact(JSONObject jSONObject, Account account, String str) {
String str2;
String str3;
String str4;
String str5;
ContactAccessorImpl contactAccessorImpl;
String str6;
String str7;
String str8;
String str9;
JSONArray optJSONArray;
String str10;
byte[] photoBytes;
JSONArray optJSONArray2;
JSONArray jSONArray;
String str11;
String str12;
JSONArray optJSONArray3;
JSONArray jSONArray2;
String str13;
String jsonString;
JSONObject jSONObject2;
String str14 = "vnd.android.cursor.item/postal-address_v2";
String str15 = "vnd.android.cursor.item/photo";
String str16 = "vnd.android.cursor.item/organization";
String str17 = "type";
ArrayList<ContentProviderOperation> arrayList = new ArrayList<>();
if (account != null) {
str2 = "raw_contact_id=? and mimetype=?";
str3 = "raw_contact_id";
str4 = "mimetype";
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.RawContacts.CONTENT_URI).withValue("account_type", account.type).withValue("account_name", account.name).build());
} else {
str2 = "raw_contact_id=? and mimetype=?";
str3 = "raw_contact_id";
str4 = "mimetype";
}
try {
jsonString = getJsonString(jSONObject, "displayName");
jSONObject2 = jSONObject.getJSONObject("name");
str5 = "name";
} catch (JSONException unused) {
str5 = "name";
}
try {
ContentProviderOperation.Builder withSelection = ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/name"});
withSelection.withValue("data1", jsonString);
withSelection.withValue("data3", getJsonString(jSONObject2, "familyName"));
withSelection.withValue("data5", getJsonString(jSONObject2, "middleName"));
withSelection.withValue("data2", getJsonString(jSONObject2, "givenName"));
withSelection.withValue("data4", getJsonString(jSONObject2, "honorificPrefix"));
withSelection.withValue("data6", getJsonString(jSONObject2, "honorificSuffix"));
arrayList.add(withSelection.build());
} catch (JSONException unused2) {
Log.d("ContactsAccessor", "Could not get name");
String str18 = "data5";
String str19 = str2;
String str20 = "data1";
String str21 = str3;
String str22 = "data2";
String str23 = str4;
modifyContactOption(arrayList, jSONObject.optJSONArray("phoneNumbers"), str, "vnd.android.cursor.item/phone_v2", "data1", "data2");
modifyContactOption(arrayList, jSONObject.optJSONArray("emails"), str, "vnd.android.cursor.item/email_v2", "data1", "data2");
modifyContactOption(arrayList, jSONObject.optJSONArray("ims"), str, "vnd.android.cursor.item/im", "data1", "data2");
modifyContactOption(arrayList, jSONObject.optJSONArray("websites"), str, "vnd.android.cursor.item/website", "data1", "data2");
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str19, new String[]{String.valueOf(str), "vnd.android.cursor.item/postal-address_v2"}).build());
optJSONArray3 = jSONObject.optJSONArray("addresses");
if (optJSONArray3 != null) {
}
contactAccessorImpl = this;
str6 = str17;
str7 = str22;
str8 = str20;
str9 = "ContactsAccessor";
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str19, new String[]{String.valueOf(str), str16}).build());
optJSONArray2 = jSONObject.optJSONArray("organizations");
if (optJSONArray2 != null) {
}
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str19, new String[]{String.valueOf(str), str15}).build());
optJSONArray = jSONObject.optJSONArray("photos");
if (optJSONArray != null) {
}
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/note"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "note")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/nickname"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "nickname")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=? AND data2=?", new String[]{str, "vnd.android.cursor.item/contact_event", "3"}).withValue(str7, 3).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "birthday")).build());
contactAccessorImpl.mApp.getContentResolver().applyBatch("com.android.contacts", arrayList);
return true;
}
String str182 = "data5";
String str192 = str2;
String str202 = "data1";
String str212 = str3;
String str222 = "data2";
String str232 = str4;
modifyContactOption(arrayList, jSONObject.optJSONArray("phoneNumbers"), str, "vnd.android.cursor.item/phone_v2", "data1", "data2");
modifyContactOption(arrayList, jSONObject.optJSONArray("emails"), str, "vnd.android.cursor.item/email_v2", "data1", "data2");
modifyContactOption(arrayList, jSONObject.optJSONArray("ims"), str, "vnd.android.cursor.item/im", "data1", "data2");
modifyContactOption(arrayList, jSONObject.optJSONArray("websites"), str, "vnd.android.cursor.item/website", "data1", "data2");
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), "vnd.android.cursor.item/postal-address_v2"}).build());
optJSONArray3 = jSONObject.optJSONArray("addresses");
if (optJSONArray3 != null) {
int i = 0;
while (i < optJSONArray3.length()) {
JSONObject optJSONObject = optJSONArray3.optJSONObject(i);
if (optJSONObject != null) {
ContentValues contentValues = new ContentValues();
contentValues.put(str212, str);
contentValues.put(str232, str14);
contactAccessorImpl = this;
str6 = str17;
try {
str7 = str222;
} catch (Exception unused3) {
str7 = str222;
str8 = str202;
str9 = "ContactsAccessor";
Log.d(str9, "Could not get addresses");
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str16}).build());
optJSONArray2 = jSONObject.optJSONArray("organizations");
if (optJSONArray2 != null) {
}
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str15}).build());
optJSONArray = jSONObject.optJSONArray("photos");
if (optJSONArray != null) {
}
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/note"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "note")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/nickname"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "nickname")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=? AND data2=?", new String[]{str, "vnd.android.cursor.item/contact_event", "3"}).withValue(str7, 3).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "birthday")).build());
contactAccessorImpl.mApp.getContentResolver().applyBatch("com.android.contacts", arrayList);
return true;
}
try {
contentValues.put(str7, Integer.valueOf(contactAccessorImpl.getAddressType(contactAccessorImpl.getJsonString(optJSONObject, str6))));
jSONArray2 = optJSONArray3;
str8 = str202;
try {
contentValues.put(str8, contactAccessorImpl.getJsonString(optJSONObject, "formatted"));
contentValues.put("data4", contactAccessorImpl.getJsonString(optJSONObject, "streetAddress"));
str13 = str14;
contentValues.put("data7", contactAccessorImpl.getJsonString(optJSONObject, "locality"));
contentValues.put("data8", contactAccessorImpl.getJsonString(optJSONObject, "region"));
contentValues.put("data9", contactAccessorImpl.getJsonString(optJSONObject, "postalCode"));
contentValues.put("data10", contactAccessorImpl.getJsonString(optJSONObject, "country"));
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValues(contentValues).build());
} catch (Exception unused4) {
str9 = "ContactsAccessor";
Log.d(str9, "Could not get addresses");
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str16}).build());
optJSONArray2 = jSONObject.optJSONArray("organizations");
if (optJSONArray2 != null) {
}
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str15}).build());
optJSONArray = jSONObject.optJSONArray("photos");
if (optJSONArray != null) {
}
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/note"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "note")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/nickname"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "nickname")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=? AND data2=?", new String[]{str, "vnd.android.cursor.item/contact_event", "3"}).withValue(str7, 3).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "birthday")).build());
contactAccessorImpl.mApp.getContentResolver().applyBatch("com.android.contacts", arrayList);
return true;
}
} catch (Exception unused5) {
str8 = str202;
str9 = "ContactsAccessor";
Log.d(str9, "Could not get addresses");
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str16}).build());
optJSONArray2 = jSONObject.optJSONArray("organizations");
if (optJSONArray2 != null) {
}
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str15}).build());
optJSONArray = jSONObject.optJSONArray("photos");
if (optJSONArray != null) {
}
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/note"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "note")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/nickname"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "nickname")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=? AND data2=?", new String[]{str, "vnd.android.cursor.item/contact_event", "3"}).withValue(str7, 3).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "birthday")).build());
contactAccessorImpl.mApp.getContentResolver().applyBatch("com.android.contacts", arrayList);
return true;
}
} else {
jSONArray2 = optJSONArray3;
str6 = str17;
str7 = str222;
str8 = str202;
str13 = str14;
}
i++;
str202 = str8;
str17 = str6;
str14 = str13;
optJSONArray3 = jSONArray2;
str222 = str7;
}
}
contactAccessorImpl = this;
str6 = str17;
str7 = str222;
str8 = str202;
str9 = "ContactsAccessor";
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str16}).build());
optJSONArray2 = jSONObject.optJSONArray("organizations");
if (optJSONArray2 != null) {
int i2 = 0;
while (i2 < optJSONArray2.length()) {
JSONObject optJSONObject2 = optJSONArray2.optJSONObject(i2);
if (optJSONObject2 != null) {
ContentValues contentValues2 = new ContentValues();
contentValues2.put(str212, str);
jSONArray = optJSONArray2;
String str24 = str16;
contentValues2.put(str232, str24);
str16 = str24;
contentValues2.put(str7, Integer.valueOf(contactAccessorImpl.getOrgType(contactAccessorImpl.getJsonString(optJSONObject2, str6))));
str11 = str6;
String str25 = str182;
contentValues2.put(str25, contactAccessorImpl.getJsonString(optJSONObject2, "department"));
str182 = str25;
str12 = str5;
contentValues2.put(str8, contactAccessorImpl.getJsonString(optJSONObject2, str12));
contentValues2.put("data4", contactAccessorImpl.getJsonString(optJSONObject2, AbsoluteConst.JSON_KEY_TITLE));
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValues(contentValues2).build());
} else {
jSONArray = optJSONArray2;
str11 = str6;
str12 = str5;
}
i2++;
str5 = str12;
str6 = str11;
optJSONArray2 = jSONArray;
}
}
try {
arrayList.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(str192, new String[]{String.valueOf(str), str15}).build());
optJSONArray = jSONObject.optJSONArray("photos");
if (optJSONArray != null) {
int i3 = 0;
while (i3 < optJSONArray.length()) {
JSONObject optJSONObject3 = optJSONArray.optJSONObject(i3);
if (optJSONObject3 == null || (photoBytes = contactAccessorImpl.getPhotoBytes(contactAccessorImpl.getJsonString(optJSONObject3, IApp.ConfigProperty.CONFIG_VALUE))) == null) {
str10 = str15;
} else {
ContentValues contentValues3 = new ContentValues();
contentValues3.put(str212, str);
str10 = str15;
contentValues3.put(str232, str10);
contentValues3.put("is_super_primary", (Integer) 1);
contentValues3.put("data15", photoBytes);
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValues(contentValues3).build());
}
i3++;
str15 = str10;
}
}
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/note"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "note")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=?", new String[]{str, "vnd.android.cursor.item/nickname"}).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "nickname")).build());
arrayList.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).withSelection("raw_contact_id=? AND mimetype=? AND data2=?", new String[]{str, "vnd.android.cursor.item/contact_event", "3"}).withValue(str7, 3).withValue(str8, contactAccessorImpl.getJsonString(jSONObject, "birthday")).build());
} catch (Exception unused6) {
Log.d(str9, "Could not get photos");
}
try {
contactAccessorImpl.mApp.getContentResolver().applyBatch("com.android.contacts", arrayList);
return true;
} catch (OperationApplicationException e) {
Log.e(str9, e.getMessage(), e);
Log.e(str9, Log.getStackTraceString(e), e);
return false;
} catch (RemoteException e2) {
Log.e(str9, e2.getMessage(), e2);
Log.e(str9, Log.getStackTraceString(e2), e2);
return false;
}
}
private void insertWebsite(ArrayList<ContentProviderOperation> arrayList, JSONObject jSONObject) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/website").withValue("data1", getJsonString(jSONObject, IApp.ConfigProperty.CONFIG_VALUE)).withValue("data2", Integer.valueOf(getContactType(getJsonString(jSONObject, "type")))).build());
}
private void insertIm(ArrayList<ContentProviderOperation> arrayList, JSONObject jSONObject) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/im").withValue("data1", getJsonString(jSONObject, IApp.ConfigProperty.CONFIG_VALUE)).withValue("data2", Integer.valueOf(getContactType(getJsonString(jSONObject, "type")))).build());
}
private void insertOrganization(ArrayList<ContentProviderOperation> arrayList, JSONObject jSONObject) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/organization").withValue("data2", Integer.valueOf(getOrgType(getJsonString(jSONObject, "type")))).withValue("data5", getJsonString(jSONObject, "department")).withValue("data1", getJsonString(jSONObject, "name")).withValue("data4", getJsonString(jSONObject, AbsoluteConst.JSON_KEY_TITLE)).build());
}
private void insertAddress(ArrayList<ContentProviderOperation> arrayList, JSONObject jSONObject) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/postal-address_v2").withValue("data2", Integer.valueOf(getAddressType(getJsonString(jSONObject, "type")))).withValue("data1", getJsonString(jSONObject, "formatted")).withValue("data4", getJsonString(jSONObject, "streetAddress")).withValue("data7", getJsonString(jSONObject, "locality")).withValue("data8", getJsonString(jSONObject, "region")).withValue("data9", getJsonString(jSONObject, "postalCode")).withValue("data10", getJsonString(jSONObject, "country")).build());
}
private void insertEmail(ArrayList<ContentProviderOperation> arrayList, JSONObject jSONObject) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/email_v2").withValue("data1", getJsonString(jSONObject, IApp.ConfigProperty.CONFIG_VALUE)).withValue("data2", Integer.valueOf(getPhoneType(getJsonString(jSONObject, "type")))).build());
}
private void insertPhone(ArrayList<ContentProviderOperation> arrayList, JSONObject jSONObject) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/phone_v2").withValue("data1", getJsonString(jSONObject, IApp.ConfigProperty.CONFIG_VALUE)).withValue("data2", Integer.valueOf(getPhoneType(getJsonString(jSONObject, "type")))).build());
}
private void insertPhoto(ArrayList<ContentProviderOperation> arrayList, JSONObject jSONObject) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("is_super_primary", 1).withValue("mimetype", "vnd.android.cursor.item/photo").withValue("data15", getPhotoBytes(getJsonString(jSONObject, IApp.ConfigProperty.CONFIG_VALUE))).build());
}
private byte[] getPhotoBytes(String str) {
int indexOf = str.indexOf(";base64,");
if (indexOf > 0) {
String substring = str.substring(indexOf + 8);
if (DeviceInfo.sDeviceSdkVer >= 8) {
return Base64.decode(substring, 2);
}
return io.dcloud.common.util.Base64.decode2bytes(substring);
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
long j = 0;
try {
InputStream pathFromUri = getPathFromUri(str);
if (pathFromUri != null) {
byte[] bArr = new byte[8192];
while (true) {
int read = pathFromUri.read(bArr, 0, 8192);
if (read == -1 || j > 1048576) {
break;
}
byteArrayOutputStream.write(bArr, 0, read);
j += read;
}
pathFromUri.close();
byteArrayOutputStream.flush();
}
} catch (FileNotFoundException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
} catch (IOException e2) {
Log.e("ContactsAccessor", e2.getMessage(), e2);
}
return byteArrayOutputStream.toByteArray();
}
private InputStream getPathFromUri(String str) throws IOException {
if (str.startsWith("content:")) {
return this.mApp.getContentResolver().openInputStream(Uri.parse(str));
} else if (str.startsWith("http:") || str.startsWith("file:")) {
return new URL(str).openStream();
} else {
return this.mView.obtainFrameView().obtainApp().obtainResInStream(this.mView.obtainFullUrl(), str);
}
}
private boolean createNewContact(JSONObject jSONObject, Account account) {
ArrayList<ContentProviderOperation> arrayList = new ArrayList<>();
ArrayList arrayList2 = new ArrayList();
if (account != null) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI).withValue("account_type", account.type).withValue("account_name", account.name).build());
} else {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI).withValue("aggregation_mode", 3).build());
}
arrayList2.add(jSONObject);
JSONObject optJSONObject = jSONObject.optJSONObject("name");
String jsonString = getJsonString(jSONObject, "displayName");
if (jsonString != null || optJSONObject != null) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/name").withValue("data1", jsonString).withValue("data3", getJsonString(optJSONObject, "familyName")).withValue("data5", getJsonString(optJSONObject, "middleName")).withValue("data2", getJsonString(optJSONObject, "givenName")).withValue("data4", getJsonString(optJSONObject, "honorificPrefix")).withValue("data6", getJsonString(optJSONObject, "honorificSuffix")).build());
arrayList2.add(optJSONObject);
}
try {
JSONArray jSONArray = jSONObject.getJSONArray("phoneNumbers");
if (jSONArray != null) {
for (int i = 0; i < jSONArray.length(); i++) {
insertPhone(arrayList, (JSONObject) jSONArray.get(i));
}
}
} catch (JSONException unused) {
Log.d("ContactsAccessor", "Could not get phone numbers");
}
try {
JSONArray jSONArray2 = jSONObject.getJSONArray("emails");
if (jSONArray2 != null) {
for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
JSONObject jSONObject2 = (JSONObject) jSONArray2.get(i2);
insertEmail(arrayList, jSONObject2);
arrayList2.add(jSONObject2);
}
}
} catch (JSONException unused2) {
Log.d("ContactsAccessor", "Could not get emails");
}
try {
JSONArray jSONArray3 = jSONObject.getJSONArray("addresses");
if (jSONArray3 != null) {
for (int i3 = 0; i3 < jSONArray3.length(); i3++) {
JSONObject jSONObject3 = (JSONObject) jSONArray3.get(i3);
insertAddress(arrayList, jSONObject3);
arrayList2.add(jSONObject3);
}
}
} catch (JSONException unused3) {
Log.d("ContactsAccessor", "Could not get addresses");
}
try {
JSONArray jSONArray4 = jSONObject.getJSONArray("organizations");
if (jSONArray4 != null) {
for (int i4 = 0; i4 < jSONArray4.length(); i4++) {
JSONObject jSONObject4 = (JSONObject) jSONArray4.get(i4);
insertOrganization(arrayList, jSONObject4);
arrayList2.add(jSONObject4);
}
}
} catch (JSONException unused4) {
Log.d("ContactsAccessor", "Could not get organizations");
}
try {
JSONArray jSONArray5 = jSONObject.getJSONArray("ims");
if (jSONArray5 != null) {
for (int i5 = 0; i5 < jSONArray5.length(); i5++) {
JSONObject jSONObject5 = (JSONObject) jSONArray5.get(i5);
insertIm(arrayList, jSONObject5);
arrayList2.add(jSONObject5);
}
}
} catch (JSONException unused5) {
Log.d("ContactsAccessor", "Could not get emails");
}
try {
JSONArray jSONArray6 = jSONObject.getJSONArray("websites");
if (jSONArray6 != null) {
for (int i6 = 0; i6 < jSONArray6.length(); i6++) {
JSONObject jSONObject6 = (JSONObject) jSONArray6.get(i6);
insertWebsite(arrayList, jSONObject6);
arrayList2.add(jSONObject6);
}
}
} catch (JSONException unused6) {
Log.d("ContactsAccessor", "Could not get websites");
}
try {
JSONArray jSONArray7 = jSONObject.getJSONArray("photos");
if (jSONArray7 != null) {
for (int i7 = 0; i7 < jSONArray7.length(); i7++) {
JSONObject jSONObject7 = (JSONObject) jSONArray7.get(i7);
insertPhoto(arrayList, jSONObject7);
arrayList2.add(jSONObject7);
}
}
} catch (JSONException unused7) {
Log.d("ContactsAccessor", "Could not get photos");
}
String jsonString2 = getJsonString(jSONObject, "birthday");
if (jsonString2 != null) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/contact_event").withValue("data2", 3).withValue("data1", jsonString2).build());
}
String jsonString3 = getJsonString(jSONObject, "note");
if (jsonString3 != null) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/note").withValue("data1", jsonString3).build());
}
String jsonString4 = getJsonString(jSONObject, "nickname");
if (jsonString4 != null) {
arrayList.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/nickname").withValue("data1", jsonString4).build());
}
try {
ContentProviderResult[] applyBatch = this.mApp.getContentResolver().applyBatch("com.android.contacts", arrayList);
if (applyBatch.length >= 0) {
for (int i8 = 0; i8 < arrayList2.size(); i8++) {
String lastPathSegment = applyBatch[i8].uri.getLastPathSegment();
JSONObject jSONObject8 = (JSONObject) arrayList2.get(i8);
if (jSONObject8 != null) {
jSONObject8.put("id", lastPathSegment);
}
}
}
return true;
} catch (OperationApplicationException e) {
Log.e("ContactsAccessor", e.getMessage(), e);
return false;
} catch (RemoteException e2) {
Log.e("ContactsAccessor", e2.getMessage(), e2);
return false;
} catch (JSONException e3) {
Logger.e(e3.getMessage());
return false;
}
}
@Override
public boolean remove(String str) {
ArrayList<ContentProviderOperation> arrayList = new ArrayList<>();
arrayList.add(ContentProviderOperation.newDelete(ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI, Long.parseLong(str))).build());
try {
return this.mApp.getContentResolver().applyBatch("com.android.contacts", arrayList).length > 0;
} catch (Exception unused) {
return false;
}
}
private int getPhoneType(String str) {
if ("home".equals(str.toLowerCase())) {
return 1;
}
if ("mobile".equals(str.toLowerCase())) {
return 2;
}
if ("work".equals(str.toLowerCase())) {
return 3;
}
if ("work fax".equals(str.toLowerCase())) {
return 4;
}
if ("home fax".equals(str.toLowerCase())) {
return 5;
}
if ("fax".equals(str.toLowerCase())) {
return 4;
}
if ("pager".equals(str.toLowerCase())) {
return 6;
}
if ("other".equals(str.toLowerCase())) {
return 7;
}
if ("car".equals(str.toLowerCase())) {
return 9;
}
if ("company main".equals(str.toLowerCase())) {
return 10;
}
if ("isdn".equals(str.toLowerCase())) {
return 11;
}
if ("main".equals(str.toLowerCase())) {
return 12;
}
if ("other fax".equals(str.toLowerCase())) {
return 13;
}
if ("radio".equals(str.toLowerCase())) {
return 14;
}
if ("telex".equals(str.toLowerCase())) {
return 15;
}
if ("work mobile".equals(str.toLowerCase())) {
return 17;
}
if ("work pager".equals(str.toLowerCase())) {
return 18;
}
if ("assistant".equals(str.toLowerCase())) {
return 19;
}
if ("mms".equals(str.toLowerCase())) {
return 20;
}
if ("callback".equals(str.toLowerCase())) {
return 8;
}
if ("tty ttd".equals(str.toLowerCase())) {
return 16;
}
return "custom".equals(str.toLowerCase()) ? 0 : 7;
}
private int getContactType(String str) {
if (str != null) {
if ("home".equals(str.toLowerCase())) {
return 1;
}
if ("work".equals(str.toLowerCase())) {
return 2;
}
if ("other".equals(str.toLowerCase())) {
return 3;
}
if ("mobile".equals(str.toLowerCase())) {
return 4;
}
if ("custom".equals(str.toLowerCase())) {
return 0;
}
}
return 3;
}
private int getOrgType(String str) {
if (str != null) {
if ("work".equals(str.toLowerCase())) {
return 1;
}
if (!"other".equals(str.toLowerCase()) && "custom".equals(str.toLowerCase())) {
return 0;
}
}
return 2;
}
private int getAddressType(String str) {
if (str != null) {
if ("work".equals(str.toLowerCase())) {
return 2;
}
if (!"other".equals(str.toLowerCase()) && "home".equals(str.toLowerCase())) {
return 1;
}
}
return 3;
}
}