6

How can I change the preferred network type with ADB?

Example: set Use only GSM, use only WCDMA, use only LTE or automatic.

Sidartha Carvalho
  • 320
  • 1
  • 3
  • 6

3 Answers3

1

This is working for my devices:

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update global SET value = 1 WHERE name = 'preferred_network_mode'"
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select value FROM secure WHERE name = 'preferred_network_mode'"
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
sleep 5;
adb shell settings put global airplane_mode_on 0
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false
pooja
  • 71
  • 3
  • Could you mention why `sleep 5` is needed? And which Android version are your using? –  Jul 01 '15 at 10:29
  • Beside is there a reason `sqlite3 ...` is used and not `settings put global preferred_network_mode 1`? Also, what does second command does? –  Jul 01 '15 at 10:32
  • Nope! Not working on CM12 rooted. It changes the value in `.db` but the changes doesn't take place on the radio level. You can check it in "Phone Info" through `*#*#4636#*#*` where the preferred_network_type remains the same. What's more, a reboot is kinda reverting things back. Would you mind for the explanation of the commands? –  Jul 01 '15 at 10:48
  • @Arch Its working for lollipop and kitkat. This commands is used to open ur device setting.db and changing preferred_network_mode field with new values. – pooja Jul 01 '15 at 12:07
  • I did the both reboot and airplane mode .. I don't want to reboot device that's why AP mode used. Sleep used to make some delay. It is changing in device network options. – pooja Jul 01 '15 at 12:11
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/82095/discussion-between-arch-and-pooja). –  Jul 01 '15 at 13:52
  • This is not working on a rooted Samsung S5 (SM-G901F). – Kozuch Dec 09 '16 at 13:07
  • @Arch why have you not used settings put global preferred_network_mode 1? Why it doesn't work ?(I tried and it's not working) – Prajwal Jul 27 '18 at 10:59
0

I hope this helps:

GSM Only:

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update global SET value=1 WHERE name='preferred_network_mode'"

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select value FROM secure WHERE name='preferred_network_mode'"

adb reboot

For LTE, change value=11 For WCDMA, change value=2

Grayson Henry
  • 834
  • 3
  • 11
  • 22
0

ADB command to set RAT:

**adb shell settings put global preferred_network_mode1 2 --> WCDMA on SUB1

adb shell settings put global preferred_network_mode2 1 --> GSM on SUB2

adb shell stop ril-daemon

adb shell start ril-daemon

adb shell settings put global airplane_mode_on 1

adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true

sleep 5;

adb shell settings put global airplane_mode_on 0

adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false**

RIL_PreferredNetworkType:

PREF_NET_TYPE_GSM_WCDMA                = 0, /* GSM/WCDMA (WCDMA preferred) */
PREF_NET_TYPE_GSM_ONLY                 = 1, /* GSM only */
PREF_NET_TYPE_WCDMA                    = 2, /* WCDMA  */
PREF_NET_TYPE_GSM_WCDMA_AUTO           = 3, /* GSM/WCDMA (auto mode, according to PRL) */
PREF_NET_TYPE_CDMA_EVDO_AUTO           = 4, /* CDMA and EvDo (auto mode, according to PRL) */
PREF_NET_TYPE_CDMA_ONLY                = 5, /* CDMA only */
PREF_NET_TYPE_EVDO_ONLY                = 6, /* EvDo only */
PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7, /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) */
PREF_NET_TYPE_LTE_CDMA_EVDO            = 8, /* LTE, CDMA and EvDo */
PREF_NET_TYPE_LTE_GSM_WCDMA            = 9, /* LTE, GSM/WCDMA */
PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA  = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */
PREF_NET_TYPE_LTE_ONLY                 = 11, /* LTE only */
PREF_NET_TYPE_LTE_WCDMA                = 12,  /* LTE/WCDMA */
PREF_NET_TYPE_TD_SCDMA_ONLY            = 13, /* TD-SCDMA only */
PREF_NET_TYPE_TD_SCDMA_WCDMA           = 14, /* TD-SCDMA and WCDMA */
PREF_NET_TYPE_TD_SCDMA_LTE             = 15, /* TD-SCDMA and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM             = 16, /* TD-SCDMA and GSM */
PREF_NET_TYPE_TD_SCDMA_GSM_LTE         = 17, /* TD-SCDMA,GSM and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA       = 18, /* TD-SCDMA, GSM/WCDMA */
PREF_NET_TYPE_TD_SCDMA_WCDMA_LTE       = 19, /* TD-SCDMA, WCDMA and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_LTE   = 20, /* TD-SCDMA, GSM/WCDMA and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO  = 21, /* TD-SCDMA, GSM/WCDMA, CDMA and EvDo */
PREF_NET_TYPE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA   = 22  /* TD-SCDMA, LTE, CDMA, EvDo GSM/WCDMA */
Sudhir Sinha
  • 693
  • 9
  • 18