OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046

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


package com.excelliance.kxqp.gs.util;

import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Process;
import android.util.Log;
import com.excelliance.kxqp.GameUtil;
import com.excelliance.kxqp.gs.util.ch;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

public class ba {

    public static boolean f11881a = true;

    private static ba f11882b;
    private static String c;
    private static String e;
    private static boolean g;
    private static long h;
    private static String k;
    private static boolean l;
    private Context j;
    private a d = null;
    private long i = 600000;
    private String m = null;
    private int f = Process.myPid();

    public static ba a(Context context) {
        if (f11882b == null) {
            f11882b = new ba(context);
            e = context.getPackageName();
        }
        return f11882b;
    }

    private ba(Context context) {
        this.j = context;
    }

    public void b(Context context) {
        if (Environment.getExternalStorageState().equals("mounted")) {
            c = context.getExternalCacheDir() + File.separator + "log";
        } else {
            c = context.getCacheDir() + File.separator + "log";
        }
        File file = new File(c);
        if (file.exists()) {
            return;
        }
        file.mkdirs();
    }

    public void c(Context context) {
        if (Environment.getExternalStorageState().equals("mounted")) {
            k = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "log";
        } else {
            k = context.getFilesDir().getAbsolutePath() + File.separator + "log";
        }
        File file = new File(k);
        if (file.exists() && file.isDirectory()) {
            return;
        }
        file.mkdirs();
    }

    public void a() {
        if (l) {
            return;
        }
        l = true;
        if (this.d == null) {
            this.d = new a(String.valueOf(this.f), k);
        }
        this.d.a(null, k);
        if (g) {
            return;
        }
        this.d.start();
    }

    public void b() {
        if (this.d != null) {
            if (!g) {
                this.d.a();
                this.d = null;
            }
            l = false;
        }
    }

    public void c() {
        if (g) {
            return;
        }
        h = System.currentTimeMillis();
        g = true;
        if (this.d == null) {
            this.d = new a(String.valueOf(this.f), c);
        }
        this.d.a(c, null);
        if (l) {
            return;
        }
        this.d.start();
    }

    public void d() {
        if (this.d != null) {
            if (!l) {
                this.d.a();
                this.d = null;
            }
            g = false;
        }
    }

    public void e() {
        if (this.m == null || this.m.length() == 0) {
            return;
        }
        File file = new File(this.m);
        Log.d("LogcatHelper", String.format("LogcatHelper/deleteLog:thread(%s) logFile(%s)", Thread.currentThread().getName(), file.getAbsolutePath()));
        if (file.exists()) {
            file.delete();
        }
    }

    public class a extends Thread {

        String f11883a;
        private Process c;
        private String f;
        private BufferedInputStream d = null;
        private volatile boolean e = true;
        private FileOutputStream g = null;
        private FileOutputStream h = null;

        a(String str, String str2) {
            this.f11883a = null;
            this.f = str;
            if (ba.l) {
                this.f11883a = "logcat -v threadtime";
            } else {
                this.f11883a = "logcat";
            }
            Log.d("LogcatHelper", "LogDumper cmds: " + this.f11883a);
        }

