Why doesn't Android compass react to magnet?
The sensor algorithm people worked hard to make sure that the "compass sensor" is not affected by stray ambient magnetic field. If you want to see magnetic field data, use the magnetic field sensor instead.

The common way to know that the device is subjected to an external magnetic disturbance is by comparing the magnetic sensor data with motion sensors (accelerometer and more importantly the gyroscope), if there is no motion, the algorithm will suppress any change to compass heading, because it is trying to reflect reality that compass heading did not change. For more details, look under the subject of "sensor fusion."