Software
Code - https://github.com/PrivateKit/private-kit/tree/magnetometer
Commit 334cd86
Environment
Device A - Samsung Galaxy S8 running Android 9
Device B - Google Pixel 3a running Android 10
Linux system acting as server endpoint (phones connected via USB)
Limitations
Human error in distance measurement +/- 2cm
Only Android and two types of device used
The phones remained flat, although it is known that tilting the phone changes the outputs
Method
Built and installed APK via USB to both phones
Over 45 minutes (with a tape measure) moving the two devices running the app around at distances between 0 and 320cm (changing distance every two minutes)
Extracted the readings from the phone databases manually (method)
Over ~20 hours, measurements continue to be collected indoors, although distances were not measured.
Observations & Analysis
It is notable that no new permissions were requested by the phone.
In terms of the results, this requires data science support. The x,y,z points need to be transformed to a value that should correlate with distance. See work to prepare the data here: https://github.com/AdamLeonSmith/privkittools/blob/master/Magnetometer.ipynb
Detailed Results
See attached files for the measurement data.