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

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


package com.baidu.bottom.service;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.text.TextUtils;
import com.baidu.bottom.ap;
import com.baidu.bottom.aq;
import com.baidu.bottom.az;
import com.baidu.bottom.ba;
import com.baidu.bottom.ci;
import com.baidu.bottom.ck;
import com.baidu.bottom.cr;
import com.baidu.bottom.ct;
import com.baidu.mobstat.StatService;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.security.MessageDigest;
import java.util.ArrayList;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;

public final class BottomManager {
    private static final BottomManager a = new BottomManager();
    private Handler b;
    private volatile boolean c = false;
    private HandlerThread d;
    private Handler e;

    public static BottomManager instance() {
        return a;
    }

    private BottomManager() {
        HandlerThread handlerThread = new HandlerThread("BottomManagerThread");
        handlerThread.start();
        handlerThread.setPriority(10);
        this.b = new Handler(handlerThread.getLooper());
    }

    private void a(Context context) {
        if (!this.c && context != null) {
            if (this.d == null || !this.d.isAlive()) {
                this.d = new HandlerThread("dataAnalyzeThread");
                this.d.start();
                Looper looper = this.d.getLooper();
                if (looper != null) {
                    this.e = new Handler(looper);
                }
            }
            if (this.e != null) {
                this.e.post(new ap(this, context));
                this.c = true;
            }
        }
    }

    public void init(Context context, String str, String str2) {
        try {
            a(context.getApplicationContext());
        } catch (Throwable th) {
        }
        if (az.a) {
            StatService.onErised(context, str2, "Baidu_Erised_UP_Def", "");
        }
        this.b.post(new aq(this, context, str));
    }

    public void a(Context context, String str) {
        b(context, str);
    }

    private void b(Context context, String str) {
        ArrayList arrayList = new ArrayList();
        String a2 = ct.a(context);
        String o = ct.o(context);
        String signature = getSignature(context, context.getPackageName());
        try {
            byte[] a3 = ci.a();
            byte[] b = ci.b();
            String a4 = cr.a(a3);
            String a5 = cr.a(b);
            arrayList.add(new BasicNameValuePair("k", a4));
            arrayList.add(new BasicNameValuePair("iv", a5));
            arrayList.add(new BasicNameValuePair("c", ci.b(a3, b, a2.getBytes())));
            arrayList.add(new BasicNameValuePair("dm", ci.b(a3, b, o.getBytes())));
            arrayList.add(new BasicNameValuePair("ac", ci.b(a3, b, str.getBytes())));
            arrayList.add(new BasicNameValuePair("s", ci.b(a3, b, signature.getBytes())));
            String str2 = "https://datax.baidu.com/xs.gif?" + URLEncodedUtils.format(arrayList, "utf-8");
            ba.a("update req url is:" + str2);
            httpGet(context, str2);
        } catch (Exception e) {
            ba.a(e);
        }
    }

    public String httpGet(Context context, String str) {
        HttpURLConnection d = ck.d(context, str);
        d.setDoOutput(false);
        d.setInstanceFollowRedirects(false);
        d.setUseCaches(false);
        d.setRequestProperty(HTTP.CONTENT_TYPE, "gzip");
        d.connect();
        ba.a("AdUtil.httpGet connected");
        try {
            if (d.getResponseCode() != 200) {
                throw new IOException("http 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();
                }
            }
        } finally {
            d.disconnect();
        }
    }

    public String getSignature(Context context, String str) {
        Signature[] rawSignature = getRawSignature(context, str);
        if (rawSignature == null || rawSignature.length == 0) {
            return null;
        }
        return a(rawSignature[0].toByteArray());
    }

    public Signature[] getRawSignature(Context context, String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 64);
            if (packageInfo != null) {
                return packageInfo.signatures;
            }
            return null;
        } catch (PackageManager.NameNotFoundException e) {
            return null;
        }
    }

    private final String a(byte[] bArr) {
        int i = 0;
        char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.update(bArr);
            byte[] digest = messageDigest.digest();
            char[] cArr2 = new char[digest.length * 2];
            for (byte b : digest) {
                int i2 = i + 1;
                cArr2[i] = cArr[(b >>> 4) & 15];
                i = i2 + 1;
                cArr2[i2] = cArr[b & 15];
            }
            return new String(cArr2);
        } catch (Exception e) {
            ba.a(e);
            return null;
        }
    }
}