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


package defpackage;

import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import com.umeng.analytics.pro.ak;
import java.io.File;
import java.io.FileInputStream;
import java.net.URLEncoder;
import org.json.JSONException;
import org.json.JSONObject;

/* renamed from: w45  reason: default package */
public class w45 {

    /* renamed from: a  reason: collision with root package name */
    public static String f33857a;

    /* renamed from: b  reason: collision with root package name */
    public static String f33858b;

    /* renamed from: w45$a */
    public class a implements Runnable {

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ Context f33859a;

        public a(Context context) {
            this.f33859a = context;
        }

        public void run() {
            w45.this.e(this.f33859a);
            v45.j(this, 900000);
        }
    }

    /* renamed from: w45$b */
    public static class b {

        /* renamed from: a  reason: collision with root package name */
        public static w45 f33861a = new w45(null);
    }

    public /* synthetic */ w45(a aVar) {
        this();
    }

    public static w45 a() {
        return b.f33861a;
    }

    public static String c(@NonNull Context context) {
        if (!TextUtils.isEmpty(f33857a)) {
            return f33857a;
        }
        String b2 = y45.b(context);
        f33857a = b2;
        return b2;
    }

    public final JSONObject b(Context context) {
        Throwable th;
        FileInputStream fileInputStream;
        String str;
        File file = new File(x45.f + "/" + "_qumeng_remote.jar");
        try {
            if (file.isFile()) {
                fileInputStream = new FileInputStream(file);
                try {
                    str = y45.d(fileInputStream, 0, -1);
                } catch (Throwable th2) {
                    th = th2;
                }
            } else {
                str = "";
                fileInputStream = null;
            }
            String str2 = Build.VERSION.RELEASE;
            if (str2 != null) {
                String str3 = Build.BRAND;
                String str4 = Build.MODEL;
                int i = context.getResources().getDisplayMetrics().heightPixels;
                int i2 = context.getResources().getDisplayMetrics().widthPixels;
                String packageName = context.getPackageName();
                if (!packageName.contains("androidx") && y45.g()) {
                    Log.d("_bootstrap_update", "is androidx");
                }
                String c = c(context);
                if (TextUtils.isEmpty(c)) {
                    if (fileInputStream != null) {
                        try {
                            fileInputStream.close();
                        } catch (Throwable th3) {
                            th3.printStackTrace();
                        }
                    }
                    return null;
                }
                JSONObject jSONObject = new JSONObject();
                d(context);
                jSONObject.put("current_md5", str).put("dsheight", i).put("dswidth", i2).put("brand", str3).put("model", str4).put(ak.y, str2).put("package_name", packageName).put("app_version", c).put("dda", URLEncoder.encode(p45.b("CPC!@#$%Q529! 1*", f33858b)));
                if (fileInputStream != null) {
                    try {
                        fileInputStream.close();
                    } catch (Throwable th4) {
                        th4.printStackTrace();
                    }
                }
                return jSONObject;
            }
            throw new IllegalStateException();
        } catch (Throwable th5) {
            th = th5;
            fileInputStream = null;
            try {
                th.printStackTrace();
                if (fileInputStream != null) {
                    try {
                        fileInputStream.close();
                    } catch (Throwable th6) {
                        th6.printStackTrace();
                    }
                }
                return null;
            } catch (Throwable th7) {
                th7.printStackTrace();
            }
        }
        throw th;
    }

    public void d(Context context) {
        if (TextUtils.isEmpty(f33858b)) {
            try {
                f33858b = Settings.Secure.getString(context.getContentResolver(), "android_id");
            } catch (Throwable unused) {
                f33858b = "";
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:47:0x00e2 A[ADDED_TO_REGION] */
    /* JADX WARNING: Removed duplicated region for block: B:63:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
    public void e(Context context) {
        String str;
        String str2;
        Exception e;
        Exception e2;
        try {
            JSONObject b2 = b(context);
            if (b2 != null) {
                String e3 = y45.e(x45.c, b2.toString());
                if (!TextUtils.isEmpty(e3)) {
                    JSONObject jSONObject = new JSONObject(e3);
                    int i = jSONObject.getInt("action");
                    if (i == 0) {
                        Log.i("_bootstrap_update", "当前是最新版本,无需更新!");
                    } else if (i != 1) {
                        str = null;
                        str2 = null;
                        if (str2 != null && str != null) {
                            try {
                                Log.i("_bootstrap_update", "下载失败,执行上报");
                                Object[] objArr = new Object[6];
                                objArr[0] = "http://tracelog-debug.aiclk.com";
                                objArr[1] = URLEncoder.encode(Build.VERSION.RELEASE, "UTF-8");
                                if (str2 == null) {
                                    str2 = "none";
                                }
                                objArr[2] = URLEncoder.encode(str2, "UTF-8");
                                if (str == null) {
                                    str = "none";
                                }
                                objArr[3] = URLEncoder.encode(str, "UTF-8");
                                objArr[4] = URLEncoder.encode(Build.BRAND, "UTF-8");
                                objArr[5] = URLEncoder.encode(Build.MODEL, "UTF-8");
                                String uri = Uri.parse(String.format("%s?iclicashsid=baadfaad&os=Android&v=%s&op1=%s&t=%s&op2=%s&op3=%s", objArr)).toString();
                                Log.i("_bootstrap_update", "上报url=\"" + uri + "\"");
                                y45.e(uri, null);
                                Log.i("_bootstrap_update", "上报download失败完成");
                            } catch (Exception e4) {
                                e4.printStackTrace();
                                Log.e("_bootstrap_update", "下载失败,执行上报失败!");
                            }
                        }
                    } else {
                        String optString = jSONObject.optString("version");
                        if (TextUtils.isEmpty(optString) || TextUtils.isEmpty(x45.f34262b) || x45.f34262b.compareTo(optString) < 0) {
                            String string = jSONObject.getString("target_url");
                            Log.i("_bootstrap_update", "开始下载 \"" + string + "\"");
                            String c = y45.c(context, string, x45.f, "_qumeng_remote.jar");
                            Log.i("_bootstrap_update", "下载完成");
                            if (!TextUtils.isEmpty(c)) {
                                x45.e(jSONObject);
                                Log.i("_bootstrap_update", "预加载完成");
                                return;
                            }
                            return;
                        }
                        Log.i("_bootstrap_update", "线上版本过低,不下载该版本:version = " + optString + " , sInnerSdkVer = " + x45.f34262b);
                    }
                }
            }
        } catch (JSONException e5) {
            try {
                e5.printStackTrace();
                try {
                    str2 = e5.getMessage();
                    try {
                        str = e5.getClass().getName();
                    } catch (Exception e6) {
                        e2 = e6;
                    }
                } catch (Exception e7) {
                    e2 = e7;
                    str2 = null;
                    try {
                        e2.printStackTrace();
                        str = null;
                    } catch (Exception e8) {
                        e = e8;
                        e.printStackTrace();
                        try {
                            str2 = e.getMessage();
                            str = e.getClass().getName();
                        } catch (Exception e9) {
                            e9.printStackTrace();
                        }
                        if (str2 != null) {
                        }
                    }
                    if (str2 != null) {
                    }
                }
            } catch (Exception e10) {
                e = e10;
                str2 = null;
                e.printStackTrace();
                str2 = e.getMessage();
                str = e.getClass().getName();
                if (str2 != null) {
                }
            }
        }
    }

    public void f(Context context) {
        d(context);
        v45.i(new a(context));
    }

    public w45() {
    }
}