package p7;

import android.content.Context;
import android.media.AudioManager;
import com.google.android.gms.internal.ads.ao;
import com.google.android.gms.internal.ads.tn;

/* JADX INFO: loaded from: classes2.dex */
public final class a {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static volatile float f31640c = -1.0f;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static volatile long f31641d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final Object f31642e = new Object();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public boolean f31643a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public float f31644b;

    public static float b(Context context) {
        tn tnVar = ao.f9059rf;
        n7.y yVar = n7.y.f31093e;
        float f10 = 0.0f;
        if (!((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
            AudioManager audioManager = (AudioManager) context.getSystemService("audio");
            if (audioManager == null) {
                return 0.0f;
            }
            int streamMaxVolume = audioManager.getStreamMaxVolume(3);
            int streamVolume = audioManager.getStreamVolume(3);
            if (streamMaxVolume == 0) {
                return 0.0f;
            }
            return streamVolume / streamMaxVolume;
        }
        m7.n nVar = m7.n.C;
        nVar.f30472k.getClass();
        long jCurrentTimeMillis = System.currentTimeMillis();
        long jIntValue = ((Integer) yVar.f31096c.b(ao.f9075sf)).intValue();
        if (f31640c != -1.0f && jCurrentTimeMillis - f31641d < jIntValue) {
            return f31640c;
        }
        synchronized (f31642e) {
            try {
                nVar.f30472k.getClass();
                long jCurrentTimeMillis2 = System.currentTimeMillis();
                if (f31640c != -1.0f && jCurrentTimeMillis2 - f31641d < jIntValue) {
                    return f31640c;
                }
                AudioManager audioManager2 = (AudioManager) context.getSystemService("audio");
                if (audioManager2 == null) {
                    f31640c = 0.0f;
                    f31641d = jCurrentTimeMillis2;
                    return 0.0f;
                }
                int streamMaxVolume2 = audioManager2.getStreamMaxVolume(3);
                int streamVolume2 = audioManager2.getStreamVolume(3);
                if (streamMaxVolume2 != 0) {
                    f10 = streamVolume2 / streamMaxVolume2;
                }
                f31640c = f10;
                f31641d = jCurrentTimeMillis2;
                return f31640c;
            } finally {
            }
        }
    }

    public final synchronized float a() {
        synchronized (this) {
            float f10 = this.f31644b;
            if (f10 >= 0.0f) {
                return f10;
            }
            return 1.0f;
        }
    }
}
