和通讯录 v3.9.6版本的 MD5 值为:669178e2ee1b2311daf378bd20c6bbe1

以下内容为反编译后的 CommonTools.java 源代码,内容仅作参考


package com.chinamobile.contacts.im.mms2.utils;

import android.annotation.TargetApi;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.provider.Telephony;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.widget.Toast;
import com.android.internal.telephony.PhoneConstants;
import com.chinamobile.contacts.im.App;
import com.chinamobile.contacts.im.config.j;
import com.chinamobile.contacts.im.data.simcard.MultiSimCardAccessor;
import com.chinamobile.contacts.im.data.simcard.ReflectHelper;
import com.chinamobile.contacts.im.mms2.data.Conversation;
import com.chinamobile.contacts.im.mms2.data.MessageList;
import com.chinamobile.contacts.im.mms2.data.RecipientIdCache;
import com.chinamobile.contacts.im.mms2.g.d;
import com.chinamobile.contacts.im.mms2.g.f;
import com.chinamobile.contacts.im.mms2.g.g;
import com.chinamobile.contacts.im.mms2.g.h;
import com.chinamobile.contacts.im.mms2.g.o;
import com.chinamobile.contacts.im.mms2.model.SmsMessage;
import com.chinamobile.contacts.im.mms2.view.ConversationListItem;
import com.chinamobile.contacts.im.ui.ICloudActivity;
import com.chinamobile.contacts.im.utils.ApplicationUtils;
import com.chinamobile.contacts.im.utils.aq;
import com.chinamobile.contacts.im.utils.bb;
import com.chinamobile.contacts.im.view.BaseToast;
import com.cmcc.sso.sdk.util.SsoSdkConstants;
import com.google.android.mms.pdu.EncodedStringValue;
import com.google.android.mms.pdu.GenericPdu;
import com.google.android.mms.pdu.PduBody;
import com.google.android.mms.pdu.PduPart;
import com.google.android.mms.pdu.PduPersister;
import com.google.android.mms.util.SqliteWrapper;
import com.huawei.mcs.base.constant.Constant;
import com.huawei.mcs.cloud.msg.base.mms.Telephony;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;

@TargetApi(19)
public class CommonTools {
    private static CommonTools instance;
    private static long lastTime;
    private static String sLocalNumber;
    private Handler mHandler;
    private String TAG = "CommonTools";
    private volatile StringBuffer threads = new StringBuffer();
    private volatile StringBuffer msgIds = new StringBuffer();
    private volatile ArrayList<Long> mCollection = new ArrayList<>();
    private final String[] MMS_POP = {"全部信息", "未读信息", "通讯录好友", "陌生人", "信息收藏", "拦截信息"};
    private volatile boolean createMmsFrist = false;
    private volatile boolean firstComposeMessage = false;
    private HashMap<Long, Integer> allunRead = new HashMap<>();
    private int all139Unread = -1;
    private int allNotificationUnread = -1;
    private List<Long> all139UnreadList = new ArrayList();
    private List<Long> allNotificationUnreadList = new ArrayList();

    private CommonTools() {
    }

    public static synchronized CommonTools getInstance() {
        CommonTools commonTools;
        synchronized (CommonTools.class) {
            if (instance == null) {
                instance = new CommonTools();
            }
            commonTools = instance;
        }
        return commonTools;
    }

    public boolean isFirstComposeMessage() {
        return this.firstComposeMessage;
    }

    public void setFirstComposeMessage(boolean z) {
        this.firstComposeMessage = z;
    }

    public boolean isSDIsVia() {
        return Environment.getExternalStorageState().equals("mounted");
    }

