36 lines
1.3 KiB
Java
36 lines
1.3 KiB
Java
package com.ubt.jimu.utils;
|
|
|
|
import android.content.Context;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class NetWorkUtil {
|
|
|
|
public enum NetworkType {
|
|
WIFI,
|
|
MOBILE,
|
|
OTHER,
|
|
NONE_NET
|
|
}
|
|
|
|
public static NetworkType a(Context context) {
|
|
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
|
|
if (connectivityManager == null) {
|
|
return NetworkType.NONE_NET;
|
|
}
|
|
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
|
if (activeNetworkInfo == null) {
|
|
return NetworkType.NONE_NET;
|
|
}
|
|
int type = activeNetworkInfo.getType();
|
|
return type == -1 ? NetworkType.NONE_NET : type == 0 ? NetworkType.MOBILE : type == 1 ? NetworkType.WIFI : NetworkType.OTHER;
|
|
}
|
|
|
|
public static boolean b(Context context) {
|
|
ConnectivityManager connectivityManager;
|
|
NetworkInfo activeNetworkInfo;
|
|
return (context == null || (connectivityManager = (ConnectivityManager) context.getSystemService("connectivity")) == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || !activeNetworkInfo.isConnected()) ? false : true;
|
|
}
|
|
}
|