I've been trying to search about changing network mode programmatically which was already answered, but I noticed that when using:
settings put global preferred_network_mode x settings put global preferred_network_modex x
Changes doesn't reflect to the Test settings, which can be access through
*#*#4636#*#*, and some device doesn't get the change in their phone signal literally after the command.
Why using ADB command 'settings put global preferred_network_mode' doesn't reflect the changes in Test Settings but manually changing the network preference under Settings or the opposite changing from Test settings using UI will reflect the change to each other.