[GUIDE][Difficulty: Beginner] Switch to 2G when Connected to WiFi

Search This thread

tdas777

Senior Member
May 13, 2015
54
2
Moto X Play
Redmi Note 8
It;s true it cut the line ( stoppoing network ) . I just play around with below & you see if this apply on your phone function well .........

When Screen Off ( Entry task )
setenforce permissive;
settings put global preferred_network_mode 1;
settings put global preferred_network_mode1 1;
setenforce enforcing

( Exit task )
setenforce permissive;
settings put global preferred_network_mode 9;
settings put global preferred_network_mode9 9;
setenforce enforcing

- You see it skipped again the two command lines
stop ril-daemon;
start ril-daemon;
- Exit task above is 2G/3G/4G
- Try to add a ** wait 8 seconds ** as the first line in exit task .

So that once the screen on you can quickly switch to CELLULAR SETTING PAGE on your phone to see if it is on 2G ansd you have 8 seconds to watching if it successfully switch from 2G to 2G/3G/4G

Hope works for you

Thanks
edmond
I'll try and update here...
Thanks
 

zrzhu

Senior Member
Oct 22, 2011
326
34
It;s true it cut the line ( stoppoing network ) . I just play around with below & you see if this apply on your phone function well .........

When Screen Off ( Entry task )
setenforce permissive;
settings put global preferred_network_mode 1;
settings put global preferred_network_mode1 1;
setenforce enforcing

( Exit task )
setenforce permissive;
settings put global preferred_network_mode 9;
settings put global preferred_network_mode9 9;
setenforce enforcing

- You see it skipped again the two command lines
stop ril-daemon;
start ril-daemon;
- Exit task above is 2G/3G/4G
- Try to add a ** wait 8 seconds ** as the first line in exit task .

So that once the screen on you can quickly switch to CELLULAR SETTING PAGE on your phone to see if it is on 2G ansd you have 8 seconds to watching if it successfully switch from 2G to 2G/3G/4G

Hope works for you

Thanks
edmond

i put in the exact same command. How can I check if it works? I went to "About phone" ---> "Mobile network type", it still shows "LTE".
 

eeeemc88

Member
May 15, 2018
18
2
i put in the exact same command. How can I check if it works? I went to "About phone" ---> "Mobile network type", it still shows "LTE".

I check from : Setting > Sim > Cellar Network > Preferred Network Mode.

I guess definitely not starting from About Phone

Thanks
 

zrzhu

Senior Member
Oct 22, 2011
326
34
I check from : Setting > Sim > Cellar Network > Preferred Network Mode.

I guess definitely not starting from About Phone

Thanks

I have LG v30. I have this in Setting ---> Network--->Mobile Networks ---->Network mode---->Preferred network mode: Automatic LTE/3G/2G.
 

anzhaki

Senior Member
Sep 19, 2014
290
48
Hello ,

Full correct run shell command is :

setenforce permissive;
settings put global preferred_network_mode 1;
ettings put global preferred_network_mode1 1;
stop ril-daemon;
start ril-daemon;
setenforce enforcing

Secondly , there not need using Securty Setting apps as I only applied above RUN SHELL command and my phone can turn itself to 2G ( **** in Asia GSM environment )

I'm still looking for a run shell command for GSM to PURELY 3G ( or PURELY Lte )

Thank you !
Edmond.

Unfortunately those commands are not working anymore. I'm currently on stock android Pie (Mi A2 lite).
In settings menu, network switching works from 2g to 4g or viceverse, but it is not being applied.
Are there new commands?
 

ktmom

Retired Forum Moderator
Apr 22, 2015
5,186
3,377
Deep Space Station K7
Unfortunately those commands are not working anymore. I'm currently on stock android Pie (Mi A2 lite).
In settings menu, network switching works from 2g to 4g or viceverse, but it is not being applied.
Are there new commands?

You may need multiple preferred network commands or to toggle airplane mode to make it take.

These tasks would be an example.

Data to 2G


Data to 4G




"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini
 
  • Like
Reactions: anzhaki

anzhaki

Senior Member
Sep 19, 2014
290
48
You may need multiple preferred network commands or to toggle airplane mode to make it take.

These tasks would be an example.

Data to 2G


Data to 4G




"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini

Thank you but still the same problem, in menu settings it changes but not getting applied effectively.
 
Last edited:

anzhaki

Senior Member
Sep 19, 2014
290
48
Is there any way to at least open the dialog menu from settings to choose the preferred network? In tasker options I only found the way to open network settings but then I have to manually navigate to the option to switch network.
Thanks
 

