package xyz.stream.view;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
import android.view.Window;
import android.view.WindowManager;

/* JADX INFO: loaded from: classes3.dex */
public class BrightnessHelper {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ContentResolver f36212a;

    public BrightnessHelper(Context context) {
        this.f36212a = context.getContentResolver();
    }

    public int getBrightness() {
        return Settings.System.getInt(this.f36212a, "screen_brightness", 255);
    }

    public int getMaxBrightness() {
        return 255;
    }

    public void offAutoBrightness() {
        ContentResolver contentResolver = this.f36212a;
        try {
            if (Settings.System.getInt(contentResolver, "screen_brightness_mode") == 1) {
                Settings.System.putInt(contentResolver, "screen_brightness_mode", 0);
            }
        } catch (Settings.SettingNotFoundException e10) {
            ViewLog.e(e10.getMessage());
        }
    }

    public void setAppBrightness(float f10, Activity activity) {
        Window window = activity.getWindow();
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.screenBrightness = f10;
        window.setAttributes(attributes);
    }

    public void setSystemBrightness(int i10) {
        if (i10 < 0) {
            i10 = 0;
        } else if (i10 > 255) {
            i10 = 255;
        }
        Settings.System.putInt(this.f36212a, "screen_brightness", i10);
    }
}
