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


package cn.jiguang.u;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.core.view.MotionEventCompat;
import cn.jiguang.af.a;
import cn.jiguang.internal.JConstants;
import cn.jiguang.t.b;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class d {
    private static b a(String str, int i, List<b> list) {
        if (list != null && !list.isEmpty() && !TextUtils.isEmpty(str)) {
            for (b bVar : list) {
                if (a(str, i, bVar)) {
                    return bVar;
                }
            }
        }
        return null;
    }

    public static String a(Context context) {
        String e = cn.jiguang.o.d.e(context, "");
        if (a(e)) {
            return e;
        }
        String c = Build.VERSION.SDK_INT < 26 ? c(context) : d(context);
        if (!TextUtils.isEmpty(c)) {
            return c;
        }
        String c2 = b.c(context);
        return a(c2) ? c2 : "";
    }

    public static String a(Context context, String str) {
        String e = cn.jiguang.o.d.e(context, "");
        if (!TextUtils.isEmpty(e)) {
            return e;
        }
        ArrayList<b> b = b.b(context);
        if (b != null && !b.isEmpty()) {
            Iterator<b> it = b.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                b next = it.next();
                if (!TextUtils.isEmpty(next.a)) {
                    str = next.a;
                    break;
                }
            }
        }
        return str;
    }

    private static List<b> a(String str, int i, List<b> list, b bVar) {
        if (list == null || list.isEmpty() || TextUtils.isEmpty(str) || bVar == null) {
            return null;
        }
        Iterator<b> it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            b next = it.next();
            if (a(str, i, next)) {
                next.b = bVar.b;
                next.c = bVar.c;
                break;
            }
        }
        return list;
    }

    private static boolean a(String str) {
        return !TextUtils.isEmpty(str) && str.trim().length() != 0 && str.length() == 14;
    }

    private static boolean a(String str, int i, b bVar) {
        switch (i) {
            case 0:
                return str.equals(bVar.a);
            case 1:
                return str.equals(bVar.b);
            case 2:
                return str.equals(bVar.c);
            default:
                return false;
        }
    }

    public static List<b> b(Context context) {
        b a;
        b a2 = b.a(context);
        ArrayList<b> a3 = e.a(context);
        ArrayList<b> b = b.b(context);
        if (a3 != null && !a3.isEmpty()) {
            for (int size = a3.size() - 1; size >= 0; size--) {
                if (a3.get(size).b()) {
                    a3.remove(size);
                }
            }
        }
        if (a3 != null && !a3.isEmpty()) {
            for (b bVar : a3) {
                if (TextUtils.isEmpty(bVar.a) && !TextUtils.isEmpty(bVar.b)) {
                    b a4 = a(bVar.b, 1, b);
                    if (a4 != null) {
                        bVar.a = a4.a;
                    }
                } else if (TextUtils.isEmpty(bVar.b) && !TextUtils.isEmpty(bVar.a) && (a = a(bVar.a, 1, b)) != null) {
                    bVar.b = a.b;
                    bVar.c = a.c;
                }
            }
            return a3;
        } else if (a2 == null || a2.b()) {
            return b;
        } else {
            if (b == null || b.size() != 1) {
                b a5 = a(a2.a, 0, b);
                return (a5 != null && TextUtils.isEmpty(a5.b) && a(a2.b, 1, b) == null) ? a(a2.a, 0, b, a2) : b;
            }
            if (TextUtils.isEmpty(a2.a) || !a2.a.equals(b.get(0).a)) {
                if (!TextUtils.isEmpty(a2.b) && a2.b.equals(b.get(0).b)) {
                    a2.b = "";
                    a2.c = "";
                    if (a2.b()) {
                        return b;
                    }
                }
            } else if (TextUtils.isEmpty(a2.b) || a2.b.equals(b.get(0).b)) {
                return b;
            }
            b.add(a2);
            return b;
        }
    }

    @TargetApi(23)
    private static String c(Context context) {
        try {
            if (JConstants.isAndroidQ(context, false, "do not getMeidForM") || !cn.jiguang.o.d.a(context, "android.permission.READ_PHONE_STATE")) {
                return null;
            }
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            Method method = Class.forName("android.os.SystemProperties").getMethod("get", String.class, String.class);
            String str = (String) method.invoke(null, "ril.cdma.meid", "");
            if (!TextUtils.isEmpty(str) && str.trim().length() != 0) {
                return str;
            }
            String str2 = (String) method.invoke(null, "ril.gsm.imei", "");
            if (!TextUtils.isEmpty(str2)) {
                String[] split = str2.split(",");
                if (split == null || split.length <= 0) {
                    String deviceId = telephonyManager.getDeviceId(0);
                    if (a(deviceId)) {
                        return deviceId;
                    }
                    String deviceId2 = telephonyManager.getDeviceId(1);
                    if (a(deviceId2)) {
                        return deviceId2;
                    }
                } else if (a(split[0])) {
                    return split[0];
                } else {
                    if (split.length <= 1) {
                        String deviceId3 = telephonyManager.getDeviceId(1);
                        if (a(deviceId3)) {
                            return deviceId3;
                        }
                    } else if (a(split[1])) {
                        return split[1];
                    }
                }
            } else {
                String deviceId4 = telephonyManager.getDeviceId(0);
                if (a(deviceId4)) {
                    return deviceId4;
                }
                String deviceId5 = telephonyManager.getDeviceId(1);
                if (a(deviceId5)) {
                    return deviceId5;
                }
            }
            return null;
        } catch (Throwable th) {
            a.d("JDeviceSimHelper", "[getMeidForM] failed:" + th.getMessage());
        }
    }

    @TargetApi(MotionEventCompat.AXIS_SCROLL)
    private static String d(Context context) {
        try {
            if (JConstants.isAndroidQ(context, false, "do not getIMEIforO") || !cn.jiguang.o.d.a(context, "android.permission.READ_PHONE_STATE")) {
                return null;
            }
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            String meid = telephonyManager.getMeid();
            if (!TextUtils.isEmpty(meid) && meid.trim().length() != 0) {
                return meid;
            }
            String meid2 = telephonyManager.getMeid(0);
            if (!TextUtils.isEmpty(meid2) && meid2.trim().length() != 0) {
                return meid2;
            }
            String meid3 = telephonyManager.getMeid(1);
            if (!TextUtils.isEmpty(meid3) && meid3.trim().length() != 0) {
                return meid3;
            }
            String imei = telephonyManager.getImei(0);
            if (a(imei)) {
                return imei;
            }
            String imei2 = telephonyManager.getImei(1);
            if (a(imei2)) {
                return imei2;
            }
            return null;
        } catch (Throwable th) {
            a.d("JDeviceSimHelper", "[getIMEIforO] failed:" + th.getMessage());
        }
    }
}