大漢易經書院.apk(点击下载) / av.java


package com.xiaomi.push;

import android.content.Context;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import com.xiaomi.channel.commonutils.logger.b;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/* access modifiers changed from: package-private */
public class av implements au, InvocationHandler {
    private static final String[][] a = {new String[]{"com.bun.supplier.IIdentifierListener", "com.bun.supplier.IdSupplier"}, new String[]{"com.bun.miitmdid.core.IIdentifierListener", "com.bun.miitmdid.supplier.IdSupplier"}};

    /* renamed from: a  reason: collision with other field name */
    private volatile int f6750a = 0;

    /* renamed from: a  reason: collision with other field name */
    private volatile long f6751a = 0;

    /* renamed from: a  reason: collision with other field name */
    private Context f6752a;

    /* renamed from: a  reason: collision with other field name */
    private volatile a f6753a = null;

    /* renamed from: a  reason: collision with other field name */
    private Class f6754a = null;

    /* renamed from: a  reason: collision with other field name */
    private final Object f6755a = new Object();

    /* renamed from: a  reason: collision with other field name */
    private Method f6756a = null;
    private Class b = null;

    /* renamed from: b  reason: collision with other field name */
    private Method f6757b = null;
    private Method c = null;
    private Method d = null;
    private Method e = null;
    private Method f = null;
    private Method g = null;

    /* access modifiers changed from: private */
    public class a {

        /* renamed from: a  reason: collision with other field name */
        Boolean f6758a;

        /* renamed from: a  reason: collision with other field name */
        String f6759a;
        String b;
        String c;
        String d;

        private a() {
            this.f6758a = null;
            this.f6759a = null;
            this.b = null;
            this.c = null;
            this.d = null;
        }

        /* access modifiers changed from: package-private */
        public boolean a() {
            if (!TextUtils.isEmpty(this.f6759a) || !TextUtils.isEmpty(this.b) || !TextUtils.isEmpty(this.c) || !TextUtils.isEmpty(this.d)) {
                this.f6758a = true;
            }
            return this.f6758a != null;
        }
    }

    public av(Context context) {
        this.f6752a = context.getApplicationContext();
        a(context);
        b(context);
    }

    private static Class<?> a(Context context, String str) {
        try {
            return v.a(context, str);
        } catch (Throwable unused) {
            return null;
        }
    }

    private static <T> T a(Method method, Object obj, Object... objArr) {
        if (method == null) {
            return null;
        }
        try {
            T t = (T) method.invoke(obj, objArr);
            if (t != null) {
                return t;
            }
            return null;
        } catch (Throwable unused) {
            return null;
        }
    }

    private static Method a(Class<?> cls, String str, Class<?>... clsArr) {
        if (cls == null) {
            return null;
        }
        try {
            return cls.getMethod(str, clsArr);
        } catch (Throwable unused) {
            return null;
        }
    }

    /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
    /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x000b */
    @Override // com.xiaomi.push.au, com.xiaomi.push.au
    private void a() {
        synchronized (this.f6755a) {
            this.f6755a.notifyAll();
        }
    }

    private void a(Context context) {
        Class<?> a2 = a(context, "com.bun.miitmdid.core.MdidSdk");
        Class<?> cls = null;
        Class<?> cls2 = null;
        int i = 0;
        while (true) {
            String[][] strArr = a;
            if (i >= strArr.length) {
                break;
            }
            String[] strArr2 = strArr[i];
            Class<?> a3 = a(context, strArr2[0]);
            Class<?> a4 = a(context, strArr2[1]);
            if (a3 != null && a4 != null) {
                b("found class in index " + i);
                cls2 = a4;
                cls = a3;
                break;
            }
            i++;
            cls2 = a4;
            cls = a3;
        }
        this.f6754a = a2;
        this.f6756a = a(a2, "InitSdk", Context.class, cls);
        this.b = cls;
        this.f6757b = a(cls2, "getUDID", new Class[0]);
        this.c = a(cls2, "getOAID", new Class[0]);
        this.d = a(cls2, "getVAID", new Class[0]);
        this.e = a(cls2, "getAAID", new Class[0]);
        this.f = a(cls2, "isSupported", new Class[0]);
        this.g = a(cls2, "shutDown", new Class[0]);
    }

