[ASUS ZenFone 8] bnsmb:
In the OmniROM (tested in OmniROM 12 and OmniROM 13) - and I assume in other Android distributions also - global settings are stored the file

/data/system/users/0/settings_global.xml

The file settings_global.xml is in the Android Binary XML format and can not be edited via text editor. To change the entries in that file via script it must be converted to text format and after the necessary changes are done in the file in human readable format converted back from text format to the Android Binary XML format. This can be done with the Android executables abx2xml and xml2abx:

ASUS_I006D:/ # abx2xml -h
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2

usage: abx2xml [-i] input [output]
usage: xml2abx [-i] input [output]

Converts between human-readable XML and Android Binary XML.

When invoked with the '-i' argument, the output of a successful conversion
will overwrite the original input file. Input can be '-' to use stdin, and
output can be '-' to use stdout.

ASUS_I006D:/ #

Note:

See here https://www.cclsolutionsgroup.com/post/android-abx-binary-xml or here https://cs.android.com/android/plat...ndroid/internal/util/BinaryXmlSerializer.java for details about the Android Binary XML file format.

A lot of xml files in Android are in the Android Binary XML format (there may be others on other phones):

ASUS_I006D:/ # find /data/system -name "*.xml" -exec file {} \; 2>/dev/null | grep "Android Binary XML" | wc -l
31
ASUS_I006D:/ #

Spoiler content hidden.

So to change the settings in the file settings_global.xml these commands are necessary:

Example:

# convert the file into a human readable format
#
ASUS_I006D:/ # abx2xml /data/system/users/0/settings_global.xml /data/local/tmp/setttings_global.xml.human
ASUS_I006D:/ #

ASUS_I006D:/ # ls -l /data/local/tmp/setttings_global.xml.human
-rw-r--r-- 1 root root 15425 2022-11-20 14:30 /data/local/tmp/setttings_global.xml.human
ASUS_I006D:/ #

ASUS_I006D:/ # file /data/local/tmp/setttings_global.xml.human
/data/local/tmp/setttings_global.xml.human: ASCII text
ASUS_I006D:/ #

ASUS_I006D:/ # head -5 /data/local/tmp/setttings_global.xml.human
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<settings version="210">
<setting id="140" name="adb_wifi_enabled" value="0" package="android" defaultValue="0" defaultSysSet="true" />
<setting id="86" name="mobile_data1" value="0" package="com.android.phone" defaultValue="0" defaultSysSet="true" />
<setting id="91" name="mobile_data2" value="0" package="com.android.phone" defaultValue="0" defaultSysSet="true" preserve_in_restore="true" />
ASUS_I006D:/ #

Now edit the file /data/local/tmp/setttings_global.xml.human and convert it back to Android Binary XML format

# convert the XML file in human readable format into the Android Binary XML format
#
ASUS_I006D:/ # xml2abx /data/local/tmp/setttings_global.xml.human /data/system/users/0/settings_global.xml
ASUS_I006D:/ #

ASUS_I006D:/ # ls -l /data/system/users/0/settings_global.xml
-rw------- 1 system system 10697 2022-11-20 15:34 /data/system/users/0/settings_global.xml
ASUS_I006D:/ #

To activate the new settings just reboot the phone.

Note:

The global settings in the file settings_global.xml in the OmniROM 13 are (there may be others on other phones):

Spoiler content hidden.

Working with files in Android Binary XML format on a PC

I do not know a tool to convert a file in Android Binary XML format to human readable format on a PC.

