MOTIVATION Device orientation sensors can be easily used for fingerprinting. As it highly unlikely that two devices visiting the same site will be oriented exactly the same, the orientation itself can serve as a fingerprint.
WRAPPING AbsoluteOrientationSensor returns a quaterion decribing the physical orientation of the device in relation to the Earth's reference coordinate system. The faked orientation of the device is saved inside the "orient" global variable that is accessible to all wrappers. The value is chosen pseudorandomly from the domain hash. The wrappper supports possible change of orientation. With each reading, it loads the "orient"'s contents, converts the rotation matrix to a quaternion that is returned by the wrapped getter.
RelativeOrientationSensor also describes the orientation, but without regard to the Earth's reference coordinate system. We suppose the coordinate system is chosen at the beginning of the sensor instance creation. As we observed, no matter how the device is oriented, there is always a slight difference from the AbsoluteOrientationSensor's in at least one axis. When the device moves, both sensors' readings change. But their difference should be always constant. And thus, we pseudorandomly generate a deviation from the Earth's reference coordinate system. And for each reading, we take the values from the fake AbsoluteOrientationSensor and modify them by the constant deviation.
POSSIBLE IMPROVEMENTS Study the supported coordinate systems of the RelativeOrientationSensor and modify the wrapper behavior if needed.