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.tools.ab; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.mbsignalcommon.windvane.g; import org.json.JSONObject; /* loaded from: classes4.dex */ public class NetWorkStateReceiver extends BroadcastReceiver { private static final String a = "NetWorkStateReceiver"; private WebView b; private int c; public final void a() { this.b = null; } public NetWorkStateReceiver(WebView webView) { this.b = webView; } @Override // android.content.BroadcastReceiver public void onReceive(Context context, Intent intent) { try { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity"); if (connectivityManager == null) { a(this.b, 0); return; } if (com.mbridge.msdk.foundation.same.a.z) { NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetworkInfo == null) { a(this.b, 0); return; } if (activeNetworkInfo.getState() != NetworkInfo.State.CONNECTING && 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 b = ab.b(networkType); this.c = b; a(this.b, b); return; } return; } a(this.b, 0); } catch (Throwable th) { af.a(a, th.getMessage()); } } private void a(WebView webView, int i) { if (webView != null) { try { JSONObject jSONObject = new JSONObject(); jSONObject.put("netstat", i); g.a().a(webView, "onNetstatChanged", Base64.encodeToString(jSONObject.toString().getBytes(), 2)); } catch (Throwable th) { af.a(a, th.getMessage()); } } } }