Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid infinite loop by adding a parameter on whether or not the statu…
…s should be recomputed The current code has an infinite loop if there is a problem with the location settings or permission. In that case, we generate a `CFCTransitionGeofenceCreationError` ``` else { /* Log.i(ctxt, TAG, "location settings are valid, but location permission is not, generating tracking error and visible notification"); Log.i(ctxt, TAG, "curr status check results = " + " loc permission, motion permission, notification, unused apps "+ Arrays.toString(allOtherChecks)); */ // Should replace with TRACKING_ERROR but looks like we // don't have any [[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName object:CFCTransitionGeofenceCreationError]; [self generateOpenAppSettingsNotification]; ``` which should cause the app go to into the start state. ``` } else if ([transition isEqualToString:CFCTransitionGeofenceCreationError]) { [self setState:kStartState]; ``` However, with 2fc078b, we now check the app state in `setState`. ``` -(void)setState:(TripDiaryStates) newState { ... [SensorControlBackgroundChecker checkAppState]; ``` So we end up with an infinite loop: - check app settings - permission checks fail - geofence creation error - set state to start - check app settings - permission checks fail - geofence creation error - set state to start - check app settings ... On android, we handle this by including a parameter that indicates whether the app status should be recomputed or not (in 9560859) This commit makes similar changes to iOS. On android, we would avoid recomputing only once and that would be the case for iOS as well. ``` Log.i(this, TAG, "Already in the start state, so going to stay there"); - setNewState(mCurrState); + setNewState(mCurrState, false); return; ``` Testing done: - No infinite loop on start (when we have no permissions)
- Loading branch information