Free Fire v1.103.1版本的 MD5 值为:f6c45f9f1485263aa5af0fb400f973fc

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


package g1;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import com.FF.voiceengine.FFVoiceConst;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.zip.GZIPOutputStream;
public class b extends g {
    private static final String f8244b = "b";
    private static String f8245c;
    private static SimpleDateFormat f8246d;
    private static SimpleDateFormat f8247e;
    public static String f8248f;
    public static String f8249g;
    private HashMap<String, ArrayList<c>> f8250a;

    public class a implements Comparator<File> {
        a() {
        }

        @Override
        public int compare(File file, File file2) {
            if (file.lastModified() > file2.lastModified()) {
                return 1;
            }
            return file.lastModified() < file2.lastModified() ? -1 : 0;
        }
    }

    public class C0125b implements Comparator<c> {
        C0125b() {
        }

        @Override
        public int compare(c cVar, c cVar2) {
            long j10 = cVar.f8254b;
            long j11 = cVar2.f8254b;
            if (j10 - j11 > 0) {
                return 1;
            }
            return j10 - j11 < 0 ? -1 : 0;
        }
    }

    public static class c {
        String f8253a;
        long f8254b;
        String f8255c;
        boolean f8256d;
        boolean f8257e;
        String f8258f;
        String f8259g;

        private c(Intent intent) {
            this.f8254b = intent.getLongExtra("time", 0L);
            this.f8255c = intent.getStringExtra("log");
            this.f8253a = b.f8246d.format(new Date(this.f8254b));
            this.f8256d = intent.getBooleanExtra("isFatal", false);
            this.f8257e = intent.getBooleanExtra("forceFlush", false);
            this.f8258f = intent.getStringExtra("file");
            this.f8259g = intent.getStringExtra("dir_path");
        }

        c(Intent intent, a aVar) {
            this(intent);
        }
    }

    static {
        Locale locale = Locale.ENGLISH;
        f8246d = new SimpleDateFormat("yyyy-MM-dd-HH", locale);
        f8247e = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", locale);
        f8248f = "http://203.116.180.99/crash/logs/";
        f8249g = "crashreporter.beetalkmobile.com";
    }

    public b() {
        super("log2file");
        this.f8250a = new HashMap<>();
    }

    private void b(String str) {
        if (TextUtils.isEmpty(str)) {
            String e10 = e();
            Locale locale = Locale.ENGLISH;
            StringBuilder sb = new StringBuilder();
            sb.append(Environment.getExternalStorageDirectory());
            String str2 = File.separator;
            sb.append(str2);
            sb.append("%s");
            sb.append(str2);
            sb.append("logs");
            str = String.format(locale, sb.toString(), e10.toLowerCase(locale));
        }
        f8245c = str;
        File file = new File(f8245c);
        if (file.exists() || !file.mkdirs()) {
            return;
        }
        String str3 = f8244b;
        Log.d(str3, "current dir " + f8245c);
    }

    private void c() {
        File[] listFiles;
        try {
            File file = new File(f8245c);
            if (file.exists() && (listFiles = file.listFiles()) != null && listFiles.length > 168) {
                Arrays.sort(listFiles, new a());
                for (int i10 = 0; i10 < listFiles.length - 168; i10++) {
                    if (listFiles[i10].exists()) {
                        listFiles[i10].delete();
                    }
                }
            }
        } catch (Exception e10) {
            e10.printStackTrace();
        }
    }

    private void d() {
        synchronized (this.f8250a) {
            for (String str : this.f8250a.keySet()) {
                StringBuffer stringBuffer = new StringBuffer();
                ArrayList<c> arrayList = this.f8250a.get(str);
                Collections.sort(arrayList, new C0125b());
                c[] cVarArr = (c[]) arrayList.toArray(new c[0]);
                arrayList.clear();
                for (c cVar : cVarArr) {
                    String format = f8247e.format(new Date(cVar.f8254b));
                    stringBuffer.append('[');
                    stringBuffer.append(format);
                    stringBuffer.append(']');
                    stringBuffer.append('\t');
                    stringBuffer.append(cVar.f8255c);
                    stringBuffer.append('\n');
                }
                FileWriter fileWriter = null;
                try {
                    fileWriter = h(str);
                    fileWriter.append((CharSequence) stringBuffer.toString());
                    Thread.sleep(200L);
                } catch (IOException | InterruptedException unused) {
                    if (fileWriter != null) {
                    }
                } catch (Throwable th) {
                    if (fileWriter != null) {
                        try {
                            fileWriter.close();
                        } catch (IOException unused2) {
                        }
                    }
                    throw th;
                }
                try {
                    fileWriter.close();
                } catch (IOException unused3) {
                }
            }
        }
    }

    private String e() {
        return getString(getApplicationContext().getApplicationInfo().labelRes, Locale.ENGLISH);
    }

