[APP][2.0+] Toggle2G (Tasker/LTE/Rootless) [v0.3.5 / 1/13/2013]

Search This thread

TheMasterBaron

Inactive Recognized Developer
Jan 27, 2009
510
537
Denver, CO
Google Pixel 6 Pro
I've made a java application to take "any" flashable ROM zip and resign the zip and inject Toggle2G into it. Check the downloads for ResignUpdate.zip. Check the readme-first.txt in the zip for more information. Works with Windows/OSX/Linux with java installed

Here is a little app I've started working on that enables the 2G Only setting automatically when the phone is asleep to save battery.

As always with these kinds of things, I am not responsible if something goes wrong, so use at your own risk.

Working on Android versions since 2.1. I'm using it on my Nexus 4.

Installation:
The flashable Toggle2G-Update.zip is designed to work with CyanogenMod based ROMs. There is no need to resign any CyanogenMod ROMs.
The easiest way to see if Toggle2G works on your ROM is flash the Toggle2G-Update.zip from the recovery. If your ROM is compatible, Toggle2G will show up in your app drawer.
ONLY IF THAT DOES NOT WORK, then you can try the ResignUpdate java application to convert your ROM. ROMs must be in zip form and be flashable through a recovery like CWM or TWRP. Download the ResignUpdate.zip and read the included readme-first.txt file. Once you resigned your ROM, you then wipe and flash the resigned ROM.
See the troubleshooting section below if you have trouble.


ResignUpdate Change Log:
v3.0.1 - Don't close out of the GUI on certain errors
v3.0.0 - Automatic SecPhone.apk and SecSettings.apk detection | Running ResignUpdate.bat/sh without any parameters pops up a GUI so you can pick the ROM.zip file (Should help with path issues). You can still use the command line options if you want and it will bypass the GUI.
v2.1.3 - Update Toggle2G.apk to v0.2.0.
v2.1.2 - Overrides ROM's Toggle2G.apk when injecting.
v2.1.1 - Bug fix during Toggle2G.apk injection.
v2.1.0 - ZipAlign resigned files.
v2.0.4 - It seems keys need to be physical files..fixed
v2.0.3 - Don't fail on unreadable apks. Sign resigned zip. Move injection files into ResignUpdate.jar so no path issues.
v2.0.2 - Better detection of RSA file in an APK. Some additional optional parameters to help with any fringe cases that might come up
v2.0.1 - Don't change apk's storage method when processing it
v2.0.0 - Initial Release

