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

倾然丶 夕夏残阳落幕 提交于 2019-12-05 07:21:53

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/10018692/is-it-possible-to-unlock-the-sim-and-let-the-software-put-in-the-pincode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!