    private int f() {
        int i10 = 0;
        for (String str : this.f8250a.keySet()) {
            i10 += this.f8250a.get(str).size();
        }
        return i10;
    }

    private String g(String str) {
        return f8245c + File.separator + str + ".txt";
    }

    private FileWriter h(String str) {
        b(f8245c);
        File file = new File(g(str));
        if (!file.exists()) {
            file.createNewFile();
        }
        return new FileWriter(file, true);
    }

    private static String i(long j10) {
        if (j10 < ((long) FFVoiceConst.FFVoiceEvent.FFVoice_EVENT_EOF)) {
            return j10 + " B";
        }
        double d10 = j10;
        double log = Math.log(d10);
        double d11 = (double) FFVoiceConst.FFVoiceEvent.FFVoice_EVENT_EOF;
        int log2 = (int) (log / Math.log(d11));
        String str = "kMGTPE".charAt(log2 - 1) + "";
        double pow = Math.pow(d11, log2);
        Double.isNaN(d10);
        return String.format("%.1f %sB", Double.valueOf(d10 / pow), str);
    }

    public static void j(Context context, String str, boolean z10, String str2) {
        Intent intent = new Intent(context, b.class);
        intent.putExtra("time", System.currentTimeMillis());
        intent.putExtra("log", str);
        intent.putExtra("forceFlush", z10);
        intent.putExtra("dir_path", str2);
        if (Build.VERSION.SDK_INT >= 26) {
            context.startForegroundService(intent);
        } else {
            context.startService(intent);
        }
    }

    private static boolean k(String str, String str2) {
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
            try {
                h hVar = new h(f8248f, "UTF-8");
                hVar.b("Host", f8249g);
                hVar.a("logfile", new File(str));
                hVar.a("attachment", new File(str2));
                if (hVar.c()) {
                    StringBuffer stringBuffer = new StringBuffer();
                    stringBuffer.append("====\n");
                    stringBuffer.append("post LogFile = " + str);
                    stringBuffer.append('\n');
                    stringBuffer.append("post AttachFile = " + str2);
                    stringBuffer.append("\n done!");
                    Log.i("post", stringBuffer.toString());
                    return true;
                }
            } catch (IOException unused) {
            }
        }
        return false;
    }

    private void l(c cVar) {
        File file = new File(g(cVar.f8253a));
        File file2 = new File(g(f8246d.format(new Date(cVar.f8254b - 3600000))));
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append('\n');
        stringBuffer.append("curFile= " + file.getAbsolutePath() + " exist = " + file.exists() + " size = " + i(file.length()));
        stringBuffer.append('\n');
        stringBuffer.append("preFile= " + file2.getAbsolutePath() + " exist = " + file2.exists() + " size = " + i(file2.length()));
        Log.i("reportToServer", stringBuffer.toString());
        try {
            File file3 = new File(f8245c + File.separator + "report.gz");
            file3.createNewFile();
            GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(new FileOutputStream(file3));
            byte[] bArr = new byte[1024];
            if (file2.exists()) {
                FileInputStream fileInputStream = new FileInputStream(file2);
                while (true) {
                    int read = fileInputStream.read(bArr);
                    if (read <= 0) {
                        break;
                    }
                    gZIPOutputStream.write(bArr, 0, read);
                }
                fileInputStream.close();
            }
            gZIPOutputStream.write("\n ---second_file--- \n".getBytes());
            if (file.exists()) {
                FileInputStream fileInputStream2 = new FileInputStream(file);
                while (true) {
                    int read2 = fileInputStream2.read(bArr);
                    if (read2 <= 0) {
                        break;
                    }
                    gZIPOutputStream.write(bArr, 0, read2);
                }
                fileInputStream2.close();
            }
            gZIPOutputStream.flush();
            gZIPOutputStream.finish();
            gZIPOutputStream.close();
            if (k(cVar.f8258f, file3.getAbsolutePath())) {
                File file4 = new File(cVar.f8258f);
                if (file4.delete()) {
                    Log.i("reportToServer", "file =" + file4.getAbsolutePath() + " deleted");
                }
                if (file3.delete()) {
                    Log.i("reportToServer", "file =" + file3.getAbsolutePath() + " deleted");
                }
            }
        } catch (IOException unused) {
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        d();
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        if (intent == null) {
            return;
        }
        c cVar = new c(intent, null);
        b(cVar.f8259g);
        c();
        if (this.f8250a.get(cVar.f8253a) == null) {
            this.f8250a.put(cVar.f8253a, new ArrayList<>());
        }
        this.f8250a.get(cVar.f8253a).add(cVar);
        if (f() > 16 || cVar.f8256d || cVar.f8257e) {
            d();
        }
        if (cVar.f8256d) {
            l(cVar);
        }
    }
}