万能钥匙.apk(点击下载) / h.java


package com.huawei.hianalytics.v2.a.b;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Pair;
import com.huawei.hianalytics.a.a;
import com.huawei.hianalytics.a.c;
import com.huawei.hianalytics.b.b;
import com.huawei.hianalytics.util.e;
import com.huawei.hianalytics.util.f;
import com.huawei.hianalytics.util.g;
import com.huawei.hianalytics.util.k;
import com.huawei.hianalytics.util.o;
import com.sdk.plus.action.guard.GuardResultHandle;
import com.xiaomi.mipush.sdk.Constants;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public final class h implements m {

    /* renamed from: a  reason: collision with root package name */
    private static volatile boolean f4941a;
    @SuppressLint({"StaticFieldLeak"})

    /* renamed from: b  reason: collision with root package name */
    private static h f4942b = new h();
    private static Context c = null;
    private static c d;

    public static m a() {
        return f();
    }

    public static void a(int i, String str, String str2) {
        if (d == null) {
            b.c("AnalyticsImpl", "checkCollectURL() SDK is not init!");
            return;
        }
        String str3 = i == 1 ? "maint" : "oper";
        String str4 = d.y().get(str3);
        if (TextUtils.isEmpty(str4) || TextUtils.isEmpty(str2)) {
            b.c("AnalyticsImpl", "The URLs are different,URL will set to empty ,SDK stop to collect and report this kind data!");
            d.a(str3, str, "");
            return;
        }
        String trim = str4.trim();
        if (trim.endsWith("/") || trim.endsWith("\\")) {
            trim = trim.substring(0, trim.length() - 1);
        }
        String trim2 = str2.trim();
        if (trim2.endsWith("/") || trim2.endsWith("\\")) {
            trim2 = trim2.substring(0, trim2.length() - 1);
        }
        if (trim.compareToIgnoreCase(trim2) != 0) {
            b.c("AnalyticsImpl", "The URLs are different,URL will set to empty ,SDK stop to collect and report this kind data!");
            d.a(str3, str, "");
        }
    }

    private static void a(Context context, com.huawei.hianalytics.a.b bVar) {
        c = context.getApplicationContext();
        d = new c();
        a(bVar);
        i.a(context, d);
    }

    public static synchronized void a(com.huawei.hianalytics.a.b bVar, Context context) {
        synchronized (h.class) {
            if (!f4941a) {
                b.b("HiAnalytics", "HiAnalyticsImpl.init() is execute.");
                if (bVar != null) {
                    if (context != null) {
                        a(context, bVar);
                        f4941a = true;
                    }
                }
                b.c("AnalyticsImpl", "init() HiAnalyticsConf is null");
            }
        }
    }

    public static synchronized void a(com.huawei.hianalytics.a.b bVar, boolean z) {
        synchronized (h.class) {
            if (f4941a) {
                b.b("HiAnalytics", "Builder.refresh(boolean enableCleanData) is execute.");
                if (d == null) {
                    b.c("AnalyticsImpl", "refresh() HiAnalyticsConf is null");
                    return;
                }
                if (z) {
                    f.a(c);
                }
                a(bVar);
                return;
            }
            b.b("HiAnalytics", "Please execute Builder.create()");
        }
    }

    public static void a(String str) {
        c cVar = d;
        if (cVar == null) {
            b.c("AnalyticsImpl", "SDK was not init!");
        } else {
            cVar.l(g.a(str));
        }
    }

    private static void a(Map<Object, String> map, String str) {
        String str2 = map.get(str);
        if (TextUtils.isEmpty(str2) || !g.a(str2, "(https://)[\\w-]+\\.[\\w-]+(\\.hicloud\\.com:)[\\d]{2,5}(\\\\|\\/)?")) {
            b.d("AnalyticsImpl", "collectURL Parameter error!");
            map.remove(str);
        }
    }

    public static void a(boolean z) {
        c cVar = d;
        if (cVar == null) {
            b.c("AnalyticsImpl", "SDK was not init!");
        } else {
            cVar.a(z ? GuardResultHandle.GUARD_RUNING : "false");
        }
    }

    private static boolean a(com.huawei.hianalytics.a.b bVar) {
        d.w();
        g.a(d, bVar, c);
        d.b(o.b());
        d.e(o.a(c));
        d.f(o.b(c));
        Pair<String, String> e = o.e(c);
        d.c((String) e.first);
        d.d((String) e.second);
        b(bVar);
        String s = d.s();
        if (!TextUtils.isEmpty(s)) {
            d.p(s);
            return true;
        }
        d.p(e.c(c));
        return true;
    }

    private static void b(com.huawei.hianalytics.a.b bVar) {
        boolean z;
        c cVar;
        HashMap<Object, String> e = bVar.e();
        SharedPreferences a2 = k.a(c, "global_v2");
        if (a2 != null) {
            String a3 = k.a(a2, "upload_url", "");
            if (!TextUtils.isEmpty(a3)) {
                e.put("preins", a3);
                cVar = d;
                z = false;
            } else {
                cVar = d;
                z = true;
            }
            cVar.e(z);
            String a4 = k.a(a2, "uuid", "");
            if (TextUtils.isEmpty(a4)) {
                String replace = UUID.randomUUID().toString().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "");
                d.q(replace);
                a2.edit().putString("uuid", replace).apply();
            } else {
                d.q(a4);
            }
        }
        a(e, "oper");
        a(e, "maint");
        d.x();
        d.a(e);
    }

    public static void b(String str) {
        c cVar = d;
        if (cVar == null) {
            b.c("AnalyticsImpl", "SDK was not init!");
        } else {
            cVar.m(g.a(str));
        }
    }

    public static synchronized boolean b() {
        boolean z;
        synchronized (h.class) {
            z = f4941a;
        }
        return z;
    }

    public static void e() {
        f.a(c);
    }

    private static synchronized h f() {
        h hVar;
        synchronized (h.class) {
            hVar = f4942b;
        }
        return hVar;
    }

    @Override // com.huawei.hianalytics.v2.a.b.m
    public final void c() {
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - a.a() > 30000) {
            b.b("AnalyticsImpl", "begin to call onReport!");
            a.a(currentTimeMillis);
            i.a();
        }
    }

    @Override // com.huawei.hianalytics.v2.a.b.m
    public final c d() {
        return d;
    }
}