Is it possible to unlock the sim and let the software put in the pincode
Asked Answered
G

1

1

I´m going to give away phones (Android) to clients (mostly kids) and want to create a ´lock´-app. I don´t want the clients to bother with the pincode for the phone, but when you turn on the device, the ´lock´-app should just start. I then overwrite the buttons and they shouldn´t be able to make phonecalls.

Only thing is, in case of removal of the sim, or in case of theft, I want a pincode on the simcard. So is it possible that my ´lock´-app unlocks the sim by putting in the pin by code?

How can I do that?

Gomphosis answered 4/4, 2012 at 20:23 Comment(0)
P
6

That is possible. I do it in this code:

    try {
        @SuppressWarnings("rawtypes")
        Class clazz = Class.forName(telephonyManager.getClass().getName());
        Method m = clazz.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        ITelephony it = (ITelephony) m.invoke(telephonyManager);
        if (it.supplyPin("1234")) {
            // SIM unlocked
        } else {
            // not unlocked
        }

    } catch (Exception e) {
        // 
    }

In order to do that, you need the ITelephony interface. You can find its source here. Make com.android.internal.telephony package in your src folder and put iTelephony.java there. This approach uses *android.permission.MODIFY_PHONE_STATE* permission, which is only available up to Android 2.2. Since version 2.3 this permission is limited to system apps. If you want to use that code in latest version, you have to move your application apk file from /data/app to /system/app folder.

Parthenon answered 29/8, 2012 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.