柬埔寨通 v6.1.5版本的 MD5 值为:9b68581ac30883219d6a25858a099d6b

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


package com.qiniu.pili.droid.shortvideo.b;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import anet.channel.strategy.dispatch.DispatchConstants;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONException;
import org.json.JSONObject;

public class g {
    private static boolean a = false;
    private static boolean b = true;
    private static g d;
    private JSONObject c;
    private volatile boolean e = false;
    private Context f;

    public static synchronized g a(Context context) {
        g gVar;
        synchronized (g.class) {
            if (d == null) {
                d = new g(context.getApplicationContext());
            }
            gVar = d;
        }
        return gVar;
    }

    private g(Context context) {
        this.f = context.getApplicationContext();
        String[] strArr = c.a;
        int length = strArr.length;
        int i = 0;
        while (true) {
            if (i >= length) {
                break;
            }
            if (com.qiniu.pili.droid.shortvideo.g.j.j(context).contains(strArr[i])) {
                b = false;
                break;
            }
            i++;
        }
        if (c()) {
            this.c = e();
        } else {
            this.c = g();
        }
    }

    public synchronized void a(String str) {
        try {
            if (this.c.optInt(str) != 1) {
                this.c.put(str, 1);
            }
        } catch (JSONException unused) {
            b("Error on recording function");
        }
    }

    public synchronized void a(int i) {
        try {
            String str = "error_code_" + Integer.toString(i);
            if (this.c.optInt(str) != 1) {
                this.c.put(str, 1);
            }
        } catch (JSONException unused) {
            b("Error on recording error");
        }
    }

    public synchronized void a() {
        b();
        try {
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(this.f.openFileOutput("status.json", 0));
            outputStreamWriter.write(this.c.toString());
            outputStreamWriter.close();
        } catch (IOException unused) {
            b("Error on saving json data");
        }
    }

    private synchronized void b() {
        if (b && !this.e) {
            if (d()) {
                this.e = true;
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        g.this.f();
                        g.this.e = false;
                    }
                }).start();
            }
        }
    }

    private boolean c() {
        return new File(this.f.getFilesDir().getPath() + "/status.json").exists();
    }

    private boolean d() {
        long currentTimeMillis = System.currentTimeMillis();
        try {
            if (this.c.has("createTime")) {
                if (currentTimeMillis - this.c.getLong("createTime") < 86400000) {
                    return false;
                }
            }
            return true;
        } catch (JSONException unused) {
            b("Error on detect file expiration");
            return false;
        }
    }

    private JSONObject e() {
        File file = new File(this.f.getFilesDir().getPath() + "/status.json");
        try {
            StringBuilder sb = new StringBuilder();
            BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    sb.append(readLine);
                    sb.append("\n");
                } else {
                    bufferedReader.close();
                    return new JSONObject(sb.toString());
                }
            }
        } catch (IOException | JSONException unused) {
            b("Error on reading json file");
            return g();
        }
    }

    public void f() {
        try {
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL("https://shortvideo.qiniuapi.com/v1/status/a").openConnection();
            httpsURLConnection.setRequestMethod("POST");
            httpsURLConnection.addRequestProperty("Content-Type", "application/json");
            httpsURLConnection.getOutputStream().write(this.c.toString().getBytes());
            if (httpsURLConnection.getResponseCode() != 200) {
                b("Error on sending status data");
                return;
            }
            if (c()) {
                new File(this.f.getFilesDir().getPath() + "/status.json").delete();
            }
            this.c = g();
        } catch (IOException unused) {
            b("Error on sending status data");
        }
    }

    private JSONObject g() {
        SharedPreferences sharedPreferences = this.f.getSharedPreferences("ShortVideo", 0);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        if (sharedPreferences.getString("SDK_ID", null) == null) {
            edit.putString("SDK_ID", com.qiniu.pili.droid.shortvideo.g.j.c());
            edit.apply();
        }
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("createTime", System.currentTimeMillis());
            jSONObject.put("app_bundle_id", com.qiniu.pili.droid.shortvideo.g.j.g(this.f));
            jSONObject.put("app_name", com.qiniu.pili.droid.shortvideo.g.j.i(this.f));
            jSONObject.put("app_version", com.qiniu.pili.droid.shortvideo.g.j.h(this.f));
            jSONObject.put("device_model", com.qiniu.pili.droid.shortvideo.g.j.b());
            jSONObject.put("os_platform", DispatchConstants.ANDROID);
            jSONObject.put("os_version", Build.VERSION.RELEASE);
            jSONObject.put("sdk_version", "3.0.0");
            jSONObject.put("sdk_id", sharedPreferences.getString("SDK_ID", ""));
        } catch (JSONException unused) {
            b("Error on creating json data");
        }
        return jSONObject;
    }

    private void b(String str) {
        if (a) {
            com.qiniu.pili.droid.shortvideo.g.e.l.e("QosManager", str);
        }
    }
}