val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager
        ?: return "null"

var sim = tm.simSerialNumber ?: "null"

如上所示方法获取sim卡号是获取不到的,需要下面的方法,原因请看源码,这里不做解析了:

val context = Utils.getApp() ?: return "null"
        val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager
                ?: return "null"

        var sim = tm.simSerialNumber ?: "null"
        if ("null" == sim ||sim.length!=20) {
            sim = SystemProp.get("ril.iccid.sim1", "")
        }
        LogUtils.d("getSimSerialNumber: $sim")