There is a tool to convert binary XML files used in apk files to human readable format and vice versa called xml2axml (https://github.com/hzw1199/xml2axml)

XML files used in apk files are in AXML format, which is also a binary format for XML files, but different from the Android Binary XML format.

I used xml2axml successfully to convert XML files used in apk files but xml2axml does not work for files in the Android Binary XML format.

I did not test it but I assume that's also true for other tools to work with apk files like apktool or dex2jar.

Other tools for files in Android Binary XML format I found are:

The abx converter from here https://github.com/cclgroupltd/android-bits/tree/main/ccl_abx claims to be a tool to convert Android Binary XML files but seems not to work for Android Binary XML files from OmniROM 13:

[xtrnaw7@t15g /data/develop/android/android-bits-main/ccl_abx]$ python3 ccl_abx.py ../../test2/settings_global.xml
Traceback (most recent call last):
File "/data/develop/android/android-bits-main/ccl_abx/ccl_abx.py", line 292, in <module>
main(sys.argv[1:])
File "/data/develop/android/android-bits-main/ccl_abx/ccl_abx.py", line 284, in main
doc = reader.read(is_multi_root=multi_root)
File "/data/develop/android/android-bits-main/ccl_abx/ccl_abx.py", line 266, in read
raise NotImplementedError(f"unexpected XML type: {xml_type}")
NotImplementedError: unexpected XML type: 7
[xtrnaw7@t15g /data/develop/android/android-bits-main/ccl_abx]$

Update 23.11.2022 /bs

ccl_abx.py works for the Android Binary XML files from OmniROM 12, e.g.

[xtrnaw7@t15g /data/develop/android/android-bits-main/ccl_abx]$ python3 ccl_abx.py ../../test2/settings_global_a12.xml -mr | sed "s/>/>\n/g" | more
<root>
<settings version="205">
<setting id="67" name="adb_wifi_enabled" value="0" package="android" defaultValue="0" defaultSysSet="true" />
<setting id="91" name="mobile_data1" value="0" package="com.android.phone" defaultValue="0" defaultSysSet="true" preserve_in_restore="true" />
<setting id="87" name="mobile_data2" value="0" package="com.android.phone" defaultValue="0" defaultSysSet="true" />
<setting id="41" name="low_battery_sound_timeout" value="0" package="android" defaultValue="0" defaultSysSet="true" />
<setting id="33" name="car_undock_sound" value="/product/media/audio/ui/Undock.ogg" package="android" defaultValue="/product/media/audio/ui/Undock.ogg" defaultSysSet="true" />
<setting id="101" name="time_remaining_estimate_based_on_usage" value="0" package="com.android.systemui" defaultValue="0" defaultSysSet="true" preserve_in_restore="true" />
....
<setting id="85" name="wifi_on" value="1" package="android" defaultValue="1" defaultSysSet="true" preserve_in_restore="true" />
<setting id="57" name="wireless_charging_started_sound" value="/product/media/audio/ui/WirelessChargingStarted.ogg" package="android" defaultValue="/product/media/audio/ui/WirelessChargingStarted.ogg" defaultSysSet="true" />
[xtrnaw7@t15g /data/develop/android/android-bits-main/ccl_abx]$

There is a github repo with an abx parser in go https://github.com/SagerNet/abx-go (I did not test this)

Example

I wrote a little script to use the method described above to enable WiFi

enable_wifi.sh

The script will enable WiFi in the persistent settings if it's currently disabled; if WiFi is already enabled the script will change nothing.

The script must be executed by the user root on the phone.

Example output of the script:

Output if WiFi is disabled:

ASUS_I006D:/ # /data/local/tmp/enable_wifi.sh
Checking WiFi status in the persistent global settings ...
Converting the file "/data/system/users/0/settings_global.xml" to an XML file in text format "data/local/tmp/setttings_global.xml.human.9574" ...
WiFi is currently disabled -- enabling WiFi now :..
... WiFi enabled in the persistent global settings.

To activate the change reboot the phone
ASUS_I006D:/ #

Output if WiFi is already enabled:

ASUS_I006D:/ # /data/local/tmp/enable_wifi.sh
Checking WiFi status in the persistent global settings ...
Converting the file "/data/system/users/0/settings_global.xml" to an XML file in text format "data/local/tmp/setttings_global.xml.human.9613" ...
WiFi is already enabled in the persistent global settings
ASUS_I006D:/ #

The script is attached to this post ; it can also be downloaded from here: enable_wifi.sh.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Important Note

After writing this HowTo I discovered that there is a native Android command to change the settings stored in the file /data/system/users/0/settings_global.xml:

settings

Spoiler content hidden.

Spoiler content hidden.

A description of the known settings is here:

https://developer.android.com/reference/android/provider/Settings.Global

https://developer.android.com/reference/android/provider/Settings.Secure

https://developer.android.com/reference/android/provider/Settings.System

But since this HowTo is mainly about editing files in Android Binary XML format and the change of the WiFi status is only meant as an example, I leave it like this