Toggle 2G Change Log:
Always reboot after an update!
v0.3.5 Added option to always switch to 3G. This is if you want 3G except when on wifi or data off or low battery. / Fixed Spanish translation crashing Toggle 2G. / Start to refer to networks as fast/slow. This is because users might want to toggle from LTE to 3G.
v0.3.4 Fixed bug that was switching back to 3G
v0.3.3 Enable data in auto swich mode will reactive 3G
v0.3.2 Fix retry of network change when data off setting is used
v0.3.1 Fix bug when toggling data that was preventing the Manual Notifications from working.
v0.3.0 Added LTE networks and removed the need for ROOT (You will need to re-setup Toggle2G after upgrade)
v0.2.4 New icons from LeopardSurd. Show version number at top of Toggle 2G settings screen.
v0.2.3 Try for 5 seconds to get network to switch after data turning off data. I hope this helps with switching on phone like the Galaxy S II; German translation thanks to Aiakio; Italian translation thanks to krinet
v0.2.2 Fixed bug where sometimes network would switch to the same network causing data to disable then enable
v0.2.1 Fix some issues with not switching.
v0.2.0 Option to wait for phone unlock before switching to 3G; Option to turn data off to switch networks; Option to switch to 2g when data is off; French translation thanks to mooondark
v0.0.20 Set SDK to v8 to fix compatibility with CM6
v0.0.19 Updated German using the translation from Aiakio.
v0.0.18 Added translations by muchopoli83. (Danish, German, Spanish, French, Hungarian, Italian, Portuguese, Russian, and Chinese)
v0.0.17 Tweaked chmod on preferences folder
v0.0.16 Switch to 2g when data is disabled. Better fix for bug where settings are not surviving a reboot.
v0.0.15 Fix bug where settings are not surviving a reboot (I hope). New icon from hawkeyexp, thanks!v0.0.14 2G when sleep on/off option, 2G Notification fixes/options, Options reworked
v0.0.13 Option to not switch to 2G if network is being used. Default threshold of 2 KBps means 2G will not enable if >= 2 KBps is being used. Threshold is configurable in settings
v0.0.12 You can pick a specific network through the Tasker/Local plug-in (not just 2G or 3G) / Battery feature can be turned off / Disable options only applicable to auto manage when its off
v0.0.11 Delay switching to 2G when wifi is turned on to prevent network outage during transition. Also added option to off the feature that switches to 2G when using wifi.
v0.0.10 Fix bug that was not changing auto manage
v0.0.8 Customizable network selections for 2G and 3G modes.
v0.0.7 Added home widget. The Toggle 2G plug-in app is needed to use the widget.
v0.0.6 Option to allow user to choose when to switch back to 3G using the notification bar. Requires a separate plug-in app attached here or from the market
v0.0.5 more fixes to try and prevent switching when phone rings and phone wakes up
v0.0.3 fix issues with disconnecting incoming call
v0.0.2 adds Tasker/Locale plugin support!

Automatic Mode Features:
  • Switch to 2G when wifi is connected.
  • Switch to 2G when data is turned off.
  • If screen is off for more that 10 minutes (configurable in the app) it will switch to 2G
  • If screen is off and battery is below 30% (configurable in the app) it will switch to 2G
  • Network usage monitoring to prevent switching to 2G if network is being used.
  • 3G can be re-enabled as soon as the screen is turned on or unlocked or it can be done manually
  • Option to Disable data before switching network. (Required on some phones/ROMs)
  • Option for manual switching back to 3G. This setting allows user to choose when to switch back to 3G by selecting a notification in the notification bar. Requires separate app located on market or use link below

Notes:
  • Runs in the com.android.phone process to gain access to the 2G Only setting.
  • Shares process with system so installing will list pretty much all of the permissions
  • Uses root access to save preferences, seems running in the com.android.phone process can causes some problems with creating a preferences folder to hold the preferences file. Root access is needed to save preferences. I have a new system for saving preferences that does not need root. However, as a backup, if Toggle2G fails to use the new system it will fall back to this old system and use Root, (I didn't want to break it for phones I can't test on)
  • Does not change network while in a call. Otherwise the call will drop because the radio resets. (Even if Tasker/Locale tells it to)
  • Changing network can be slow. You may have to wait a second for 3G to reactivate. I suggest using the manual switch to 3G option and plugin if this is the case.
  • Due to issues with how Toggle 2G uses a shared user id, I've implemented the notifications and home widget under a separate app.
  • 3 settings for the Tasker/Locale plugin and home screen widget. Automatic, 2G , or 3G (Setting 2G or 3G disables auto mode)

ToDo:
  • Don't switch to 2g while tethering
  • disable the 3g when the reception is between ___ and ___ to keep it from flip-flopping. (Can't be done, you can't monitor 3G reception levels while in 2G)
  • Use g sensors to detect movement and reactivate 3G to lower radio down time after unlocking phone (Monitoring these sensors would drain battery and defeat the purpose)

If you think of a feature or find a bug, let me know.

Also, I've attached a values.zip file so that everyone can contribute to translating Toggle2G to other languages.

I'm a code junkie, please support my habit


SOURCE CODE IS AVAILABLE HERE:
Toggle 2G Source
Toggle 2G Plugin Source

TROUBLESHOOTING
* Make sure you have Java 6 or higher installed
* I get an "Failed to find any apk with a key" error when signing my ROM

