package com.mbridge.msdk.advanced.common; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.telephony.TelephonyManager; import android.util.Base64; import android.webkit.WebView; import com.mbridge.msdk.foundation.same.a; import com.mbridge.msdk.foundation.tools.s; import com.mbridge.msdk.foundation.tools.w; import com.mbridge.msdk.mbjscommon.windvane.h; import org.json.JSONObject; public class NetWorkStateReceiver extends BroadcastReceiver { private static final String a = "NetWorkStateReceiver"; private WebView b; private int c; public NetWorkStateReceiver(WebView webView) { this.b = webView; } public void onReceive(Context context, Intent intent) { try { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity"); if (connectivityManager == null) { a(this.b, 0); } else if (a.g) { NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetworkInfo == null) { a(this.b, 0); } else if (activeNetworkInfo.getState() == NetworkInfo.State.CONNECTING) { } else { if (activeNetworkInfo.getState() != NetworkInfo.State.DISCONNECTING) { if (activeNetworkInfo.getType() == 1) { a(this.b, 9); return; } TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone"); if (telephonyManager == null) { a(this.b, 0); return; } int networkType = telephonyManager.getNetworkType(); this.c = networkType; int a2 = s.a(networkType); this.c = a2; a(this.b, a2); } } } else { a(this.b, 0); } } catch (Throwable th) { w.a(a, th.getMessage()); } } public final void a() { this.b = null; } private void a(WebView webView, int i) { if (webView != null) { try { JSONObject jSONObject = new JSONObject(); jSONObject.put("netstat", i); h.a().a(webView, "onNetstatChanged", Base64.encodeToString(jSONObject.toString().getBytes(), 2)); } catch (Throwable th) { w.a(a, th.getMessage()); } } } }