@Override
                public void onSensorChanged(final SensorEvent event) {
                    if (isTruncationNeeded) {
                        // Since only the four first elements are used (and accepted), we truncate the vector.
                        System.arraycopy(event.values, 0, values, 0, 4);
                        SensorManager.getRotationMatrixFromVector(rotationMatrix, values);
                    } else {
                        try {
                            SensorManager.getRotationMatrixFromVector(rotationMatrix, event.values);
                        } catch (final IllegalArgumentException ignored) {
                            Log.d("installing workaround for mismatched number of values in rotation vector");
                            // Install workaround and retry
                            isTruncationNeeded = true;
                            onSensorChanged(event);
                            return;
                        }
                    }
                    emitter.onNext(dirDataCalculator.calculateDirectionData(rotationMatrix));
                }
On some Samsung devices, {@link SensorManager#getRotationMatrixFromVector} throws an exception if the rotation
vector has more than 4 elements.
<p/>
This will be detected and remembered after the first occurrence of the exception. Concurrent access
is not a problem as this variable can only go from {@code false} to {@code true} and being {@code false}
instead of {@code true} is innocuous and will be changed immediately when needed.

@see <a href="http://stackoverflow.com/a/22138449">this Stack Overflow answer</a>
main/src/main/java/cgeo/geocaching/sensors/RotationProvider.java