If you get this error it means that ResignUpdate tool could not find one of these files in the ROM's zip file:
  • system/app/phone.apk
  • system/app/settings.apk
  • system/app/SecPhone.apk
  • system/app/SecSettings.apk
At lease one of these files is needed to identify what in the ROM needs to be resigned. You can open the ROM's zip file and try and find where one of these files are. If you find it in a folder other than system/app you can specify one of these files in the -keyapk parameter when running ResignRom. For example, if you find that the SecPhone.apk is actually in the preload/symlink/system/app folder, then put preload/symlink/system/app/SecPhone.apk in the -keyapk parameter.

attachment.php


Cheers!
Master Baron
Follow me
 

Attachments

  • values.zip
    20.8 KB · Views: 3,634
  • screenshot.JPG
    screenshot.JPG
    82.7 KB · Views: 238,378
  • Toggle2G-v0.3.5.apk
    82.4 KB · Views: 30,275
  • Toggle2G-v0.3.5-Update.zip
    171.7 KB · Views: 22,719
  • ResignUpdate-v3.0.1-Toggle2G-v0.3.5.zip
    254.5 KB · Views: 10,823
Last edited:

THATTON

Senior Member
Aug 27, 2007
1,554
193
Bakersfield
OK, so here is a little app I've started working on that enables the 2G Only setting automatically when the phone is asleep to save battery. It's not polished at this point, just trying out the features and come up with more to add.

** REQUIRES CyanogenMod 6 **

Notes:
  • Signed using the CM6 platform.x509.pem so not sure what other ROMs it will work with.
  • Runs in the com.android.phone process to gain access to the 2G Only setting.
  • Uses root access to save preferences, seems running in the com.android.phone process can causes some problems with creating a preferences folder to hold the preferences file. Root access does a mkdir to make the preferences folder and that is all.
  • Does not change the 2G Only flag while in a call. Otherwise the call will drop because the radio resets
  • Changing the 2G Only flag can be slow. You may have to wait a second for 3G when turning the screen on after it has switched to 2G while the phone was asleep

Features:
  • It doesn't bother switching to 2G if phone is plugged in
  • It doesn't bother switching to 2G until wifi disconnects
  • If screen is off for more that 10 minutes, it will enable 2G Only setting
  • If screen is off and battery is below 30% (configurable in the app) enable 2G Only setting
  • 3G is re-enabled as soon as the screen is turned on unless battery is below configured percentage

Install the apk then reboot the phone.

After reboot, run the Toggle2G app to enable the service and configure the low battery %

ToDo:
  • Widget to switch between Auto, 3G and 2G.

If you think of a feature or find a bug, let me know.

Enjoy!
Master Baron


This could be awesome!!! I think this should probably go in the themes and apps section though. Thank you for this. I will test it out now.
 

bimmerd00d

Senior Member
Jan 24, 2008
723
115
Locale plugin would be utterly awesome. If i could make this thing autoset 2G when i go to bed or whatever other conditions i choose, that'd make this thing complete.
 

TheMasterBaron

Inactive Recognized Developer
Jan 27, 2009
510
537
Denver, CO
Google Pixel 6 Pro
I think i read this wrong, you mean it switches to 2G once wifi is connected?

Unless I'm wrong, it doesn't appear that the 2G/3G radio is on when wifi is on, so it doesn't bother switching it from 3G to 2G because it resets the radio and I didn't want it to do that if it didn't matter. So basically, when wifi is on and connected, it never switches to 2G when the phone is asleep until wifi finally disconnects.

Adjustable timer is next and the Locale plugin is a great idea.
 

massari90

Senior Member
Dec 5, 2009
106
5
Unless I'm wrong, it doesn't appear that the 2G/3G radio is on when wifi is on, so it doesn't bother switching it from 3G to 2G because it resets the radio and I didn't want it to do that if it didn't matter. So basically, when wifi is on and connected, it never switches to 2G when the phone is asleep until wifi finally disconnects.

