Change locale system language via ADB in starting from Android 6.0 For manual UI testing purposes, on my Android 6.0 &amp; 7.0 devices, I use a shortcut to access language preferences via ADB, then choose one of the three languages ar_DZ, en_GB, fr_FR manually

adb shell am start -n com.android.settings/.Settings\$LocalePickerActivity


Question: is is possible to automate the task of changing the system locale (without root) via ADB?
This solution doesn't use adb directly but meets the end result using automation on unrooted devices

macrodroid is preferred choice of automation for me,  being simple and free up to 5 macros

Preliminary Steps


Install Macrodroid and grant all permissions it asks for
Actions desired by OP require root. Macrodroid offers a way to do it by without root using adb methods, explained here. In essence, it is granting WRITE_SECURE_SETTINGS and CHANGE_CONFIGURATION by running the following commands


adb shell pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS

followed by

adb shell pm grant com.arlosoft.macrodroid android.permission.CHANGE_CONFIGURATION

Reboot to ensure commands are updated in the app

Creating Macros and Testing


Trigger : Select Empty Trigger
Action : Set language &rarr; French &rarr; France ( corresponding to fr_FR)
Constraints : Leave blank
Test it by selecting Test Macro from the 3 dots menu of the macro. The system language should change to French . Save the macro for example French. Create two similar macros for other two choices


Creating Home Screen Shortcut

Usually, if you long press the home screen, you will find the icon for widgets collection. Among them you will find Macrodroid widgets. One of them is Macrodroid shortcuts. Drag and drop that to your home screen , it will ask you which macro it should be assigned to , while displaying a list of Macros. Select the macro and rename the widget e.g., French.  When you press on that widget corresponding macro is executed. Repeat for other Macros. If you are using a custom launcher you will need to search how to access the widgets collection

Notes


Drop down menu selection for languages can be implemented but that would require another Macro. Besides this  method of one desktop icon shortcut for each language keeps it simple and easier to debug
This method will not work on Oreo (You do not get the set language action, maybe due to the way it is implemented)