public synchronized Collection < Beacon > finalizeBeacons ( ) { Map < Beacon , RangedBeacon > newRangedBeacons = new HashMap < Beacon , RangedBeacon > ( ) ; ArrayList < Beacon > finalizedBeacons = new ArrayList < Beacon > ( ) ; synchronized ( mRangedBeacons ) { for ( Beacon beacon : mRangedBeacons . keySet ( ) ) { RangedBeacon rangedBeacon = mRangedBeacons . get ( beacon ) ; if ( rangedBeacon != null ) { if ( rangedBeacon . isTracked ( ) ) { rangedBeacon . commitMeasurements ( ) ; // calculates accuracy if ( ! rangedBeacon . noMeasurementsAvailable ( ) ) { finalizedBeacons . add ( rangedBeacon . getBeacon ( ) ) ; } } // If we still have useful measurements, keep it around but mark it as not // tracked anymore so we don't pass it on as visible unless it is seen again if ( ! rangedBeacon . noMeasurementsAvailable ( ) == true ) { //if TrackingCache is enabled, allow beacon to not receive //measurements for a certain amount of time if ( ! sUseTrackingCache || rangedBeacon . isExpired ( ) ) rangedBeacon . setTracked ( false ) ; newRangedBeacons . put ( beacon , rangedBeacon ) ; } else { LogManager . d ( TAG , "Dumping beacon from RangeState because it has no recent measurements." ) ; } } } mRangedBeacons = newRangedBeacons ; } return finalizedBeacons ; }
be there for the next cycle