Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

When switching on the phone, one is by default asked to enter the SIM-PIN -- which is a good security measure, to prevent "strangers" from causing you costs. Now the same applies when returning from airplane mode: one has to enter the SIM-PIN again. Which renders certain energy-savers useless: if an app e.g. enters airplane mode on signal loss (see: What is Cell standby and how can I keep it from eating my battery?), it would be unable to return to normal operation without user interaction.

I'm looking for a way to selectively disable this: Have the PIN request active when powering up the device -- but not being asked for the SIM-PIN when returning from airplane mode.

Please do not confuse this with "keyguard": I'm not asking about the screen lock (PIN/pattern/password). Here I know my way around, as there is an API for apps to use (so I can e.g. temporarily turn this off with Tasker).

I know this works with Samsung devices -- but I preferably want a device independent solution which works for all manufacturers.

share|improve this question
2  
Really! Let me quote from above question: I'm looking for a way to selectively disable this -- not to completely disable the check. I know it can be completely disabled (which is what I currently use) -- but I want to disable it only for switching back from Airplane mode, not for device startup. –  Izzy Oct 2 '12 at 13:38

3 Answers 3

up vote 1 down vote accepted

DISCLAIMER

  1. This needs root. No way around that one.
  2. Your device must be running Android 4.1+
  3. This workaround may be too advanced for some users. Only try to apply it when you know what you're doing.
  4. I'm not to be held responsible if something goes awry or Ragnarök starts during the process. You're doing this on your own risk. Proceed with caution.
  5. I'm not the author of or otherwise affiliated with any of the mods mentioned. I merely found this and I'm sharing it for your benefit.

WORKAROUND

I found a workaround for the problem that's working beautifully on a Samsung Galaxy S2 with Cyanogenmod 10.2 and Dorimanx Kernel 9.41 installed. The necessary steps are as follows:

  1. Make sure your device is rooted.

  2. Download and install Xposed Framework Installer.

  3. When Xposed asks for root anywhere in the near future, grant it.

  4. Open the app and click on Framework -Tab.

  5. Click Install/Update.

  6. Reboot.

  7. Download and install Jelly Bean 4.x Airplane Mode Helper.

  8. Open Xposed Framework Installer-App again and select Modules.

  9. Tick (set active) Jelly Bean 4.x Airplane Mode Helper.

  10. Reboot.

  11. Open Jelly Bean 4.x Airplane Mode Helper.

  12. Tick (set active) Enabled.

  13. Reboot.

That's it! Airplane Mode should work again as in previous Android versions and does not ask for SIM-PIN any longer when being turned off. It still does at startup, though, thus keeping your SIM-Card somewhat safe. I set up an automated battery saving procedure with Llama Location Profiles similar to the one described here (Thx a bunch, Izzy) and it's working flawlessly.

Good luck, folks!

share|improve this answer
1  
Thanks a lot for your answer! I've just edited it to improve formatting (lists) and added the fact it requires JB+. As my devices are not yet running JB, I cannot test it – but I suspect you might have missed the most important part of the question (at least you do not mention it): Does it ask for the SIM-PIN when returning from Airplane mode – or can that be skipped this way? –  Izzy Sep 27 '13 at 9:31
1  
Rest assured, I completely got your problem and my answer is exactly what you've been looking for ;) - it does not ask for the SIM-PIN when returning from Airplane Mode, but it still does at boot. Thus, your security is being kept but your battery saving script is working again. Thanks for the formatting upgrade! –  FuzzyQ Sep 27 '13 at 9:35
    
I added the most important information as you were right - I totally forgot to mention the fact that this does in fact remove the need to unlock your SIM again after airplane mode. –  FuzzyQ Sep 27 '13 at 9:40
1  
In this case, it is exactly what I was after: Automated jobs do work without manual intervention, but the device is still protected when it comes to "initialization" (i.e. following a boot). Excellent! I upvote it for now. As I cannot test t0mm13b's solution either, I have to trust you concerning my "accept": this looks like the most promising (and free!) solution so far, though being limited to JB+. –  Izzy Sep 27 '13 at 9:52
    
