219 lines
5.4 KiB
Smali
219 lines
5.4 KiB
Smali
.class public final Lcom/blankj/utilcode/util/BrightnessUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "BrightnessUtils.java"
|
|
|
|
|
|
# direct methods
|
|
.method private constructor <init>()V
|
|
.locals 2
|
|
|
|
.line 20
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
.line 21
|
|
new-instance v0, Ljava/lang/UnsupportedOperationException;
|
|
|
|
const-string v1, "u can\'t instantiate me..."
|
|
|
|
invoke-direct {v0, v1}, Ljava/lang/UnsupportedOperationException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public static getBrightness()I
|
|
.locals 2
|
|
|
|
.line 66
|
|
:try_start_0
|
|
invoke-static {}, Lcom/blankj/utilcode/util/Utils;->getApp()Landroid/app/Application;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroid/app/Application;->getContentResolver()Landroid/content/ContentResolver;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "screen_brightness"
|
|
|
|
.line 65
|
|
invoke-static {v0, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;)I
|
|
|
|
move-result v0
|
|
:try_end_0
|
|
.catch Landroid/provider/Settings$SettingNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
return v0
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
.line 70
|
|
invoke-virtual {v0}, Landroid/provider/Settings$SettingNotFoundException;->printStackTrace()V
|
|
|
|
const/4 v0, 0x0
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public static getWindowBrightness(Landroid/view/Window;)I
|
|
.locals 1
|
|
|
|
const-string v0, "Argument \'window\' of type Window (#0 out of 1, zero-based) is marked by @android.support.annotation.NonNull but got null for it"
|
|
|
|
.line 108
|
|
invoke-static {p0, v0}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
|
|
|
|
.line 109
|
|
invoke-virtual {p0}, Landroid/view/Window;->getAttributes()Landroid/view/WindowManager$LayoutParams;
|
|
|
|
move-result-object p0
|
|
|
|
.line 110
|
|
iget p0, p0, Landroid/view/WindowManager$LayoutParams;->screenBrightness:F
|
|
|
|
const/4 v0, 0x0
|
|
|
|
cmpg-float v0, p0, v0
|
|
|
|
if-gez v0, :cond_0
|
|
|
|
.line 111
|
|
invoke-static {}, Lcom/blankj/utilcode/util/BrightnessUtils;->getBrightness()I
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
|
|
:cond_0
|
|
const/high16 v0, 0x437f0000 # 255.0f
|
|
|
|
mul-float/2addr p0, v0
|
|
|
|
float-to-int p0, p0
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method public static isAutoBrightnessEnabled()Z
|
|
.locals 3
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 32
|
|
:try_start_0
|
|
invoke-static {}, Lcom/blankj/utilcode/util/Utils;->getApp()Landroid/app/Application;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v1}, Landroid/app/Application;->getContentResolver()Landroid/content/ContentResolver;
|
|
|
|
move-result-object v1
|
|
|
|
const-string v2, "screen_brightness_mode"
|
|
|
|
.line 31
|
|
invoke-static {v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;)I
|
|
|
|
move-result v1
|
|
:try_end_0
|
|
.catch Landroid/provider/Settings$SettingNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
const/4 v2, 0x1
|
|
|
|
if-ne v1, v2, :cond_0
|
|
|
|
move v0, v2
|
|
|
|
:cond_0
|
|
return v0
|
|
|
|
:catch_0
|
|
move-exception v1
|
|
|
|
.line 37
|
|
invoke-virtual {v1}, Landroid/provider/Settings$SettingNotFoundException;->printStackTrace()V
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public static setAutoBrightnessEnabled(Z)Z
|
|
.locals 2
|
|
|
|
.line 51
|
|
invoke-static {}, Lcom/blankj/utilcode/util/Utils;->getApp()Landroid/app/Application;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroid/app/Application;->getContentResolver()Landroid/content/ContentResolver;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "screen_brightness_mode"
|
|
|
|
.line 50
|
|
invoke-static {v0, v1, p0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method public static setBrightness(I)Z
|
|
.locals 3
|
|
|
|
.line 83
|
|
invoke-static {}, Lcom/blankj/utilcode/util/Utils;->getApp()Landroid/app/Application;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroid/app/Application;->getContentResolver()Landroid/content/ContentResolver;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "screen_brightness"
|
|
|
|
.line 84
|
|
invoke-static {v0, v1, p0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
|
|
|
|
move-result p0
|
|
|
|
.line 85
|
|
invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;
|
|
|
|
move-result-object v1
|
|
|
|
const/4 v2, 0x0
|
|
|
|
invoke-virtual {v0, v1, v2}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method public static setWindowBrightness(Landroid/view/Window;I)V
|
|
.locals 2
|
|
|
|
const-string v0, "Argument \'window\' of type Window (#0 out of 2, zero-based) is marked by @android.support.annotation.NonNull but got null for it"
|
|
|
|
.line 95
|
|
invoke-static {p0, v0}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
|
|
|
|
.line 97
|
|
invoke-virtual {p0}, Landroid/view/Window;->getAttributes()Landroid/view/WindowManager$LayoutParams;
|
|
|
|
move-result-object v0
|
|
|
|
int-to-float p1, p1
|
|
|
|
const/high16 v1, 0x437f0000 # 255.0f
|
|
|
|
div-float/2addr p1, v1
|
|
|
|
.line 98
|
|
iput p1, v0, Landroid/view/WindowManager$LayoutParams;->screenBrightness:F
|
|
|
|
.line 99
|
|
invoke-virtual {p0, v0}, Landroid/view/Window;->setAttributes(Landroid/view/WindowManager$LayoutParams;)V
|
|
|
|
return-void
|
|
.end method
|