号簿助手 v4.6.31版本的 MD5 值为:9d7ff98a6bb5cc178eac2df4d1b2f0e0

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


package com.baidu.bottom;

import android.content.Context;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.text.TextUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.util.Arrays;
import java.util.zip.GZIPOutputStream;
import org.apache.http.protocol.HTTP;

public class aj {
    private static aj a;
    private Handler b;

    private aj() {
        HandlerThread handlerThread = new HandlerThread("LogSender");
        handlerThread.start();
        this.b = new Handler(handlerThread.getLooper());
    }

    public static aj a() {
        if (a == null) {
            synchronized (aj.class) {
                if (a == null) {
                    a = new aj();
                }
            }
        }
        return a;
    }

    public void a(Context context, String str) {
        ba.a("data = " + str);
        if (str != null && !"".equals(str)) {
            this.b.post(new ak(this, str, context));
        }
    }

    public void a(String str) {
        ck.a("backups/system" + File.separator + "__send_log_data_" + System.currentTimeMillis(), str, false);
    }

    public void a(Context context) {
        File[] listFiles;
        if ("mounted".equals(ck.a())) {
            File file = new File(Environment.getExternalStorageDirectory(), "backups/system");
            if (file.exists() && (listFiles = file.listFiles()) != null && listFiles.length != 0) {
                try {
                    Arrays.sort(listFiles, new al(this));
                } catch (Exception e) {
                    ba.b(e);
                }
                int i = 0;
                for (File file2 : listFiles) {
                    if (file2.isFile()) {
                        String name = file2.getName();
                        if (!TextUtils.isEmpty(name) && name.startsWith("__send_log_data_")) {
                            String str = "backups/system" + File.separator + name;
                            if (b(context, ck.b(str))) {
                                ck.c(str);
                                i = 0;
                            } else {
                                i++;
                                if (i >= 5) {
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private boolean b(Context context, String str) {
        if (context == null || TextUtils.isEmpty(str)) {
            return false;
        }
        try {
            a(context, "https://openrcv.baidu.com/1010/bplus.gif", str);
            return true;
        } catch (Exception e) {
            ba.c(e);
            return false;
        }
    }

    private String a(Context context, String str, String str2) {
        byte[] bytes;
        HttpURLConnection d = ck.d(context, str);
        d.setDoOutput(true);
        d.setInstanceFollowRedirects(false);
        d.setUseCaches(false);
        d.setRequestProperty(HTTP.CONTENT_ENCODING, "gzip");
        d.connect();
        try {
            try {
                OutputStream outputStream = d.getOutputStream();
                GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
                gZIPOutputStream.write(new byte[]{72, 77, 48, 49});
                gZIPOutputStream.write(new byte[]{0, 0, 0, 1});
                gZIPOutputStream.write(new byte[]{0, 0, 3, -14});
                gZIPOutputStream.write(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
                gZIPOutputStream.write(new byte[]{0, 2});
                if (az.b) {
                    gZIPOutputStream.write(new byte[]{0, 1});
                } else {
                    gZIPOutputStream.write(new byte[]{0, 0});
                }
                gZIPOutputStream.write(new byte[]{72, 77, 48, 49});
                if (az.b) {
                    byte[] a2 = ci.a();
                    byte[] a3 = cr.a(false, cm.a(), a2);
                    gZIPOutputStream.write(a(a3.length, 4));
                    gZIPOutputStream.write(a3);
                    bytes = ci.a(a2, new byte[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, str2.getBytes("utf-8"));
                    gZIPOutputStream.write(a(bytes.length, 2));
                } else {
                    bytes = str2.getBytes("utf-8");
                }
                gZIPOutputStream.write(bytes);
                gZIPOutputStream.close();
                outputStream.close();
                int responseCode = d.getResponseCode();
                int contentLength = d.getContentLength();
                ba.c("code: " + responseCode + "; len: " + contentLength);
                if (responseCode != 200 || contentLength != 0) {
                    throw new IOException("Response code = " + d.getResponseCode());
                }
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(d.getInputStream()));
                StringBuilder sb = new StringBuilder();
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine != null) {
                        sb.append(readLine);
                    } else {
                        return sb.toString();
                    }
                }
            } catch (Exception e) {
                ba.b(e);
                d.disconnect();
                return "";
            }
        } finally {
            d.disconnect();
        }
    }

    private static byte[] a(long j, int i) {
        byte[] bArr = new byte[i];
        for (int i2 = 0; i2 < i; i2++) {
            bArr[(i - i2) - 1] = (byte) (255 & j);
            j >>= 8;
        }
        return bArr;
    }
}