Your phone contains a 3-axis magnetometer — the same sensor used by the compass app. It measures the total magnetic field in microtesla. Earth's field points toward magnetic north, but ferromagnetic materials (steel, iron, cast iron pipes) bend and amplify the field locally.
When you walk past a steel beam or an electrical panel, the heading changes suddenly — not because you turned, but because the local field is distorted. The jump in heading (in degrees) tells you how strong the anomaly is. A shift of more than 15° while standing still is significant.
The compass uses the deviceorientationabsolute event, which gives calibrated
absolute heading in degrees from true north (0° = north, 90° = east, 180° = south).