package o;

import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicBoolean;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.gc0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class ComponentCallbacks2C1301gc0 implements ComponentCallbacks2 {
    public final Context l;
    public final WeakReference m;
    public final InterfaceC0810bS n;

    /* renamed from: o, reason: collision with root package name */
    public volatile boolean f541o;
    public final AtomicBoolean p;

    public ComponentCallbacks2C1301gc0(C2961y00 c2961y00, Context context) {
        InterfaceC0810bS j7;
        this.l = context;
        this.m = new WeakReference(c2961y00);
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(ConnectivityManager.class);
        if (connectivityManager == null || Co0.l(context, "android.permission.ACCESS_NETWORK_STATE") != 0) {
            j7 = new J7(18);
        } else {
            try {
                j7 = new C3126zm0(connectivityManager, this);
            } catch (Exception unused) {
                j7 = new J7(18);
            }
        }
        this.n = j7;
        this.f541o = j7.f();
        this.p = new AtomicBoolean(false);
    }

    public final void a() {
        if (this.p.getAndSet(true)) {
            return;
        }
        this.l.unregisterComponentCallbacks(this);
        this.n.shutdown();
    }

    @Override // android.content.ComponentCallbacks
    public final void onConfigurationChanged(Configuration configuration) {
        if (((C2961y00) this.m.get()) == null) {
            a();
        }
    }

    @Override // android.content.ComponentCallbacks
    public final void onLowMemory() {
        onTrimMemory(80);
    }

    @Override // android.content.ComponentCallbacks2
    public final void onTrimMemory(int i) {
        Oh0 oh0;
        C2961y00 c2961y00 = (C2961y00) this.m.get();
        if (c2961y00 != null) {
            C00 c00 = (C00) c2961y00.b.getValue();
            if (c00 != null) {
                c00.a.f(i);
                C1254g2 c1254g2 = c00.b;
                synchronized (c1254g2) {
                    if (i >= 10 && i != 20) {
                        c1254g2.c();
                    }
                }
            }
            oh0 = Oh0.a;
        } else {
            oh0 = null;
        }
        if (oh0 == null) {
            a();
        }
    }
}