ktmom

Retired Forum Moderator
Apr 22, 2015
5,186
3,377
Deep Space Station K7
Is there any way to at least open the dialog menu from settings to choose the preferred network? In tasker options I only found the way to open network settings but then I have to manually navigate to the option to switch network.
Thanks
The best I can suggest is the Mobile Data Settings action with a AutoInput action to expand the advanced menu. You could continue with AutoInput actions to automate the entire process.



"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini
 
  • Like
Reactions: anzhaki

anzhaki

Senior Member
Sep 19, 2014
290
48
The best I can suggest is the Mobile Data Settings action with a AutoInput action to expand the advanced menu. You could continue with AutoInput actions to automate the entire process.



"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini

I tried the shell command "input tap x y" to automate the process once Mobile Data Settings is opened and it works fine. The only problem is the exit condition, that when I turn off WiFi the exit condition to turn on 3g is somehow being detected at an indefinite time (from 30 seconds to 2 minutes) and is not immediate.
Well anyway I don't think I will use this to turn on 2g.
Thanks anyway.
 

ktmom

Retired Forum Moderator
Apr 22, 2015
5,186
3,377
Deep Space Station K7
I tried the shell command "input tap x y" to automate the process once Mobile Data Settings is opened and it works fine. The only problem is the exit condition, that when I turn off WiFi the exit condition to turn on 3g is somehow being detected at an indefinite time (from 30 seconds to 2 minutes) and is not immediate.
Well anyway I don't think I will use this to turn on 2g.
Thanks anyway.
Have you done anything the this to make Tasker work reliably? The following is cribbed from https://tasker.joaoapps.com/userguide/en/faqs/faq-problem.html#00

enable foreground notification in Tasker settings

enable the "Use reliable alarms" option

Disable battery optimization for the apps

