PowerMonitor.smali

.class public Laegon/chrome/base/PowerMonitor;
.super Ljava/lang/Object;


# annotations
.annotation runtime Laegon/chrome/base/annotations/JNINamespace;
    value = "base::android"
.end annotation


# static fields
.field static final synthetic $assertionsDisabled:Z

.field private static sInstance:Laegon/chrome/base/PowerMonitor;


# instance fields
.field private mIsBatteryPower:Z


# direct methods
.method static constructor <clinit>()V
    .registers 1

    const-class v0, Laegon/chrome/base/PowerMonitor;

    invoke-virtual {v0}, Ljava/lang/Class;->desiredAssertionStatus()Z

    move-result v0

    if-nez v0, :cond_c

    const/4 v0, 0x1

    :goto_9
    sput-boolean v0, Laegon/chrome/base/PowerMonitor;->$assertionsDisabled:Z

    return-void

    :cond_c
    const/4 v0, 0x0

    goto :goto_9
.end method

.method private constructor <init>()V
    .registers 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method static synthetic access$000(Landroid/content/Intent;)V
    .registers 1

    invoke-static {p0}, Laegon/chrome/base/PowerMonitor;->onBatteryChargingChanged(Landroid/content/Intent;)V

    return-void
.end method

.method public static create()V
    .registers 3

    invoke-static {}, Laegon/chrome/base/ThreadUtils;->assertOnUiThread()V

    sget-object v0, Laegon/chrome/base/PowerMonitor;->sInstance:Laegon/chrome/base/PowerMonitor;

    if-eqz v0, :cond_8

    :goto_7
    return-void

    :cond_8
    invoke-static {}, Laegon/chrome/base/ContextUtils;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    new-instance v1, Laegon/chrome/base/PowerMonitor;

    invoke-direct {v1}, Laegon/chrome/base/PowerMonitor;-><init>()V

    sput-object v1, Laegon/chrome/base/PowerMonitor;->sInstance:Laegon/chrome/base/PowerMonitor;

    new-instance v1, Landroid/content/IntentFilter;

    const-string v2, "android.intent.action.BATTERY_CHANGED"

    invoke-direct {v1, v2}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    const/4 v2, 0x0

    invoke-virtual {v0, v2, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    move-result-object v1

    if-eqz v1, :cond_24

    invoke-static {v1}, Laegon/chrome/base/PowerMonitor;->onBatteryChargingChanged(Landroid/content/Intent;)V

    :cond_24
    new-instance v1, Landroid/content/IntentFilter;

    invoke-direct {v1}, Landroid/content/IntentFilter;-><init>()V

    const-string v2, "android.intent.action.ACTION_POWER_CONNECTED"

    invoke-virtual {v1, v2}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    const-string v2, "android.intent.action.ACTION_POWER_DISCONNECTED"

    invoke-virtual {v1, v2}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    new-instance v2, Laegon/chrome/base/PowerMonitor$1;

    invoke-direct {v2}, Laegon/chrome/base/PowerMonitor$1;-><init>()V

    invoke-virtual {v0, v2, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    goto :goto_7
.end method

.method public static createForTests()V
    .registers 1

    new-instance v0, Laegon/chrome/base/PowerMonitor;

    invoke-direct {v0}, Laegon/chrome/base/PowerMonitor;-><init>()V

    sput-object v0, Laegon/chrome/base/PowerMonitor;->sInstance:Laegon/chrome/base/PowerMonitor;

    return-void
.end method

.method private static isBatteryPower()Z
    .registers 1
    .annotation build Laegon/chrome/base/annotations/CalledByNative;
    .end annotation

    sget-object v0, Laegon/chrome/base/PowerMonitor;->sInstance:Laegon/chrome/base/PowerMonitor;

    if-nez v0, :cond_7

    invoke-static {}, Laegon/chrome/base/PowerMonitor;->create()V

    :cond_7
    sget-object v0, Laegon/chrome/base/PowerMonitor;->sInstance:Laegon/chrome/base/PowerMonitor;

    iget-boolean v0, v0, Laegon/chrome/base/PowerMonitor;->mIsBatteryPower:Z

    return v0
.end method

.method private static native nativeOnBatteryChargingChanged()V
.end method

.method private static onBatteryChargingChanged(Landroid/content/Intent;)V
    .registers 5

    const/4 v0, 0x1

    sget-boolean v1, Laegon/chrome/base/PowerMonitor;->$assertionsDisabled:Z

    if-nez v1, :cond_f

    sget-object v1, Laegon/chrome/base/PowerMonitor;->sInstance:Laegon/chrome/base/PowerMonitor;

    if-nez v1, :cond_f

    new-instance v0, Ljava/lang/AssertionError;

    invoke-direct {v0}, Ljava/lang/AssertionError;-><init>()V

    throw v0

    :cond_f
    const-string v1, "plugged"

    const/4 v2, -0x1

    invoke-virtual {p0, v1, v2}, Landroid/content/Intent;->getIntExtra(Ljava/lang/String;I)I

    move-result v1

    sget-object v2, Laegon/chrome/base/PowerMonitor;->sInstance:Laegon/chrome/base/PowerMonitor;

    const/4 v3, 0x2

    if-eq v1, v3, :cond_23

    if-eq v1, v0, :cond_23

    :goto_1d
    iput-boolean v0, v2, Laegon/chrome/base/PowerMonitor;->mIsBatteryPower:Z

    invoke-static {}, Laegon/chrome/base/PowerMonitor;->nativeOnBatteryChargingChanged()V

    return-void

    :cond_23
    const/4 v0, 0x0

    goto :goto_1d
.end method