最右.apk(点击下载) / a.java


package com.mobile.auth.d;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.os.Build;
import android.text.TextUtils;
import com.mobile.auth.a.b;
import com.mobile.auth.c.e;
import com.mobile.auth.d.e;
import com.mobile.auth.d.i;
import com.nirvana.tools.core.MobileNetRequestManager;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public final class a {

    /* renamed from: a  reason: collision with root package name */
    private static final String f20568a = "a";

    public static /* synthetic */ String a() {
        try {
            return f20568a;
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
            return null;
        }
    }

    public static String a(Context context, String str, String str2, Network network) {
        try {
            return c(context, d.a(context, str, network), str2, network);
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
            return null;
        }
    }

    private String a(Context context, String str, String str2, String str3, Network network, String str4, String str5) {
        try {
            String b2 = b();
            String a2 = g.a(context, str, str2, str3, b2);
            String str6 = f20568a;
            com.mobile.auth.a.a.a(str6, "request params : " + a2);
            String a3 = d.a(context, "https://id6.me/auth/preauth.do", a2, network, str4, str5);
            com.mobile.auth.a.a.a(str6, "request result : " + a3);
            String b3 = b(context, a3, b2, network);
            if (TextUtils.isEmpty(b3)) {
                return "{\"result\":80001,\"msg\":\"请求异常\"}";
            }
            e.a(str5, b3, a2);
            return b3;
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
            return null;
        }
    }

    private static String a(Context context, List<String> list, String str, Network network) {
        for (int i = 0; i < list.size(); i++) {
            try {
                try {
                    String str2 = list.get(i);
                    if (!TextUtils.isEmpty(list.get(i)) && context != null && Build.VERSION.SDK_INT < 21) {
                        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
                        if (connectivityManager.getNetworkInfo(5).getState().compareTo((Enum) NetworkInfo.State.CONNECTED) == 0) {
                            int a2 = e.a(e.b(str2));
                            Class<?> cls = Class.forName("android.net.ConnectivityManager");
                            Class<?> cls2 = Integer.TYPE;
                            ((Boolean) cls.getMethod("requestRouteToHost", cls2, cls2).invoke(connectivityManager, 5, Integer.valueOf(a2))).booleanValue();
                        }
                    }
                    String a3 = a(context, list.get(i), str, network);
                    try {
                        JSONObject jSONObject = !TextUtils.isEmpty(a3) ? new JSONObject(a3) : null;
                        if (jSONObject != null && jSONObject.getInt("result") == 0) {
                            return a3;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            } catch (Throwable th) {
                com.mobile.auth.gatewayauth.a.a(th);
                return null;
            }
        }
        return null;
    }

    public static /* synthetic */ String a(a aVar, Context context, String str, String str2, String str3, Network network, String str4, String str5) {
        try {
            return aVar.a(context, str, str2, str3, network, str4, str5);
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
            return null;
        }
    }

    public static String a(String str, String str2) {
        try {
            return com.mobile.auth.b.a.c(str, str2);
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
            return null;
        }
    }

    private void a(final Context context, final String str, final i.a aVar, final int i, final b bVar) {
        try {
            final Future b2 = i.a().b(aVar);
            i.a().a(new Runnable() {
                /* class com.mobile.auth.d.a.AnonymousClass4 */

                public void run() {
                    Future future;
                    try {
                        b2.get((long) i, TimeUnit.MILLISECONDS);
                        try {
                            Future future2 = b2;
                            if (future2 != null && !future2.isDone()) {
                                future = b2;
                                future.cancel(true);
                            }
                        } catch (Throwable th) {
                            com.mobile.auth.gatewayauth.a.a(th);
                        }
                    } catch (Throwable th2) {
                        Future future3 = b2;
                        if (future3 != null && !future3.isDone()) {
                            b2.cancel(true);
                        }
                        throw th2;
                    }
                }
            });
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
        }
    }

    private String b() {
        try {
            String uuid = UUID.randomUUID().toString();
            if (TextUtils.isEmpty(uuid)) {
                return "";
            }
            String replace = uuid.replace("-", "");
            return replace.length() >= 16 ? replace.substring(0, 16) : replace;
        } catch (Throwable th) {
            try {
                com.mobile.auth.gatewayauth.a.a(th);
                return null;
            } catch (Throwable th2) {
                com.mobile.auth.gatewayauth.a.a(th2);
                return null;
            }
        }
    }

    private String b(Context context, String str, String str2, Network network) {
        try {
            if (TextUtils.isEmpty(str)) {
                return null;
            }
            try {
                JSONObject jSONObject = new JSONObject(str);
                int optInt = jSONObject.optInt("result");
                String optString = jSONObject.optString("data");
                if ((optInt == 0 || optInt == 30002) && !TextUtils.isEmpty(optString)) {
                    String a2 = a(optString, str2);
                    if (!TextUtils.isEmpty(a2)) {
                        try {
                            jSONObject.put("data", new JSONObject(a2));
                        } catch (JSONException e) {
                            e.printStackTrace();
                            jSONObject.put("data", a2);
                        }
                        if (optInt != 30002) {
                            return jSONObject.toString();
                        }
                        ArrayList arrayList = new ArrayList();
                        JSONArray optJSONArray = ((JSONObject) jSONObject.opt("data")).optJSONArray("urls");
                        if (optJSONArray != null) {
                            for (int i = 0; i < optJSONArray.length(); i++) {
                                arrayList.add(optJSONArray.getString(i));
                            }
                        }
                        if (arrayList.isEmpty()) {
                            return null;
                        }
                        return a(context, arrayList, str2, network);
                    }
                }
                return jSONObject.toString();
            } catch (Throwable th) {
                com.mobile.auth.a.a.a(f20568a, "decryptResult error", th);
                return null;
            }
        } catch (Throwable th2) {
            com.mobile.auth.gatewayauth.a.a(th2);
            return null;
        }
    }

    private static String c(Context context, String str, String str2, Network network) {
        try {
            if (TextUtils.isEmpty(str)) {
                return null;
            }
            try {
                JSONObject jSONObject = new JSONObject(str);
                int optInt = jSONObject.optInt("result");
                String optString = jSONObject.optString("data");
                if (optInt == 0 && !TextUtils.isEmpty(optString)) {
                    String a2 = a(optString, str2);
                    if (!TextUtils.isEmpty(a2)) {
                        try {
                            jSONObject.put("data", new JSONObject(a2));
                        } catch (JSONException e) {
                            e.printStackTrace();
                            jSONObject.put("data", a2);
                        }
                    }
                }
                return jSONObject.toString();
            } catch (Throwable th) {
                com.mobile.auth.a.a.a(f20568a, "decryptResult error", th);
                return null;
            }
        } catch (Throwable th2) {
            com.mobile.auth.gatewayauth.a.a(th2);
            return null;
        }
    }

    public void a(final Context context, final String str, final String str2, final String str3, final b bVar) {
        try {
            int i = com.mobile.auth.a.a.f20529b;
            int i2 = i <= 0 ? 10000 : i;
            final String a2 = c.a();
            final String a3 = c.a(context);
            e.a(a2).a(str).b(a3).d("preauth").c(f.f(context)).i(context.getPackageName());
            a(context, a2, new i.a() {
                /* class com.mobile.auth.d.a.AnonymousClass1 */

                public void run() {
                    try {
                        String a2 = a.a(a.this, context, str, str2, str3, null, a3, a2);
                        if (!a()) {
                            com.mobile.auth.a.a.b(context, a2, a2, bVar);
                        }
                    } catch (Throwable th) {
                        com.mobile.auth.gatewayauth.a.a(th);
                    }
                }
            }, i2, bVar);
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
        }
    }

    public void b(final Context context, final String str, final String str2, final String str3, final b bVar) {
        try {
            int i = com.mobile.auth.a.a.f20529b;
            int i2 = i <= 0 ? 10000 : i;
            final String a2 = c.a();
            final String a3 = c.a(context);
            e.a(a2).a(str).b(a3).d("preauth").c(f.f(context)).i(context.getPackageName());
            if (Build.VERSION.SDK_INT >= 21) {
                e eVar = new e();
                eVar.a(context, new e.a() {
                    /* class com.mobile.auth.d.a.AnonymousClass2 */
                    private boolean i = false;
                    private boolean j = false;

                    @Override // com.mobile.auth.d.e.a
                    public synchronized void a() {
                        try {
                            this.i = true;
                            if (!this.j) {
                                com.mobile.auth.c.e.a(a2, "{\"result\":80000,\"msg\":\"请求超时\"}", "");
                                com.mobile.auth.a.a.b(context, "{\"result\":80000,\"msg\":\"请求超时\"}", a2, bVar);
                            }
                        } catch (Throwable th) {
                            com.mobile.auth.gatewayauth.a.a(th);
                        }
                        return;
                    }

                    @Override // com.mobile.auth.d.e.a
                    public synchronized void a(int i2, String str, long j2) {
                        try {
                            if (!this.i) {
                                if (!this.j) {
                                    this.j = true;
                                    com.mobile.auth.c.b a2 = com.mobile.auth.c.e.a(a2);
                                    a2.h("switchToMobile_L  onFail()  expendTime : " + j2).a(i2).f(str).b(j2);
                                    com.mobile.auth.a.a.b(context, h.a(i2, str), a2, bVar);
                                    String a3 = a.a();
                                    com.mobile.auth.a.a.a(a3, "Switching network failed (L), errorMsg :" + str + " , expendTime :" + j2);
                                    return;
                                }
                            }
                            return;
                        } catch (Throwable th) {
                            com.mobile.auth.gatewayauth.a.a(th);
                        }
                    }

                    @Override // com.mobile.auth.d.e.a
                    public void a(Network network, long j2) {
                        try {
                            String a2 = a.a();
                            com.mobile.auth.a.a.a(a2, "Switching network successfully (L) , expendTime :" + j2);
                            if (this.i) {
                                return;
                            }
                            if (!this.j) {
                                com.mobile.auth.c.e.a(a2).b(j2);
                                String a3 = a.a(a.this, context, str, str2, str3, network, a3, a2);
                                synchronized (this) {
                                    if (!this.i) {
                                        if (!this.j) {
                                            this.j = true;
                                            com.mobile.auth.a.a.b(context, a3, a2, bVar);
                                        }
                                    }
                                }
                            }
                        } catch (Throwable th) {
                            com.mobile.auth.gatewayauth.a.a(th);
                        }
                    }
                });
                eVar.a(i2);
                return;
            }
            a(context, a2, new i.a() {
                /* class com.mobile.auth.d.a.AnonymousClass3 */

                public void run() {
                    try {
                        if (new e().a(context, "https://id6.me/auth/preauth.do")) {
                            if (!a()) {
                                String a2 = a.a(a.this, context, str, str2, str3, null, a3, a2);
                                if (!a()) {
                                    com.mobile.auth.a.a.b(context, a2, a2, bVar);
                                }
                            }
                        } else if (!a()) {
                            com.mobile.auth.a.a.b(context, h.a(MobileNetRequestManager.CODE_SWITCH_TIMEOUT, MobileNetRequestManager.MSG_SWITCH_TIMEOUT), a2, bVar);
                        }
                    } catch (Throwable th) {
                        com.mobile.auth.gatewayauth.a.a(th);
                    }
                }
            }, i2, bVar);
        } catch (Throwable th) {
            com.mobile.auth.gatewayauth.a.a(th);
        }
    }
}