Saturday, March 17, 2012

Fix for excessive "Cell standby" battery drain on Android with b-mobile data-only SIMs

THIS POST IS OUT OF DATE. SEE: http://www.japanmobiletech.com/2013/08/improved-fix-for-docomo-mvno-data-only.html

Can you tell which of these phones has a data-only SIM?
We figured that the fix for the infamous signal bars/battery drain issue was probably trivial, once someone figured out exactly what needed to be fixed. That someone is best known simply as "oov" and prefers not be called a developer because he only started tinkering with Android a few months ago. If you read Japanese, hop over to his site for a description of the patch, a windows batch file to execute, and a list of handsets confirmed compatible. Even if you don't read Japanese, I provided an English localization of the patch - select English when running.

For those unfamiliar with the problem, JCI was instrumental in the opening (though government arbitration) of NTT Docomo's FOMA network to MVNOs. The results are readily seen as an explosion of innovative cellular data products that even Docomo has began copying. However, while the SIMs that are distributed by DCM to MVNOs appear identical to a standard FOMA SIM card, they lack certain components that Android expects. This makes it appear to the OS in some (but not all) handsets that there is no cell signal when there actually is. As a result, power is boosted to radio, and "Cell standby" quickly drains the battery.

Give up? the data-only SIM is in the left screenshot (note the erroneous "G" - HTC Desire)
I've personally confirmed that the patch works on an unlocked Softbank HTC Desire (X06HT II) running both CyanogenMod 7.1 Stable and a beta version of ICS. The fix has also been reported to work on a number of other HTC phones including the Nexus One. It also seems to work for Samsung Galaxy series phones, such as the Galaxy S and S2, the Nexus S, and the Galaxy Nexus. Motorola Droid and Atrix phones are also reported fixed, as are various Xperia handsets. Patched files are hardware/software specific. You cannot use a patch for one model phone on a different model or OS version.

Requirements

