小红书.apk(点击下载) / a.java


package com.tencent.beacon.core.strategy;

import android.content.Context;
import android.util.Base64;
import android.util.SparseArray;
import com.ali.auth.third.login.LoginConstants;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.tencent.beacon.core.d.f;
import com.tencent.beacon.core.d.h;
import com.tencent.beacon.core.protocol.a.b;
import com.tencent.beacon.core.protocol.a.c;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.Set;

/* compiled from: StrategyBean */
public class a {

    /* renamed from: a  reason: collision with root package name */
    private static a f30695a;

    /* renamed from: b  reason: collision with root package name */
    private boolean f30696b = false;

    /* renamed from: c  reason: collision with root package name */
    private String f30697c = "http://oth.str.mdt.qq.com:8080/analytics/upload";

    /* renamed from: d  reason: collision with root package name */
    private int f30698d = 360;

    /* renamed from: e  reason: collision with root package name */
    private int f30699e = 100;

    /* renamed from: f  reason: collision with root package name */
    private SparseArray<C0437a> f30700f = null;

    /* renamed from: g  reason: collision with root package name */
    private Map<String, String> f30701g = null;

    /* renamed from: h  reason: collision with root package name */
    private byte f30702h = 3;

    /* renamed from: i  reason: collision with root package name */
    private byte f30703i = 2;

    /* renamed from: j  reason: collision with root package name */
    private String f30704j = "";

    /* renamed from: k  reason: collision with root package name */
    private String f30705k = "";

    /* renamed from: l  reason: collision with root package name */
    private String f30706l = "";

    /* renamed from: m  reason: collision with root package name */
    private boolean f30707m = true;

    private a() {
        SparseArray<C0437a> sparseArray = new SparseArray<>(3);
        this.f30700f = sparseArray;
        sparseArray.put(1, new C0437a(1));
        this.f30700f.put(2, new C0437a(2));
        this.f30700f.put(3, new C0437a(3));
    }

    public final String b() {
        String a14 = b.a(!a().h(), false, false, this.f30697c);
        com.tencent.beacon.core.d.b.b("[net] module strategy url: %s", a14);
        return a14;
    }

    public final int c() {
        return this.f30698d;
    }

    public final Map<String, String> d() {
        return this.f30701g;
    }

    public final synchronized SparseArray<C0437a> e() {
        if (this.f30700f == null) {
            return null;
        }
        new f();
        return f.a(this.f30700f);
    }

    public final int f() {
        String str;
        Map<String, String> map = this.f30701g;
        if (map == null || (str = map.get("maxStrategyQueryOneDay")) == null || str.trim().equals("")) {
            return this.f30699e;
        }
        int i10 = this.f30699e;
        try {
            return Integer.valueOf(str).intValue();
        } catch (Exception unused) {
            return i10;
        }
    }

    public final synchronized boolean g() {
        String str;
        Map<String, String> map = this.f30701g;
        if (map == null || (str = map.get("zeroPeak")) == null || !"y".equalsIgnoreCase(str) || Calendar.getInstance().get(11) != 0) {
            return false;
        }
        return true;
    }

    public final boolean h() {
        Object[] objArr = new Object[1];
        objArr[0] = this.f30707m ? "socket" : "http";
        com.tencent.beacon.core.d.b.b("[strategy] -> use %s to upload.", objArr);
        return this.f30707m;
    }

    public final void i() {
        com.tencent.beacon.core.d.b.b("[net] -> change to http mode.", new Object[0]);
        this.f30707m = false;
    }

    public final void j() {
        String b14 = b("isSocketOnOff");
        if (b14 != null && GoogleApiAvailabilityLight.TRACKING_SOURCE_NOTIFICATION.equals(b14)) {
            i();
        }
    }

    public final int k() {
        Map<String, String> c14;
        String str;
        C0437a aVar = this.f30700f.get(1);
        if (aVar == null || (c14 = aVar.c()) == null || (str = c14.get("socketPort")) == null) {
            return 8081;
        }
        return Integer.valueOf(str).intValue();
    }

    public final synchronized byte l() {
        return this.f30702h;
    }

    public final synchronized byte m() {
        return this.f30703i;
    }

    public final synchronized String n() {
        return this.f30704j;
    }

    public final synchronized String o() {
        return this.f30705k;
    }

    public final synchronized String p() {
        return this.f30706l;
    }

    /* renamed from: com.tencent.beacon.core.strategy.a$a  reason: collision with other inner class name */
    /* compiled from: StrategyBean */
    public static class C0437a {

        /* renamed from: a  reason: collision with root package name */
        private final int f30711a;

        /* renamed from: b  reason: collision with root package name */
        private boolean f30712b = false;

