Enabling SIM/RUIM lock using USSD code - Android / Airtel India
<p>I would like to start by mentioning that what I'm trying to achieve is to be used only on those devices which are distributed by us and we have complete ownership on these devices and the applications which run on these devices.</p>

<p>My requirement is to enable "Lock SIM card" under Settings -> Security -> SIM Card Lock Settings on android phones and set/change the SIM lock/unlock pin. All the phones are rooted and are at remote locations. I don't have physical access to these devices but I have remote access to ADB shell.</p>

<p>I came across an USSD code to reset the sim pin. For eg. **04*1234*2345*2345# can be used to change the pin from 1234 to 2345. However if the "Lock SIM card" is disabled in the sim lock settings, the above USSD says "PIN change Unsuccessful, enable SIM/RUIM Lock". </p>

<p>I monitored the logcat output while trying to enable the "Lock SIM card" checkbox manually for pointers on which service is being called and figured out is the task is handled by the method com.android.internal.telephony.IccCard.setIccLockEnabled which is not exposed through SDK. </p>

<p>I am stuck there. Is there any way (USSD/programmatically using reflection/adb shell command) by which I can enable the "Lock SIM card" setting (automatically accepting the popup it shows/disabling the popup if possible) and then set/reset the pin.</p>

<p>Thanks in advance.</p>