You know, it's funny how I got there in the first place. I found your question & answer to the cell standby problem and soon ended up with the airplane mode-SIM-PIN-problem. Since I've been using Xposed Framework for some time now, I had the idea to look for a xposed module that would deal with the issue. :) –  FuzzyQ Sep 27 '13 at 9:56

I am not sure that you need to do what you are trying to do.

You might, instead:

  • Set up two Tasker tasks to switch on/off everything that enabling/disabling Airplane mode does.
  • Don't ever use actually your Airplane mode. Use your Tasker tasks.

You may have to see if any apps are enabled to automatically turn on a hardware radio. Watch to see if an app tries to background sync or whatever, they might try to toggle disabled radios on. If so, disable that app's ability to automatically turn on your e.g. WiFi. I say this because Airplane mode certainly stopped the unexpected WiFi connections before but not anymore, if you try this answer.

You could also set up Tasker to always go into Airplane mode at shutdown. That way you would see the PIN Lock at boot time.

share|improve this answer
    
Thank you, zero2cx -- but I'm not asking for me alone, and not especially for Tasker (I'm aware of the fact that I could disable things separately here; but disabling cell radio separately does not work with my Milestone²). In the linked questions answer, I also mention two other apps. They reportedly require the PIN either to be entered or disabled, as they use airplane mode. So please understand I do not want a specific Tasker solution (as many find Tasker too complex), but rather a generic solution to do what I asked for: disable the PIN request on return from airplane mode only. –  Izzy Sep 24 '12 at 7:40
    
Okay. I'm stumped, then. There's got to be a way to toggle it with software, but in in a more nuanced way. How does Samsung let you do it? –  zero2cx Sep 24 '12 at 7:49
    
