package p138.p176.p177.p242.p265.p266;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import p000.p001.p002.p003.p004.C0567;
import p138.p176.p177.p242.p246.p253.C4312;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ބ.֏.ŕ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C4765 extends AbstractC4812 {

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public volatile C4754 f14358;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public C4754 f14359;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public C4754 f14360;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final Map<Activity, C4754> f14361;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public Activity f14362;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public volatile C4754 f14363;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public C4754 f14364;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final Object f14365;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public String f14366;

    public C4765(C4974 c4974) {
        super(c4974);
        this.f14365 = new Object();
        this.f14361 = new ConcurrentHashMap();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static String m7987(String str) {
        String[] strArrSplit = str.split("\\.");
        String str2 = strArrSplit.length > 0 ? strArrSplit[strArrSplit.length - 1] : "";
        return str2.length() > 100 ? str2.substring(0, 100) : str2;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m7988(C4754 c4754, Bundle bundle, boolean z) {
        if (bundle == null || c4754 == null || (bundle.containsKey("_sc") && !z)) {
            if (bundle != null && c4754 == null && z) {
                bundle.remove("_sn");
                bundle.remove("_sc");
                bundle.remove("_si");
                return;
            }
            return;
        }
        String str = c4754.f14284;
        if (str != null) {
            bundle.putString("_sn", str);
        } else {
            bundle.remove("_sn");
        }
        String str2 = c4754.f14285;
        if (str2 != null) {
            bundle.putString("_sc", str2);
        } else {
            bundle.remove("_sc");
        }
        bundle.putLong("_si", c4754.f14286);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C4754 m7989(boolean z) {
        m8066();
        mo8008();
        if (!this.f14588.f15015.m8177(C4915.f14911) || !z) {
            return this.f14360;
        }
        C4754 c4754 = this.f14360;
        return c4754 != null ? c4754 : this.f14364;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7990(Activity activity) {
        if (this.f14588.f15015.m8177(C4915.f14911)) {
            synchronized (this.f14365) {
                if (activity != this.f14362) {
                    synchronized (this.f14365) {
                        this.f14362 = activity;
                    }
                    if (this.f14588.f15015.m8177(C4915.f14910) && this.f14588.f15015.m8190().booleanValue()) {
                        this.f14363 = null;
                        C4771 c4771Mo8163 = mo8163();
                        RunnableC4778 runnableC4778 = new RunnableC4778(this);
                        c4771Mo8163.m8482();
                        C0567.m1910(runnableC4778);
                        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4778, "Task exception on worker thread"));
                    }
                }
            }
        }
        if (this.f14588.f15015.m8177(C4915.f14910) && !this.f14588.f15015.m8190().booleanValue()) {
            this.f14358 = this.f14363;
            C4771 c4771Mo81632 = mo8163();
            RunnableC4944 runnableC4944 = new RunnableC4944(this);
            c4771Mo81632.m8482();
            C0567.m1910(runnableC4944);
            c4771Mo81632.m8005(new C4894<>(c4771Mo81632, runnableC4944, "Task exception on worker thread"));
            return;
        }
        m7993(activity, m7998(activity), false);
        C4923 c4923M8057 = m8057();
        if (((C4312) c4923M8057.f14588.f15022) == null) {
            throw null;
        }
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        C4771 c4771Mo81633 = c4923M8057.mo8163();
        RunnableC4969 runnableC4969 = new RunnableC4969(c4923M8057, jElapsedRealtime);
        c4771Mo81633.m8482();
        C0567.m1910(runnableC4969);
        c4771Mo81633.m8005(new C4894<>(c4771Mo81633, runnableC4969, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7991(Activity activity, Bundle bundle) {
        Bundle bundle2;
        if (!this.f14588.f15015.m8190().booleanValue() || bundle == null || (bundle2 = bundle.getBundle("com.google.app_measurement.screen_service")) == null) {
            return;
        }
        this.f14361.put(activity, new C4754(bundle2.getString("name"), bundle2.getString("referrer_name"), bundle2.getLong("id")));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7992(Activity activity, String str, String str2) {
        if (!this.f14588.f15015.m8190().booleanValue()) {
            mo8165().f14449.m8034("setCurrentScreen cannot be called while screen reporting is disabled.");
            return;
        }
        if (this.f14358 == null) {
            mo8165().f14449.m8034("setCurrentScreen cannot be called while no activity active");
            return;
        }
        if (this.f14361.get(activity) == null) {
            mo8165().f14449.m8034("setCurrentScreen must be called with an activity in the activity lifecycle");
            return;
        }
        if (str2 == null) {
            str2 = m7987(activity.getClass().getCanonicalName());
        }
        boolean zM8232 = C4887.m8232(this.f14358.f14285, str2);
        boolean zM82322 = C4887.m8232(this.f14358.f14284, str);
        if (zM8232 && zM82322) {
            mo8165().f14449.m8034("setCurrentScreen cannot be called with the same class and name");
            return;
        }
        if (str != null && (str.length() <= 0 || str.length() > 100)) {
            mo8165().f14449.m8035("Invalid screen name length in setCurrentScreen. Length", Integer.valueOf(str.length()));
            return;
        }
        if (str2 != null && (str2.length() <= 0 || str2.length() > 100)) {
            mo8165().f14449.m8035("Invalid class name length in setCurrentScreen. Length", Integer.valueOf(str2.length()));
            return;
        }
        mo8165().f14452.m8036("Setting current screen to name, class", str == null ? "null" : str, str2);
        C4754 c4754 = new C4754(str, str2, m8167().m8272());
        this.f14361.put(activity, c4754);
        m7993(activity, c4754, true);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7993(Activity activity, C4754 c4754, boolean z) {
        C4754 c47542;
        C4754 c47543 = this.f14358 == null ? this.f14359 : this.f14358;
        if (c4754.f14285 == null) {
            c47542 = new C4754(c4754.f14284, activity != null ? m7987(activity.getClass().getCanonicalName()) : null, c4754.f14286, c4754.f14288);
        } else {
            c47542 = c4754;
        }
        this.f14359 = this.f14358;
        this.f14358 = c47542;
        if (((C4312) this.f14588.f15022) == null) {
            throw null;
        }
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        C4771 c4771Mo8163 = mo8163();
        RunnableC4947 runnableC4947 = new RunnableC4947(this, c47542, c47543, jElapsedRealtime, z);
        c4771Mo8163.m8482();
        C0567.m1910(runnableC4947);
        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4947, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7994(String str, C4754 c4754) {
        mo8008();
        synchronized (this) {
            if (this.f14366 == null || this.f14366.equals(str) || c4754 != null) {
                this.f14366 = str;
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7995(C4754 c4754, boolean z, long j) {
        C4923 c4923M8057 = m8057();
        if (((C4312) this.f14588.f15022) == null) {
            throw null;
        }
        c4923M8057.m8474(SystemClock.elapsedRealtime());
        if (!m8063().m8480(c4754 != null && c4754.f14287, z, j) || c4754 == null) {
            return;
        }
        c4754.f14287 = false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m7996(Activity activity) {
        if (this.f14588.f15015.m8177(C4915.f14911)) {
            synchronized (this.f14365) {
            }
        }
        if (this.f14588.f15015.m8177(C4915.f14910) && !this.f14588.f15015.m8190().booleanValue()) {
            this.f14358 = null;
            C4771 c4771Mo8163 = mo8163();
            RunnableC4783 runnableC4783 = new RunnableC4783(this);
            c4771Mo8163.m8482();
            C0567.m1910(runnableC4783);
            c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4783, "Task exception on worker thread"));
            return;
        }
        C4754 c4754M7998 = m7998(activity);
        this.f14359 = this.f14358;
        this.f14358 = null;
        if (((C4312) this.f14588.f15022) == null) {
            throw null;
        }
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        C4771 c4771Mo81632 = mo8163();
        RunnableC4896 runnableC4896 = new RunnableC4896(this, c4754M7998, jElapsedRealtime);
        c4771Mo81632.m8482();
        C0567.m1910(runnableC4896);
        c4771Mo81632.m8005(new C4894<>(c4771Mo81632, runnableC4896, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final void m7997(Activity activity) {
        synchronized (this.f14365) {
            if (activity == this.f14362) {
                this.f14362 = null;
            }
        }
        if (this.f14588.f15015.m8190().booleanValue()) {
            this.f14361.remove(activity);
        }
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final C4754 m7998(Activity activity) {
        C0567.m1910(activity);
        C4754 c4754 = this.f14361.get(activity);
        if (c4754 == null) {
            C4754 c47542 = new C4754(null, m7987(activity.getClass().getCanonicalName()), m8167().m8272());
            this.f14361.put(activity, c47542);
            c4754 = c47542;
        }
        if (!this.f14588.f15015.m8177(C4915.f14911)) {
        }
        return c4754;
    }

    @Override // p138.p176.p177.p242.p265.p266.AbstractC4812
    /* JADX INFO: renamed from: ޕ */
    public final boolean mo7982() {
        return false;
    }
}
