小红书.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.alibaba.baichuan.android.trade.AlibcTrade;
import com.alipay.sdk.data.a;
import com.alipay.sdk.sys.a;
import com.alipay.sdk.sys.b;
import com.alipay.sdk.util.c;
import com.alipay.sdk.util.k;
import com.huawei.hms.support.api.entity.common.CommonConstant;
import com.tencent.wcdb.database.SQLiteDatabase;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.cybergarage.upnp.std.av.server.object.SearchCriteria;
import org.json.JSONException;
import org.json.JSONObject;

public final class OpenAuthTask {
    public static final int Duplex = 5000;
    public static final int NOT_INSTALLED = 4001;
    public static final int OK = 9000;
    public static final int SYS_ERR = 4000;

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

    /* renamed from: b  reason: collision with root package name */
    private static long f17969b = -1;

    /* renamed from: c  reason: collision with root package name */
    private static final int f17970c = 122;

    /* renamed from: d  reason: collision with root package name */
    private volatile boolean f17971d = false;

    /* renamed from: e  reason: collision with root package name */
    private final Activity f17972e;

    /* renamed from: f  reason: collision with root package name */
    private Callback f17973f;

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

    /* renamed from: com.alipay.sdk.app.OpenAuthTask$1  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass1 {

        /* renamed from: a  reason: collision with root package name */
        public static final /* synthetic */ int[] f17975a;