        void a(String str, String str2) {
            if (str != null && this.g == null) {
                ba.this.m = str + File.separator + ba.this.e(ba.this.j);
                try {
                    this.g = new FileOutputStream(new File(ba.this.m));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (str2 == null || this.h != null) {
                return;
            }
            try {
                Log.d("LogcatHelper", "initFile dirDebug: " + str2 + "/" + ba.f());
                this.h = new FileOutputStream(new File(str2, "Log-" + ba.f() + ba.this.j.getPackageName() + ".log"), true);
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }

        void a() {
            this.e = false;
        }

        @Override
        public void run() {
            int read;
            try {
                try {
                    if (ba.f11881a) {
                        Runtime.getRuntime().exec("logcat -c");
                    }
                    Runtime.getRuntime().exec("logcat -G 16M");
                    this.c = Runtime.getRuntime().exec(this.f11883a);
                    this.d = new BufferedInputStream(this.c.getInputStream(), 8192);
                    long currentTimeMillis = System.currentTimeMillis();
                    if (this.g != null) {
                        this.g.write("\n\n=================================================================== start ==================================================================\n\n".getBytes());
                        this.g.write(("{" + ck.k(ba.this.j) + com.alipay.sdk.util.i.d).getBytes());
                        this.g.write("\n\n".getBytes());
                        this.g.write(("{" + ck.e(ba.this.j) + com.alipay.sdk.util.i.d).getBytes());
                        this.g.write("\n\n".getBytes());
                        this.g.write(("{" + ck.f(ba.this.j) + com.alipay.sdk.util.i.d).getBytes());
                        this.g.write("\n\n".getBytes());
                        this.g.write(("{" + ck.j() + com.alipay.sdk.util.i.d).getBytes());
                        this.g.write("\n\n".getBytes());
                    }
                    if (this.h != null) {
                        this.h.write("\n\n=================================================================== start d ==================================================================\n\n".getBytes());
                        this.h.write(("{" + ck.k(ba.this.j) + com.alipay.sdk.util.i.d).getBytes());
                        this.h.write("\n\n".getBytes());
                        this.h.write(("{" + ck.e(ba.this.j) + com.alipay.sdk.util.i.d).getBytes());
                        this.h.write("\n\n".getBytes());
                        this.h.write(("{" + ck.f(ba.this.j) + com.alipay.sdk.util.i.d).getBytes());
                        this.h.write("\n\n".getBytes());
                        this.h.write(("{" + ck.j() + com.alipay.sdk.util.i.d).getBytes());
                        this.h.write("\n\n".getBytes());
                    }
                    byte[] bArr = new byte[4096];
                    while (true) {
                        if (!this.e || (((read = this.d.read(bArr, 0, 4096)) == -1 || currentTimeMillis - ba.h >= ba.this.i) && !ba.l)) {
                            break;
                        }
                        if (!this.e) {
                            while (read > 0) {
                                try {
                                    if (this.g != null) {
                                        this.g.write(bArr, 0, read);
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                try {
                                    if (ba.l && this.h != null) {
                                        this.h.write(bArr, 0, read);
                                    }
                                } catch (Exception e2) {
                                    e2.printStackTrace();
                                }
                                int available = this.d.available();
                                if (available > 0) {
                                    BufferedInputStream bufferedInputStream = this.d;
                                    if (available >= 4096) {
                                        available = 4096;
                                    }
                                    read = bufferedInputStream.read(bArr, 0, available);
                                } else {
                                    read = 0;
                                }
                            }
                        } else if (read == -1 || read == 0) {
                            try {
                                if (ba.l && this.h != null) {
                                    String str = this.c + "";
                                    if (str != null && str.contains("hasExited=true") && read == -1) {
                                        try {
                                            q.a(this.d);
                                            if (this.c != null) {
                                                this.c.destroy();
                                            }
                                        } catch (Exception unused) {
                                        }
                                        Runtime.getRuntime().exec("logcat -c");
                                        Thread.sleep(500L);
                                        this.c = Runtime.getRuntime().exec(this.f11883a);
                                        this.d = new BufferedInputStream(this.c.getInputStream(), 8192);
                                        Thread.sleep(500L);
                                    }
                                }
                            } catch (Exception e3) {
                                e3.printStackTrace();
                            }
                        } else {
                            try {
                                if (this.g != null) {
                                    this.g.write(bArr, 0, read);
                                }
                            } catch (Exception e4) {
                                e4.printStackTrace();
                            }
                            try {
                                if (ba.l && this.h != null) {
                                    this.h.write(bArr, 0, read);
                                    if (this.d.available() <= 0) {
                                        Thread.sleep(1000L);
                                        this.d.available();
                                    }
                                }
                            } catch (Exception e5) {
                                e5.printStackTrace();
                            }
                            currentTimeMillis = System.currentTimeMillis();
                        }
                    }
                    if (this.g != null) {
                        this.g.write("\n\n=================================================================== e n d ===========================================\n\n".getBytes());
                    }
                } catch (IOException e6) {
                    e6.printStackTrace();
                }
            } catch (Throwable th) {
                if (this.c != null) {
                    this.c.destroy();
                    this.c = null;
                }
                q.a(this.d);
                q.a(this.g);
                q.a(this.h);
                throw th;
            }
        }
    }

    public String e(Context context) {
        String str;
        try {
            Bundle bundle = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData;
            str = bundle.getInt("MainChId") + "_" + bundle.getInt("SubChId") + "_GMS_" + GameUtil.g(context) + "_";
        } catch (Exception e2) {
            e2.printStackTrace();
            str = "";
        }
        return str + new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date(System.currentTimeMillis())) + ".txt";
    }

    public static String f() {
        return new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis()));
    }

    public void d(Context context) {
        if (this.m == null) {
            return;
        }
        Log.d("LogcatHelper", String.format("LogcatHelper/reportLog:thread(%s)", Thread.currentThread().getName()));
        StringBuilder sb = new StringBuilder("http://log.ourplay.com.cn/gmslog.php");
        try {
            sb.append("?&brand=" + URLEncoder.encode(Build.BRAND, "UTF-8").replaceAll("\\+", "%20"));
            sb.append("&manufacturer=" + URLEncoder.encode(Build.MANUFACTURER, "UTF-8").replaceAll("\\+", "%20"));
            sb.append("&model=" + URLEncoder.encode(Build.MODEL, "UTF-8").replaceAll("\\+", "%20"));
            sb.append("&plugininstall=yes");
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        try {
            File file = new File(this.m);
            this.m = null;
            if (!file.exists()) {
                Log.d("LogcatHelper", String.format("LogcatHelper/reportLog:thread(%s) file(%s) not exist", Thread.currentThread().getName(), file.getAbsolutePath()));
                return;
            }
            HashMap hashMap = new HashMap();
            hashMap.put(file.getName(), file);
            ch.a a2 = ch.a("http://log.ourplay.com.cn/gmslog.php", null, hashMap);
            if (a2.f11960a == 1) {
                Log.d("LogcatHelper", String.format("LogcatHelper/reportLog:thread(%s) filePath(%s) success", Thread.currentThread().getName(), file.getAbsolutePath()));
            } else {
                Log.d("LogcatHelper", String.format("LogcatHelper/reportLog:thread(%s) filePath(%s) fail msg(%s)", Thread.currentThread().getName(), file.getAbsolutePath(), a2.f11961b));
            }
        } catch (Exception e3) {
            e3.printStackTrace();
        }
    }
}