Program: 2304
Project: 2304
Buggy source:
private void handleLocationChangedLocked(Location location,boolean passive){
  if (D)   Log.d(TAG,"String_Node_Str" + location);
  long now=SystemClock.elapsedRealtime();
  String provider=(passive ? LocationManager.PASSIVE_PROVIDER : location.getProvider());
  LocationProviderInterface p=mProvidersByName.get(provider);
  if (p == null)   return;
  Location noGPSLocation=location.getExtraLocation(Location.EXTRA_NO_GPS_LOCATION);
  Location lastNoGPSLocation=null;
  Location lastLocation=mLastLocation.get(provider);
  if (lastLocation == null) {
    lastLocation=new Location(provider);
    mLastLocation.put(provider,lastLocation);
  }
 else {
    lastNoGPSLocation=lastLocation.getExtraLocation(Location.EXTRA_NO_GPS_LOCATION);
    if (noGPSLocation == null && lastNoGPSLocation != null) {
      location.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION,lastNoGPSLocation);
    }
  }
  lastLocation.set(location);
  ArrayList<UpdateRecord> records=mRecordsByProvider.get(provider);
  if (records == null || records.size() == 0)   return;
  Location coarseLocation=null;
  if (noGPSLocation != null && !noGPSLocation.equals(lastNoGPSLocation)) {
    coarseLocation=mLocationFudger.getOrCreate(noGPSLocation);
  }
  long newStatusUpdateTime=p.getStatusUpdateTime();
  Bundle extras=new Bundle();
  int status=p.getStatus(extras);
  ArrayList<Receiver> deadReceivers=null;
  ArrayList<UpdateRecord> deadUpdateRecords=null;
  for (  UpdateRecord r : records) {
    Receiver receiver=r.mReceiver;
    boolean receiverDead=false;
    int receiverUserId=UserHandle.getUserId(receiver.mUid);
    if (receiverUserId != mCurrentUserId) {
      if (D) {
        Log.d(TAG,"String_Node_Str" + receiverUserId + "String_Node_Str"+ mCurrentUserId+ "String_Node_Str"+ receiver.mPackageName+ "String_Node_Str");
      }
      continue;
    }
    if (mBlacklist.isBlacklisted(receiver.mPackageName)) {
      if (D)       Log.d(TAG,"String_Node_Str" + receiver.mPackageName);
      continue;
    }
    if (!reportLocationAccessNoThrow(receiver.mUid,receiver.mPackageName,receiver.mAllowedResolutionLevel)) {
      if (D)       Log.d(TAG,"String_Node_Str" + receiver.mPackageName);
      continue;
    }
    Location notifyLocation=null;
    if (receiver.mAllowedResolutionLevel < RESOLUTION_LEVEL_FINE) {
      notifyLocation=coarseLocation;
    }
 else {
      notifyLocation=lastLocation;
    }
    if (notifyLocation != null) {
      Location lastLoc=r.mLastFixBroadcast;
      if ((lastLoc == null) || shouldBroadcastSafe(notifyLocation,lastLoc,r,now)) {
        if (lastLoc == null) {
          lastLoc=new Location(notifyLocation);
          r.mLastFixBroadcast=lastLoc;
        }
 else {
          lastLoc.set(notifyLocation);
        }
        if (!receiver.callLocationChangedLocked(notifyLocation)) {
          Slog.w(TAG,"String_Node_Str" + receiver);
          receiverDead=true;
        }
        r.mRequest.decrementNumUpdates();
      }
    }
    long prevStatusUpdateTime=r.mLastStatusBroadcast;
    if ((newStatusUpdateTime > prevStatusUpdateTime) && (prevStatusUpdateTime != 0 || status != LocationProvider.AVAILABLE)) {
      r.mLastStatusBroadcast=newStatusUpdateTime;
      if (!receiver.callStatusChangedLocked(provider,status,extras)) {
        receiverDead=true;
        Slog.w(TAG,"String_Node_Str" + receiver);
      }
    }
    if (r.mRequest.getNumUpdates() <= 0 || r.mRequest.getExpireAt() < now) {
      if (deadUpdateRecords == null) {
        deadUpdateRecords=new ArrayList<UpdateRecord>();
      }
      deadUpdateRecords.add(r);
    }
    if (receiverDead) {
      if (deadReceivers == null) {
        deadReceivers=new ArrayList<Receiver>();
      }
      if (!deadReceivers.contains(receiver)) {
        deadReceivers.add(receiver);
      }
    }
  }
  if (deadReceivers != null) {
    for (    Receiver receiver : deadReceivers) {
      removeUpdatesLocked(receiver);
    }
  }
  if (deadUpdateRecords != null) {
    for (    UpdateRecord r : deadUpdateRecords) {
      r.disposeLocked(true);
    }
    applyRequirementsLocked(provider);
  }
}