    public int createOrUpdateMmsApnConfig(Context context) {
        Cursor query = SqliteWrapper.query(context, context.getContentResolver(), d.f2711a, null, null, null, null);
        while (query != null && query.moveToNext()) {
            if (query.getInt(query.getColumnIndex(Telephony.Carriers.CURRENT)) != 0 && query.getString(query.getColumnIndex("type")).equals("mms")) {
                for (int i = 0; i < query.getColumnNames().length; i++) {
                    aq.a(this.TAG, query.getColumnNames()[i] + ":" + query.getString(query.getColumnIndex(query.getColumnNames()[i])));
                }
                aq.a(this.TAG, "-----------------------------");
                return 1;
            }
        }
        query.close();
        setSystemApnConfig(context);
        return 0;
    }

    public void setSystemApnConfig(Context context) {
        context.getContentResolver().insert(d.f2711a, getApnValues());
    }

    public ContentValues getApnValues() {
        ContentValues contentValues = new ContentValues();
        contentValues.put("name", "中国移动彩信");
        contentValues.put("apn", "cmwap");
        contentValues.put(Telephony.Carriers.MMSPROXY, "10.0.0.172");
        contentValues.put(Telephony.Carriers.MMSPORT, "80");
        contentValues.put(Telephony.Carriers.MMSC, "http://mmsc.monternet.com");
        contentValues.put("type", "mms");
        contentValues.put(Telephony.Carriers.MCC, "460");
        contentValues.put(Telephony.Carriers.MNC, "00");
        contentValues.put(Telephony.Carriers.NUMERIC, "46000");
        return contentValues;
    }

    public static String getLocalNumber() {
        if (sLocalNumber == null) {
            sLocalNumber = App.a().f().getLine1Number();
        }
        return sLocalNumber;
    }

    public static boolean isLocalNumber(String str) {
        if (str != null && str.indexOf(64) < 0) {
            return bb.a(str, getLocalNumber());
        }
        return false;
    }

    private boolean isSpecialChar(char c) {
        return c == '*' || c == '%' || c == '$';
    }

