.class public Lcom/moji/appwidget/skin/DozeUtil;
.super Ljava/lang/Object;
.source "DozeUtil.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/moji/appwidget/skin/DozeUtil$UserSettingListener;
    }
.end annotation


# direct methods
.method public constructor <init>()V
    .locals 0

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

    return-void
.end method

.method public static a(Landroid/app/Activity;Lcom/moji/appwidget/skin/DozeUtil$UserSettingListener;)V
    .locals 6

    .line 54
    invoke-static {p0}, Landroid/view/LayoutInflater;->from(Landroid/content/Context;)Landroid/view/LayoutInflater;

    move-result-object v0

    .line 55
    sget v1, Lcom/moji/appwidget/R$layout;->layout_permission_setting:I

    const/4 v2, 0x0

    invoke-virtual {v0, v1, v2}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v0

    .line 56
    sget v1, Lcom/moji/appwidget/R$id;->rational_text_title:I

    invoke-virtual {v0, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v1

    check-cast v1, Landroid/widget/TextView;

    .line 57
    sget v2, Lcom/moji/appwidget/R$id;->rational_text_content:I

    invoke-virtual {v0, v2}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v2

    check-cast v2, Landroid/widget/TextView;

    .line 58
    sget v3, Lcom/moji/appwidget/R$id;->rational_positive:I

    invoke-virtual {v0, v3}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v3

    check-cast v3, Landroid/widget/TextView;

    .line 59
    sget v4, Lcom/moji/appwidget/R$id;->rational_negative:I

    invoke-virtual {v0, v4}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v4

    check-cast v4, Landroid/widget/TextView;

    .line 60
    sget v5, Lcom/moji/appwidget/R$string;->disable_doze_mode_title:I

    invoke-virtual {v1, v5}, Landroid/widget/TextView;->setText(I)V

    .line 61
    sget v1, Lcom/moji/appwidget/R$string;->disable_doze_mode_content:I

    invoke-virtual {v2, v1}, Landroid/widget/TextView;->setText(I)V

    .line 62
    sget v1, Lcom/moji/appwidget/R$string;->go_doze_setting:I

    invoke-virtual {v3, v1}, Landroid/widget/TextView;->setText(I)V

    .line 63
    sget v1, Lcom/moji/appwidget/R$string;->ignore_doze_setting:I

    invoke-virtual {v4, v1}, Landroid/widget/TextView;->setText(I)V

    .line 64
    new-instance v1, Lcom/moji/dialog/control/MJDialogDefaultControl$Builder;

    invoke-direct {v1, p0}, Lcom/moji/dialog/control/MJDialogDefaultControl$Builder;-><init>(Landroid/content/Context;)V

    invoke-virtual {v1}, Lcom/moji/dialog/control/MJDialogDefaultControl$Builder;->a()Lcom/moji/dialog/MJDialog;

    move-result-object v1

    .line 65
    invoke-virtual {v1, v0}, Lcom/moji/dialog/MJDialog;->setContentView(Landroid/view/View;)V

    const/4 v0, 0x0

    .line 66
    invoke-virtual {v1, v0}, Lcom/moji/dialog/MJDialog;->setCancelable(Z)V

    .line 67
    invoke-virtual {v1, v0}, Lcom/moji/dialog/MJDialog;->setCanceledOnTouchOutside(Z)V

    .line 68
    new-instance v0, Lcom/moji/appwidget/skin/DozeUtil$1;

    invoke-direct {v0, v1, p0}, Lcom/moji/appwidget/skin/DozeUtil$1;-><init>(Lcom/moji/dialog/MJDialog;Landroid/app/Activity;)V

    invoke-virtual {v3, v0}, Landroid/widget/TextView;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 77
    new-instance p0, Lcom/moji/appwidget/skin/DozeUtil$2;

    invoke-direct {p0, v1}, Lcom/moji/appwidget/skin/DozeUtil$2;-><init>(Lcom/moji/dialog/MJDialog;)V

    invoke-virtual {v4, p0}, Landroid/widget/TextView;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    if-eqz p1, :cond_0

    .line 84
    new-instance p0, Lcom/moji/appwidget/skin/DozeUtil$3;

    invoke-direct {p0, p1}, Lcom/moji/appwidget/skin/DozeUtil$3;-><init>(Lcom/moji/appwidget/skin/DozeUtil$UserSettingListener;)V

    invoke-virtual {v1, p0}, Lcom/moji/dialog/MJDialog;->setOnDismissListener(Landroid/content/DialogInterface$OnDismissListener;)V

    :cond_0
    const-wide/16 p0, 0x64

    .line 91
    invoke-static {p0, p1}, Landroid/os/SystemClock;->sleep(J)V

    .line 92
    invoke-virtual {v1}, Lcom/moji/dialog/MJDialog;->show()V

    return-void
.end method

.method public static a(Landroid/content/Context;)V
    .locals 3

    .line 97
    :try_start_0
    new-instance v0, Landroid/content/Intent;

    const-string v1, "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"

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

    .line 98
    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v2, "package:"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;

    .line 99
    invoke-virtual {p0, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    :try_end_0
    .catch Landroid/content/ActivityNotFoundException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception p0

    const-string v0, "DozeUtil"

    .line 108
    invoke-static {v0, p0}, Lcom/moji/tool/log/MJLogger;->a(Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_0

    .line 102
    :catch_1
    :try_start_1
    new-instance v0, Landroid/content/Intent;

    const-string v1, "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"

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

    .line 103
    invoke-virtual {p0, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_2

    goto :goto_0

    :catch_2
    move-exception p0

    const-string v0, "DozeUtil"

    .line 105
    invoke-static {v0, p0}, Lcom/moji/tool/log/MJLogger;->a(Ljava/lang/String;Ljava/lang/Throwable;)V

    :goto_0
    return-void
.end method

.method public static a(Landroid/content/Context;Ljava/lang/String;)Z
    .locals 4

    .line 31
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/4 v1, 0x0

    const/16 v2, 0x17

    if-lt v0, v2, :cond_4

    invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_0

    const-string v0, "org"

    invoke-virtual {p1, v0}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_4

    const-string v0, "ORG"

    invoke-virtual {p1, v0}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z

    move-result p1

    if-nez p1, :cond_4

    .line 32
    :cond_0
    new-instance p1, Lcom/moji/preferences/ProcessPrefer;

    invoke-direct {p1}, Lcom/moji/preferences/ProcessPrefer;-><init>()V

    .line 33
    sget-object v0, Lcom/moji/preferences/ProcessPrefer$KeyConstant;->CHANNEL:Lcom/moji/preferences/ProcessPrefer$KeyConstant;

    const-string v2, "4999"

    invoke-virtual {p1, v0, v2}, Lcom/moji/preferences/ProcessPrefer;->a(Lcom/moji/tool/preferences/core/IPreferKey;Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    const-string v0, "5029"

    invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result p1

    if-eqz p1, :cond_1

    return v1

    .line 37
    :cond_1
    invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object p1

    const-string v0, "power"

    .line 38
    invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/os/PowerManager;

    .line 39
    invoke-virtual {v0, p1}, Landroid/os/PowerManager;->isIgnoringBatteryOptimizations(Ljava/lang/String;)Z

    move-result p1

    .line 41
    new-instance v0, Landroid/content/Intent;

    const-string v2, "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"

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

    .line 42
    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v3, "package:"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v2

    invoke-virtual {v0, v2}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;

    .line 43
    new-instance v2, Landroid/content/Intent;

    const-string v3, "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"

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

    .line 44
    invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v3

    invoke-virtual {v0, v3}, Landroid/content/Intent;->resolveActivity(Landroid/content/pm/PackageManager;)Landroid/content/ComponentName;

    move-result-object v0

    if-eqz v0, :cond_3

    invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object p0

    invoke-virtual {v2, p0}, Landroid/content/Intent;->resolveActivity(Landroid/content/pm/PackageManager;)Landroid/content/ComponentName;

    move-result-object p0

    if-nez p0, :cond_2

    goto :goto_0

    :cond_2
    xor-int/lit8 p0, p1, 0x1

    return p0

    :cond_3
    :goto_0
    return v1

    :cond_4
    return v1
.end method
