翰林优商.apk(点击下载) / DevicesIDsHelper.java


package com.czhj.devicehelper.oaId.helpers;

import android.content.Context;
import android.content.res.AssetManager;
import android.os.Build;
import android.text.TextUtils;
import com.czhj.sdk.logger.SigmobLog;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.LinkedList;
import java.util.List;

public class DevicesIDsHelper {
    private static AppIdsUpdater a = null;
    private static String b = null;
    private static int d = -1;
    private static int e;
    private static String f;
    private static Class<?> g;
    private static Class<?> h;
    private static Class<?> i;
    private static Class<?> j;
    private static String k;
    private static final List<String> l = new LinkedList<String>() {
        /* class com.czhj.devicehelper.oaId.helpers.DevicesIDsHelper.AnonymousClass2 */

        {
            add("00000000-0000-0000-0000-000000000000");
            add("00000000000000000000000000000000");
        }
    };
    private static final List<String> m = new LinkedList<String>() {
        /* class com.czhj.devicehelper.oaId.helpers.DevicesIDsHelper.AnonymousClass3 */

        {
            add("msaoaidsec");
            add("nllvm1632808251147706677");
            add("nllvm1630571663641560568");
            add("nllvm1623827671");
        }
    };
    private AppIdsUpdater c;

    public interface AppIdsUpdater {
        void OnIdsAvalid(String str);
    }

    /* access modifiers changed from: package-private */
    public static class IdentifyListenerHandler implements InvocationHandler {
        IdentifyListenerHandler() {
        }

        @Override // java.lang.reflect.InvocationHandler
        public Object invoke(Object obj, Method method, Object[] objArr) throws Throwable {
            try {
                if (!"OnSupport".equalsIgnoreCase(method.getName())) {
                    return null;
                }
                Method declaredMethod = DevicesIDsHelper.h.getDeclaredMethod("getOAID", new Class[0]);
                String unused = DevicesIDsHelper.f = objArr.length == 1 ? (String) declaredMethod.invoke(objArr[0], new Object[0]) : (String) declaredMethod.invoke(objArr[1], new Object[0]);
                if (DevicesIDsHelper.a != null && !TextUtils.isEmpty(DevicesIDsHelper.f)) {
                    DevicesIDsHelper.a.OnIdsAvalid(DevicesIDsHelper.f);
                }
                SigmobLog.e("MdidSdkHelper oaid:" + DevicesIDsHelper.f);
                return null;
            } catch (Throwable unused2) {
                if (DevicesIDsHelper.a == null || TextUtils.isEmpty(DevicesIDsHelper.f)) {
                    return null;
                }
                DevicesIDsHelper.a.OnIdsAvalid(DevicesIDsHelper.f);
                return null;
            }
        }
    }

    static {
        i();
    }

    private static void a(Context context) {
        try {
            h();
            if (!(context == null || j == null || g == null)) {
                if (h != null) {
                    if (TextUtils.isEmpty(f)) {
                        b(context);
                        return;
                    }
                    AppIdsUpdater appIdsUpdater = a;
                    if (appIdsUpdater != null) {
                        appIdsUpdater.OnIdsAvalid(f);
                        return;
                    }
                    return;
                }
            }
            SigmobLog.e("OAID 读取类创建失败");
            AppIdsUpdater appIdsUpdater2 = a;
            if (appIdsUpdater2 != null) {
                appIdsUpdater2.OnIdsAvalid(f);
            }
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            AppIdsUpdater appIdsUpdater3 = a;
            if (appIdsUpdater3 != null) {
                appIdsUpdater3.OnIdsAvalid(f);
            }
        }
    }