    public boolean isRightType(ArrayList<String> arrayList, String str) {
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            String str2 = arrayList.get(i);
            if (str.equals(str2.substring(str2.lastIndexOf(Constant.FilePath.IDND_PATH) + 1, str2.length()))) {
                return true;
            }
        }
        return false;
    }

    public boolean getUpdatePart(PduPersister pduPersister, Object[] objArr) {
        try {
            Method declaredMethod = PduPersister.class.getDeclaredMethod("updateParts", Uri.class, PduBody.class, HashMap.class);
            declaredMethod.setAccessible(true);
            declaredMethod.invoke(pduPersister, objArr);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public Uri getPart(PduPersister pduPersister, Object[] objArr) {
        try {
            Method declaredMethod = PduPersister.class.getDeclaredMethod("persistPart", PduPart.class, Long.TYPE, HashMap.class);
            declaredMethod.setAccessible(true);
            return (Uri) declaredMethod.invoke(pduPersister, objArr);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Uri getUriMms(PduPersister pduPersister, Object[] objArr, Context context) {
        if (MultiSimCardAccessor.model.equals(MultiSimCardAccessor.MODEL_XIAOMI_NOTE_1S) || MultiSimCardAccessor.model.equals(MultiSimCardAccessor.MODEL_xiaomi_note2) || MultiSimCardAccessor.model.equals(MultiSimCardAccessor.MODEL_REDMI_NOTE3) || MultiSimCardAccessor.model.equals(MultiSimCardAccessor.MODEL_MI_NOTE_LTE)) {
            if (objArr != null && objArr[1].toString().endsWith("inbox")) {
                Object[] objArr2 = {objArr[0], h.f2716a, null, -1};
                try {
                    Class<?> cls = Class.forName("com.google.android.mms.pdu.MiuiPduPersister");
                    Object callStaticMethod = ReflectHelper.callStaticMethod(cls, "getPduPersister", (Class<?>[]) new Class[]{Context.class}, new Object[]{context});
                    Method declaredMethod = cls.getDeclaredMethod("persist", GenericPdu.class, Uri.class, Uri.class, Long.TYPE);
                    declaredMethod.setAccessible(true);
                    return (Uri) declaredMethod.invoke(callStaticMethod, objArr2);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                Object[] objArr3 = {objArr[0], g.f2715a, null, -1};
                try {
                    Class<?> cls2 = Class.forName("com.google.android.mms.pdu.MiuiPduPersister");
                    Object callStaticMethod2 = ReflectHelper.callStaticMethod(cls2, "getPduPersister", (Class<?>[]) new Class[]{Context.class}, new Object[]{context});
                    Method declaredMethod2 = cls2.getDeclaredMethod("persist", GenericPdu.class, Uri.class, Uri.class, Long.TYPE);
                    declaredMethod2.setAccessible(true);
                    return (Uri) declaredMethod2.invoke(callStaticMethod2, objArr3);
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        } else {
            try {
                Method declaredMethod3 = PduPersister.class.getDeclaredMethod("persist", GenericPdu.class, Uri.class, Boolean.TYPE, Boolean.TYPE, HashMap.class);
                declaredMethod3.setAccessible(true);
                return (Uri) declaredMethod3.invoke(pduPersister, objArr);
            } catch (Exception e3) {
                e3.printStackTrace();
            }
        }
        return null;
    }

    public boolean isSDK17() {
        String mobileModel = ApplicationUtils.getMobileModel();
        return (Build.VERSION.SDK_INT < 17 || mobileModel.equals("HS-T970") || mobileModel.equals("ZTE U988S") || mobileModel.equals("HS-T959") || mobileModel.equals("M701") || mobileModel.equals(MultiSimCardAccessor.MODEL_COOLPAD_8729D) || mobileModel.equals(MultiSimCardAccessor.MODEL_COOLPAD9190_T00)) ? false : true;
    }

    public int getSim(Context context) {
        String subscriberId = ((TelephonyManager) context.getSystemService(PhoneConstants.PHONE_KEY)).getSubscriberId();
        if (subscriberId != null) {
            if (subscriberId.startsWith("46000") || subscriberId.startsWith("46002")) {
                return 1;
            }
            if (subscriberId.startsWith("46001")) {
                return 2;
            }
            if (subscriberId.startsWith("46003")) {
                return 3;
            }
        }
        return 1;
    }

    public HashMap<Long, Integer> getAllUnRead() {
        return this.allunRead;
    }

    public int getAll139UnreadCount() {
        return this.all139Unread;
    }

    public int getAllNotificationUnreadCount() {
        return this.allNotificationUnread;
    }

    public List<Long> getAll139UnreadList() {
        return this.all139UnreadList;
    }

    public List<Long> getAllNotificationUnreadList() {
        return this.allNotificationUnreadList;
    }

    public void loadUnreadAll(Context context) {
        MultiSimCardAccessor.getInstance().loadUnRead(context, this.allunRead);
        loadAllNotificationUnReadCount(context);
        loadAll139UnReadCount(context);
    }

    private int loadAll139UnReadCount(Context context) {
        ArrayList<Long> arrayList = new ArrayList<>(RecipientIdCache.m139ThreadsList);
        this.all139Unread = loadAllUnReadCount(arrayList, context);
        synchronized (this.all139UnreadList) {
            this.all139UnreadList.clear();
            this.all139UnreadList.addAll(arrayList);
        }
        return this.all139Unread;
    }

    private int loadAllNotificationUnReadCount(Context context) {
        ArrayList<Long> arrayList = new ArrayList<>(RecipientIdCache.mNotificationThreadsList);
        this.allNotificationUnread = loadAllUnReadCount(arrayList, context);
        synchronized (this.allNotificationUnreadList) {
            this.allNotificationUnreadList.clear();
            this.allNotificationUnreadList.addAll(arrayList);
        }
        return this.allNotificationUnread;
    }

    public int loadAllUnReadCount(ArrayList<Long> arrayList, Context context) {
        Cursor cursor;
        Cursor cursor2;
        int i;
        int i2 = 0;
        Cursor cursor3 = null;
        synchronized (ConversationListItem.class) {
            try {
                StringBuffer stringBuffer = new StringBuffer();
                Iterator<Long> it = arrayList.iterator();
                while (it.hasNext()) {
                    stringBuffer.append(MultiSimCardAccessor.getInstance().getCommonThreadID(it.next().longValue()) + ",");
                }
                if (TextUtils.isEmpty(stringBuffer.toString())) {
                    stringBuffer.append("-1,");
                }
                arrayList.clear();
                cursor = context.getContentResolver().query(o.f2724a, new String[]{"_id", "thread_id"}, "read=0 and thread_id in(" + stringBuffer.toString().substring(0, stringBuffer.length() - 1) + ")", null, null);
                if (cursor != null) {
                    try {
                        try {
                            int count = cursor.getCount() + 0;
                            try {
                            } catch (Exception e) {
                                i = count;
                                cursor2 = null;
                                cursor3 = cursor;
                                if (cursor3 != null) {
                                    cursor3.close();
                                }
                                if (cursor2 != null) {
                                    cursor2.close();
                                }
                                return i;
                            }
                        } catch (Exception e2) {
                            cursor2 = null;
                            i = i2;
                            cursor3 = cursor;
                        }
                    } catch (Throwable th) {
                        th = th;
                        if (cursor != null) {
                        }
                        if (cursor3 != null) {
                        }
                        throw th;
                    }
                }
                cursor2 = context.getContentResolver().query(f.f2713a, new String[]{"_id", "thread_id"}, "read=0 and thread_id in(" + stringBuffer.toString().substring(0, stringBuffer.length() - 1) + ")", null, null);
                if (cursor2 != null) {
                    try {
                        try {
                            i = cursor2.getCount() + i2;
                            try {
                            } catch (Exception e3) {
                                cursor3 = cursor;
                                if (cursor3 != null) {
                                }
                                if (cursor2 != null) {
                                }
                                return i;
                            }
                        } catch (Throwable th2) {
                            cursor3 = cursor2;
                            th = th2;
                            if (cursor != null) {
                                cursor.close();
                            }
                            if (cursor3 != null) {
                                cursor3.close();
                            }
                            throw th;
                        }
                    } catch (Exception e4) {
                        cursor3 = cursor;
                        i = i2;
                    }
                } else {
                    i = i2;
                }
                if (cursor != null) {
                    cursor.close();
                }
                if (cursor2 != null) {
                    cursor2.close();
                }
            } catch (Exception e5) {
                cursor2 = null;
                i = 0;
            } catch (Throwable th3) {
                th = th3;
                cursor = null;
            }
        }
        return i;
    }

    public String moveSpace(String str) {
        return str.replaceAll(" ", "");
    }

    public String moveFxNum(String str) {
        return bb.e(moveSpace(str));
    }

    public boolean isFastTime(long j) {
        long currentTimeMillis = System.currentTimeMillis();
        long j2 = currentTimeMillis - lastTime;
        if (0 <= j2 && j2 <= j) {
            return true;
        }
        lastTime = currentTimeMillis;
        return false;
    }

    public void refreshMmsData(boolean z, Context context) {
        this.mHandler = createHandler(this.mHandler);
        if (z) {
        }
        String mobileModel = ApplicationUtils.getMobileModel();
        if (mobileModel.equals("K-Touch S5t") || mobileModel.equals("ZTE U889") || mobileModel.equals("K-Touch T91")) {
        }
    }

    public Handler createHandler(Handler handler) {
        Handler handler2;
        if (handler == null) {
            if (Looper.myLooper() == null) {
                handler2 = new Handler(Looper.getMainLooper());
            } else {
                handler2 = new Handler();
            }
            return handler2;
        }
        return handler;
    }

    public boolean isGarbled(String str) {
        char[] charArray = str.toCharArray();
        int i = 0;
        for (char c : charArray) {
            if (c == '?') {
                i++;
            }
        }
        if (i > charArray.length * 0) {
            return true;
        }
        try {
            byte[] bytes = str.getBytes("iso8859-1");
            int i2 = 0;
            int i3 = 0;
            for (byte b2 : bytes) {
                if (b2 == 63) {
                    return false;
                }
                if (b2 >= 0) {
                    i2++;
                } else if (b2 < 0) {
                    i3++;
                }
            }
            if (i2 == bytes.length) {
                return false;
            }
        } catch (UnsupportedEncodingException e) {
            aq.b(this.TAG, e.getMessage());
        }
        return true;
    }

    public String getStringOfGarbled(String str, int i) {
        if (isGarbled(str) && i >= 0) {
            try {
                return getStringOfGarbled(new String(str.getBytes("iso8859-1"), "utf-8"), i - 1);
            } catch (UnsupportedEncodingException e) {
                return null;
            }
        }
        return str;
    }

    public static boolean isExistById(String str, Context context) {
        Cursor cursor;
        Cursor cursor2 = null;
        try {
            Cursor query = context.getContentResolver().query(Conversation.sAllThreadsUri, null, "recipient_ids='" + str + "'", null, null);
            try {
                if (query.getCount() > 0) {
                    ApplicationUtils.closeCursor(query);
                    return true;
                }
                ApplicationUtils.closeCursor(query);
                return false;
            } catch (Exception e) {
                cursor = query;
                ApplicationUtils.closeCursor(cursor);
                return false;
            } catch (Throwable th) {
                th = th;
                cursor2 = query;
                ApplicationUtils.closeCursor(cursor2);
                throw th;
            }
        } catch (Exception e2) {
            cursor = null;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public MessageList getSearchResultSet(Context context, String str) {
        String substring;
        Cursor cursor;
        MessageList messageList = new MessageList();
        synchronized (this.threads) {
            if (this.threads.length() == 0) {
                this.threads.append("-1,");
            }
            substring = this.threads.toString().substring(0, this.threads.length() - 1);
        }
        ?? searchContact = Conversation.searchContact(str);
        messageList.addAll(searchContact);
        try {
            try {
                cursor = context.getContentResolver().query(o.f2724a, new String[]{"_id", "address", "date", "read", "thread_id", "body"}, "type<>? and thread_id<>? and body like ?  and thread_id in(" + substring + ")", new String[]{SsoSdkConstants.BUSI_TYPE_SMSLOGIN, "0", "%" + str + "%"}, "date desc --");
                while (cursor.moveToNext()) {
                    try {
                        SmsMessage smsMessage = new SmsMessage();
                        String string = cursor.getString(cursor.getColumnIndexOrThrow("address"));
                        String string2 = cursor.getString(cursor.getColumnIndexOrThrow("body"));
                        int i = cursor.getInt(cursor.getColumnIndexOrThrow("thread_id"));
                        int i2 = cursor.getInt(cursor.getColumnIndexOrThrow("read"));
                        Date date = new Date(cursor.getLong(cursor.getColumnIndexOrThrow("date")));
                        smsMessage.setId(cursor.getInt(cursor.getColumnIndexOrThrow("_id")));
                        smsMessage.setFrom(string);
                        smsMessage.setBody(string2);
                        smsMessage.setThreadId((int) MultiSimCardAccessor.getInstance().getRealThreadID(i));
                        smsMessage.setRead(i2);
                        smsMessage.setDate(date);
                        messageList.add(smsMessage);
                    } catch (Exception e) {
                        e = e;
                        aq.b(this.TAG, e.getMessage() + "");
                        ApplicationUtils.closeCursor(cursor);
                        return messageList;
                    }
                }
            } catch (Throwable th) {
                th = th;
                ApplicationUtils.closeCursor(searchContact);
                throw th;
            }
        } catch (Exception e2) {
            e = e2;
            cursor = null;
        } catch (Throwable th2) {
            th = th2;
            searchContact = 0;
            ApplicationUtils.closeCursor(searchContact);
            throw th;
        }
        ApplicationUtils.closeCursor(cursor);
        return messageList;
    }

    public MessageList getSearchResultSetByMsgID(Context context, String str) {
        Cursor cursor;
        MessageList messageList = new MessageList();
        if (this.msgIds.length() == 0) {
            this.msgIds.append("-1,");
        }
        ?? stringBuffer = this.msgIds.toString();
        ?? length = this.msgIds.length() - 1;
        try {
            try {
                cursor = context.getContentResolver().query(o.f2724a, new String[]{"_id", "address", "date", "read", "thread_id", "body from sms where type!=3 and thread_id!=0 and body like '%" + str + "%' and _id in(" + stringBuffer.substring(0, length) + ") order by date desc --"}, null, null, null);
                while (cursor.moveToNext()) {
                    try {
                        SmsMessage smsMessage = new SmsMessage();
                        String string = cursor.getString(cursor.getColumnIndexOrThrow("address"));
                        String string2 = cursor.getString(cursor.getColumnIndexOrThrow("body"));
                        int i = cursor.getInt(cursor.getColumnIndexOrThrow("thread_id"));
                        int i2 = cursor.getInt(cursor.getColumnIndexOrThrow("read"));
                        Date date = new Date(cursor.getLong(cursor.getColumnIndexOrThrow("date")));
                        smsMessage.setId(cursor.getInt(cursor.getColumnIndexOrThrow("_id")));
                        smsMessage.setFrom(string);
                        smsMessage.setBody(string2);
                        smsMessage.setThreadId(i);
                        smsMessage.setRead(i2);
                        smsMessage.setDate(date);
                        messageList.add(smsMessage);
                    } catch (Exception e) {
                        e = e;
                        aq.b(this.TAG, e.getMessage() + " ");
                        ApplicationUtils.closeCursor(cursor);
                        return messageList;
                    }
                }
            } catch (Throwable th) {
                th = th;
                ApplicationUtils.closeCursor(length);
                throw th;
            }
        } catch (Exception e2) {
            e = e2;
            cursor = null;
        } catch (Throwable th2) {
            th = th2;
            length = 0;
            ApplicationUtils.closeCursor(length);
            throw th;
        }
        ApplicationUtils.closeCursor(cursor);
        return messageList;
    }

    public void putMmsThreads(Set<Long> set) {
        synchronized (this.threads) {
            this.threads.setLength(0);
            Iterator<Long> it = set.iterator();
            while (it.hasNext()) {
                this.threads.append(MultiSimCardAccessor.getInstance().getCommonThreadID(it.next().longValue()) + ",");
            }
        }
    }

    public void putMsgId(int i) {
        synchronized (this.msgIds) {
            this.msgIds.append(i + ",");
        }
    }

    public void clearMsgId() {
        synchronized (this.msgIds) {
            this.msgIds.setLength(0);
        }
    }

    public ArrayList<Long> getCollection() {
        ArrayList<Long> arrayList;
        synchronized (this.mCollection) {
            arrayList = this.mCollection;
        }
        return arrayList;
    }

    public void putCollection(long j) {
        synchronized (this.mCollection) {
            if (!this.mCollection.contains(Long.valueOf(j))) {
                this.mCollection.add(Long.valueOf(j));
            }
        }
    }

    public void clearCollection() {
        synchronized (this.mCollection) {
            this.mCollection.clear();
        }
    }

    public void Toast(Context context, String str) {
        BaseToast.makeText(context, str, 1).show();
    }

    public String[] getMmsGroups() {
        return this.MMS_POP;
    }

    public void setCreateMmsState(boolean z) {
        this.createMmsFrist = z;
    }

    public boolean getCreateMmsState() {
        return this.createMmsFrist;
    }

    public Bitmap createVideoThumbnail(Context context, Uri uri) {
        try {
            return MediaStore.Video.Thumbnails.getThumbnail(context.getContentResolver(), ContentUris.parseId(uri), 1, null);
        } catch (Exception e) {
            e.printStackTrace();
            aq.a(this.TAG, "OH,no,can't createVideoThumbnail.please check here!!~~~~");
            return null;
        }
    }

    public void destoryIcloudActionMode(Context context) {
        if (context instanceof ICloudActivity) {
            ((ICloudActivity) context).destoryIcloudActionMode();
        }
    }

    public boolean isCursorValid(Cursor cursor) {
        return (cursor.isClosed() || cursor.isBeforeFirst() || cursor.isAfterLast()) ? false : true;
    }

    public String isFilter(String str) {
        return Pattern.compile("^((\\+86)|(12520))").matcher(str).replaceAll("");
    }

    public void setDefaultApp(Context context) {
        String packageName = context.getPackageName();
        Intent intent = new Intent("android.provider.Telephony.ACTION_CHANGE_DEFAULT");
        intent.putExtra("package", packageName);
        intent.setFlags(268435456);
        context.startActivity(intent);
        if (!com.chinamobile.contacts.im.config.h.f1787a && !j.h(context)) {
            j.d(context, true);
            j.c(context, true);
        }
    }

    @TargetApi(19)
    public boolean isDefaultApp(Context context) {
        int systemVersion = ApplicationUtils.getSystemVersion();
        if (systemVersion < 19) {
            return true;
        }
        if (ApplicationUtils.getMobileManufacturer().equalsIgnoreCase("meizu") && systemVersion < 21) {
            return true;
        }
        String defaultSmsPackage = Telephony.Sms.getDefaultSmsPackage(context);
        return defaultSmsPackage != null && defaultSmsPackage.equals(context.getPackageName());
    }

    public static boolean isHtc44Vesion(Context context) {
        if (!MultiSimCardAccessor.MODEL_HTC_E9t.equals(Build.MODEL) && !MultiSimCardAccessor.MODEL_HTC_E9pt.equals(Build.MODEL) && !MultiSimCardAccessor.MODEL_HTC_M9et.equals(Build.MODEL) && !MultiSimCardAccessor.MODEL_HTCD820U_UNKNOW.equals(Build.MODEL) && !MultiSimCardAccessor.MODEL_HTC_D826T.equals(Build.MODEL)) {
            return false;
        }
        Toast.makeText(context, "此机型暂不支持收发彩信!", 1).show();
        return true;
    }

    public boolean isMultipleCard() {
        return MultiSimCardAccessor.getInstance().getSimCardOneStatus() && MultiSimCardAccessor.getInstance().getSimCardTwoStatus();
    }

    public void setSimCardForMsg(ContentValues contentValues) {
        contentValues.put("sim_id", Integer.valueOf(MultiSimCardAccessor.getInstance().getCurrentSimStatus()));
    }

    public EncodedStringValue[] getPduTo(Uri uri, Context context) {
        Cursor cursor;
        Cursor cursor2;
        EncodedStringValue[] encodeStrings;
        Cursor cursor3 = null;
        try {
            try {
                cursor = context.getContentResolver().query(f.f2713a, new String[]{"thread_id"}, "_id=" + ContentUris.parseId(uri), null, null);
                if (cursor != null) {
                    try {
                        if (cursor.moveToFirst()) {
                            encodeStrings = EncodedStringValue.encodeStrings(Conversation.get(context, cursor.getLong(0), true).getRecipients().getNumbers(true));
                            ApplicationUtils.closeCursor(cursor);
                            return encodeStrings;
                        }
                    } catch (Throwable th) {
                        th = th;
                        aq.a(this.TAG, th.toString());
                        ApplicationUtils.closeCursor(cursor);
                        return null;
                    }
                }
                encodeStrings = null;
                ApplicationUtils.closeCursor(cursor);
                return encodeStrings;
            } catch (Throwable th2) {
                th = th2;
                cursor3 = cursor2;
                ApplicationUtils.closeCursor(cursor3);
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
            cursor = null;
        }
    }
}