        /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|(3:5|6|8)) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0012 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001d */
        static {
            int[] iArr = new int[BizType.values().length];
            f17975a = iArr;
            iArr[BizType.Deduct.ordinal()] = 1;
            f17975a[BizType.AccountAuth.ordinal()] = 2;
            try {
                f17975a[BizType.Invoice.ordinal()] = 3;
            } catch (NoSuchFieldError unused) {
            }
        }
    }

    public enum BizType {
        Invoice("20000920"),
        AccountAuth("20000067"),
        Deduct("60000157");
        
        private String appId;

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

    public interface Callback {
        void onResult(int i10, String str, Bundle bundle);
    }

    public final class a implements Runnable {

        /* renamed from: a  reason: collision with root package name */
        public final int f17976a;

        /* renamed from: b  reason: collision with root package name */
        public final String f17977b;

        /* renamed from: c  reason: collision with root package name */
        public final Bundle f17978c;

        public /* synthetic */ a(OpenAuthTask openAuthTask, int i10, String str, Bundle bundle, AnonymousClass1 r53) {
            this(i10, str, bundle);
        }

        public void run() {
            if (OpenAuthTask.this.f17973f != null) {
                OpenAuthTask.this.f17973f.onResult(this.f17976a, this.f17977b, this.f17978c);
            }
        }

        private a(int i10, String str, Bundle bundle) {
            this.f17976a = i10;
            this.f17977b = str;
            this.f17978c = bundle;
        }
    }

    public OpenAuthTask(Activity activity) {
        this.f17972e = activity;
        b.a().a(activity);
    }

    public void execute(String str, BizType bizType, Map<String, String> map, Callback callback, boolean z14) {
        Activity activity = this.f17972e;
        String valueOf = String.valueOf(map);
        com.alipay.sdk.sys.a aVar = new com.alipay.sdk.sys.a(activity, valueOf, "oa-" + bizType);
        this.f17973f = callback;
        if (a(aVar, str, bizType, map, z14)) {
            com.alipay.sdk.app.statistic.a.b(this.f17972e, aVar, "", aVar.f18257q);
        }
    }

    private boolean a(com.alipay.sdk.sys.a aVar, String str, BizType bizType, Map<String, String> map, boolean z14) {
        PackageInfo packageInfo;
        if (this.f17971d) {
            this.f17974g.post(new a(this, 4000, "该 OpenAuthTask 已在执行", null, null));
            return true;
        }
        this.f17971d = true;
        long elapsedRealtime = SystemClock.elapsedRealtime();
        if (elapsedRealtime - f17969b <= 3000) {
            this.f17974g.post(new a(this, 5000, "3s 内重复支付", null, null));
            return true;
        }
        f17969b = elapsedRealtime;
        a.a("");
        String a14 = k.a(32);
        HashMap hashMap = new HashMap(map);
        hashMap.put("mqpPkgName", this.f17972e.getPackageName());
        hashMap.put("mqpScene", "sdk");
        List<a.C0289a> o14 = com.alipay.sdk.data.a.p().o();
        if (!com.alipay.sdk.data.a.p().f18163a || o14 == null) {
            o14 = a.f18013a;
        }
        k.a a15 = k.a(aVar, this.f17972e, o14);
        if (a15 != null && !a15.a(aVar) && !a15.a() && (packageInfo = a15.f18345a) != null && packageInfo.versionCode >= 122) {
            try {
                HashMap<String, String> a16 = com.alipay.sdk.sys.a.a(aVar);
                a16.put("ts_scheme", String.valueOf(SystemClock.elapsedRealtime()));
                hashMap.put("mqpLoc", new JSONObject(a16).toString());
            } catch (Throwable unused) {
                this.f17974g.post(new a(this, 4000, "业务参数错误", null, null));
                return true;
            }
            String a17 = a(bizType, hashMap);
            f17968a.put(a14, this.f17973f);
            String str2 = null;
            try {
                str2 = a(elapsedRealtime, a14, bizType, a17);
            } catch (JSONException e14) {
                com.alipay.sdk.app.statistic.a.a(aVar, com.alipay.sdk.app.statistic.b.f18057b, com.alipay.sdk.app.statistic.b.f18048al, e14);
            }
            if (TextUtils.isEmpty(str2)) {
                this.f17974g.post(new a(this, 4000, AlibcTrade.ERRMSG_PARAM_ERROR, null, null));
                return true;
            }
            Intent intent = new Intent(CommonConstant.ACTION.HWID_SCHEME_URL, new Uri.Builder().scheme("alipays").authority("platformapi").path(com.igexin.push.core.b.f25387o).appendQueryParameter("appId", "20001129").appendQueryParameter("payload", str2).build());
            intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
            intent.setPackage(a15.f18345a.packageName);
            try {
                com.alipay.sdk.app.statistic.a.b(aVar, com.alipay.sdk.app.statistic.b.f18057b, com.alipay.sdk.app.statistic.b.S, "" + elapsedRealtime);
                a.C0291a.a(aVar, a14);
                this.f17972e.startActivity(intent);
            } catch (Throwable th3) {
                com.alipay.sdk.app.statistic.a.a(aVar, com.alipay.sdk.app.statistic.b.f18057b, "StartWalletEx", th3);
            }
            return false;
        } else if (z14) {
            hashMap.put("mqpScheme", String.valueOf(str));
            hashMap.put("mqpNotifyName", a14);
            hashMap.put("mqpScene", "landing");
            String a18 = a(bizType, hashMap);
            Intent intent2 = new Intent(this.f17972e, H5OpenAuthActivity.class);
            intent2.putExtra("url", String.format("https://render.alipay.com/p/s/i?scheme=%s", Uri.encode(a18)));
            a.C0291a.a(aVar, intent2);
            this.f17972e.startActivity(intent2);
            return false;
        } else {
            this.f17974g.post(new a(this, 4001, "支付宝未安装或签名错误", null, null));
            return true;
        }
    }

    private String a(BizType bizType, Map<String, String> map) {
        if (bizType != null) {
            Uri.Builder appendQueryParameter = new Uri.Builder().scheme("alipays").authority("platformapi").path(com.igexin.push.core.b.f25387o).appendQueryParameter("appId", bizType.appId);
            if (AnonymousClass1.f17975a[bizType.ordinal()] == 1) {
                appendQueryParameter.appendQueryParameter("appClearTop", SearchCriteria.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 j14, String str, BizType bizType, String str2) throws JSONException {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("startTime", String.valueOf(j14));
        jSONObject.put("session", str);
        jSONObject.put("package", this.f17972e.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);
    }

    public static void a(String str, int i10, String str2, Bundle bundle) {
        Callback remove = f17968a.remove(str);
        if (remove != null) {
            try {
                remove.onResult(i10, str2, bundle);
            } catch (Throwable th3) {
                c.a(th3);
            }
        }
    }
}