    private void a(final Context context, final String str) {
        new Thread(new Runnable() {
            /* class com.czhj.devicehelper.oaId.helpers.DevicesIDsHelper.AnonymousClass1 */

            public void run() {
                c cVar;
                if ("ASUS".equals(str)) {
                    new a(context).a(DevicesIDsHelper.this.c);
                } else if ("HUAWEI".equals(str)) {
                    new b(context).a(DevicesIDsHelper.this.c);
                } else if ("OPPO".equals(str)) {
                    new g(context).a(DevicesIDsHelper.this.c);
                } else {
                    if ("LENOVO".equals(str)) {
                        cVar = new c(context);
                    } else if ("MOTOLORA".equals(str)) {
                        cVar = new c(context);
                    } else if ("MEIZU".equals(str)) {
                        new d(context).a(DevicesIDsHelper.this.c);
                        return;
                    } else if ("SAMSUNG".equals(str)) {
                        new h(context).a(DevicesIDsHelper.this.c);
                        return;
                    } else if ("ONEPLUS".equals(str)) {
                        new f(context).a(DevicesIDsHelper.this.c);
                        return;
                    } else {
                        ("ZTE".equals(str) ? new k(context) : ("FERRMEOS".equals(str) || DevicesIDsHelper.a()) ? new k(context) : ("SSUI".equals(str) || DevicesIDsHelper.b()) ? new k(context) : new k(context)).a(DevicesIDsHelper.this.c);
                        return;
                    }
                    cVar.a(DevicesIDsHelper.this.c);
                }
            }
        }).start();
    }

    public static void a(String str) {
        b = str;
    }

    public static boolean a() {
        String d2 = d("ro.build.freeme.label");
        return !TextUtils.isEmpty(d2) && d2.equalsIgnoreCase("FREEMEOS");
    }

    private static void b(Context context) {
        try {
            c(context);
            try {
                Class<?> cls = i;
                if (cls != null && cls.getField("classLoader").get(i) == null) {
                    i.getDeclaredMethod("InitEntry", Context.class).invoke(i, context);
                }
            } catch (Exception unused) {
            }
            IdentifyListenerHandler identifyListenerHandler = new IdentifyListenerHandler();
            int intValue = ((Integer) j.getDeclaredMethod("InitSdk", Context.class, Boolean.TYPE, g).invoke(null, context, true, Proxy.newProxyInstance(context.getClassLoader(), new Class[]{g}, identifyListenerHandler))).intValue();
            SigmobLog.e("MdidSdkHelper ErrorCode : " + intValue);
            if (intValue != 1008614 && intValue != 1008610 && a != null && !TextUtils.isEmpty(f)) {
                a.OnIdsAvalid(f);
            }
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            if (a != null && !TextUtils.isEmpty(f)) {
                a.OnIdsAvalid(f);
            }
        }
    }

    public static void b(Context context, AppIdsUpdater appIdsUpdater) {
        a = appIdsUpdater;
        a(context);
    }

    public static void b(String str) {
        k = str;
    }

    public static boolean b() {
        String d2 = d("ro.ssui.product");
        return !TextUtils.isEmpty(d2) && !d2.equalsIgnoreCase("unknown");
    }

