Skip to content

Commit

Permalink
Replace systemUptime calls with CACurrentMediaTime() to comply wi…
Browse files Browse the repository at this point in the history
…th Apple privacy requirements (#5819)

## Summary

Closes #5801.

This PR replaces all `[[NSProcessInfo processInfo] systemUptime]` calls
with `CACurrentMediaTime() * 1000`.

## Test plan

Check if `useAnimatedSensor` with interval works properly.
  • Loading branch information
tomekzaw authored Mar 21, 2024
1 parent d6dab8f commit 1ea5d1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Example/ios/MBFingerTipWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ - (void)removeInactiveFingerTips
{
self.fingerTipRemovalScheduled = NO;

NSTimeInterval now = [[NSProcessInfo processInfo] systemUptime];
NSTimeInterval now = CACurrentMediaTime() * 1000;
const CGFloat REMOVAL_DELAY = 0.2;

for (MBFingerTipView *touchView in [self.overlayWindow subviews])
Expand Down
10 changes: 5 additions & 5 deletions apple/sensor/ReanimatedSensor.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (bool)initializeGyroscope
[_motionManager
startGyroUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMGyroData *sensorData, NSError *error) {
double currentTime = [[NSProcessInfo processInfo] systemUptime];
double currentTime = CACurrentMediaTime() * 1000;
if (currentTime - self->_lastTimestamp < self->_interval) {
return;
}
Expand All @@ -69,7 +69,7 @@ - (bool)initializeAccelerometer
[_motionManager startAccelerometerUpdates];
[_motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMAccelerometerData *sensorData, NSError *error) {
double currentTime = [[NSProcessInfo processInfo] systemUptime];
double currentTime = CACurrentMediaTime() * 1000;
if (currentTime - self->_lastTimestamp < self->_interval) {
return;
}
Expand All @@ -96,7 +96,7 @@ - (bool)initializeGravity
[_motionManager
startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
double currentTime = [[NSProcessInfo processInfo] systemUptime];
double currentTime = CACurrentMediaTime() * 1000;
if (currentTime - self->_lastTimestamp < self->_interval) {
return;
}
Expand All @@ -121,7 +121,7 @@ - (bool)initializeMagnetometer
[_motionManager
startMagnetometerUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMMagnetometerData *sensorData, NSError *error) {
double currentTime = [[NSProcessInfo processInfo] systemUptime];
double currentTime = CACurrentMediaTime() * 1000;
if (currentTime - self->_lastTimestamp < self->_interval) {
return;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ - (bool)initializeOrientation
[_motionManager startDeviceMotionUpdatesUsingReferenceFrame:(1 << _referenceFrame)
toQueue:[NSOperationQueue mainQueue]
withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
double currentTime = [[NSProcessInfo processInfo] systemUptime];
double currentTime = CACurrentMediaTime() * 1000;
if (currentTime - self->_lastTimestamp < self->_interval) {
return;
}
Expand Down

0 comments on commit 1ea5d1d

Please sign in to comment.