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


package ux2;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.alibclinkpartner.smartlink.constants.ALPUserTrackConstant;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.igexin.push.config.c;
import com.tencent.map.geolocation.TencentLocationListener;
import com.xiaomi.mipush.sdk.Constants;
import com.xingin.library.videoedit.define.XavFilterDef;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import n02.d;
import tv.danmaku.ijk.media.player.IMediaPlayer;

/* compiled from: SessionTracker */
public final class k implements Application.ActivityLifecycleCallbacks {

    /* renamed from: t  reason: collision with root package name */
    public static final String[] f139070t = {"/system/xbin/su", "/system/bin/su", "/system/app/Superuser.apk", "/system/app/SuperSU.apk", "/system/app/Superuser", "/system/app/SuperSU", "/system/xbin/daemonsu", "/su/bin"};

    /* renamed from: a  reason: collision with root package name */
    public final Collection<String> f139071a = new ConcurrentLinkedQueue();

    /* renamed from: b  reason: collision with root package name */
    public final long f139072b;

    /* renamed from: c  reason: collision with root package name */
    public final long f139073c;

    /* renamed from: d  reason: collision with root package name */
    public final AtomicLong f139074d = new AtomicLong(0);

    /* renamed from: e  reason: collision with root package name */
    public final AtomicLong f139075e = new AtomicLong(0);

    /* renamed from: f  reason: collision with root package name */
    public final AtomicLong f139076f = new AtomicLong(0);

    /* renamed from: g  reason: collision with root package name */
    public final AtomicReference<f> f139077g = new AtomicReference<>();