I cannot tell (don't have a Samsung device). But I've got reports that it is doable on many (all?) Samsung devices as well as with LG. On my Milestone² I didn't explicitly check, as my current SIM was in my HTC Buzz/Wildfire before, were I had to completely disable the SIM-PIN for this purpose. –  Izzy Sep 24 '12 at 7:56

The answer lies in the source... it seems to be that the property to request pin-lock is built into build.prop or default.prop.

Have a look at the reference found in the TelephonyManager source, between lines 735 and 755. For brevity,

public int getSimState() {
        String prop = SystemProperties.get(TelephonyProperties.PROPERTY_SIM_STATE);
        if ("ABSENT".equals(prop)) {
            return SIM_STATE_ABSENT;
        }
        else if ("PIN_REQUIRED".equals(prop)) {
            return SIM_STATE_PIN_REQUIRED;
        }
        else if ("PUK_REQUIRED".equals(prop)) {
            return SIM_STATE_PUK_REQUIRED;
        }
        else if ("NETWORK_LOCKED".equals(prop)) {
            return SIM_STATE_NETWORK_LOCKED;
        }
        else if ("READY".equals(prop)) {
            return SIM_STATE_READY;
        }
        else {
            return SIM_STATE_UNKNOWN;
        }
    }

The key is TelephonyProperties.PROPERTY_SIM_STATE which is referred elsewhere, between lines 94 and 98.

//****** SIM Card
/**
 * One of <code>"UNKNOWN"</code> <code>"ABSENT"</code> <code>"PIN_REQUIRED"</code>
 * <code>"PUK_REQUIRED"</code> <code>"NETWORK_LOCKED"</code> or <code>"READY"</code>
 */
static String PROPERTY_SIM_STATE = "gsm.sim.state";

After searching through the source code here on my machine, I'll give you the idea of how often this method getSimState is called, notice the names of the java source to clue in on how its integrated within Android, not just in the Telephony layer but elsewhere.

services/java/com/android/server/am/BatteryStatsService.java 219:      int simState = TelephonyManager.getDefault().getSimState();

telephony/java/android/telephony/TelephonyManager.java 523:    public int getSimState() { 551:     * @see #getSimState 562:     * @see getSimState

policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java 478:    public IccCard.State getSimState() {

policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java 545:            final IccCard.State state = mUpdateMonitor.getSimState();

policy/src/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java 57:        final IccCard.State simState = mUpdateMonitor.getSimState();

policy/src/com/android/internal/policy/impl/LockScreen.java 273:       mStatus = getCurrentStatus(updateMonitor.getSimState());

policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java 173:                && (mUpdateMonitor.getSimState() == IccCard.State.ABSENT); 217:                final IccCard.State simState = mUpdateMonitor.getSimState(); 469:                && (mUpdateMonitor.getSimState() != IccCard.State.PUK_REQUIRED)) { 512:   secure = mUpdateMonitor.getSimState() == IccCard.State.PIN_REQUIRED 513:                            || mUpdateMonitor.getSimState() == IccCard.State.PUK_REQUIRED; 643:        final IccCard.State simState = mUpdateMonitor.getSimState(); 662:        final IccCard.State simState
= mUpdateMonitor.getSimState();

policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java 49:        public IccCard.State getSimState() {

Do those file names give a clue, yup, in the lock screen...

Theory

This requires root at this point, by invoking the adb shell and calling getprop and setprop to do this, the only part is this, by invoking

adb shell getprop will get back the pertinent information as shown below

sh-4.1# getprop
[gsm.sim.state]: [READY]

This subtle property seems to be dynamically persisted into a backing property store, from the moment of powering up and is adjusted accordingly, based on number of things, service, and not to mention accidentally dropping the handset which may knock the sim-card out of its reader which would change the state of the card to "not-ready" or "unknown". (ref: system/core/include/cutils/properties.h and system/core/toolbox/ [ getprop | setprop ].c)

Now at this point, theoretically, by invoking setprop prior to locking the screen, it could be circumvented temporarily, but then again, that could get resetted by the telephony layer! Have not tried that! Which is leading to this...

Conclusion

The only way this can be switched off, is to effectively disable the pin-lock request on the actual sim-card. That is where the "magic" bit-flag is stored on that, in which the telephony's RIL layer reads it in via the proprietary htc/samsung/qualcomm's library, and that would prevent propragation of the persisting of the property "PIN_REQUIRED" up through the layers of Android.

A possible work-around, for Android Developers only :)

This would require hacking and recompiling the source. For the airplane mode, when entering that mode and leaving airplane mode, the property could be split up, into two, gsm.sim.state can be left as is, but devise another property, something like this, gsm.sim.state.airplane.mode and assign a value along the lines of SIM_STATE_PIN_NOT_REQUIRED, and modify the airplane mode check, to read that property and if set to that, do not show the pin dialog box, otherwise as usually does, prompt it.

share|improve this answer
    
Thank you for the detailed explanation, t0mm13b! So we must assume that Samsung and LG have changed the code in all the places you mentioned -- if the reports I got about Samsung and LG devices (where people said they could disable the SIM PIN check separately, as described in my question) are correct? –  Izzy Sep 27 '12 at 16:05
    
Thanks again! If you could tell were to find that setting in CM, and since when it is in there, this would already be a big help -- as CM is available for many devices :) My devices are all running CM 7.x, so I could verify -- though I did not encounter such a setting yet (which is why I'm asking for the place where to look ;) –  Izzy Sep 27 '12 at 16:16
    
Try Settings > Location & Security Settings, Sim Card lock? –  t0mm13b Sep 27 '12 at 16:19
    
I had to delete the comment that was an answer to your question in there within same, its present in AOSP sources, (first time have seen it as my sim card is already unlocked and free of pin request lock anyway) –  t0mm13b Sep 27 '12 at 16:21
1  
Not confirmed for Gingerbread (CM7.2 on my Motorola Droid²/Milestone²). True, SIM PIN can be configured at the described place -- but only on/off, not selective for "only at power-on". Sorry. –  Izzy Sep 27 '12 at 17:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.