智能工厂.apk(点击下载) / e.java


package cn.jiguang.u;

import android.annotation.SuppressLint;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import cn.jiguang.o.d;
import cn.jiguang.t.b;
import cn.jiguang.v.a;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;

@SuppressLint({"MissingPermission"})
public class e {
    public static final byte[] a = {113, 116, 68, 115, 108, 106, 101, 114, 66, 73, 123, 109, 100, 88, 84};
    private static int b;

    private static int a(int i) {
        try {
            Method declaredMethod = Class.forName("android.telephony.SubscriptionManager").getDeclaredMethod("getSubId", Integer.TYPE);
            declaredMethod.setAccessible(true);
            int[] iArr = (int[]) declaredMethod.invoke(null, Integer.valueOf(i));
            return iArr.length > 0 ? iArr[0] : i;
        } catch (Throwable unused) {
            return i;
        }
    }

    private static int a(TelephonyManager telephonyManager) {
        try {
            return ((Integer) telephonyManager.getClass().getMethod("getSimCount", new Class[0]).invoke(telephonyManager, new Object[0])).intValue();
        } catch (Throwable unused) {
            return -1;
        }
    }

    public static ArrayList<b> a(Context context) {
        if (d.a(context, false, "do not get sim info")) {
            return null;
        }
        int i = b;
        if ((i == 0 || i == 1) && a()) {
            b = 1;
            return b(context);
        }
        int i2 = b;
        if ((i2 == 0 || i2 == 2) && c(context)) {
            b = 2;
            return d(context);
        }
        int i3 = b;
        if ((i3 == 0 || i3 == 3) && e(context)) {
            b = 3;
            return f(context);
        }
        int i4 = b;
        if ((i4 == 0 || i4 == 4) && g(context)) {
            b = 4;
            return h(context);
        }
        b = 1;
        return b(context);
    }

    private static boolean a() {
        try {
            return TelephonyManager.class.getMethod("getSimCount", new Class[0]) != null;
        } catch (Throwable unused) {
            return false;
        }
    }

    private static ArrayList<b> b(Context context) {
        ArrayList<b> arrayList = new ArrayList<>();
        try {
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            int a2 = a(telephonyManager);
            if (a2 > 0) {
                try {
                    Method declaredMethod = telephonyManager.getClass().getDeclaredMethod("getImei", Integer.TYPE);
                    declaredMethod.setAccessible(true);
                    Method declaredMethod2 = telephonyManager.getClass().getDeclaredMethod("getSimSerialNumber", Integer.TYPE);
                    declaredMethod2.setAccessible(true);
                    Method declaredMethod3 = telephonyManager.getClass().getDeclaredMethod(a.b(a), Integer.TYPE);
                    declaredMethod3.setAccessible(true);
                    for (int i = 0; i < a2; i++) {
                        int a3 = a(i);
                        b bVar = new b();
                        try {
                            bVar.a = b.a((String) declaredMethod.invoke(telephonyManager, Integer.valueOf(i)));
                            bVar.c = (String) declaredMethod2.invoke(telephonyManager, Integer.valueOf(a3));
                            bVar.b = (String) declaredMethod3.invoke(telephonyManager, Integer.valueOf(a3));
                        } catch (Throwable unused) {
                        }
                        arrayList.add(bVar);
                    }
                } catch (Throwable unused2) {
                    arrayList.clear();
                }
            }
        } catch (Throwable unused3) {
            arrayList.clear();
        }
        return arrayList;
    }

