萝莉来了 v1.2.1版本的 MD5 值为:6055c21e001561c5b114d0da5b392fcb

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


package cn.cmgame.sdk.network;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import cn.cmgame.sdk.e.h;
import java.util.ArrayList;

public class a {
    private static final String PORT = "80";
    public static final String TAG = "APNSetting";
    public static final String eb = "cmwap";
    public static final String ec = "cmnet";
    public static final String ed = "none";
    public static final String ee = "apn_id";
    public static final String ef = "CMCC_CMWAP";
    private static final String eg = "460";
    private static final String eh = "00";
    private static final String ei = "02";
    private static final String ej = "07";
    private static final String ek = "10.0.0.172";
    private static final String el = "default";
    private static String em = null;
    private static final Uri en = Uri.parse("content://telephony/carriers");
    private static final Uri eo = Uri.parse("content://telephony/carriers/preferapn");
    private static int ep = 0;

    public static int f(Context context) {
        int i;
        h.m("Network", "create a new apn:cmcc_cmwap");
        String g = g(context);
        ContentValues contentValues = new ContentValues();
        contentValues.put("name", ef);
        contentValues.put("numeric", String.valueOf(P(g)) + Q(g));
        contentValues.put("mcc", P(g));
        contentValues.put("mnc", Q(g));
        contentValues.put("apn", "cmwap");
        contentValues.put("proxy", "10.0.0.172");
        contentValues.put("port", PORT);
        contentValues.put("type", el);
        contentValues.put("current", "1");
        try {
            Uri insert = context.getContentResolver().insert(en, contentValues);
            Cursor query = context.getContentResolver().query(insert, null, null, null, null);
            if (query == null) {
                i = 0;
            } else {
                query.moveToFirst();
                i = query.getInt(query.getColumnIndex("_id"));
                query.close();
            }
            h.m("Network", "CMCC_WAP.uri=" + insert + " and id=" + i);
            return i;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    private static String g(Context context) {
        return ((TelephonyManager) context.getSystemService("phone")).getSimOperator();
    }

    private static String P(String str) {
        if (str == null) {
            return null;
        }
        try {
            if ("".equals(str)) {
                return null;
            }
            return str.substring(0, 3);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private static String Q(String str) {
        if (str == null) {
            return null;
        }
        try {
            if ("".equals(str)) {
                return null;
            }
            return str.substring(3, 5);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static boolean h(Context context) {
        try {
            String g = g(context);
            if (!P(g).equals(eg)) {
                return false;
            }
            String Q = Q(g);
            if (!eh.equals(Q) && !ei.equals(Q)) {
                if (!ej.equals(Q)) {
                    return false;
                }
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static boolean c(Context context, String str) {
        String str2;
        boolean z;
        try {
            Cursor query = context.getContentResolver().query(en, null, null, null, null);
            String g = g(context);
            if (TextUtils.isEmpty(g)) {
                str2 = "";
            } else {
                str2 = Q(g);
            }
            while (query != null && query.moveToNext()) {
                String string = query.getString(query.getColumnIndex("name"));
                String string2 = query.getString(query.getColumnIndex("apn"));
                String string3 = query.getString(query.getColumnIndex("proxy"));
                String string4 = query.getString(query.getColumnIndex("port"));
                String string5 = query.getString(query.getColumnIndex("type"));
                boolean z2 = "cmwap".equals(string2) && "10.0.0.172".equals(string3) && PORT.equals(string4) && "1".equals(query.getString(query.getColumnIndex("current"))) && eg.equalsIgnoreCase(query.getString(query.getColumnIndex("mcc"))) && str2 != null && str2.equals(query.getString(query.getColumnIndex("mnc"))) && string5 != null && string5.indexOf(el) != -1;
                if (!TextUtils.isEmpty(str)) {
                    z2 = str.equalsIgnoreCase(string) && z2;
                }
                if (z2) {
                    z = true;
                    break;
                }
            }
            z = false;
            if (query != null) {
                query.close();
            }
            return z;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static ArrayList<Integer> d(Context context, String str) {
        String str2;
        ArrayList<Integer> arrayList = new ArrayList<>();
        Cursor query = context.getContentResolver().query(en, null, "mcc = '460'", null, null);
        String g = g(context);
        if (TextUtils.isEmpty(g)) {
            str2 = "";
        } else {
            str2 = Q(g);
        }
        while (query != null && query.moveToNext()) {
            String string = query.getString(query.getColumnIndex("port"));
            String string2 = query.getString(query.getColumnIndex("type"));
            String string3 = query.getString(query.getColumnIndex("name"));
            boolean z = "cmwap".equals(query.getString(query.getColumnIndex("apn"))) && PORT.equals(string) && string2 != null && string2.indexOf(el) != -1 && "1".equals(query.getString(query.getColumnIndex("current"))) && str2 != null && str2.equals(query.getString(query.getColumnIndex("mnc")));
            if (!TextUtils.isEmpty(str)) {
                z = ef.equalsIgnoreCase(string3) && z;
            }
            if (z) {
                arrayList.add(Integer.valueOf(query.getInt(query.getColumnIndex("_id"))));
            }
        }
        if (query != null) {
            query.close();
        }
        return arrayList;
    }

    public static int i(Context context) {
        Cursor query = context.getContentResolver().query(eo, null, null, null, null);
        if (query != null && query.moveToNext()) {
            int i = query.getInt(query.getColumnIndex("_id"));
            query.close();
            return i;
        }
        if (query != null) {
            query.close();
        }
        return 0;
    }

    public static boolean j(Context context) {
        try {
            ArrayList<Integer> d = d(context, null);
            int i = i(context);
            if (i != 0 && d != null) {
                for (int i2 = 0; i2 < d.size(); i2++) {
                    if (d.get(i2).intValue() == i) {
                        return true;
                    }
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public static boolean k(Context context) {
        Cursor query = context.getContentResolver().query(en, null, " name='CMCC_CMWAP' ", null, null);
        boolean z = false;
        if (query != null && query.moveToFirst()) {
            z = true;
            query.close();
        }
        h.m("Network", " is exist apn: cmcc cmwap ? " + z);
        return z;
    }

    public static void l(Context context) {
        ep = 0;
        if (cn.cmgame.billing.api.a.bV()) {
            ((WifiManager) context.getSystemService("wifi")).setWifiEnabled(true);
        }
        h.a("Network", "restoreApn and the old apn " + em, true);
        if (TextUtils.isEmpty(em) || "cmwap".equals(em)) {
            em = null;
        } else {
            g(context, em);
            em = null;
        }
    }

    public static boolean m(Context context) {
        ep++;
        if (ep > 1) {
            return true;
        }
        em = h.w(context);
        h.a("Network", "setCmwapApn and the old apn " + em, true);
        if ("cmwap".equalsIgnoreCase(em)) {
            return true;
        }
        if (TextUtils.isEmpty(em) || em.contains("none")) {
            em = "cmnet";
        }
        if (!h(context)) {
            return false;
        }
        if (!c(context, ef)) {
            return a(f(context), context);
        }
        boolean a = a(f(context, "cmwap"), context);
        h.m("Network", "Try to connect cmcc_cmwap apn... and result is " + a);
        return a;
    }

    private static int e(Context context, String str) {
        Cursor cursor;
        try {
            cursor = context.getContentResolver().query(en, null, "apn = ? and current = 1", new String[]{str.toLowerCase()}, null);
            if (cursor != null) {
                try {
                    if (cursor.moveToFirst()) {
                        int i = cursor.getInt(cursor.getColumnIndex("_id"));
                        if (cursor != null) {
                            cursor.close();
                            return i;
                        }
                        return i;
                    }
                } catch (Throwable th) {
                    th = th;
                    if (cursor != null) {
                        cursor.close();
                    }
                    throw th;
                }
            }
            if (cursor != null) {
                cursor.close();
            }
            return -1;
        } catch (Throwable th2) {
            th = th2;
            cursor = null;
        }
    }

    private static int f(Context context, String str) {
        Cursor cursor;
        try {
            cursor = context.getContentResolver().query(en, null, "name=? and apn = ? ", new String[]{ef, str.toLowerCase()}, null);
            if (cursor != null) {
                try {
                    if (cursor.moveToFirst()) {
                        int i = cursor.getInt(cursor.getColumnIndex("_id"));
                        if (cursor != null) {
                            cursor.close();
                            return i;
                        }
                        return i;
                    }
                } catch (Throwable th) {
                    th = th;
                    if (cursor != null) {
                        cursor.close();
                    }
                    throw th;
                }
            }
            if (cursor != null) {
                cursor.close();
            }
            return -1;
        } catch (Throwable th2) {
            th = th2;
            cursor = null;
        }
    }

    public static boolean a(int i, Context context) {
        try {
            ContentValues contentValues = new ContentValues();
            contentValues.put(ee, Integer.valueOf(i));
            return context.getContentResolver().update(eo, contentValues, null, null) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static int g(Context context, String str) {
        int i = -1;
        try {
            int f = "cmwap".equals(str) ? f(context, str) : e(context, str);
            h.m("Network", "Update current apn, new apn=" + str + " and apnId=" + f);
            if (f > -1) {
                ContentValues contentValues = new ContentValues();
                contentValues.put(ee, Integer.valueOf(f));
                i = context.getContentResolver().update(eo, contentValues, null, null);
                return i;
            }
            return 0;
        } catch (SQLException e) {
            e.printStackTrace();
            return i;
        }
    }

    public static void R(String str) {
        em = str;
    }

    public static String bz() {
        return em;
    }
}