checkForCarrierPrivileges

mail@pastecode.io avatar
unknown
java
2 years ago
960 B
1
Indexable
Never
private fun checkForCarrierPrivileges() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            val tm = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager

            if (tm.hasCarrierPrivileges()) {
                Toast.makeText(this, "hasCarrierPrivileges = true", Toast.LENGTH_SHORT).show()
                Log.e("ANKUSH", "hasCarrierPrivileges = true")
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                    Log.e("ANKUSH", "tm.uiccCardsInfo = ${tm.uiccCardsInfo}")
                    tm.uiccCardsInfo.forEachIndexed { index, uiccCardInfo ->
                        Log.e("ANKUSH", "forEachIndexed = ${uiccCardInfo.eid}")
                    }
                }

            } else {
                Toast.makeText(this, "hasCarrierPrivileges = false", Toast.LENGTH_SHORT).show()
                Log.e("ANKUSH", "hasCarrierPrivileges = false")
            }
        }
    }