    private static void c(Context context) {
        try {
            String d2 = !TextUtils.isEmpty(b) ? b : d(context);
            if (!TextUtils.isEmpty(d2)) {
                j.getDeclaredMethod("InitCert", Context.class, String.class).invoke(null, context, d2);
            }
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:0x0041 A[LOOP:0: B:8:0x003b->B:10:0x0041, LOOP_END] */
    /* JADX WARNING: Removed duplicated region for block: B:16:0x004a A[SYNTHETIC] */
    private static String d(Context context) {
        InputStream inputStream;
        BufferedReader bufferedReader;
        StringBuilder sb;
        String readLine;
        try {
            String str = context.getPackageName() + ".cert.pem";
            AssetManager assets = context.getAssets();
            if (!TextUtils.isEmpty(k)) {
                try {
                    inputStream = assets.open(k);
                } catch (IOException unused) {
                }
                bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                sb = new StringBuilder();
                while (true) {
                    readLine = bufferedReader.readLine();
                    if (readLine != null) {
                        return sb.toString();
                    }
                    sb.append(readLine);
                    sb.append('\n');
                }
            }
            inputStream = assets.open(str);
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            sb = new StringBuilder();
            while (true) {
                readLine = bufferedReader.readLine();
                if (readLine != null) {
                }
                sb.append(readLine);
                sb.append('\n');
            }
        } catch (IOException unused2) {
            SigmobLog.d("loadPemFromAssetFile failed");
            return "";
        }
    }

    private static String d(String str) {
        if (str == null) {
            return null;
        }
        try {
            Class<?> cls = Class.forName("android.os.SystemProperties");
            return (String) cls.getMethod("get", String.class, String.class).invoke(cls, str, "unknown");
        } catch (Exception unused) {
            return null;
        }
    }

    private static String f() {
        return Build.BRAND.toUpperCase();
    }

    private static String g() {
        return Build.MANUFACTURER.toUpperCase();
    }

    private static void h() {
        try {
            j = Class.forName("com.bun.miitmdid.core.MdidSdkHelper");
            try {
                g = Class.forName("com.bun.miitmdid.interfaces.IIdentifierListener");
                h = Class.forName("com.bun.miitmdid.interfaces.IdSupplier");
            } catch (Exception unused) {
                try {
                    g = Class.forName("com.bun.supplier.IIdentifierListener");
                    h = Class.forName("com.bun.supplier.IdSupplier");
                    i = Class.forName("com.bun.miitmdid.core.JLibrary");
                } catch (Exception unused2) {
                    try {
                        g = Class.forName("com.bun.miitmdid.core.IIdentifierListener");
                        h = Class.forName("com.bun.miitmdid.supplier.IdSupplier");
                        i = Class.forName("com.bun.miitmdid.core.JLibrary");
                    } catch (Exception unused3) {
                    }
                }
            }
        } catch (ClassNotFoundException e2) {
            SigmobLog.e(e2.getMessage());
        }
    }

    private static void i() {
        for (String str : m) {
            try {
                System.loadLibrary(str);
                return;
            } catch (Throwable unused) {
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:42:0x00e1  */
    /* JADX WARNING: Removed duplicated region for block: B:44:? A[RETURN, SYNTHETIC] */
    public void a(Context context, AppIdsUpdater appIdsUpdater) {
        String str;
        AppIdsUpdater appIdsUpdater2;
        j jVar;
        this.c = appIdsUpdater;
        SigmobLog.d("getManufacturer ===> " + g());
        String upperCase = g().toUpperCase();
        if (!"ASUS".equals(upperCase) && !"HUAWEI".equals(upperCase) && !"LENOVO".equals(upperCase) && !"MOTOLORA".equals(upperCase) && !"MEIZU".equals(upperCase)) {
            if ("NUBIA".equals(upperCase)) {
                str = new e(context).a();
            } else if (!"OPPO".equals(upperCase) && !"SAMSUNG".equals(upperCase)) {
                if ("VIVO".equals(upperCase)) {
                    str = new i(context).a();
                } else {
                    if ("XIAOMI".equals(upperCase)) {
                        jVar = new j(context);
                    } else if ("BLACKSHARK".equals(upperCase)) {
                        jVar = new j(context);
                    } else if (!"ONEPLUS".equals(upperCase) && !"ZTE".equals(upperCase) && !"FERRMEOS".equals(upperCase) && !a() && !"SSUI".equals(upperCase)) {
                        b();
                    }
                    str = jVar.a();
                }
            }
            appIdsUpdater2 = this.c;
            if (appIdsUpdater2 == null) {
                appIdsUpdater2.OnIdsAvalid(str);
                return;
            }
            return;
        }
        a(context, upperCase);
        str = null;
        appIdsUpdater2 = this.c;
        if (appIdsUpdater2 == null) {
        }
    }
}