0

I'm trying to check if sim Pin is enabled or not.I'm aiming at 4.2 on wards. I have already tried this:

TelephonyManager manager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
int state = manager.getSimState();
Log.i(TAG,"SIM State is: "+String.valueOf(state));

if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED ||state ==TelephonyManager.SIM_STATE_PUK_REQUIRED)
{
  Log.i(TAG,"Pin required");
}`

but its always returns 5 (SIM_READY_STATE)

I have also tried using reflection

TelephonyManager tm = (TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
Class<?> clazz;
try {
                clazz = Class.forName(tm.getClass().getName());         
                Method m;           
                m = clazz.getDeclaredMethod("getITelephony");               
                m.setAccessible(true);
                ITelephony it =(ITelephony) m.invoke(tm);                   
                if(it.isSimPinEnabled())                    
                    Log.i(TAG,"Pin required");
    }

but this also returns false.

Can someone suggest something here? Please note that mine is a system app.

Edit: If someone can tell me where is this toggle value stored, that will also do. I have seen this link Detect changes of "Lock SIM card" in Settings/Security/Set up SIM card lock but I can't find this particular setting in my settings.db

Community
  • 1
  • 1
Ekta
  • 338
  • 2
  • 9
  • 26
  • see [this](http://stackoverflow.com/questions/5322291/how-to-detect-if-pin-code-is-required-to-unlock-sim) – user3355820 May 08 '14 at 05:41
  • That's exactly what I've given as in the question. They don't work. Anyways thanks for your help. :) – Ekta May 08 '14 at 06:09

0 Answers0