    /* renamed from: h  reason: collision with root package name */
    public final String f139078h = UUID.randomUUID().toString().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "");

    /* renamed from: i  reason: collision with root package name */
    public final AtomicLong f139079i = new AtomicLong(0);

    /* renamed from: j  reason: collision with root package name */
    public final AtomicInteger f139080j;

    /* renamed from: k  reason: collision with root package name */
    public final Map<Class<?>, Bundle> f139081k;

    /* renamed from: l  reason: collision with root package name */
    public i f139082l;

    /* renamed from: m  reason: collision with root package name */
    public g f139083m;

    /* renamed from: n  reason: collision with root package name */
    public c f139084n;

    /* renamed from: o  reason: collision with root package name */
    public a f139085o;

    /* renamed from: p  reason: collision with root package name */
    public b f139086p;

    /* renamed from: q  reason: collision with root package name */
    public d f139087q;

    /* renamed from: r  reason: collision with root package name */
    public String f139088r;

    /* renamed from: s  reason: collision with root package name */
    public boolean f139089s;

    /* compiled from: SessionTracker */
    public class a implements a {
        public a() {
        }

        @Override // ux2.a
        public Map<String, Object> a() {
            return k.this.h();
        }

        @Override // ux2.a
        public Map<String, Object> b() {
            return k.this.l();
        }
    }

    public k(Application application, b bVar) {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        this.f139080j = atomicInteger;
        this.f139081k = new HashMap();
        this.f139073c = SystemClock.elapsedRealtime();
        this.f139072b = c.f25221k;
        this.f139088r = UUID.randomUUID().toString();
        atomicInteger.set(0);
        v(new Date());
        this.f139086p = bVar;
        application.registerActivityLifecycleCallbacks(this);
    }

    public static String[] f() {
        if (Build.VERSION.SDK_INT >= 21) {
            return Build.SUPPORTED_ABIS;
        }
        String str = Build.CPU_ABI;
        String str2 = Build.CPU_ABI2;
        if (TextUtils.isEmpty(str2)) {
            return new String[]{str};
        }
        return new String[]{str, str2};
    }

    /* access modifiers changed from: private */
    public /* synthetic */ void t(f fVar) {
        l lVar = new l(fVar, this.f139085o);
        String g10 = this.f139082l.g(lVar);
        if (vx2.c.c(lVar)) {
            this.f139082l.b(new File(g10));
        }
    }

    public final String d() {
        int i10 = this.f139083m.o().getResources().getConfiguration().orientation;
        if (i10 != 1) {
            return i10 != 2 ? "unknown" : "landscape";
        }
        return "portrait";
    }

    public void e() {
        List<File> d14 = this.f139082l.d();
        if (!d14.isEmpty()) {
            for (File file : d14) {
                l a14 = wx2.c.a(file);
                if (a14 == null) {
                    this.f139082l.b(file);
                    return;
                } else if (vx2.c.c(a14)) {
                    this.f139082l.b(file);
                } else {
                    this.f139082l.a(file);
                }
            }
        }
    }

    public final String g(Activity activity) {
        return activity.getClass().getSimpleName();
    }

    public final Map<String, Object> h() {
        HashMap hashMap = new HashMap();
        try {
            hashMap.put("userId", this.f139084n.getUserId());
            hashMap.put("appName", this.f139083m.l());
            hashMap.put("appIdentifier", this.f139083m.l());
            hashMap.put("appBuildId", this.f139084n.b());
            hashMap.put("cpuInstallType", this.f139084n.a());
            hashMap.put("appVersion", this.f139083m.n());
            hashMap.put("appVersionCode", String.valueOf(this.f139083m.m()));
            hashMap.put("appStartTime", Long.valueOf(System.currentTimeMillis() - (SystemClock.elapsedRealtime() - this.f139073c)));
            hashMap.put("duration", Long.valueOf(SystemClock.elapsedRealtime() - this.f139073c));
            hashMap.put("durationInForeground", Long.valueOf(m()));
            hashMap.put("inForeground", Boolean.valueOf(r()));
            hashMap.put(RemoteMessageConst.Notification.CHANNEL_ID, this.f139084n.getChannel());
            hashMap.put("processName", this.f139083m.q());
            hashMap.put("activeScreen", j());
            hashMap.put("releaseStage", this.f139083m.r());
        } catch (Exception unused) {
        }
        return hashMap;
    }

    @SuppressLint({"MissingPermission"})
    public final String i() {
        boolean z14;
        NetworkCapabilities networkCapabilities;
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) this.f139083m.o().getSystemService("connectivity");
            if (connectivityManager == null) {
                return null;
            }
            boolean z15 = false;
            boolean z16 = true;
            if (Build.VERSION.SDK_INT >= 23) {
                Network activeNetwork = connectivityManager.getActiveNetwork();
                if (activeNetwork == null || (networkCapabilities = connectivityManager.getNetworkCapabilities(activeNetwork)) == null) {
                    return null;
                }
                boolean hasTransport = networkCapabilities.hasTransport(3);
                z14 = networkCapabilities.hasTransport(1);
                z16 = networkCapabilities.hasTransport(0);
                z15 = hasTransport;
            } else {
                NetworkInfo d14 = d.d(connectivityManager);
                if (d14 == null) {
                    return null;
                }
                int type = d14.getType();
                if (type != 0) {
                    if (type == 1) {
                        z14 = true;
                    } else if (type != 9) {
                        z14 = false;
                    } else {
                        z14 = false;
                        z15 = true;
                    }
                    z16 = false;
                } else {
                    z14 = false;
                }
            }
            if (z15) {
                return "ethernet";
            }
            if (z14) {
                return TencentLocationListener.WIFI;
            }
            if (z16) {
                return "cellular";
            }
            return null;
        } catch (Throwable unused) {
            return null;
        }
    }

    public String j() {
        if (this.f139071a.isEmpty()) {
            return null;
        }
        int size = this.f139071a.size();
        return ((String[]) this.f139071a.toArray(new String[size]))[size - 1];
    }

    public String k() {
        f fVar = this.f139077g.get();
        return (fVar == null || fVar.f139047a.get()) ? "" : fVar.a();
    }

    public final Map<String, Object> l() {
        HashMap hashMap = new HashMap();
        String p14 = this.f139083m.p();
        if (TextUtils.isEmpty(p14)) {
            p14 = this.f139083m.p();
        }
        hashMap.put("deviceId", p14);
        hashMap.put("manufacturer", Build.MANUFACTURER);
        hashMap.put("brand", Build.BRAND);
        hashMap.put("model", Build.MODEL);
        hashMap.put(IMediaPlayer.OnNativeInvokeListener.ARG_FAMILY, n());
        hashMap.put("modelId", Build.ID);
        hashMap.put("kernelVersion", o());
        hashMap.put(ALPUserTrackConstant.METHOD_BUILD, Build.DISPLAY);
        hashMap.put("name", "Android");
        hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_VERSION, Build.VERSION.RELEASE);
        hashMap.put("androidApiLevel", Integer.valueOf(Build.VERSION.SDK_INT));
        hashMap.put("cpuAbi", f());
        hashMap.put("rooted", Boolean.valueOf(s()));
        hashMap.put(XavFilterDef.FxFlipParams.ORIENTATION, d());
        hashMap.put("networkAccess", i());
        hashMap.put("deviceLevel", Integer.valueOf(this.f139084n.c()));
        return hashMap;
    }

    public long m() {
        long elapsedRealtime = SystemClock.elapsedRealtime();
        long j14 = this.f139075e.get();
        long j15 = (!r() || j14 == 0) ? 0 : elapsedRealtime - j14;
        if (j15 > 0) {
            return j15;
        }
        return 0;
    }

    public final String n() {
        try {
            return Build.MODEL.split(" ")[0];
        } catch (Exception e14) {
            e14.printStackTrace();
            return null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:18:0x002f A[SYNTHETIC, Splitter:B:18:0x002f] */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0036 A[SYNTHETIC, Splitter:B:24:0x0036] */
    public final String o() {
        Throwable th3;
        String property = System.getProperty("os.version");
        BufferedReader bufferedReader = null;
        try {
            File file = new File("/proc/version");
            if (!file.canRead()) {
                return property;
            }
            BufferedReader bufferedReader2 = new BufferedReader(new FileReader(file));
            try {
                String readLine = bufferedReader2.readLine();
                try {
                    bufferedReader2.close();
                } catch (IOException unused) {
                }
                return readLine;
            } catch (Exception unused2) {
                bufferedReader = bufferedReader2;
                if (bufferedReader != null) {
                }
                return property;
            } catch (Throwable th4) {
                th3 = th4;
                bufferedReader = bufferedReader2;
                if (bufferedReader != null) {
                }
                throw th3;
            }
        } catch (Exception unused3) {
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException unused4) {
                }
            }
            return property;
        } catch (Throwable th5) {
            th3 = th5;
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException unused5) {
                }
            }
            throw th3;
        }
    }

    public void onActivityCreated(Activity activity, Bundle bundle) {
        this.f139081k.put(activity.getClass(), activity.getIntent().getExtras());
    }

    public void onActivityDestroyed(Activity activity) {
        this.f139081k.remove(activity.getClass());
    }

    public void onActivityPaused(Activity activity) {
        b bVar = this.f139086p;
        if (bVar != null) {
            bVar.onBeforePageResumeEvent(SystemClock.elapsedRealtime() - this.f139076f.get(), this.f139081k.get(activity.getClass()));
        }
    }

    public void onActivityResumed(Activity activity) {
        this.f139076f.set(SystemClock.elapsedRealtime());
    }

    public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
    }

    public void onActivityStarted(Activity activity) {
        x(g(activity), true, SystemClock.elapsedRealtime());
    }

    public void onActivityStopped(Activity activity) {
        x(g(activity), false, SystemClock.elapsedRealtime());
    }

    public String p() {
        return this.f139088r;
    }

    public void q(g gVar, c cVar, i iVar, d dVar) {
        this.f139082l = iVar;
        this.f139083m = gVar;
        this.f139084n = cVar;
        this.f139087q = dVar;
        this.f139085o = new a();
    }

    public boolean r() {
        return this.f139089s;
    }

    public final boolean s() {
        String str = Build.TAGS;
        if (str != null && str.contains("test-keys")) {
            return true;
        }
        try {
            for (String str2 : f139070t) {
                if (new File(str2).exists()) {
                    return true;
                }
            }
        } catch (Exception unused) {
        }
        return false;
    }

    public void u() {
        f fVar = this.f139077g.get();
        if (fVar != null) {
            w(fVar);
        }
    }

    public final f v(Date date) {
        if (this.f139079i.get() > 4095) {
            this.f139079i.set(0);
        }
        f fVar = new f(wx2.d.a(this.f139078h, wx2.d.b(Long.toHexString(this.f139079i.getAndIncrement()))), date);
        this.f139077g.set(fVar);
        Log.e("SENTRY_SESSION", String.format("startNewSession sessionId=%s", fVar.a()));
        return fVar;
    }

    public final void w(f fVar) {
        if (fVar.b().compareAndSet(false, true)) {
            try {
                nx2.c.b().execute(new j(this, fVar));
            } catch (RejectedExecutionException unused) {
            }
        }
    }

    public final void x(String str, boolean z14, long j14) {
        if (z14) {
            long j15 = 0;
            if (this.f139074d.get() != 0) {
                j15 = j14 - this.f139074d.get();
            }
            if (this.f139071a.isEmpty()) {
                this.f139088r = UUID.randomUUID().toString();
                this.f139075e.set(j14);
                this.f139089s = true;
                b bVar = this.f139086p;
                if (bVar != null) {
                    bVar.onAfterForegroundEvent(j14);
                }
                if (j15 >= this.f139072b) {
                    v(new Date(j14));
                    u();
                    d dVar = this.f139087q;
                    if (dVar != null) {
                        dVar.a(k(), p());
                    }
                }
            }
            this.f139071a.add(str);
            return;
        }
        this.f139071a.remove(str);
        if (this.f139071a.isEmpty()) {
            b bVar2 = this.f139086p;
            if (bVar2 != null) {
                bVar2.onBeforeBackgroundEvent(j14 - this.f139075e.get());
            }
            this.f139089s = false;
            this.f139074d.set(j14);
        }
    }
}