    private static ArrayList<Integer> b(TelephonyManager telephonyManager) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        try {
            Field[] declaredFields = TelephonyManager.class.getDeclaredFields();
            int i = 0;
            for (Field field : declaredFields) {
                field.setAccessible(true);
                if (TextUtils.equals(field.getType().getName(), "com.android.internal.telephony.ITelephonyRegistry") && field.get(telephonyManager) != null) {
                    arrayList.add(Integer.valueOf(i));
                    i++;
                }
            }
        } catch (Throwable unused) {
            arrayList.clear();
            arrayList.add(0);
            arrayList.add(1);
        }
        return arrayList;
    }

    private static boolean c(Context context) {
        try {
            b((TelephonyManager) context.getSystemService("phone"));
            Method declaredMethod = TelephonyManager.class.getDeclaredMethod("getSubscriberIdGemini", Integer.TYPE);
            Method declaredMethod2 = TelephonyManager.class.getDeclaredMethod("getDeviceIdGemini", Integer.TYPE);
            Method declaredMethod3 = TelephonyManager.class.getDeclaredMethod("getPhoneTypeGemini", Integer.TYPE);
            Field declaredField = TelephonyManager.class.getDeclaredField("mtkGeminiSupport");
            if (!(declaredMethod == null || declaredMethod2 == null || declaredMethod3 == null || declaredField == null)) {
                declaredField.setAccessible(true);
                if (((Boolean) declaredField.get(null)).booleanValue()) {
                    return true;
                }
            }
        } catch (Throwable unused) {
        }
        return false;
    }

    @SuppressLint({"PrivateApi"})
    private static ArrayList<b> d(Context context) {
        ArrayList<b> arrayList = new ArrayList<>();
        try {
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            Method declaredMethod = TelephonyManager.class.getDeclaredMethod("getSubscriberIdGemini", Integer.TYPE);
            Method declaredMethod2 = TelephonyManager.class.getDeclaredMethod("getDeviceIdGemini", Integer.TYPE);
            Method declaredMethod3 = TelephonyManager.class.getDeclaredMethod("getSimSerialNumberGemini", Integer.TYPE);
            ArrayList<Integer> b2 = b(telephonyManager);
            for (int i = 0; i < b2.size(); i++) {
                b bVar = new b();
                try {
                    int intValue = b2.get(i).intValue();
                    bVar.b = (String) declaredMethod.invoke(telephonyManager, Integer.valueOf(intValue));
                    bVar.a = b.a((String) declaredMethod2.invoke(telephonyManager, Integer.valueOf(intValue)));
                    bVar.c = (String) declaredMethod3.invoke(telephonyManager, Integer.valueOf(intValue));
                } catch (Throwable unused) {
                }
                arrayList.add(bVar);
            }
            return arrayList;
        } catch (Throwable unused2) {
            return null;
        }
    }

    @SuppressLint({"PrivateApi"})
    private static boolean e(Context context) {
        try {
            Class<?> cls = Class.forName("android.telephony.MSimTelephonyManager");
            return (context.getSystemService("phone_msim") == null || cls.getMethod("getDeviceId", new Class[]{Integer.TYPE}) == null || cls.getMethod("getSubscriberId", new Class[]{Integer.TYPE}) == null) ? false : true;
        } catch (Throwable unused) {
        }
    }

    @SuppressLint({"PrivateApi"})
    private static ArrayList<b> f(Context context) {
        ArrayList<b> arrayList = new ArrayList<>();
        try {
            Class<?> cls = Class.forName("android.telephony.MSimTelephonyManager");
            Object systemService = context.getSystemService("phone_msim");
            Method method = cls.getMethod("getDeviceId", Integer.TYPE);
            Method method2 = cls.getMethod("getSubscriberId", Integer.TYPE);
            b bVar = new b();
            try {
                bVar.a = b.a((String) method.invoke(systemService, 0));
                bVar.b = (String) method2.invoke(systemService, 0);
            } catch (Throwable unused) {
            }
            arrayList.add(bVar);
            b bVar2 = new b();
            try {
                bVar2.a = b.a((String) method.invoke(systemService, 1));
                bVar2.b = (String) method2.invoke(systemService, 1);
            } catch (Throwable unused2) {
            }
            arrayList.add(bVar2);
            return arrayList;
        } catch (Throwable unused3) {
            return null;
        }
    }

    @SuppressLint({"PrivateApi"})
    private static boolean g(Context context) {
        try {
            Class<?> cls = Class.forName("com.android.internal.telephony.PhoneFactory");
            Method method = cls.getMethod("getServiceName", String.class, Integer.TYPE);
            String str = (String) method.invoke(cls, "phone", 1);
            return (method == null || str == null || ((TelephonyManager) context.getSystemService(str)) == null) ? false : true;
        } catch (Throwable unused) {
        }
    }

    @SuppressLint({"PrivateApi"})
    private static ArrayList<b> h(Context context) {
        ArrayList<b> arrayList = new ArrayList<>();
        try {
            Class<?> cls = Class.forName("com.android.internal.telephony.PhoneFactory");
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService((String) cls.getMethod("getServiceName", String.class, Integer.TYPE).invoke(cls, "phone", 1));
            TelephonyManager telephonyManager2 = (TelephonyManager) context.getSystemService("phone");
            b bVar = new b();
            try {
                bVar.b = telephonyManager2.getSubscriberId();
                bVar.a = telephonyManager2.getDeviceId();
                bVar.c = telephonyManager2.getSimSerialNumber();
            } catch (Throwable unused) {
            }
            arrayList.add(bVar);
            b bVar2 = new b();
            try {
                bVar2.b = telephonyManager.getSubscriberId();
                bVar2.a = telephonyManager.getDeviceId();
                bVar2.c = telephonyManager.getSimSerialNumber();
            } catch (Throwable unused2) {
            }
            arrayList.add(bVar2);
            return arrayList;
        } catch (Throwable unused3) {
            return null;
        }
    }
}