Skip to content

Commit

Permalink
Fix default Magnetic Sensor interval causing a security exception (#5812
Browse files Browse the repository at this point in the history
)

## Summary

Currently default magnetic sampling interval equals 2ms, which triggers
a `HIGH_SAMPLE_RATE` security exception.
This fix defaults the probing interval to 8ms.

Note: `'auto'` setting defaults to `-1`, which is then replaced by `2`.

## Test plan

Download a new emulator on Android Studio - I'm using `Pixel 8
UpsideDownCake`
Launch the magnetic sensor example before, and after applying this
patch.

---------

Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
  • Loading branch information
latekvo and tomekzaw authored Mar 25, 2024
1 parent d224237 commit 9e79766
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ReanimatedSensor {
Sensor sensor;
ReanimatedSensorType sensorType;
int interval;
private static final int DEFAULT_INTERVAL = 8;

ReanimatedSensor(
WeakReference<ReactApplicationContext> reactContext,
Expand All @@ -30,7 +31,7 @@ public class ReanimatedSensor {
(SensorManager) reactContext.get().getSystemService(reactContext.get().SENSOR_SERVICE);
this.sensorType = sensorType;
if (interval == -1) {
this.interval = SensorManager.SENSOR_DELAY_UI;
this.interval = DEFAULT_INTERVAL;
} else {
this.interval = interval;
}
Expand Down

0 comments on commit 9e79766

Please sign in to comment.