.class public Lcom/alipay/sdk/app/AuthTask;
.super Ljava/lang/Object;
.source "SourceFile"


# static fields
.field private static final ALIPAY_VERSION_CODE_8_5:I = 0x49

.field static final sLock:Ljava/lang/Object;


# instance fields
.field private mContext:Landroid/app/Activity;

.field private mJumpLoading:Lcom/alipay/sdk/widget/JumpLoading;


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

    .line 50
    const-class v0, Lcom/alipay/sdk/util/PayHelper;

    sput-object v0, Lcom/alipay/sdk/app/AuthTask;->sLock:Ljava/lang/Object;

    return-void
.end method

.method public constructor <init>(Landroid/app/Activity;)V
    .locals 3

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

    .line 53
    iput-object p1, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    .line 54
    invoke-static {}, Lcom/alipay/sdk/sys/GlobalContext;->getInstance()Lcom/alipay/sdk/sys/GlobalContext;

    move-result-object v0

    iget-object v1, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-static {}, Lcom/alipay/sdk/data/MspConfig;->create()Lcom/alipay/sdk/data/MspConfig;

    move-result-object v2

    invoke-virtual {v0, v1, v2}, Lcom/alipay/sdk/sys/GlobalContext;->init(Landroid/content/Context;Lcom/alipay/sdk/data/MspConfig;)V

    .line 55
    invoke-static {p1}, Lcom/alipay/sdk/app/statistic/StatisticManager;->initialze(Landroid/content/Context;)V

    .line 56
    new-instance v0, Lcom/alipay/sdk/widget/JumpLoading;

    const-string v1, "\u53bb\u652f\u4ed8\u5b9d\u6388\u6743"

    invoke-direct {v0, p1, v1}, Lcom/alipay/sdk/widget/JumpLoading;-><init>(Landroid/app/Activity;Ljava/lang/String;)V

    iput-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mJumpLoading:Lcom/alipay/sdk/widget/JumpLoading;

    return-void
.end method

.method static synthetic access$000(Lcom/alipay/sdk/app/AuthTask;)V
    .locals 0

    .line 43
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    return-void
.end method