Adjustable timer is next and the Locale plugin is a great idea.

Well I leave my wifi on all the time (when im at home or watever), I guess thats where the widget to set 2g would come in handy :D
 

bimmerd00d

Senior Member
Jan 24, 2008
723
115
Unless I'm wrong, it doesn't appear that the 2G/3G radio is on when wifi is on, so it doesn't bother switching it from 3G to 2G because it resets the radio and I didn't want it to do that if it didn't matter. So basically, when wifi is on and connected, it never switches to 2G when the phone is asleep until wifi finally disconnects.

Adjustable timer is next and the Locale plugin is a great idea.

Actually i think it is in fact doing that. I opened up the "Network" app and noticed that if i enable wifi, GPRS service goes to disconnected so you may be right after all.
 
D

diversificationied

Guest
It would be awesome if you could add a db value threshold as well.

BTW, I'm convinced this same method is used on iphone 4 to get the battery life it does.
 
D

diversificationied

Guest
Once I get it cleaned up I may do just that.


Can you elaborate on what you mean by db value threshold?

In a low reception area the phone tends to switch back and forth between 3g/2g. I think somewhere around 104.

So basically disable the 3g when the reception is between ___ and ___.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 244
    I've made a java application to take "any" flashable ROM zip and resign the zip and inject Toggle2G into it. Check the downloads for ResignUpdate.zip. Check the readme-first.txt in the zip for more information. Works with Windows/OSX/Linux with java installed

    Here is a little app I've started working on that enables the 2G Only setting automatically when the phone is asleep to save battery.

    As always with these kinds of things, I am not responsible if something goes wrong, so use at your own risk.

    Working on Android versions since 2.1. I'm using it on my Nexus 4.

    Installation:
    The flashable Toggle2G-Update.zip is designed to work with CyanogenMod based ROMs. There is no need to resign any CyanogenMod ROMs.
    The easiest way to see if Toggle2G works on your ROM is flash the Toggle2G-Update.zip from the recovery. If your ROM is compatible, Toggle2G will show up in your app drawer.
    ONLY IF THAT DOES NOT WORK, then you can try the ResignUpdate java application to convert your ROM. ROMs must be in zip form and be flashable through a recovery like CWM or TWRP. Download the ResignUpdate.zip and read the included readme-first.txt file. Once you resigned your ROM, you then wipe and flash the resigned ROM.
    See the troubleshooting section below if you have trouble.


    ResignUpdate Change Log:
    v3.0.1 - Don't close out of the GUI on certain errors
    v3.0.0 - Automatic SecPhone.apk and SecSettings.apk detection | Running ResignUpdate.bat/sh without any parameters pops up a GUI so you can pick the ROM.zip file (Should help with path issues). You can still use the command line options if you want and it will bypass the GUI.
    v2.1.3 - Update Toggle2G.apk to v0.2.0.
    v2.1.2 - Overrides ROM's Toggle2G.apk when injecting.
    v2.1.1 - Bug fix during Toggle2G.apk injection.
    v2.1.0 - ZipAlign resigned files.
    v2.0.4 - It seems keys need to be physical files..fixed
    v2.0.3 - Don't fail on unreadable apks. Sign resigned zip. Move injection files into ResignUpdate.jar so no path issues.
    v2.0.2 - Better detection of RSA file in an APK. Some additional optional parameters to help with any fringe cases that might come up
    v2.0.1 - Don't change apk's storage method when processing it
    v2.0.0 - Initial Release

    Toggle 2G Change Log:
    Always reboot after an update!
    v0.3.5 Added option to always switch to 3G. This is if you want 3G except when on wifi or data off or low battery. / Fixed Spanish translation crashing Toggle 2G. / Start to refer to networks as fast/slow. This is because users might want to toggle from LTE to 3G.
    v0.3.4 Fixed bug that was switching back to 3G
    v0.3.3 Enable data in auto swich mode will reactive 3G
    v0.3.2 Fix retry of network change when data off setting is used
    v0.3.1 Fix bug when toggling data that was preventing the Manual Notifications from working.
    v0.3.0 Added LTE networks and removed the need for ROOT (You will need to re-setup Toggle2G after upgrade)
    v0.2.4 New icons from LeopardSurd. Show version number at top of Toggle 2G settings screen.
    v0.2.3 Try for 5 seconds to get network to switch after data turning off data. I hope this helps with switching on phone like the Galaxy S II; German translation thanks to Aiakio; Italian translation thanks to krinet
    v0.2.2 Fixed bug where sometimes network would switch to the same network causing data to disable then enable
    v0.2.1 Fix some issues with not switching.
    v0.2.0 Option to wait for phone unlock before switching to 3G; Option to turn data off to switch networks; Option to switch to 2g when data is off; French translation thanks to mooondark
    v0.0.20 Set SDK to v8 to fix compatibility with CM6
    v0.0.19 Updated German using the translation from Aiakio.
    v0.0.18 Added translations by muchopoli83. (Danish, German, Spanish, French, Hungarian, Italian, Portuguese, Russian, and Chinese)
    v0.0.17 Tweaked chmod on preferences folder
    v0.0.16 Switch to 2g when data is disabled. Better fix for bug where settings are not surviving a reboot.
    v0.0.15 Fix bug where settings are not surviving a reboot (I hope). New icon from hawkeyexp, thanks!v0.0.14 2G when sleep on/off option, 2G Notification fixes/options, Options reworked
    v0.0.13 Option to not switch to 2G if network is being used. Default threshold of 2 KBps means 2G will not enable if >= 2 KBps is being used. Threshold is configurable in settings
    v0.0.12 You can pick a specific network through the Tasker/Local plug-in (not just 2G or 3G) / Battery feature can be turned off / Disable options only applicable to auto manage when its off
    v0.0.11 Delay switching to 2G when wifi is turned on to prevent network outage during transition. Also added option to off the feature that switches to 2G when using wifi.
    v0.0.10 Fix bug that was not changing auto manage
    v0.0.8 Customizable network selections for 2G and 3G modes.
    v0.0.7 Added home widget. The Toggle 2G plug-in app is needed to use the widget.
    v0.0.6 Option to allow user to choose when to switch back to 3G using the notification bar. Requires a separate plug-in app attached here or from the market
    v0.0.5 more fixes to try and prevent switching when phone rings and phone wakes up
    v0.0.3 fix issues with disconnecting incoming call
    v0.0.2 adds Tasker/Locale plugin support!

    Automatic Mode Features:
    • Switch to 2G when wifi is connected.
    • Switch to 2G when data is turned off.
    • If screen is off for more that 10 minutes (configurable in the app) it will switch to 2G
    • If screen is off and battery is below 30% (configurable in the app) it will switch to 2G
    • Network usage monitoring to prevent switching to 2G if network is being used.
    • 3G can be re-enabled as soon as the screen is turned on or unlocked or it can be done manually
    • Option to Disable data before switching network. (Required on some phones/ROMs)
    • Option for manual switching back to 3G. This setting allows user to choose when to switch back to 3G by selecting a notification in the notification bar. Requires separate app located on market or use link below

    Notes:
    • Runs in the com.android.phone process to gain access to the 2G Only setting.
    • Shares process with system so installing will list pretty much all of the permissions
    • Uses root access to save preferences, seems running in the com.android.phone process can causes some problems with creating a preferences folder to hold the preferences file. Root access is needed to save preferences. I have a new system for saving preferences that does not need root. However, as a backup, if Toggle2G fails to use the new system it will fall back to this old system and use Root, (I didn't want to break it for phones I can't test on)
    • Does not change network while in a call. Otherwise the call will drop because the radio resets. (Even if Tasker/Locale tells it to)
    • Changing network can be slow. You may have to wait a second for 3G to reactivate. I suggest using the manual switch to 3G option and plugin if this is the case.
    • Due to issues with how Toggle 2G uses a shared user id, I've implemented the notifications and home widget under a separate app.
    • 3 settings for the Tasker/Locale plugin and home screen widget. Automatic, 2G , or 3G (Setting 2G or 3G disables auto mode)

    ToDo:
    • Don't switch to 2g while tethering
    • disable the 3g when the reception is between ___ and ___ to keep it from flip-flopping. (Can't be done, you can't monitor 3G reception levels while in 2G)
    • Use g sensors to detect movement and reactivate 3G to lower radio down time after unlocking phone (Monitoring these sensors would drain battery and defeat the purpose)

    If you think of a feature or find a bug, let me know.

    Also, I've attached a values.zip file so that everyone can contribute to translating Toggle2G to other languages.

    I'm a code junkie, please support my habit


    SOURCE CODE IS AVAILABLE HERE:
    Toggle 2G Source
    Toggle 2G Plugin Source

    TROUBLESHOOTING
    * Make sure you have Java 6 or higher installed
    * I get an "Failed to find any apk with a key" error when signing my ROM

    If you get this error it means that ResignUpdate tool could not find one of these files in the ROM's zip file:
    • system/app/phone.apk
    • system/app/settings.apk
    • system/app/SecPhone.apk
    • system/app/SecSettings.apk
    At lease one of these files is needed to identify what in the ROM needs to be resigned. You can open the ROM's zip file and try and find where one of these files are. If you find it in a folder other than system/app you can specify one of these files in the -keyapk parameter when running ResignRom. For example, if you find that the SecPhone.apk is actually in the preload/symlink/system/app folder, then put preload/symlink/system/app/SecPhone.apk in the -keyapk parameter.

    attachment.php


    Cheers!
    Master Baron
    Follow me
    8
    How to use ResignUpdate:

    1) Ensure you have java SDK installed, if not google it and install it.

    2) Download resignupdate and extract it.

    3) Download your desired rom and place the file into resignupdate directory.

    4) Open command prompt and change directory to where resign update is.

    Example, cd C;\ResignUpdate

    5) Run the script, Resignupdate.bat xx.zip

    Ensure you leave a space after bat xx = name of rom

    Example, Resignupdate.bat Hyperdroid_Androimeda.zip

    6) Keep a look out while script is running to ensure there are no errors, once complete you will have another zip file in the resign directory labeled something like rom name Toogle2G-resigned.zip.

    7) Copy onto phone and flash away using CWM.

    8) Enjoy the benefits.

    Sent from my GT-I9100 using Tapatalk
    7
    As I find less and less time to work on more and more projects, I've decided to release the source for Toggle 2G with the hopes the community can help improve and evolve it!

    SOURCE CODE IS AVAILABLE HERE:
    Toggle 2G Source
    Toggle 2G Plugin Source
    5
    I am working on an app that will have all the features of Toggle2G and it will work on rooted stock android and any AOSP based ROM.

    Its still in very early development.

    XDA thread:
    http://xdaforums.com/showthread.php?t=2580234

    App
    https://play.google.com/store/apps/details?id=com.voidvapps.intelli3g
    4
    hi theMasterBaron

    loving your mod! I have used the addon.d script used by gapps, superSU, etc to make Toggle2G survives a nightly flash or ROM update. perhaps you can include this in your flashable zip. I am sure many would benefit from this :)

    i used this simple tutorial here to create the addon.d script file

    [Tutorial] CM9/CM10/CM10.1 back up script
    http://xdaforums.com/showthread.php?t=1617356

    Edit: attached the script here

    this is not a flashable zip. You have to manually copy the script file to /system/addon.d/ with permission set to rwxr-xr-x

    This will only work on ROMs that supports addon.d, CM and CM based ROMs supports this. You can check whether your ROM supports this by checking whether there is /system/addon.d in the ROM

    Flowed from my Nexus 4.