Fixed version (ground truth):
private void handleLocationChangedLocked(Location location,boolean passive){
  if (D)   Log.d(TAG,"String_Node_Str" + location);
  long now=SystemClock.elapsedRealtime();
  String provider=(passive ? LocationManager.PASSIVE_PROVIDER : location.getProvider());
  LocationProviderInterface p=mProvidersByName.get(provider);
  if (p == null)   return;
  Location noGPSLocation=location.getExtraLocation(Location.EXTRA_NO_GPS_LOCATION);
  Location lastNoGPSLocation=null;
  Location lastLocation=mLastLocation.get(provider);
  if (lastLocation == null) {
    lastLocation=new Location(provider);
    mLastLocation.put(provider,lastLocation);
  }
 else {
    lastNoGPSLocation=lastLocation.getExtraLocation(Location.EXTRA_NO_GPS_LOCATION);
    if (noGPSLocation == null && lastNoGPSLocation != null) {
      location.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION,lastNoGPSLocation);
    }
  }
  lastLocation.set(location);
  Location lastLocationCoarseInterval=mLastLocationCoarseInterval.get(provider);
  if (lastLocationCoarseInterval == null) {
    lastLocationCoarseInterval=new Location(location);
    mLastLocationCoarseInterval.put(provider,lastLocationCoarseInterval);
  }
  long timeDiffNanos=location.getElapsedRealtimeNanos() - lastLocationCoarseInterval.getElapsedRealtimeNanos();
  if (timeDiffNanos > LocationFudger.FASTEST_INTERVAL_MS * NANOS_PER_MILLI) {
    lastLocationCoarseInterval.set(location);
  }
  noGPSLocation=lastLocationCoarseInterval.getExtraLocation(Location.EXTRA_NO_GPS_LOCATION);
  ArrayList<UpdateRecord> records=mRecordsByProvider.get(provider);
  if (records == null || records.size() == 0)   return;
  Location coarseLocation=null;
  if (noGPSLocation != null) {
    coarseLocation=mLocationFudger.getOrCreate(noGPSLocation);
  }
  long newStatusUpdateTime=p.getStatusUpdateTime();
  Bundle extras=new Bundle();
  int status=p.getStatus(extras);
  ArrayList<Receiver> deadReceivers=null;
  ArrayList<UpdateRecord> deadUpdateRecords=null;
  for (  UpdateRecord r : records) {
    Receiver receiver=r.mReceiver;
    boolean receiverDead=false;
    int receiverUserId=UserHandle.getUserId(receiver.mUid);
    if (receiverUserId != mCurrentUserId) {
      if (D) {
        Log.d(TAG,"String_Node_Str" + receiverUserId + "String_Node_Str"+ mCurrentUserId+ "String_Node_Str"+ receiver.mPackageName+ "String_Node_Str");
      }
      continue;
    }
    if (mBlacklist.isBlacklisted(receiver.mPackageName)) {
      if (D)       Log.d(TAG,"String_Node_Str" + receiver.mPackageName);
      continue;
    }
    if (!reportLocationAccessNoThrow(receiver.mUid,receiver.mPackageName,receiver.mAllowedResolutionLevel)) {
      if (D)       Log.d(TAG,"String_Node_Str" + receiver.mPackageName);
      continue;
    }
    Location notifyLocation=null;
    if (receiver.mAllowedResolutionLevel < RESOLUTION_LEVEL_FINE) {
      notifyLocation=coarseLocation;
    }
 else {
      notifyLocation=lastLocation;
    }
    if (notifyLocation != null) {
      Location lastLoc=r.mLastFixBroadcast;
      if ((lastLoc == null) || shouldBroadcastSafe(notifyLocation,lastLoc,r,now)) {
        if (lastLoc == null) {
          lastLoc=new Location(notifyLocation);
          r.mLastFixBroadcast=lastLoc;
        }
 else {
          lastLoc.set(notifyLocation);
        }
        if (!receiver.callLocationChangedLocked(notifyLocation)) {
          Slog.w(TAG,"String_Node_Str" + receiver);
          receiverDead=true;
        }
        r.mRequest.decrementNumUpdates();
      }
    }
    long prevStatusUpdateTime=r.mLastStatusBroadcast;
    if ((newStatusUpdateTime > prevStatusUpdateTime) && (prevStatusUpdateTime != 0 || status != LocationProvider.AVAILABLE)) {
      r.mLastStatusBroadcast=newStatusUpdateTime;
      if (!receiver.callStatusChangedLocked(provider,status,extras)) {
        receiverDead=true;
        Slog.w(TAG,"String_Node_Str" + receiver);
      }
    }
    if (r.mRequest.getNumUpdates() <= 0 || r.mRequest.getExpireAt() < now) {
      if (deadUpdateRecords == null) {
        deadUpdateRecords=new ArrayList<UpdateRecord>();
      }
      deadUpdateRecords.add(r);
    }
    if (receiverDead) {
      if (deadReceivers == null) {
        deadReceivers=new ArrayList<Receiver>();
      }
      if (!deadReceivers.contains(receiver)) {
        deadReceivers.add(receiver);
      }
    }
  }
  if (deadReceivers != null) {
    for (    Receiver receiver : deadReceivers) {
      removeUpdatesLocked(receiver);
    }
  }
  if (deadUpdateRecords != null) {
    for (    UpdateRecord r : deadUpdateRecords) {
      r.disposeLocked(true);
    }
    applyRequirementsLocked(provider);
  }
}