.method private checkAlipayClient8_5(Landroid/content/Context;)Z
    .locals 3

    const/4 v0, 0x0

    .line 192
    :try_start_0
    invoke-virtual {p1}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object p1

    .line 193
    invoke-static {}, Lcom/alipay/sdk/util/Utils;->getAlipayPkgName()Ljava/lang/String;

    move-result-object v1

    const/16 v2, 0x80

    invoke-virtual {p1, v1, v2}, Landroid/content/pm/PackageManager;->getPackageInfo(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;

    move-result-object p1

    if-nez p1, :cond_0

    return v0

    .line 197
    :cond_0
    iget p1, p1, Landroid/content/pm/PackageInfo;->versionCode:I
    :try_end_0
    .catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    const/16 v1, 0x49

    if-ge p1, v1, :cond_1

    return v0

    :cond_1
    const/4 p1, 0x1

    return p1

    :catch_0
    return v0
.end method

.method private dismissLoading()V
    .locals 1

    .line 83
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mJumpLoading:Lcom/alipay/sdk/widget/JumpLoading;

    if-eqz v0, :cond_0

    .line 84
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mJumpLoading:Lcom/alipay/sdk/widget/JumpLoading;

    invoke-virtual {v0}, Lcom/alipay/sdk/widget/JumpLoading;->dismiss()V

    :cond_0
    return-void
.end method

.method private getAlipayBindListener()Lcom/alipay/sdk/util/PayHelper$IAlipayBindListener;
    .locals 1

    .line 67
    new-instance v0, Lcom/alipay/sdk/app/AuthTask$1;

    invoke-direct {v0, p0}, Lcom/alipay/sdk/app/AuthTask$1;-><init>(Lcom/alipay/sdk/app/AuthTask;)V

    return-object v0
.end method

.method private processAuth(Landroid/app/Activity;Ljava/lang/String;)Ljava/lang/String;
    .locals 2

    .line 113
    new-instance v0, Lcom/alipay/sdk/sys/BizContext;

    iget-object v1, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-direct {v0, v1}, Lcom/alipay/sdk/sys/BizContext;-><init>(Landroid/content/Context;)V

    invoke-virtual {v0, p2}, Lcom/alipay/sdk/sys/BizContext;->format(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p2

    .line 114
    invoke-direct {p0, p1}, Lcom/alipay/sdk/app/AuthTask;->checkAlipayClient8_5(Landroid/content/Context;)Z

    move-result v0

    if-eqz v0, :cond_2

    .line 115
    new-instance v0, Lcom/alipay/sdk/util/PayHelper;

    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->getAlipayBindListener()Lcom/alipay/sdk/util/PayHelper$IAlipayBindListener;

    move-result-object v1

    invoke-direct {v0, p1, v1}, Lcom/alipay/sdk/util/PayHelper;-><init>(Landroid/app/Activity;Lcom/alipay/sdk/util/PayHelper$IAlipayBindListener;)V

    .line 116
    invoke-virtual {v0, p2}, Lcom/alipay/sdk/util/PayHelper;->pay4Client(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    const-string v1, "failed"

    .line 118
    invoke-static {v0, v1}, Landroid/text/TextUtils;->equals(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 119
    invoke-direct {p0, p1, p2}, Lcom/alipay/sdk/app/AuthTask;->startAuthWebpage(Landroid/app/Activity;Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    return-object p1

    .line 120
    :cond_0
    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result p1

    if-eqz p1, :cond_1

    .line 121
    invoke-static {}, Lcom/alipay/sdk/app/Result;->getCancel()Ljava/lang/String;

    move-result-object p1

    return-object p1

    :cond_1
    return-object v0

    .line 126
    :cond_2
    invoke-direct {p0, p1, p2}, Lcom/alipay/sdk/app/AuthTask;->startAuthWebpage(Landroid/app/Activity;Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    return-object p1
.end method

.method private processH5Auth(Lcom/alipay/sdk/protocol/ElementAction;)Ljava/lang/String;
    .locals 3

    .line 165
    invoke-virtual {p1}, Lcom/alipay/sdk/protocol/ElementAction;->getParams()[Ljava/lang/String;

    move-result-object p1

    .line 166
    new-instance v0, Landroid/os/Bundle;

    invoke-direct {v0}, Landroid/os/Bundle;-><init>()V

    const/4 v1, 0x0

    .line 167
    aget-object p1, p1, v1

    const-string v1, "url"

    .line 168
    invoke-virtual {v0, v1, p1}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 170
    new-instance p1, Landroid/content/Intent;

    iget-object v1, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    const-class v2, Lcom/alipay/sdk/app/H5AuthActivity;

    invoke-direct {p1, v1, v2}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 171
    invoke-virtual {p1, v0}, Landroid/content/Intent;->putExtras(Landroid/os/Bundle;)Landroid/content/Intent;

    .line 172
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-virtual {v0, p1}, Landroid/app/Activity;->startActivity(Landroid/content/Intent;)V

    .line 174
    sget-object p1, Lcom/alipay/sdk/app/AuthTask;->sLock:Ljava/lang/Object;

    monitor-enter p1

    .line 176
    :try_start_0
    sget-object v0, Lcom/alipay/sdk/app/AuthTask;->sLock:Ljava/lang/Object;

    invoke-virtual {v0}, Ljava/lang/Object;->wait()V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 180
    :try_start_1
    monitor-exit p1
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 182
    invoke-static {}, Lcom/alipay/sdk/app/Result;->getH5Result()Ljava/lang/String;

    move-result-object p1

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

    move-result v0

    if-eqz v0, :cond_0

    .line 184
    invoke-static {}, Lcom/alipay/sdk/app/Result;->getCancel()Ljava/lang/String;

    move-result-object p1

    :cond_0
    return-object p1

    :catchall_0
    move-exception v0

    goto :goto_0

    .line 178
    :catch_0
    :try_start_2
    invoke-static {}, Lcom/alipay/sdk/app/Result;->getCancel()Ljava/lang/String;

    move-result-object v0

    monitor-exit p1

    return-object v0

    .line 180
    :goto_0
    monitor-exit p1
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v0
.end method

.method private showLoading()V
    .locals 1

    .line 77
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mJumpLoading:Lcom/alipay/sdk/widget/JumpLoading;

    if-eqz v0, :cond_0

    .line 78
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mJumpLoading:Lcom/alipay/sdk/widget/JumpLoading;

    invoke-virtual {v0}, Lcom/alipay/sdk/widget/JumpLoading;->showProgress()V

    :cond_0
    return-void
.end method

.method private startAuthWebpage(Landroid/app/Activity;Ljava/lang/String;)Ljava/lang/String;
    .locals 2

    .line 131
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->showLoading()V

    .line 134
    :try_start_0
    new-instance v0, Lcom/alipay/sdk/packet/impl/AuthPacket;

    invoke-direct {v0}, Lcom/alipay/sdk/packet/impl/AuthPacket;-><init>()V

    .line 135
    invoke-virtual {v0, p1, p2}, Lcom/alipay/sdk/packet/impl/AuthPacket;->request(Landroid/content/Context;Ljava/lang/String;)Lcom/alipay/sdk/packet/Letter;

    move-result-object p1

    .line 136
    invoke-virtual {p1}, Lcom/alipay/sdk/packet/Letter;->getTemplete()Lorg/json/JSONObject;

    move-result-object p1

    const-string p2, "form"

    .line 138
    invoke-virtual {p1, p2}, Lorg/json/JSONObject;->optJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object p1

    const-string p2, "onload"

    .line 139
    invoke-virtual {p1, p2}, Lorg/json/JSONObject;->optJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object p1

    .line 140
    invoke-static {p1}, Lcom/alipay/sdk/protocol/ElementAction;->parse(Lorg/json/JSONObject;)Ljava/util/List;

    move-result-object p1

    .line 142
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    const/4 p2, 0x0

    .line 143
    :goto_0
    invoke-interface {p1}, Ljava/util/List;->size()I

    move-result v0

    if-ge p2, v0, :cond_1

    .line 144
    invoke-interface {p1, p2}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/alipay/sdk/protocol/ElementAction;

    invoke-virtual {v0}, Lcom/alipay/sdk/protocol/ElementAction;->getActionType()Lcom/alipay/sdk/protocol/ActionType;

    move-result-object v0

    sget-object v1, Lcom/alipay/sdk/protocol/ActionType;->WapPay:Lcom/alipay/sdk/protocol/ActionType;

    if-ne v0, v1, :cond_0

    .line 145
    invoke-interface {p1, p2}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object p1

    check-cast p1, Lcom/alipay/sdk/protocol/ElementAction;

    invoke-direct {p0, p1}, Lcom/alipay/sdk/app/AuthTask;->processH5Auth(Lcom/alipay/sdk/protocol/ElementAction;)Ljava/lang/String;

    move-result-object p1
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 154
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    return-object p1

    :cond_0
    add-int/lit8 p2, p2, 0x1

    goto :goto_0

    :catchall_0
    move-exception p1

    goto :goto_2

    :catch_0
    move-exception p1

    :try_start_1
    const-string p2, "biz"

    const-string v0, "H5AuthDataAnalysisError"

    .line 152
    invoke-static {p2, v0, p1}, Lcom/alipay/sdk/app/statistic/StatisticManager;->putError(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 154
    :cond_1
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    const/4 p1, 0x0

    goto :goto_1

    :catch_1
    move-exception p1

    .line 149
    :try_start_2
    sget-object p2, Lcom/alipay/sdk/app/ResultStatus;->NETWORK_ERROR:Lcom/alipay/sdk/app/ResultStatus;

    invoke-virtual {p2}, Lcom/alipay/sdk/app/ResultStatus;->getStatus()I

    move-result p2

    invoke-static {p2}, Lcom/alipay/sdk/app/ResultStatus;->getResultState(I)Lcom/alipay/sdk/app/ResultStatus;

    move-result-object p2

    const-string v0, "net"

    .line 150
    invoke-static {v0, p1}, Lcom/alipay/sdk/app/statistic/StatisticManager;->putError(Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 154
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    move-object p1, p2

    :goto_1
    if-nez p1, :cond_2

    .line 158
    sget-object p1, Lcom/alipay/sdk/app/ResultStatus;->FAILED:Lcom/alipay/sdk/app/ResultStatus;

    invoke-virtual {p1}, Lcom/alipay/sdk/app/ResultStatus;->getStatus()I

    move-result p1

    invoke-static {p1}, Lcom/alipay/sdk/app/ResultStatus;->getResultState(I)Lcom/alipay/sdk/app/ResultStatus;

    move-result-object p1

    .line 160
    :cond_2
    invoke-virtual {p1}, Lcom/alipay/sdk/app/ResultStatus;->getStatus()I

    move-result p2

    invoke-virtual {p1}, Lcom/alipay/sdk/app/ResultStatus;->getMemo()Ljava/lang/String;

    move-result-object p1

    const-string v0, ""

    invoke-static {p2, p1, v0}, Lcom/alipay/sdk/app/Result;->parseResult(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    return-object p1

    .line 154
    :goto_2
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    throw p1
.end method


# virtual methods
.method public declared-synchronized auth(Ljava/lang/String;Z)Ljava/lang/String;
    .locals 2

    monitor-enter p0

    if-eqz p2, :cond_0

    .line 95
    :try_start_0
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->showLoading()V

    goto :goto_0

    :catchall_0
    move-exception p1

    goto :goto_3

    .line 98
    :cond_0
    :goto_0
    invoke-static {}, Lcom/alipay/sdk/sys/GlobalContext;->getInstance()Lcom/alipay/sdk/sys/GlobalContext;

    move-result-object p2

    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-static {}, Lcom/alipay/sdk/data/MspConfig;->create()Lcom/alipay/sdk/data/MspConfig;

    move-result-object v1

    invoke-virtual {p2, v0, v1}, Lcom/alipay/sdk/sys/GlobalContext;->init(Landroid/content/Context;Lcom/alipay/sdk/data/MspConfig;)V

    .line 99
    invoke-static {}, Lcom/alipay/sdk/app/Result;->getCancel()Ljava/lang/String;

    move-result-object p2
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 101
    :try_start_1
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-direct {p0, v0, p1}, Lcom/alipay/sdk/app/AuthTask;->processAuth(Landroid/app/Activity;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    .line 105
    :try_start_2
    invoke-static {}, Lcom/alipay/sdk/data/DynamicConfig;->getInstance()Lcom/alipay/sdk/data/DynamicConfig;

    move-result-object p2

    iget-object v1, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-virtual {p2, v1}, Lcom/alipay/sdk/data/DynamicConfig;->update(Landroid/content/Context;)V

    .line 106
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    .line 107
    iget-object p2, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-static {p2, p1}, Lcom/alipay/sdk/app/statistic/StatisticManager;->submit(Landroid/content/Context;Ljava/lang/String;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    move-object p2, v0

    goto :goto_1

    :catchall_1
    move-exception p2

    goto :goto_2

    :catch_0
    move-exception v0

    .line 103
    :try_start_3
    invoke-static {v0}, Lcom/alipay/sdk/util/LogUtils;->printExceptionStackTrace(Ljava/lang/Object;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 105
    :try_start_4
    invoke-static {}, Lcom/alipay/sdk/data/DynamicConfig;->getInstance()Lcom/alipay/sdk/data/DynamicConfig;

    move-result-object v0

    iget-object v1, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-virtual {v0, v1}, Lcom/alipay/sdk/data/DynamicConfig;->update(Landroid/content/Context;)V

    .line 106
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    .line 107
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-static {v0, p1}, Lcom/alipay/sdk/app/statistic/StatisticManager;->submit(Landroid/content/Context;Ljava/lang/String;)V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    .line 109
    :goto_1
    monitor-exit p0

    return-object p2

    .line 105
    :goto_2
    :try_start_5
    invoke-static {}, Lcom/alipay/sdk/data/DynamicConfig;->getInstance()Lcom/alipay/sdk/data/DynamicConfig;

    move-result-object v0

    iget-object v1, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-virtual {v0, v1}, Lcom/alipay/sdk/data/DynamicConfig;->update(Landroid/content/Context;)V

    .line 106
    invoke-direct {p0}, Lcom/alipay/sdk/app/AuthTask;->dismissLoading()V

    .line 107
    iget-object v0, p0, Lcom/alipay/sdk/app/AuthTask;->mContext:Landroid/app/Activity;

    invoke-static {v0, p1}, Lcom/alipay/sdk/app/statistic/StatisticManager;->submit(Landroid/content/Context;Ljava/lang/String;)V

    throw p2
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    .line 93
    :goto_3
    monitor-exit p0

    throw p1
.end method

.method public declared-synchronized authV2(Ljava/lang/String;Z)Ljava/util/Map;
    .locals 0
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Z)",
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    monitor-enter p0

    .line 89
    :try_start_0
    invoke-virtual {p0, p1, p2}, Lcom/alipay/sdk/app/AuthTask;->auth(Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object p1

    .line 90
    invoke-static {p1}, Lcom/alipay/sdk/util/ResultUtil;->format(Ljava/lang/String;)Ljava/util/Map;

    move-result-object p1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    monitor-exit p0

    return-object p1

    :catchall_0
    move-exception p1

    .line 88
    monitor-exit p0

    throw p1
.end method