The perquisites to doing this will void your warranty. Do this at your own risk. Do not do this to a phone that uses voice+data SIMs. If you change to a voice+data SIM, push back the original framework.jar file that is made in the patching process using the "recovery.bat" file.
  • A data-only SIM from an MVNO using NTT Docomo's FOMA network
  • Root
  • S-Off (Nand security off)
  • Custom Recovery (such as ClockworkMod)
  • A nandroid backup of your current ROM (in case it doesn't work).
  • Windows with a Java Developer Kit if you can't compile and decompile the necessary files.

Procedure

To do this manually, see the description below. Before pushing the patched file back to the phone, you'll need to mount the system partition as writable. If you can't get the batch file to push the patched file, you can find it in the same directory and push it yourself.

Step 0. Download the zip with batch files to patch and backup your system.

Step 1. open a command line and mount your system partition as readable. With an S-OFF bootloader this should be done as adb remount with the phone booted normally. If you get a permission denied error, try doing it while booted into recovery. If you still can't do it, you're going to have to look into how to mount the system partition for your particular phone and bootloader.

Step 2. Run the batch file. Select English.



Step 3. Choose your Android version (or in the case of gingerbread, the closest version)


Step 4. Choose the mode for the patch. See the table below for suggestions. Only use 99 if the other options didn't work.

I'm aware of the typo. I blame Nicholas for not catching it.
Step 5. Choose whether you want the "emergency calls only" dialog to go away.


Step 6. Create a patched framework.jar file based on the above conditions. The compiling and decompiling will take some time. Just let it sit. It isn't doing anything to your phone at this time.


Step 7. Push the patched file to your phone. (This can be done manually if it should fail for whatever reason.)


Step 8. Boot into recovery and wipe Dalvik cache and the cache partition.

Patch Modes

I've copied the list here, but it is better to check the original site. These settings are primarily sourced from comments of people who have successfully patched their phones.

Handsets confirmed working with Mode: 0
  • Samsung Galaxy S2 (SC-02C, HyperDroid)
  • Samsung Galaxy Nexus (GT-i9250)
  • Samsung Galaxy Note
  • Samsung Galaxy Tab (probably GT-P1000)
  • Samsung Galaxy S (GT-i9000, Onecosmic's ICS Port Android 4.0.3 RC3.1)
  • Samsung Galaxy Nexus S (GT-i9020T, aokp 4.0.3)
  • Samsung Captivate Glide (SGH-I927, I927UCKI3)
  • HTC Desire HD (001HT SIMUnlocked)
  • HTC Desire HD (UK版 SIMFree, CyanogenMod7)
  • HTC Desire Z (CyanogenMod7.1, some reports of failure as well)
  • HTC Desire (X06HT, X06HTII, CyanogenMod 7.1), (X06HTII, Sandvold's ICS BETA 0.3.9 and 0.4.3 may show "G" for GPRS, even though it has 3G/H connectioin)
  • HTC myTouch 4G slide (1.28.531.10)
  • HTC HT-03A (CyanogenMod 6)
  • ZTE Blade (003Z, CyanogenMod 7.1)
  • Nexus One (2.3.3)
  • LG Optimus 2X (LG-P990, CyanogenMod 7)
Handsets confirmed working with Mode: 1
  • Sony Ericsson Xperia PLAY
  • Sony Ericsson Xperia mini pro (SK17a)
  • Sony Ericsson Xperia ray
  • Sony Ericsson Xperia pro (MK16a 4.0.2)
  • Sony Ericsson Xperia neo (MT15i, 2.3.4)
  • Sony Ericsson Xperia mini (ST15a), (ST15i)
  • Sony Ericsson Xperia Active (ST17i)
  • Sony Ericsson Xperia arc (SO-01C)
  • Sony Ericsson mini (S51SE)
Handsets confirmed working with Mode: 2
  • Motorola DROID Pro (XT610 3.8.7 / 4.6.4), (CyanogenMod7 )
  • Motorola DROID 3 (XT862 5.6.890)
  • Motorola Atrix
  • Motorola Photon (ISW11M, CyanogenMod 7)
Handsets confirmed working with Mode: 99
  • Sony Ericsson Xperia acro (SO-02C, 2.3.4)
  • HTC Sensation (Android Revolution HD, not confirmed with mode 0, XE?)
Some Xperia handsets fail with changing to not display "emergency calls only" If so, change to 0 - "don't change"

Confirmed working data-only SIMs:

Behind the Scenes

This is the general procedure (J) done by the batch file. adb is used to pull /system/framework/framework.jar to your local computer. From there, classes.dex is extracted and then decompiled with baksmali. In the output directory, the text file out/com/android/internal/telephony/gsm/GsmServiceStateTracker.smali is edited, classes.dex is recompiled and reinserted into framework.jar, which is pushed back to the phone.

The portion that is edited is just slightly below this entry: .method private regCodeToServiceState(I)I.

:pswitch_data_22
    .packed-switch 0x0
        :pswitch_1c
← Edit point for Motorola DROID Prom, DROID 3, Atrix, etc.
        :pswitch_1d ← See here.
        :pswitch_1c ← Xperia also needs to be edited here
        :pswitch_1d ← Here :pswitch_1c is changed to :pswitch_1d
        :pswitch_1c
        :pswitch_1f
        :pswitch_5
        :pswitch_5
        :pswitch_5
        :pswitch_5
        :pswitch_1c
        :pswitch_5
        :pswitch_1c
← Xperia also needs to be edited here
        :pswitch_1d ← Here :pswitch_1c is changed to :pswitch_1d
        :pswitch_1c
    .end packed-switch


The description in the batch file is counting lines starting at 0 from the first occurrence of :pswitch. For example, Xperia edits are at 2 and 12.

35 comments:

  1. hey,
    i made a quick view through ur page and its awesome!!
    I really like your work.

    But I have a question and i dont know how to contact you so i just post a comment here and hope you will read it.

    My problem. I made a contract with softbank White plan. The simplest tariff.

    But now my friend is offering me his Iphone 4 which he brought at Softbank.

    I went to Softbank to tell them, that I need a micro sim card to use an Iphone, but then they said, that if I want to use a smartphone, I have to make a complete new tariff, where I have to pay more than 4000 yen.

    Isnt there another way yo use the Iphone with keeping my old White Plan? If not it would rly suck!

    I hope you answer. Thanks a lot

    Nen

    ReplyDelete
  2. I just got an LG Optimus X through AU, it's my first smartphone. The "Cell Standby" by far uses the most battery, and the "Time Without Service" is unusually high, like over 40%, even though that's obviously not the case (I constantly have a signal all day). Any idea how to fix this or what's going on? After researching on the internet, the "airplane mode" fix doesn't seem to make a difference.

    ReplyDelete
  3. Putting it into airplane mode completely shuts off the cellular radio, so cell standby usage in that case should be zero. As far as your problem it is unrelated to what is described above, which only applies to data-only SIMs. You have voice and data. The most common cause for excessive cell standby battery usage is if you are in a fringe service area. The phone has a signal but it is relatively weak, causing the phone to boost power to the radio.

    Unfortunately, the number of bars displayed on the phone is not a good indicator of actual signal strength. It would be better to look directly at the stats that on a pure android phone can be found in Settings > About phone > Status.

    I'd check that as you go around a few places and see what tends to be a normal value.

    ReplyDelete
  4. Hello,

    I tried that fix with my Samsung Galaxy S I9000, Android 2.3.7 (CM7 nightly 11162011) kernel 2.6.35.14.
    Unfortunately it looks like it's still not working, I still have an incredible battery drain (in usage, of about 1% drop per hour !).
    This night I let my phone in sleep mode for 12 hours and the "Cell Standby" battery usage has been responsible of up to 30% of overall battery drain in a single night.
    Do you have the same kind of reports ? The patch reported "everything OK" but maybe there was something more to do.

    ReplyDelete
  5. Do you get signal bars displaying? How about an H or 3G icon? Did these display before the patch?

    One percent per hour doesn't sound bad. Your phone would last for four days in standby with that rate of drop. When the phone is asleep, cell standby SHOULD be the primary thing using your battery. If the phone is truly in deep sleep, nothing BUT cell standby should be using any battery.

    The problem is that when the phone is awake, with the screen on and other apps being used, cell standby usage should be far down the list. Use your phine normally for a day and see what is at the top of the list. If it's display, I'd say you have no problems. Especially if you have the proper icons displayed in the notification area.

    ReplyDelete
  6. Hello,
    what a quick answer ! :)
    sorry, my mistake: that wasn't 1 percent an hour but 1 percent a minute (using browser & apps) . More or less, it is totally discharged in about 5 hours, including a long time in standby mode. It wasn't this way before (I have it since 2 years now, and changed carriers/ROM/country/... multiple times)
    And the signal bars did display before and after the patch, with H and 3G depending on the moment. What would be cool is if I totally understood the patch that is done, I could maybe take a look myself (and port it to Linux also). I may understand what's going on in the phone (I'm a software engineer in that field) but definitely, Japanese is a bit too difficult for me ;)
    Does the japanese patcher/developer of the fix give more info about why and what is he modifying those lines in the apk ?

    Many thanks,

    ReplyDelete
  7. If the signal bars displayed before the patch, don't use this patch. This is designed to fix the issue of no signal bars displaying. I think you should look into the forums supporting your specific ROM/phone combination because it would seem you have a separate issue.

    For whatever reason, your phone is using too much battery. Best to look for general excessive battery usage. Use the spare parts app or similar to look at the "other usage" and time spent without sleep. It could be that something has a partial or full wake lock on your device. If so, this will hose your battery.

    ReplyDelete
  8. Hello,

    I'm wondering if anyone has tried using the tablet mode setting in Juice Defender to fix this problem. Supposedly the setting is for data only devices and should shut off the cell radio...

    -John

    ReplyDelete
  9. No, that's not going to be a viable solution. Tablet mode is similar to airplane mode in that it completely shuts off the cellular radio. This is an enhanced form of shutting off mobile data. So, in this mode, it appears that you won't have a data connection at all.

    ReplyDelete
  10. There many discovery appear which I know by which you can avoid the excessive "Cell Standby" stand by battery drain on Android. So user can get more nice service.

    ReplyDelete
  11. Works perfectly on my US AT&T Samsung Galaxy S Captivate (i897) which is same hardware as Galaxy S (i9000). I have some Cyanogenmod 9 nightly on my phone and a b-mobile 1GB SIM (actually a microSIM I bought to use with an AT&T HTC One X, but the One X is not compatible). Had no signal bars before, now H icon and pretty cyan bars!

    ReplyDelete
  12. Antoine BourgeoisAugust 6, 2012 at 6:37 PM

    If even a newcomer can find the root cause of that problem, why the morons at NTT Docomo are not releasing a patch?
    Sometimes, it feels like Docomo likes to upset the customers...

    ReplyDelete
  13. Script hasn't been updated yet for APIv16. My bmobile sim expired so I can't really test doing it manually.

    ReplyDelete
  14. I recently did it with a nexus s running 4.1.x - don't have the exact build number, but it worked perfectly.

    ReplyDelete
  15. I know this article is focused on Android but I tried googling around and I can't find anything specific to the iPhone. My friend gave me an iPhone 3GS with 4.3.3 which I rooted and unlocked and am using a 1GB flat rate SIM which works, but it never shows any bars. I don't know if this is causing extra battery usage because I haven't had it for long but I don't know how to go about fixing the lack of bars. Any idea?

    ReplyDelete
  16. before updating sc-02c on ics 4.0.3 my phone was working flawless
    but after updating to ics 4.0.3 my phone shuts down automatically after some time
    then it not bootsup
    these all problems comes after updating my phone to 4.0.3 i am in pakistan
    i m fadeup by this plz help me dudes
    thanks

    ReplyDelete
  17. my phone even not giving me enough time so i can rollback to old gingerbread
    thanks

    ReplyDelete
  18. do a factory reset on your phone. turn it off hold volume+home+power and then choose the option to wipe cache and factory reset.

    ReplyDelete
  19. Any solution for non-windows users (MacOS or linux)? Would there be a shell script available somewhere?

    ReplyDelete
  20. You'll have to do it manually or create your own shell script. Sorry, but I don't have the time to do it so I ran this in my VM (virtualbox with win xp).

    ReplyDelete
  21. Has anyone tried this with JellyBean? Thanks

    ReplyDelete
  22. yes. I have it working on a Nexus S running a ROM based on CM10 source.

    ReplyDelete
  23. anyone tried on Lg500 with Cm7?

    ReplyDelete
  24. Thanks for this wonderful site!
    I managed to get Bmobile Smart SIM 980 (yodobashi) working on my HTC Sensation (Android 4) by just changing the "Network mode" to "WCDMA only." Can download "DataConnectionMonitorLITE" from Play store to get that little 3G up/down icon in place of the X-signal.
    Hope this is of some help to other HTC Sensation users :)

    ReplyDelete
  25. Thanks!

    Unless something has changed, those icon changer apps don't actually fix the problem - they just treat the symptoms. I tried to force to wcdma mode only, but it didn't change battery usage.

    http://www.japanmobiletech.com/2011/09/forcing-htc-handsets-to-use-only-3g.html



    Check your battery stats and see if cell standby is at the top of the list. If not, then great!

    ReplyDelete
  26. Any idea if this is still compatible with Android 4.2.1 on the new Nexus 4? I'm currently running the CyanogenMod 10.1 nightlies on it and it's n amazingly fast phone. I'll be heading to Japan in a few days and aim to use the bmobile 1GB Flat Rate micro-SIM. Cheers!

    ReplyDelete
  27. Henry Ashley-CooperDecember 14, 2012 at 2:14 PM

    I'm slightly confused - I have a HTC Desire with b-mobile スマホ SIM. It provides both voice calls and data [2gig plan]. It displays an 'H' for mobile data, does that mean I don't need this patch? I hope not because getting s-off will probably involve some serious RUU work

    ReplyDelete
  28. You do not need to do it. From the article:

    Do not do this to a phone that uses voice+data SIMs.

    ReplyDelete
  29. I filed a bug report to Google here: http://code.google.com/p/android/issues/detail?id=42718 - feel free to vote on the issue to get it fixed for good.

    ReplyDelete
  30. I can confirm that this patch works with 4.2.1 JellyBean, but you have to modify the execute.bat file as specified here:
    http://androqazz.blogspot.jp/2013/01/jelly-bean421.html

    If you can't read Japanese, basically the instruction is to edit the execute.bat file and replace every instance of "framework.jar" with "telephony-common.jar"

    After you do that, it should work.

    I confirmed that the patch works with Mode 99 on my Samsung Galaxy S3 (i535) running CM10.1 Jellybean. I can now see the actual 3G reception bars, which is a first for me while using a b-mobile sim. (I'm using the 1gb 3g/4g teigaku sim.)

    ReplyDelete
  31. Can someone tell me the confirmed procedure for a Galaxy Nexus running 4.2.2 (specifically the AOKP rom, if that makes a difference)? Thanks!

    ReplyDelete
  32. should be the same for the other galaxy's. I'm pretty sure I confirmed it worked on the GN.

    ReplyDelete
  33. OK thanks, I'll give it a try and report back once I arrive in Japan.

    I see some reports that the .bat should have all references changed from framework.jar to telephony-common.jar : http://androqazz.blogspot.jp/2013/01/jelly-bean421.html

    ReplyDelete
  34. Samsung Galaxy S Duos S-7562 with b-mobile U300 sim was reporting normal signal bars, but mobile network signal was showing a constant red bar, and cell standby was very high and battery was draining faster than other sims. Option 99 fixed the issue and now no more battery drain... thanks!

    ReplyDelete
  35. Hi! I've got a Galaxy S Duos S7562 bought in Spain. Here: http://www.amazon.es/Samsung-Galaxy-Duos-S7562-Smartphone/dp/B009PLHJ3G/ref=sr_1_1?s=electronics&ie=UTF8&qid=1379759674&sr=1-1&keywords=Samsung+Galaxy+S+Duos+S-7562

    Version GT-S7562UWACOA, so...will it work with a b-mobile sim, then? Or u bought the phone in Japan?

    Thanks!

    ReplyDelete