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

Search This thread

zimmbadroid

Senior Member
Nov 8, 2011
884
353
Vitez
"Maybe" is not the same as you "can". However, OP should put in tutorial that you need to paid if you want it to work...
You can try Automate app with last flow from ss below
Note that sometimes it won't switch, at least in my case. Workaround is to Stop-Start the flow to make it switching again.
 

Attachments

  • Screenshot_20170324-162336.png
    Screenshot_20170324-162336.png
    162 KB · Views: 791
  • Like
Reactions: 22vlaja

jukyO

Senior Member
Feb 2, 2011
2,663
610
Ogulin
@MishaalRahman

Plugin --> Secure Settings. Expand the "Actions" dropdown and pick "Device Setting." For the Setting Table, pick "global."

--> I have only "system" here in drop down menu. Anything to do about it or not possible to have "global"?

[EDIT]

This one resolved it:

https://dammit.nl/20160406-how-to-f...oid-devices-with-supersu-systemless-root.html

---------- Post added at 09:57 AM ---------- Previous post was at 09:04 AM ----------

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;
settings 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.

@MishaalRahman

If we do it like this in tasker, then Secure settings part is not needed, as we have settings put global preferred_network_mode 1;
settings put global preferred_network_mode1 1; already in. Am I right?
 
Last edited:

midhunmanohar

Member
Jan 27, 2017
47
5
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.

Dayyum, you made my day. I am trying to find a solution to do a one click task to switch default data sim on dual SIM phone since a week. I was going through every single thread. I had the settings change command working but the settings never reflected in the system. That ril-daemon restarting worked and the commands are executing perfectly. You are the man! Thanks a lot!!! There are many many many threads which needs this answer. I will do my best to link this post to them.
 

eried1

Senior Member
May 27, 2016
279
20
Stockholm
When I searched for this on Nougat people wrote that I should use preferred_network_mode, preferred_network_mode0 1 and preferred_network_mode1 1? What differences does it make if you exclude preferred_network_mode0 1?
 

Plomiwn

Senior Member
Dec 5, 2008
269
34
Warsaw
Hey there,
I know it's been a while since this subject was active but anyone know how to make:

Code:
settings put global preferred_network_mode 1;
settings put global preferred_network_mode1 1;

to stick?
Because every time i switch those variables to my preference, in a second and/or after restart of ril-daemon it's back to values that was set by system before.
 

eeeemc88

Member
May 15, 2018
18
2
setenforce permissive;
settings put global preferred_network_mode 1;
ettings put global preferred_network_mode1 1;
stop ril-daemon;
start ril-daemon;
setenforce enforcing;


Perfectly works !! ( and thanks to all in the thread )

What would be the setting though force it from ( above 2G ) to " 3G ONLY ". * ( also if 4G ONLY )
*** in Europe / Asia's GSM network.

Thank you very much.
edmond.

---------- Post added at 10:41 AM ---------- Previous post was at 09:57 AM ----------

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


Perfectly works !! ( and thanks to all in the thread )

What would be the setting though force it from ( above 2G ) to " 3G ONLY ". * ( also if 4G ONLY )
*** in Europe / Asia's GSM network.

Thank you very much.
edmond.

I myself just tested & found a solution ..............................

( The above 2G task is when screen off )

Below is when screen on :
wait 5 seconds
Use Plug in: Secure Setting:
Setting table: Global
Setting Name: preferred_netword_mode ( *** do not choose preferred_netword_mode1 )
Setting Value: 0,0
( do not forget press save icon at right top )

Failure:
It appears above set to 2G/3G only ( Asia/Europe GSM situation ) instead of 3G only
( as I prefer it at purely 3G only )

Hope someone can suggest a run shell command instead of using my above method and set it at purely "3G only"

Thanks
Edmond.
 

eeeemc88

Member
May 15, 2018
18
2
works as description ! thanks for your tutorial!

Glad it works for you I guess you are on GSM ( Asia ) mobile ...........
I'm still not satisfy to the setting return back to :

Purely 3G
or
4G Lte

I tested a lot but couldn't find any correct "digit" to use.

i.e.
settings put global preferred_network_mode 1; ( set what for purely 3G or 4G Lte ? )
settings put global preferred_network_mode1 1; ( set what for purely 3G or 4G Lte ? )

Thank you !!!
 

tdas777

Senior Member
May 13, 2015
54
2
Moto X Play
Redmi Note 8
Hi,
I'm using Moto lux XT1562, lineage os 14.1.

in tasker
settings put global preferred_network_mode 1;
settings put global preferred_network_mode1 1;
stop ril-daemon;
start ril-daemon;

it's not working.

After setting network to 2g manually, I'm getting following:
settings list global | grep pref

preferred_network_mode1=1
preferred_network_mode2=9
preferred_network_mode=0
user_preferred_data_sub=1

after switching to 4G
preferred_network_mode1=9
preferred_network_mode2=9
preferred_network_mode=0
user_preferred_data_sub=1

Is there any way to make it work without secure settings?
 

eeeemc88

Member
May 15, 2018
18
2
Hi,
I'm using Moto lux XT1562, lineage os 14.1.

in tasker
settings put global preferred_network_mode 1;
settings put global preferred_network_mode1 1;
stop ril-daemon;
start ril-daemon;

it's not working.

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.
 

tdas777

Senior Member
May 13, 2015
54
2
Moto X Play
Redmi Note 8
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.

Thanks for the reply...
But i tried that also... Didn't work.
I'm in India...

To know code for 3G, you should manually switch to 3G, then run that "grep pref" command in termux/terminal app in phone.
 

eeeemc88

Member
May 15, 2018
18
2
Thanks for the reply...
But i tried that also... Didn't work.
I'm in India...

To know code for 3G, you should manually switch to 3G, then run that "grep pref" command in termux/terminal app in phone.

sorry ..... I typo missing "s" ( ettings put global preferred_network_mode1 1; )

1. Should use RUN SHELL as below
2. Each line need separate by "ENTER" ( new line )

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

I believe India is same networking environment same as mine ( Hong Kong )

Honestly , when I'am in Tasker and hit the task above , 2G immediately appear.

I'm going to post screen capture later when I am free.

Thanks
edmond

Thanks
edmond

---------- Post added at 01:08 PM ---------- Previous post was at 12:45 PM ----------

sorry ..... I typo missing "s" ( ettings put global preferred_network_mode1 1; )

1. Should use RUN SHELL as below
2. Each line need separate by "ENTER" ( new line )

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

I believe India is same networking environment same as mine ( Hong Kong )

Honestly , when I'am in Tasker and hit the task above , 2G immediately appear.

I'm going to post screen capture later when I am free.

Thanks

edmond

Thanks
edmond

How to insert pics in here from my compurter local drive...?
 

eeeemc88

Member
May 15, 2018
18
2
@eeeemc88
I tried now. It's not working. It's disabling the network and enabling but stays on 4G.

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
 

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.
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone