test_class.declarator: rule = MockitoJUnit.rule()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public MockitoRule rule = MockitoJUnit.rule();
test_class.type: MockitoRule
test_class.var_name: rule
test_class.declarator: backgroundLocationManager
test_class.modifier: private
test_class.original_string: private BackgroundLocationManager backgroundLocationManager;
test_class.type: BackgroundLocationManager
test_class.var_name: backgroundLocationManager
test_class.declarator: fakeLocationClient
test_class.modifier: private
test_class.original_string: private FakeLocationClient fakeLocationClient;
test_class.type: FakeLocationClient
test_class.var_name: fakeLocationClient
test_class.declarator: locationHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private BackgroundLocationHelper locationHelper;
test_class.type: BackgroundLocationHelper
test_class.var_name: locationHelper
test_class.file: collect_app/src/test/java/org/odk/collect/android/formentry/backgroundlocation/BackgroundLocationManagerTest.java
test_class.identifier: BackgroundLocationManagerTest
test_case.body: @Test
      public void locationRequests_Resume_WhenActivityIsDisplayed_AndFormThatAuditsLocationWasAlreadyLoaded() {
          when(locationHelper.isCurrentFormSet()).thenReturn(true);
          when(locationHelper.currentFormAuditsLocation()).thenReturn(true);
  
          when(locationHelper.arePlayServicesAvailable()).thenReturn(true);
          when(locationHelper.isBackgroundLocationPreferenceEnabled()).thenReturn(true);
          when(locationHelper.isAndroidLocationPermissionGranted()).thenReturn(true);
          when(locationHelper.getCurrentFormAuditConfig()).thenReturn(new AuditConfig("foo", "2", "3", true));
  
          backgroundLocationManager.activityDisplayed();
  
          Location location = LocationTestUtils.createLocation("GPS", 1, 2, 3, 4);
          fakeLocationClient.receiveFix(location);
          verify(locationHelper).provideLocationToAuditLogger(location);
      }
test_case.class_method_signature: BackgroundLocationManagerTest.locationRequests_Resume_WhenActivityIsDisplayed_AndFormThatAuditsLocationWasAlreadyLoaded()
test_case.full_signature: @Test public void locationRequests_Resume_WhenActivityIsDisplayed_AndFormThatAuditsLocationWasAlreadyLoaded()
test_case.identifier: locationRequests_Resume_WhenActivityIsDisplayed_AndFormThatAuditsLocationWasAlreadyLoaded
test_case.invocations: thenReturn when isCurrentFormSet thenReturn when currentFormAuditsLocation thenReturn when arePlayServicesAvailable thenReturn when isBackgroundLocationPreferenceEnabled thenReturn when isAndroidLocationPermissionGranted thenReturn when getCurrentFormAuditConfig activityDisplayed createLocation receiveFix provideLocationToAuditLogger verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void locationRequests_Resume_WhenActivityIsDisplayed_AndFormThatAuditsLocationWasAlreadyLoaded()
focal_class.declarator: currentState
focal_class.modifier: @NonNull
      private
focal_class.original_string: @NonNull
      private BackgroundLocationState currentState;
focal_class.type: BackgroundLocationState
focal_class.var_name: currentState
focal_class.declarator: locationClient
focal_class.modifier: @NonNull
      private
focal_class.original_string: @NonNull
      private LocationClient locationClient;
focal_class.type: LocationClient
focal_class.var_name: locationClient
focal_class.declarator: locationListener
focal_class.modifier: @NonNull
      private
focal_class.original_string: @NonNull
      private LocationListener locationListener;
focal_class.type: LocationListener
focal_class.var_name: locationListener
focal_class.declarator: helper
focal_class.modifier: @NonNull
      private
focal_class.original_string: @NonNull
      private BackgroundLocationHelper helper;
