我在启动设备时正在开发自动PIN/PUK服务.服务在启动时启动.我正在使用ITelephony和反身方法.我的手机是棒棒糖5.1.1,它是一个有根据的连接5.我的清单让Android Studio说"权限只授予系统应用"
我正在使用此代码段:
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
int state = tm.getSimState();
if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED || state == TelephonyManager.SIM_STATE_PUK_REQUIRED)
{
Log.d(TAG,"PIN PUK STATE = " + state );
if (state == TelephonyManager.SIM_STATE_PIN_REQUIRED ){
try {
message += ", PIN Code required" ;
Class clazz = Class.forName(tm.getClass().getName());
if (clazz != null) {
Method m = clazz.getDeclaredMethod("getITelephony");
m.setAccessible(true);
Object iTelephony = m.invoke(tm);
Class params[] = new Class[1];
params[0] = String.class;
Method m2 = iTelephony.getClass().getDeclaredMethod("supplyPin", params);
m2.setAccessible(true);
Object i = m2.invoke(iTelephony, "1111");
Log.d(TAG, …Run Code Online (Sandbox Code Playgroud)