抖阴.apk(点击下载) / OpenAuthTask.java


package com.alipay.sdk.app;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Base64;
import com.alipay.sdk.util.e;
import com.alipay.sdk.util.l;
import e.a.b.d.a;
import e.a.b.i.a;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes.dex */
public final class OpenAuthTask {

    /* renamed from: e  reason: collision with root package name */
    private static final Map<String, b> f503e = new ConcurrentHashMap();

    /* renamed from: f  reason: collision with root package name */
    private static long f504f = -1;
    public static final int g = 9000;
    public static final int h = 5000;
    public static final int i = 4001;
    public static final int j = 4000;
    private static final int k = 122;

    /* renamed from: b  reason: collision with root package name */
    private final Activity f505b;

    /* renamed from: c  reason: collision with root package name */
    private b f506c;
    private volatile boolean a = false;

    /* renamed from: d  reason: collision with root package name */
    private final Handler f507d = new Handler(Looper.getMainLooper());

    /* loaded from: classes.dex */
    public enum BizType {
        Invoice("20000920"),
        AccountAuth("20000067"),
        Deduct("60000157");
        
        private String appId;

        BizType(String str) {
            this.appId = str;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static /* synthetic */ class a {
        static final /* synthetic */ int[] a = new int[BizType.values().length];

        static {
            try {
                a[BizType.Deduct.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[BizType.AccountAuth.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[BizType.Invoice.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    /* loaded from: classes.dex */
    public interface b {
        void a(int i, String str, Bundle bundle);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public final class c implements Runnable {
        final Bundle B0;
        final int t;
        final String u;

        /* synthetic */ c(OpenAuthTask openAuthTask, int i, String str, Bundle bundle, a aVar) {
            this(i, str, bundle);
        }

        @Override // java.lang.Runnable
        public void run() {
            if (OpenAuthTask.this.f506c != null) {
                OpenAuthTask.this.f506c.a(this.t, this.u, this.B0);
            }
        }

        private c(int i, String str, Bundle bundle) {
            this.t = i;
            this.u = str;
            this.B0 = bundle;
        }
    }

    public OpenAuthTask(Activity activity) {
        this.f505b = activity;
        e.a.b.i.b.d().a(activity);
    }

    public void a(String str, BizType bizType, Map<String, String> map, b bVar, boolean z) {
        Activity activity = this.f505b;
        String valueOf = String.valueOf(map);
        e.a.b.i.a aVar = new e.a.b.i.a(activity, valueOf, "oa-" + bizType);
        this.f506c = bVar;
        if (a(aVar, str, bizType, map, z)) {
            com.alipay.sdk.app.c.a.b(this.f505b, aVar, "", aVar.f7242d);
        }
    }

    private boolean a(e.a.b.i.a aVar, String str, BizType bizType, Map<String, String> map, boolean z) {
        PackageInfo packageInfo;
        if (this.a) {
            this.f507d.post(new c(this, j, "该 OpenAuthTask 已在执行", null, null));
            return true;
        }
        this.a = true;
        long elapsedRealtime = SystemClock.elapsedRealtime();
        if (elapsedRealtime - f504f <= 3000) {
            this.f507d.post(new c(this, 5000, "3s 内重复支付", null, null));
            return true;
        }
        f504f = elapsedRealtime;
        com.alipay.sdk.app.a.a("");
        String a2 = l.a(32);
        HashMap hashMap = new HashMap(map);
        hashMap.put("mqpPkgName", this.f505b.getPackageName());
        hashMap.put("mqpScene", "sdk");
        List<a.b> o = e.a.b.d.a.p().o();
        if (!e.a.b.d.a.p().g || o == null) {
            o = com.alipay.sdk.app.a.f520d;
        }
        l.b a3 = l.a(aVar, this.f505b, o);
        if (a3 == null || a3.a(aVar) || a3.a() || (packageInfo = a3.a) == null || packageInfo.versionCode < 122) {
            if (z) {
                hashMap.put("mqpScheme", String.valueOf(str));
                hashMap.put("mqpNotifyName", a2);
                hashMap.put("mqpScene", "landing");
                String a4 = a(bizType, hashMap);
                Intent intent = new Intent(this.f505b, H5OpenAuthActivity.class);
                intent.putExtra("url", String.format("https://render.alipay.com/p/s/i?scheme=%s", Uri.encode(a4)));
                a.C0265a.a(aVar, intent);
                this.f505b.startActivity(intent);
                return false;
            }
            this.f507d.post(new c(this, i, "支付宝未安装或签名错误", null, null));
            return true;
        }
        try {
            HashMap<String, String> a5 = e.a.b.i.a.a(aVar);
            a5.put("ts_scheme", String.valueOf(SystemClock.elapsedRealtime()));
            hashMap.put("mqpLoc", new JSONObject(a5).toString());
            String a6 = a(bizType, hashMap);
            f503e.put(a2, this.f506c);
            String str2 = null;
            try {
                str2 = a(elapsedRealtime, a2, bizType, a6);
            } catch (JSONException e2) {
                com.alipay.sdk.app.c.a.a(aVar, com.alipay.sdk.app.c.b.l, com.alipay.sdk.app.c.b.v0, e2);
            }
            String str3 = str2;
            if (TextUtils.isEmpty(str3)) {
                this.f507d.post(new c(this, j, "参数错误", null, null));
                return true;
            }
            Intent intent2 = new Intent("android.intent.action.VIEW", new Uri.Builder().scheme("alipays").authority("platformapi").path("startapp").appendQueryParameter("appId", "20001129").appendQueryParameter("payload", str3).build());
            intent2.addFlags(268435456);
            intent2.setPackage(a3.a.packageName);
            try {
                com.alipay.sdk.app.c.a.b(aVar, com.alipay.sdk.app.c.b.l, com.alipay.sdk.app.c.b.c0, "" + elapsedRealtime);
                a.C0265a.a(aVar, a2);
                this.f505b.startActivity(intent2);
            } catch (Throwable th) {
                com.alipay.sdk.app.c.a.a(aVar, com.alipay.sdk.app.c.b.l, "StartWalletEx", th);
            }
            return false;
        }
    }

    private String a(BizType bizType, Map<String, String> map) {
        if (bizType != null) {
            Uri.Builder appendQueryParameter = new Uri.Builder().scheme("alipays").authority("platformapi").path("startapp").appendQueryParameter("appId", bizType.appId);
            if (a.a[bizType.ordinal()] == 1) {
                appendQueryParameter.appendQueryParameter("appClearTop", "false").appendQueryParameter("startMultApp", "YES");
            }
            for (Map.Entry<String, String> entry : map.entrySet()) {
                appendQueryParameter.appendQueryParameter(entry.getKey(), entry.getValue());
            }
            return appendQueryParameter.build().toString();
        }
        throw new RuntimeException("missing bizType");
    }

    private String a(long j2, String str, BizType bizType, String str2) throws JSONException {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("startTime", String.valueOf(j2));
        jSONObject.put("session", str);
        jSONObject.put("package", this.f505b.getPackageName());
        if (bizType != null) {
            jSONObject.put("appId", bizType.appId);
        }
        jSONObject.put("sdkVersion", "h.a.3.7.7");
        jSONObject.put("mqpURL", str2);
        return Base64.encodeToString(jSONObject.toString().getBytes(Charset.forName("UTF-8")), 2);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static void a(String str, int i2, String str2, Bundle bundle) {
        b remove = f503e.remove(str);
        if (remove != null) {
            try {
                remove.a(i2, str2, bundle);
            } catch (Throwable th) {
                e.a(th);
            }
        }
    }
}