Make sure the Android Settings -> Apps -> Tasker -> Battery -> Background activity option is enabled (this setting may be somewhere else on different OEMs, but it's a very important setting that might be disabled by default on some devices)

If you want to use features while the screen is off make sure that the options in Preferences -> Monitor -> Display Off Monitoring are enabled for the conditions you want.
Make sure that you disable any "battery saving" apps like Greenify, etc


On Xiaomi devices enable "Auto Start" for the apps and "Display on Lock Screen" under "Other Permissions"


"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini
 
  • Like
Reactions: anzhaki

anzhaki

Senior Member
Sep 19, 2014
290
48
Have you done anything the this to make Tasker work reliably? The following is cribbed from https://tasker.joaoapps.com/userguide/en/faqs/faq-problem.html#00

enable foreground notification in Tasker settings

enable the "Use reliable alarms" option

Disable battery optimization for the apps

Make sure the Android Settings -> Apps -> Tasker -> Battery -> Background activity option is enabled (this setting may be somewhere else on different OEMs, but it's a very important setting that might be disabled by default on some devices)

If you want to use features while the screen is off make sure that the options in Preferences -> Monitor -> Display Off Monitoring are enabled for the conditions you want.
Make sure that you disable any "battery saving" apps like Greenify, etc


On Xiaomi devices enable "Auto Start" for the apps and "Display on Lock Screen" under "Other Permissions"


"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini

I did the steps you mentioned but still have the same problem and is not related to battery optimization, with tasker opened after turning off wifi tasker still detect that WiFi is connected.
Another problem is that the steps with autoinput is not really reliable since the opening time of settings varies and I have to put a longer wait time.
 

eeeemc88

Member
May 15, 2018
18
2
Yes it works correctly by toggling it manually.

Xiaomi phone some time is kind of head-ache to such network things..................

If really free , build the following profile :

PROFILE CONTEXT : Mobile Network
Choose & check "2G"

PROFILE TASK :
Action 1. wait 5 seconds
Action 2. FLASH ( Text type in 2G )

so that if you mobile is having 2G environment , the screen will flashes " 2G ".

SPECIAL:
You can build as much profile as you like for 3G , 4G , Lte.
all you need to do is to create new profile and changing Profile name "3G" , "4G" so on ....
in profile context check "3G"
and , changing the task , the action 2 to say "3G" or "4G" so on....

edmond.
 

anzhaki

Senior Member
Sep 19, 2014
290
48
Xiaomi phone some time is kind of head-ache to such network things..................

If really free , build the following profile :

PROFILE CONTEXT : Mobile Network
Choose & check "2G"

PROFILE TASK :
Action 1. wait 5 seconds
Action 2. FLASH ( Text type in 2G )

so that if you mobile is having 2G environment , the screen will flashes " 2G ".

SPECIAL:
You can build as much profile as you like for 3G , 4G , Lte.
all you need to do is to create new profile and changing Profile name "3G" , "4G" so on ....
in profile context check "3G"
and , changing the task , the action 2 to say "3G" or "4G" so on....

edmond.

I did as you wrote, the profile that flashes a text doesn't activate when I pass to 2g through adb shell command because it just change the selected network in settings and not change it effectively.
 

eeeemc88

Member
May 15, 2018
18
2
I did as you wrote, the profile that flashes a text doesn't activate when I pass to 2g through adb shell command because it just change the selected network in settings and not change it effectively.

I see ......................

However , if you build as many as PROFILES respectively ( 2G , 3G , 4G LTE ...etc. )
The alert flash should "FLASHES" .

If I were you having your big difficulty now , I would first find free time & build all PROFILES ( note: these are all seperate PROFILES base on 2G , 3G , 4G & Lte ...etc. )

Then , manually press & switch to airplane mode. Switch back on to online mode.
The alert flash should at least flashes which GSM mode you are.

Edmond.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 17
    It's no secret that cellphone radios are among the biggest killers of your battery life. Among the worst offenders is the LTE radio, which is not as efficient as the 2G HSPA radio. Now, when you're connected to WiFi, no data is actually being transmitted however your phone still utilizes the LTE radio for connecting to your carrier's cell tower for calls/texts rather than the more efficient 2G HSPA radio. If you have poor LTE signal in your area, you can turn off the LTE radio while you're on WiFi to squeeze some extra battery life out of your phone.

    Prerequisites


    Instructions

    1. Create a new Profile and name it Toggle 2G/4G.
    2. Create a new State context, go to Net and choose Wifi Connected. Leave everything blank here.
    3. You can leave the task name blank, as it is unlikely you'll be using this elsewhere.
    2Cbu05j.jpg


    Now, you'll create the entry task

    1. Code --> Run Shell. These are the commands you'll need to run. Make sure you have "Use Root" checked!
      Code:
      setenforce permissive;
      svc data disable;
      setenforce enforcing
    2. Plugin --> Secure Settings. Expand the "Actions" dropdown and pick "Device Setting." For the Setting Table, pick "global." For the Setting Name, find "preferred_network_mode1" (make sure it's exactly this one, there are similar ones that don't work). Change Setting Value to 1 if you're on a GSM phone, or to 0 for WCDMA.

    Now, create the exit task by pressing on the Toggle 2G/4G profile then long-pressing on the entry task. Tasker will give you a few options here, but choose to "Add Exit Task."

    1. Code --> Run Shell. These are the commands you'll need to run. Make sure you have "Use Root" checked!
      Code:
      setenforce permissive;
      svc data enable;
      setenforce enforcing
    2. Plugin --> Secure Settings. Expand the "Actions" dropdown and pick "Device Setting." For the Setting Table, pick "global." For the Setting Name, find "preferred_network_mode1" (make sure it's exactly this one, there are similar ones that don't work). Change the Setting Value to 9 if on T-Mobile or 10 if you're on Sprint/Verizon.

    Exit out, and you're done! Now whenever you connect to WiFi, the LTE radio will be disabled, and when you disconnect it'll be enabled again! You'll still be able to receive calls and texts while on WiFi, of course, because the 2G HSPA radio is still on.
    6
    After a long search for doing this in nougat i found a thread on stackoverflow (question 37848059, but i'm not allowed to link because i made my account for this post).

    the trick is stopping and starting the ril-daemon (whatever it is :p)
    so the shell command for enabling only 2g is:

    setenforce permissive;
    settings put global preferred_network_mode 1;
    ettings put global preferred_network_mode1 1;
    stop ril-daemon;
    start ril-daemon;
    setenforce enforcing;

    Great work everybody on the forums by the way, i've solved a lot of my problems here.
    5
    if you do not have "1" this metod do not work.
    this is solution for you:
    https://play.google.com/store/apps/details?id=com.cygery.togglenetworktype
    2
    Its turn on/off mobile data.
    Not switch 2g-4g/LTE.
    2
    so, this method is not for you..
    Do you have xposed? Gravity box? Intelli3g?
    If not, instal this:
    https://play.google.com/store/apps/details?id=com.cygery.togglenetworktype
    Tasker support.