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

馋奶兔 提交于 2019-12-03 21:47:13

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.

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