        /* renamed from: c  reason: collision with root package name */
        private String f30713c = "http://oth.eve.mdt.qq.com:8080/analytics/upload";

        /* renamed from: d  reason: collision with root package name */
        private Map<String, String> f30714d = null;

        /* renamed from: e  reason: collision with root package name */
        private Set<String> f30715e = null;

        /* renamed from: f  reason: collision with root package name */
        private Set<String> f30716f = null;

        public C0437a(int i10) {
            this.f30711a = i10;
        }

        public final String b() {
            boolean z14 = !a.a().h();
            String b14 = a.a().b("stopTest");
            String a14 = b.a(z14, true, (!(b14 != null ? "y".equals(b14) : false)) & com.tencent.beacon.core.d.b.f30582b, this.f30713c);
            com.tencent.beacon.core.d.b.b("[net] module strategy url: %s", a14);
            return a14;
        }

        public final Map<String, String> c() {
            return this.f30714d;
        }

        public final Set<String> d() {
            return this.f30715e;
        }

        public final int e() {
            return this.f30711a;
        }

        public final Set<String> f() {
            return this.f30716f;
        }

        public final boolean a() {
            return this.f30712b;
        }

        public final void a(boolean z14) {
            this.f30712b = z14;
        }

        public final void a(String str) {
            if (this.f30711a != 1 || !a.a().f30696b) {
                this.f30713c = str;
            } else {
                com.tencent.beacon.core.d.b.c("[strategy] user event url has defined by api, don't change.", new Object[0]);
            }
        }

        public final void b(Set<String> set) {
            this.f30716f = set;
        }

        public final void a(Map<String, String> map) {
            this.f30714d = map;
        }

        public final void a(Set<String> set) {
            this.f30715e = set;
        }
    }

    public static a a() {
        if (f30695a == null) {
            synchronized (a.class) {
                if (f30695a == null) {
                    f30695a = new a();
                }
            }
        }
        return f30695a;
    }

    private synchronized void c(String str) {
        this.f30706l = str;
    }

    public final synchronized C0437a b(int i10) {
        SparseArray<C0437a> sparseArray = this.f30700f;
        if (sparseArray == null) {
            return null;
        }
        return sparseArray.get(i10);
    }

    public final String b(String str) {
        Map<String, String> c14;
        C0437a aVar = this.f30700f.get(1);
        if (aVar == null || (c14 = aVar.c()) == null) {
            return null;
        }
        return c14.get(str);
    }

    public final void a(String str) {
        if (this.f30696b) {
            com.tencent.beacon.core.d.b.c("[strategy] url has defined by api, don't change.", new Object[0]);
        } else {
            this.f30697c = str;
        }
    }

    public final void a(int i10) {
        this.f30698d = i10;
    }

    public final void a(Map<String, String> map) {
        this.f30701g = map;
    }

    public final synchronized void a(String str, String str2) {
        this.f30696b = true;
        String a14 = b.a(str);
        this.f30697c = a14;
        com.tencent.beacon.core.d.b.b("[strategy] set strategy url to %s by api.", a14);
        C0437a aVar = this.f30700f.get(1);
        if (aVar != null) {
            aVar.f30713c = b.a(str2);
            com.tencent.beacon.core.d.b.b("[strategy] set user event url to %s by api.", aVar.f30713c);
        }
    }

    private synchronized void a(Context context, String str) {
        this.f30705k = str;
        this.f30704j = Base64.encodeToString(c.a(context, str), 2);
    }

    public final synchronized void a(final Context context, final String str, final String str2) {
        com.tencent.beacon.core.d.b.b("[net] -> update local sid|time[%s|%s].", str, str2);
        this.f30706l = str;
        com.tencent.beacon.core.a.b.a().a(new Runnable() {
            /* class com.tencent.beacon.core.strategy.a.AnonymousClass1 */

            public final void run() {
                long j14;
                Object[] objArr = new Object[2];
                objArr[0] = str;
                try {
                    j14 = h.a(str2).getTime() / 1000;
                } catch (Exception unused) {
                    j14 = 0;
                }
                if (j14 == 0) {
                    j14 = (new Date().getTime() / 1000) + 86400;
                }
                objArr[1] = Long.valueOf(j14);
                com.tencent.beacon.core.a.a.c.a(context, LoginConstants.SID, objArr);
            }
        });
    }

    public final synchronized void a(Context context) {
        Object[] a14 = com.tencent.beacon.core.a.a.c.a(context, LoginConstants.SID);
        if (a14 != null && a14.length == 3) {
            long time = new Date().getTime() / 1000;
            long j14 = 0;
            try {
                j14 = ((Long) a14[2]).longValue();
            } catch (Exception unused) {
            }
            if (j14 > time) {
                c((String) a14[1]);
            }
        }
        a(context, h.a(context));
    }
}