灵犀直播 v1.0.127版本的 MD5 值为:a63989b077d9456fb57c6835ee2849a1

以下内容为反编译后的 c.java 源代码,内容仅作参考


package c.i.c;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import com.taobao.accs.common.Constants;
import com.umeng.analytics.pro.am;
import java.io.File;
import java.lang.ref.WeakReference;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import org.android.spdy.BuildConfig;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class c {
    public static final c f2677a = new c();
    public InterfaceC0080c f2678b;
    public Context f2679c;
    public int f2680d;
    public SharedPreferences f2681e;
    public String f2682f;
    public String f2683g;
    public Handler h;
    public String i;
    public String j;
    public String k;
    public String l;
    public boolean m;
    public long n;
    public long o;
    public String p = null;
    public a q;

    public interface a {
        JSONObject a(String str, Map<String, String> map);
    }

    public static class b extends Handler {
        public final WeakReference<c> f2684a;

        public b(c cVar, Looper looper) {
            super(looper);
            this.f2684a = new WeakReference<>(cVar);
        }

        @Override
        public void handleMessage(Message message) {
            c cVar;
            WeakReference<c> weakReference = this.f2684a;
            if (weakReference == null || (cVar = weakReference.get()) == null) {
                return;
            }
            try {
                if (message.what == 17) {
                    c.i.c.f.a.j(cVar.f2683g, cVar.c(message.arg1, message.arg2));
                }
            } catch (Throwable th) {
                c.i.c.f.b.b(String.format("[SceUpgradeManager.%s] %s", "ReportHandler.handleMessage", th.toString()));
            }
        }
    }

    public interface InterfaceC0080c {
        void a();
    }

    public static class d extends Handler {
        public final WeakReference<c> f2685a;

        public d(c cVar, Looper looper) {
            super(looper);
            this.f2685a = new WeakReference<>(cVar);
        }

        @Override
        public void handleMessage(Message message) {
            c cVar;
            WeakReference<c> weakReference = this.f2685a;
            if (weakReference == null || (cVar = weakReference.get()) == null) {
                return;
            }
            try {
                if (message.what == 1) {
                    cVar.f();
                }
            } catch (Throwable th) {
                c.i.c.f.b.b(String.format("[SceUpgradeManager.%s] %s", "UpgradeHandler.handleMessage", th.toString()));
            }
        }
    }

    public static c q() {
        return f2677a;
    }

    public long a(Context context) {
        return c.i.c.f.a.a(context);
    }

    public File b(Context context, String str) {
        File l = l(context);
        return new File(l, "lib" + str + ".so");
    }

    public final String c(int i, int i2) {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("uid", this.i);
            jSONObject.put("uuid", this.j);
            jSONObject.put("appid", this.k);
            jSONObject.put("appver", "");
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("id", "upgrade");
            jSONObject2.put(am.f4713e, "splayer");
            jSONObject2.put("act", i);
            jSONObject2.put("ret", i2);
            jSONObject2.put("net", this.f2680d);
            jSONObject2.put("osver", URLEncoder.encode(Build.VERSION.RELEASE));
            jSONObject2.put("vendor", URLEncoder.encode(Build.MANUFACTURER));
            jSONObject2.put(Constants.KEY_MODEL, URLEncoder.encode(Build.MODEL));
            jSONObject2.put("lver", this.n);
            jSONObject2.put("sver", this.o);
            JSONArray jSONArray = new JSONArray();
            jSONArray.put(jSONObject2);
            jSONObject.put("el", jSONArray);
            return jSONObject.toString();
        } catch (JSONException unused) {
            return null;
        }
    }

    public final String d(long j) {
        long currentTimeMillis = System.currentTimeMillis() / 1000;
        return String.format("%s&verCode=%s&sdk=%s&aver=%s&tm=%s&sign=%s", this.f2682f, Long.valueOf(j), 50, BuildConfig.VERSION_NAME, Long.valueOf(currentTimeMillis), c.i.c.f.a.m((currentTimeMillis + "player" + BuildConfig.VERSION_NAME).getBytes()));
    }

    public final void f() {
        long a2 = a(this.f2679c);
        long r = r();
        long max = Math.max(a2, r);
        this.n = max;
        c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", "builtinVerCode: " + a2 + ", nowUsingVerCode: " + r + ", requestVerCode: " + max));
        String d2 = d(max);
        StringBuilder sb = new StringBuilder();
        sb.append("requestUrl: ");
        sb.append(d2);
        c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", sb.toString()));
        HashMap hashMap = new HashMap(3);
        hashMap.put("appid", this.k);
        hashMap.put("marketChannelName", this.l);
        hashMap.put("uuid", this.j);
        Log.i("Splayer", "b: " + a2 + ", u: " + r + ", n: " + this.m);
        a aVar = this.q;
        JSONObject a3 = aVar != null ? aVar.a(d2, hashMap) : null;
        if (a3 != null) {
            try {
                long j = a3.getLong("verCode");
                this.o = j;
                if (j == r) {
                    c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", "upgrade none..."));
                } else if (this.m) {
                    c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", "need to download upgrade"));
                    k(a3);
                } else {
                    c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", "no need to download upgrade trigger safe mode"));
                }
            } catch (JSONException e2) {
                c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", e2.toString()));
                o(1, -2);
            }
        } else if (a2 > r) {
            c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", "no need to download upgrade, but need extract builtin"));
            b(this.f2679c, "player").delete();
            p(a2);
        } else {
            c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "checkUpgrade", "no need to download upgrade and extract builtin"));
        }
        n();
    }

    public void g(Context context, int i, String str, String str2, Map<String, String> map, boolean z) {
        this.f2679c = context;
        this.f2680d = i;
        this.p = str;
        this.f2681e = context.getSharedPreferences("Splayer_config", 0);
        this.m = z;
        this.f2682f = String.format("http://%s/api/app/v1/player_upgrade?module=splayer", str);
        HandlerThread handlerThread = new HandlerThread("SceUpgradeThread");
        handlerThread.start();
        d dVar = new d(this, handlerThread.getLooper());
        if (!TextUtils.isEmpty(str2)) {
            this.f2683g = String.format("http://%s/act?tag=plugin&ver=1", str2);
            HandlerThread handlerThread2 = new HandlerThread("SceReportThread");
            handlerThread2.start();
            this.h = new b(this, handlerThread2.getLooper());
        }
        if (map != null && !map.isEmpty()) {
            this.i = map.get("uid");
            this.j = map.get("uuid");
            this.k = map.get("app_id");
            this.l = map.get("app_channel");
        }
        dVar.sendEmptyMessage(1);
    }

    public void h(a aVar) {
        this.q = aVar;
    }

    public void i(InterfaceC0080c interfaceC0080c) {
        this.f2678b = interfaceC0080c;
    }

    public final void k(JSONObject jSONObject) {
        File file = new File(this.f2679c.getCacheDir(), "player.tmp");
        if (file.exists()) {
            file.delete();
        }
        try {
            boolean k = c.i.c.f.a.k(jSONObject.getString("fileUrl"), TextUtils.equals(jSONObject.getString("fileType"), "gz"), file);
            Log.i("Splayer", "downloadRet: " + k);
            if (k) {
                String string = jSONObject.getString("fileMd5");
                Log.i("Splayer", "fileMd5: " + string + ", " + c.i.c.f.a.c(file));
                if (string.equalsIgnoreCase(c.i.c.f.a.c(file))) {
                    boolean renameTo = file.renameTo(b(this.f2679c, "player"));
                    Log.i("Splayer", "renameRet: " + renameTo);
                    if (renameTo) {
                        c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "downloadUpgrade", "download file success"));
                        o(1, 0);
                        p(jSONObject.optLong("verCode"));
                    } else {
                        c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "downloadUpgrade", "download file rename failed"));
                        o(1, -1);
                    }
                } else {
                    c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "downloadUpgrade", "download file with invalid md5"));
                    o(1, -3);
                }
            } else {
                c.i.c.f.b.c(String.format("[SceUpgradeManager.%s] %s", "downloadUpgrade", "download file with failed result"));
                o(1, -1);
            }
        } catch (JSONException e2) {
            c.i.c.f.b.b(String.format("[SceUpgradeManager.%s] %s", "downloadUpgrade", "download with json exception: " + e2.toString()));
            o(1, -2);
        }
    }

    public File l(Context context) {
        File dir = context.getDir("datas", 0);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        return dir;
    }

    public final void n() {
        InterfaceC0080c interfaceC0080c = this.f2678b;
        if (interfaceC0080c != null) {
            interfaceC0080c.a();
        }
    }

    public final void o(int i, int i2) {
        Handler handler = this.h;
        if (handler == null || this.f2683g == null) {
            return;
        }
        handler.obtainMessage(17, i, i2);
    }

    public void p(long j) {
        this.f2681e.edit().putLong("so_version_new", j).apply();
    }

    public final long r() {
        SharedPreferences sharedPreferences;
        if (!b(this.f2679c, "player").exists() || (sharedPreferences = this.f2681e) == null) {
            return 0L;
        }
        return sharedPreferences.getLong("so_version_new", 0L);
    }
}