package com.bytedance.sdk.openadsdk.YoT;

import android.content.Context;
import android.media.AudioManager;
import com.bytedance.sdk.openadsdk.utils.DeviceUtils;
/* loaded from: classes2.dex */
public class qsH {
    private final AudioManager YFl;
    private int Sg = -1;
    private boolean tN = false;

    public boolean Sg() {
        if (this.tN) {
            this.tN = false;
            return true;
        }
        return false;
    }

    public int YFl() {
        return this.Sg;
    }

    public void YFl(int i) {
        this.Sg = i;
    }

    public qsH(Context context) {
        this.YFl = (AudioManager) context.getApplicationContext().getSystemService("audio");
    }

    public void YFl(boolean z) {
        YFl(z, false);
    }

    public void YFl(boolean z, boolean z2) {
        if (this.YFl == null) {
            return;
        }
        int i = 0;
        if (z) {
            int DSW = DeviceUtils.DSW();
            if (DSW != 0) {
                this.Sg = DSW;
            } else if (!z2) {
                return;
            }
            YFl(3, 0, 0);
            this.tN = true;
            return;
        }
        int i2 = this.Sg;
        if (i2 == 0) {
            i2 = DeviceUtils.NjR() / 15;
        } else {
            if (i2 == -1) {
                if (!z2) {
                    return;
                }
                i2 = DeviceUtils.NjR() / 15;
            }
            this.Sg = -1;
            YFl(3, i2, i);
            this.tN = true;
        }
        i = 1;
        this.Sg = -1;
        YFl(3, i2, i);
        this.tN = true;
    }

    private void YFl(int i, int i2, int i3) {
        try {
            this.YFl.setStreamVolume(i, i2, i3);
        } catch (Throwable unused) {
        }
    }
}
