package com.ys.bdtp.adm.app.tools

import android.net.ConnectivityManager
import android.net.NetworkCapabilities

/**
 * 判断是否联网
 */
fun isNet(cm: ConnectivityManager): Boolean {
    val network = cm.activeNetwork
    val nc = cm.getNetworkCapabilities(network) ?: return false
    val wifi = nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
    val cellular = nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
    return wifi || cellular
}