    private void a(String str) {
        if (this.f6753a == null) {
            long j = this.f6751a;
            long elapsedRealtime = SystemClock.elapsedRealtime() - Math.abs(j);
            int i = this.f6750a;
            if (elapsedRealtime > 3000 && i < 3) {
                synchronized (this.f6755a) {
                    if (this.f6751a == j && this.f6750a == i) {
                        b("retry, current count is " + i);
                        this.f6750a = this.f6750a + 1;
                        b(this.f6752a);
                        j = this.f6751a;
                        elapsedRealtime = SystemClock.elapsedRealtime() - Math.abs(j);
                    }
                }
            }
            if (this.f6753a == null && j >= 0 && elapsedRealtime <= 3000 && Looper.myLooper() != Looper.getMainLooper()) {
                synchronized (this.f6755a) {
                    if (this.f6753a == null) {
                        try {
                            b(str + " wait...");
                            this.f6755a.wait(3000);
                        } catch (Exception unused) {
                        }
                    }
                }
            }
        }
    }

    private static boolean a(Object obj) {
        return (obj instanceof Boolean) || (obj instanceof Character) || (obj instanceof Byte) || (obj instanceof Short) || (obj instanceof Integer) || (obj instanceof Long) || (obj instanceof Float) || (obj instanceof Double);
    }

    private void b(Context context) {
        long elapsedRealtime = SystemClock.elapsedRealtime();
        long j = -elapsedRealtime;
        Class cls = this.b;
        if (cls != null) {
            try {
                ClassLoader classLoader = cls.getClassLoader();
                if (classLoader == null) {
                    classLoader = context.getClassLoader();
                }
                Object newProxyInstance = Proxy.newProxyInstance(classLoader, new Class[]{this.b}, this);
                a(this.f6756a, this.f6754a.newInstance(), context, newProxyInstance);
            } catch (Throwable th) {
                b("call init sdk error:" + th);
            }
            this.f6751a = elapsedRealtime;
        }
        elapsedRealtime = j;
        this.f6751a = elapsedRealtime;
    }

    private static void b(String str) {
        b.m9051a("mdid:" + str);
    }

    @Override // com.xiaomi.push.au, com.xiaomi.push.au
    /* renamed from: a  reason: collision with other method in class */
    public String m9127a() {
        a("getUDID");
        if (this.f6753a == null) {
            return null;
        }
        return this.f6753a.f6759a;
    }

    @Override // com.xiaomi.push.au, com.xiaomi.push.au
    /* renamed from: a  reason: collision with other method in class */
    public boolean m9128a() {
        a("isSupported");
        return this.f6753a != null && Boolean.TRUE.equals(this.f6753a.f6758a);
    }

    @Override // com.xiaomi.push.au
    public String b() {
        a("getOAID");
        if (this.f6753a == null) {
            return null;
        }
        return this.f6753a.b;
    }

    @Override // com.xiaomi.push.au
    public String c() {
        a("getVAID");
        if (this.f6753a == null) {
            return null;
        }
        return this.f6753a.c;
    }

    @Override // com.xiaomi.push.au
    public String d() {
        a("getAAID");
        if (this.f6753a == null) {
            return null;
        }
        return this.f6753a.d;
    }

    @Override // java.lang.reflect.InvocationHandler
    public Object invoke(Object obj, Method method, Object[] objArr) {
        this.f6751a = SystemClock.elapsedRealtime();
        if (objArr != null) {
            a aVar = new a();
            int length = objArr.length;
            boolean z = false;
            int i = 0;
            while (true) {
                if (i >= length) {
                    break;
                }
                Object obj2 = objArr[i];
                if (obj2 != null && !a(obj2)) {
                    aVar.f6759a = (String) a(this.f6757b, obj2, new Object[0]);
                    aVar.b = (String) a(this.c, obj2, new Object[0]);
                    aVar.c = (String) a(this.d, obj2, new Object[0]);
                    aVar.d = (String) a(this.e, obj2, new Object[0]);
                    aVar.f6758a = (Boolean) a(this.f, obj2, new Object[0]);
                    a(this.g, obj2, new Object[0]);
                    if (aVar.a()) {
                        StringBuilder sb = new StringBuilder("has get succ, check duplicate:");
                        if (this.f6753a != null) {
                            z = true;
                        }
                        sb.append(z);
                        b(sb.toString());
                        synchronized (av.class) {
                            if (this.f6753a == null) {
                                this.f6753a = aVar;
                            }
                        }
                    }
                }
                i++;
            }
        }
        a();
        return null;
    }
}