focal_class.type: BackgroundLocationHelper
focal_class.var_name: helper
focal_class.file: collect_app/src/main/java/org/odk/collect/android/formentry/backgroundlocation/BackgroundLocationManager.java
focal_class.identifier: BackgroundLocationManager
focal_class.interfaces: implements LocationClient.LocationClientListener, LocationListener
focal_class.class_method_signature: BackgroundLocationManager.BackgroundLocationManager(LocationClient locationClient, BackgroundLocationHelper helper)
focal_class.full_signature: public  BackgroundLocationManager(LocationClient locationClient, BackgroundLocationHelper helper)
focal_class.identifier: BackgroundLocationManager
focal_class.modifiers: public
focal_class.parameters: (LocationClient locationClient, BackgroundLocationHelper helper)
focal_class.signature:  BackgroundLocationManager(LocationClient locationClient, BackgroundLocationHelper helper)
focal_class.class_method_signature: BackgroundLocationManager.formFinishedLoading()
focal_class.full_signature: public void formFinishedLoading()
focal_class.identifier: formFinishedLoading
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void formFinishedLoading()
focal_class.class_method_signature: BackgroundLocationManager.activityDisplayed()
focal_class.full_signature: public BackgroundLocationMessage activityDisplayed()
focal_class.identifier: activityDisplayed
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: BackgroundLocationMessage
focal_class.signature: BackgroundLocationMessage activityDisplayed()
focal_class.class_method_signature: BackgroundLocationManager.activityHidden()
focal_class.full_signature: public void activityHidden()
focal_class.identifier: activityHidden
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void activityHidden()
focal_class.class_method_signature: BackgroundLocationManager.isPendingPermissionCheck()
focal_class.full_signature: public boolean isPendingPermissionCheck()
focal_class.identifier: isPendingPermissionCheck
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isPendingPermissionCheck()
focal_class.class_method_signature: BackgroundLocationManager.locationPermissionGranted()
focal_class.full_signature: public BackgroundLocationMessage locationPermissionGranted()
focal_class.identifier: locationPermissionGranted
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: BackgroundLocationMessage
focal_class.signature: BackgroundLocationMessage locationPermissionGranted()
focal_class.class_method_signature: BackgroundLocationManager.locationPermissionDenied()
focal_class.full_signature: public void locationPermissionDenied()
focal_class.identifier: locationPermissionDenied
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void locationPermissionDenied()
focal_class.class_method_signature: BackgroundLocationManager.backgroundLocationPreferenceToggled()
focal_class.full_signature: public void backgroundLocationPreferenceToggled()
focal_class.identifier: backgroundLocationPreferenceToggled
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void backgroundLocationPreferenceToggled()
focal_class.class_method_signature: BackgroundLocationManager.locationPermissionChanged()
focal_class.full_signature: public void locationPermissionChanged()
focal_class.identifier: locationPermissionChanged
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void locationPermissionChanged()
focal_class.class_method_signature: BackgroundLocationManager.locationProvidersChanged()
focal_class.full_signature: public void locationProvidersChanged()
focal_class.identifier: locationProvidersChanged
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void locationProvidersChanged()
focal_class.class_method_signature: BackgroundLocationManager.startLocationRequests()
focal_class.full_signature: private void startLocationRequests()
focal_class.identifier: startLocationRequests
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void startLocationRequests()
focal_class.class_method_signature: BackgroundLocationManager.stopLocationRequests()
focal_class.full_signature: private void stopLocationRequests()
focal_class.identifier: stopLocationRequests
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void stopLocationRequests()
focal_class.class_method_signature: BackgroundLocationManager.onLocationChanged(Location location)
focal_class.full_signature: @Override public void onLocationChanged(Location location)
focal_class.identifier: onLocationChanged
focal_class.modifiers: @Override public
focal_class.parameters: (Location location)
focal_class.return: void
focal_class.signature: void onLocationChanged(Location location)
focal_class.class_method_signature: BackgroundLocationManager.onClientStart()
focal_class.full_signature: @Override public void onClientStart()
focal_class.identifier: onClientStart
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void onClientStart()
focal_class.class_method_signature: BackgroundLocationManager.onClientStartFailure()
focal_class.full_signature: @Override public void onClientStartFailure()
focal_class.identifier: onClientStartFailure
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void onClientStartFailure()
focal_class.class_method_signature: BackgroundLocationManager.onClientStop()
focal_class.full_signature: @Override public void onClientStop()
focal_class.identifier: onClientStop
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void onClientStop()
focal_method.body: public BackgroundLocationMessage activityDisplayed() {
          switch (currentState) {
              case NO_BACKGROUND_LOCATION_NEEDED:
                  // After system-initiated process death, state is reset. The form did not get
                  // reloaded and user messaging has already been displayed so go straight to
                  // requesting location.
                  if (helper.isCurrentFormSet() && helper.currentFormAuditsLocation()) {
                      startLocationRequests();
  
                      if (currentState != BackgroundLocationState.RECEIVING_LOCATIONS) {
                          // The form requests background location and some precondition failed. Change
                          // the state to STOPPED so that if preconditions change, location tracking
                          // will resume.
                          currentState = BackgroundLocationState.STOPPED;
                      }
                  }
                  break;
  
              case PENDING_PRECONDITION_CHECKS:
                  // Separate out user message so that any failed precondition is written to the audit
                  // log. If Play Services are unavailable AND the location preference is disabled,
                  // show the Play Services unavailable message only.
                  BackgroundLocationMessage userMessage = null;
  
                  if (!helper.isBackgroundLocationPreferenceEnabled()) {
                      helper.logAuditEvent(AuditEvent.AuditEventType.LOCATION_TRACKING_DISABLED);
                      userMessage = BackgroundLocationMessage.LOCATION_PREF_DISABLED;
                  }
  
                  if (!helper.arePlayServicesAvailable()) {
                      helper.logAuditEvent(AuditEvent.AuditEventType.GOOGLE_PLAY_SERVICES_NOT_AVAILABLE);
                      userMessage = BackgroundLocationMessage.PLAY_SERVICES_UNAVAILABLE;
                  }
  
                  if (userMessage == null) {
                      helper.logAuditEvent(AuditEvent.AuditEventType.LOCATION_TRACKING_ENABLED);
                      currentState = BackgroundLocationState.PENDING_PERMISSION_CHECK;
                  } else {
                      currentState = BackgroundLocationState.STOPPED;
                  }
  
                  return userMessage;
  
              case STOPPED:
                  // All preconditions could be met either because we were collecting location, hid
                  // the activity and showed it again or because a precondition became met.
                  startLocationRequests();
                  break;
          }
  
          return null;
      }
focal_method.class_method_signature: BackgroundLocationManager.activityDisplayed()
focal_method.full_signature: public BackgroundLocationMessage activityDisplayed()
focal_method.identifier: activityDisplayed
focal_method.invocations: isCurrentFormSet currentFormAuditsLocation startLocationRequests isBackgroundLocationPreferenceEnabled logAuditEvent arePlayServicesAvailable logAuditEvent logAuditEvent startLocationRequests
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: BackgroundLocationMessage
focal_method.signature: BackgroundLocationMessage activityDisplayed()