Is there any way to view IMSI and ICCID numbers of my SIM-cards? I didn't find such menu neither in About-Status nor anywhere else.
1 Answer
There are APIs available which apps (like this) use to read SIM information. Looking for CLI solution (refer to this, this and this), we can get IMSI and ICCID with following commands respectively (up to Android 9):
~$ service call iphonesubinfo 7
~$ service call iphonesubinfo 10
* Codes depend on order of methods defined here, which may differ on different Android versions.
* For dual SIM device use code 8
and 11
instead and append i32 2
to command to get second SIM information.
Pass the output through following pipes to convert hexadecimal output to a good looking string:
... | grep -oE '[0-9a-f]{8} ' | while read hex; do echo -ne "\u${hex:4:4}\u${hex:0:4}"; done; echo
Terminal emulator apps usually don't have permission READ_PHONE_STATE
(though you can grant manually with root) which is required by both functions. So commands need to be executed from adb shell
.
Codes 7
/8
correspond to getSubscriberId and 10
/11
to getSimSerialNumber. However both methods have been removed for normal apps usage in Android 10. Only system apps with READ_PRIVILEGED_PHONE_STATE
will be able to get this information. iphonesubinfo
service can't be dumped with dumpsys
either. So root is the only solution on Android 10+.
RIL may also log the operator/SIM related information to logcat
when SIM state changes. With root access it's possible to read telephony database (the component of application framework which interfaces RIL) and also RIL database itself (which interfaces modem). On my Qualcomm device RILD stores information to /data/vendor/radio/qcril.db
including ICCID and MCC/MNC.
~# sqlite3 -line /data/user_de/0/com.android.providers.telephony/databases/telephony.db 'select icc_id,card_id,carrier_name,display_name,mcc,mnc from siminfo'
~# sqlite3 /data/vendor/radio/qcril.db 'select ICCID from qcril_manual_prov_table'
As of Android 9 IMSI is also stored in /data/system/netpolicy.xml
to set mobile data limits for MNOs separately.
~# grep -o 'subscriberId=[^ ]*' /data/system/netpolicy.xml
RELATED:
-
Thanks, finally tried this exceptional answer, it works! Commented Dec 18, 2019 at 19:01
-
One more question: I have 2-SIM phone, but putting the
i32 2
after 8 or 11 doesn't do the job, it gives me the same numbers as w/o this append. Is my command correct? Commented Dec 18, 2019 at 19:04 -
service call iphonesubinfo 11 i32 2 | grep -oE '[0-9a-f]{8} ' | while read hex; do echo -ne "\u${hex:4:4}\u${hex:0:4}"; done; echo
Commented Dec 18, 2019 at 19:04 -
@Suncatcher you may try
i32 1
ori32 0
. For all Android 9 sub-releases order ofgetSubscriberIdForSubscriber
andgetIccSerialNumberForSubscriber
methods is 8 and 11. If it doesn't work then possibly Xiaomi changed the source code. You have to do hit and trial. Commented Dec 19, 2019 at 5:55 -
Well, for IMSI
8 i32 3
works, and for ICCID11 i32 3
gives8938001120308300159F
instead of8938001120308300159
. Probably we should correct regex for extraction of ICCID but I have no idea how. I've never dealt with hex-extract in regex Commented Dec 19, 2019 at 15:30