手机管家 v7.2.0版本的 MD5 值为:dd92ba71696e35a4b841cd1b5de53cd3

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


package com.tencent.halley.common.downloader_detector;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.tencent.kingkong.database.SQLiteDatabase;
import java.net.InetSocketAddress;
import java.net.Proxy;
import meri.pluginsdk.d;
import tcs.bog;
import tcs.bok;
import tmsdk.common.internal.utils.y;

public class DownloaderApn {
    private static a gig;
    public static String ctX = y.ctX;
    public static String ctY = y.ctY;
    public static String ctZ = y.ctZ;
    public static String cua = y.cua;
    public static String cub = y.cub;
    public static String cuc = y.cuc;
    public static String cud = y.cud;
    public static String cue = y.cue;
    public static String cuf = y.cuf;
    private static volatile boolean ghZ = true;
    public static String gia = SQLiteDatabase.KeyEmpty;
    private static int gib = 0;
    private static boolean gic = false;
    public static String gid = SQLiteDatabase.KeyEmpty;
    public static int gie = 0;
    public static int gif = 0;
    private static BroadcastReceiver gih = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            DownloaderApn.aiK();
            DownloaderApn.aiS();
        }
    };
    private static volatile boolean gii = false;

    public static class PhoneStateMonitor extends PhoneStateListener {
        public void onSignalStrengthsChanged(SignalStrength signalStrength) {
            super.onSignalStrengthsChanged(signalStrength);
            DownloaderApn.gie = DownloaderApn.jV((signalStrength.getGsmSignalStrength() * 2) - 113);
        }
    }

    public interface a {
        void af(int i, String str);
    }

    public static void a(a aVar) {
        gig = aVar;
    }

    public static int aW(int i, int i2) {
        if (Build.VERSION.SDK_INT >= 14) {
            return WifiManager.calculateSignalLevel(i, i2);
        }
        if (i <= -100) {
            return 0;
        }
        if (i >= -55) {
            return i2 - 1;
        }
        return (int) (((i - (-100)) * (i2 - 1)) / 45);
    }

    public static void aiK() {
        ?? equals;
        ConnectivityManager connectivityManager;
        bog.c("DownloaderApn", "updateApn");
        if (gii) {
            return;
        }
        gii = true;
        synchronized (DownloaderApn.class) {
            try {
                String str = gia;
                try {
                    connectivityManager = (ConnectivityManager) bok.agJ().getSystemService("connectivity");
                } catch (Throwable th) {
                    th.printStackTrace();
                    aiL();
                    if (!str.equals(gia) && gig != null) {
                        gig.af(aiQ(), gia);
                    }
                    gii = false;
                }
                if (connectivityManager == null) {
                    aiL();
                    ghZ = false;
                    if (!str.equals(gia) && gig != null) {
                        gig.af(aiQ(), gia);
                    }
                    gii = false;
                    return;
                }
                NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
                if (activeNetworkInfo == null) {
                    aiL();
                    ghZ = false;
                    if (!str.equals(gia) && gig != null) {
                        gig.af(aiQ(), gia);
                    }
                    gii = false;
                    return;
                }
                if (activeNetworkInfo.isConnected()) {
                    ghZ = true;
                } else {
                    ghZ = false;
                }
                int type = activeNetworkInfo.getType();
                if (type == 1) {
                    gib = 1;
                    gic = false;
                    gid = SQLiteDatabase.KeyEmpty;
                    WifiInfo connectionInfo = ((WifiManager) bok.agJ().getSystemService("wifi")).getConnectionInfo();
                    if (connectionInfo.getBSSID() != null) {
                        gif = aW(connectionInfo.getRssi(), 5);
                    }
                    gia = "wifi_" + connectionInfo.getSSID() + "_" + connectionInfo.getBSSID();
                    if (!str.equals(gia) && gig != null) {
                        gig.af(aiQ(), gia);
                    }
                    gii = false;
                    return;
                }
                String extraInfo = activeNetworkInfo.getExtraInfo();
                if (extraInfo == null) {
                    aiL();
                    if (!str.equals(gia) && gig != null) {
                        gig.af(aiQ(), gia);
                    }
                    gii = false;
                    return;
                }
                gia = extraInfo.trim().toLowerCase();
                if (type == 0) {
                    int subtype = activeNetworkInfo.getSubtype();
                    if (subtype == 1 || subtype == 2 || subtype == 4) {
                        gib = 2;
                    } else if (subtype == 13) {
                        gib = 4;
                    } else {
                        gib = 3;
                    }
                }
                if (gia.contains(ctZ)) {
                    gic = true;
                    gid = "10.0.0.172";
                } else if (gia.contains(ctX)) {
                    gic = true;
                    gid = "10.0.0.172";
                } else if (gia.contains(cub)) {
                    gic = true;
                    gid = "10.0.0.172";
                } else if (gia.contains(cud)) {
                    gic = true;
                    gid = "10.0.0.200";
                } else {
                    gic = false;
                    gid = SQLiteDatabase.KeyEmpty;
                }
                if (!str.equals(gia) && gig != null) {
                    gig.af(aiQ(), gia);
                }
                gii = false;
            } catch (Throwable th2) {
                if (!equals.equals(gia) && gig != null) {
                    gig.af(aiQ(), gia);
                }
                gii = false;
                throw th2;
            }
        }
    }

    private static void aiL() {
        gia = SQLiteDatabase.KeyEmpty;
        gib = 0;
        gic = false;
        gid = SQLiteDatabase.KeyEmpty;
    }

    public static Proxy aiM() {
        if (!gic || TextUtils.isEmpty(gid)) {
            return null;
        }
        return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(gid, 80));
    }

    public static boolean aiN() {
        return gib == 1;
    }

    public static boolean aiO() {
        return gib == 2 || gib == 3 || gib == 4;
    }

    public static boolean aiP() {
        return gic;
    }

    public static int aiQ() {
        return gib;
    }

    public static boolean aiR() {
        return ghZ;
    }

    public static void aiS() {
        bog.c("DownloaderApn", "showApnInfo... Apn:" + gia + ",sIsNetworkOk:" + ghZ + ",sNetType:" + gib + ",sIsProxy:" + gic + ",sProxyAddress:" + gid);
    }

    public static boolean aiV() {
        if (aiO()) {
            return b.aji();
        }
        return false;
    }

    public static int jV(int i) {
        if (i <= -105) {
            return 0;
        }
        if (i >= -85) {
            return 5;
        }
        return (int) ((5 * (i - d.j.dKI)) / 20);
    }

    public static void vr() {
        aiK();
        aiS();
        bok.agJ().registerReceiver(gih, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
        TelephonyManager telephonyManager = (TelephonyManager) bok.agJ().getSystemService("phone");
        if (telephonyManager != null) {
            telephonyManager.listen(new PhoneStateMonitor(), 257);
        }
    }
}