Program: 839
Project: 839
Buggy source:
/** 
 * Turn any periodic sync operations that are ready to run into pending sync operations.
 * @return the desired start time of the earliest future  periodic sync operation,in milliseconds since boot
 */
private long scheduleReadyPeriodicSyncs(){
  final boolean isLoggable=Log.isLoggable(TAG,Log.VERBOSE);
  if (isLoggable) {
    Log.v(TAG,"String_Node_Str");
  }
  final boolean backgroundDataUsageAllowed=getConnectivityManager().getBackgroundDataSetting();
  long earliestFuturePollTime=Long.MAX_VALUE;
  if (!backgroundDataUsageAllowed) {
    return earliestFuturePollTime;
  }
  AccountAndUser[] accounts=mRunningAccounts;
  final long nowAbsolute=System.currentTimeMillis();
  final long shiftedNowAbsolute=(0 < nowAbsolute - mSyncRandomOffsetMillis) ? (nowAbsolute - mSyncRandomOffsetMillis) : 0;
  ArrayList<Pair<AuthorityInfo,SyncStatusInfo>> infos=mSyncStorageEngine.getCopyOfAllAuthoritiesWithSyncStatus();
  for (  Pair<AuthorityInfo,SyncStatusInfo> info : infos) {
    final AuthorityInfo authorityInfo=info.first;
    final SyncStatusInfo status=info.second;
    if (!containsAccountAndUser(accounts,authorityInfo.account,authorityInfo.userId)) {
      continue;
    }
    if (!mSyncStorageEngine.getMasterSyncAutomatically(authorityInfo.userId) || !mSyncStorageEngine.getSyncAutomatically(authorityInfo.account,authorityInfo.userId,authorityInfo.authority)) {
      continue;
    }
    if (getIsSyncable(authorityInfo.account,authorityInfo.userId,authorityInfo.authority) == 0) {
      continue;
    }
    for (int i=0, N=authorityInfo.periodicSyncs.size(); i < N; i++) {
      final PeriodicSync sync=authorityInfo.periodicSyncs.get(i);
      final Bundle extras=sync.extras;
      final long periodInMillis=sync.period * 1000;
      final long flexInMillis=sync.flexTime * 1000;
      if (periodInMillis <= 0) {
        continue;
      }
      final long lastPollTimeAbsolute=status.getPeriodicSyncTime(i);
      long remainingMillis=periodInMillis - (shiftedNowAbsolute % periodInMillis);
      long timeSinceLastRunMillis=(nowAbsolute - lastPollTimeAbsolute);
      boolean runEarly=remainingMillis <= flexInMillis && timeSinceLastRunMillis > periodInMillis - flexInMillis;
      if (isLoggable) {
        Log.v(TAG,"String_Node_Str" + i + "String_Node_Str"+ authorityInfo.authority+ "String_Node_Str"+ "String_Node_Str"+ (periodInMillis)+ "String_Node_Str"+ (flexInMillis)+ "String_Node_Str"+ (remainingMillis)+ "String_Node_Str"+ timeSinceLastRunMillis+ "String_Node_Str"+ lastPollTimeAbsolute+ "String_Node_Str"+ shiftedNowAbsolute+ "String_Node_Str"+ runEarly);
      }
      if (runEarly || remainingMillis == periodInMillis || lastPollTimeAbsolute > nowAbsolute || timeSinceLastRunMillis >= periodInMillis) {
        final Pair<Long,Long> backoff=mSyncStorageEngine.getBackoff(authorityInfo.account,authorityInfo.userId,authorityInfo.authority);
        final RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo;
        syncAdapterInfo=mSyncAdapters.getServiceInfo(SyncAdapterType.newKey(authorityInfo.authority,authorityInfo.account.type),authorityInfo.userId);
        if (syncAdapterInfo == null) {
          continue;
        }
        mSyncStorageEngine.setPeriodicSyncTime(authorityInfo.ident,authorityInfo.periodicSyncs.get(i),nowAbsolute);
        scheduleSyncOperation(new SyncOperation(authorityInfo.account,authorityInfo.userId,SyncOperation.REASON_PERIODIC,SyncStorageEngine.SOURCE_PERIODIC,authorityInfo.authority,extras,0,0,backoff != null ? backoff.first : 0,mSyncStorageEngine.getDelayUntilTime(authorityInfo.account,authorityInfo.userId,authorityInfo.authority),syncAdapterInfo.type.allowParallelSyncs()));
      }
      long nextPollTimeAbsolute;
      if (runEarly) {
        nextPollTimeAbsolute=nowAbsolute + periodInMillis + remainingMillis;
      }
 else {
        nextPollTimeAbsolute=nowAbsolute + remainingMillis;
      }
      if (nextPollTimeAbsolute < earliestFuturePollTime) {
        earliestFuturePollTime=nextPollTimeAbsolute;
      }
    }
  }
  if (earliestFuturePollTime == Long.MAX_VALUE) {
    return Long.MAX_VALUE;
  }
  return SystemClock.elapsedRealtime() + ((earliestFuturePollTime < nowAbsolute) ? 0 : (earliestFuturePollTime - nowAbsolute));
}

Fixed version (ground truth):
/** 
 * Turn any periodic sync operations that are ready to run into pending sync operations.
 * @return the desired start time of the earliest future  periodic sync operation,in milliseconds since boot
 */
private long scheduleReadyPeriodicSyncs(){
  final boolean isLoggable=Log.isLoggable(TAG,Log.VERBOSE);
  if (isLoggable) {
    Log.v(TAG,"String_Node_Str");
  }
  final boolean backgroundDataUsageAllowed=getConnectivityManager().getBackgroundDataSetting();
  long earliestFuturePollTime=Long.MAX_VALUE;
  if (!backgroundDataUsageAllowed) {
    return earliestFuturePollTime;
  }
  AccountAndUser[] accounts=mRunningAccounts;
  final long nowAbsolute=System.currentTimeMillis();
  final long shiftedNowAbsolute=(0 < nowAbsolute - mSyncRandomOffsetMillis) ? (nowAbsolute - mSyncRandomOffsetMillis) : 0;
  ArrayList<Pair<AuthorityInfo,SyncStatusInfo>> infos=mSyncStorageEngine.getCopyOfAllAuthoritiesWithSyncStatus();
  for (  Pair<AuthorityInfo,SyncStatusInfo> info : infos) {
    final AuthorityInfo authorityInfo=info.first;
    final SyncStatusInfo status=info.second;
    if (TextUtils.isEmpty(authorityInfo.authority)) {
      Log.e(TAG,"String_Node_Str" + authorityInfo);
      continue;
    }
    if (!containsAccountAndUser(accounts,authorityInfo.account,authorityInfo.userId)) {
      continue;
    }
    if (!mSyncStorageEngine.getMasterSyncAutomatically(authorityInfo.userId) || !mSyncStorageEngine.getSyncAutomatically(authorityInfo.account,authorityInfo.userId,authorityInfo.authority)) {
      continue;
    }
    if (getIsSyncable(authorityInfo.account,authorityInfo.userId,authorityInfo.authority) == 0) {
      continue;
    }
    for (int i=0, N=authorityInfo.periodicSyncs.size(); i < N; i++) {
      final PeriodicSync sync=authorityInfo.periodicSyncs.get(i);
      final Bundle extras=sync.extras;
      final long periodInMillis=sync.period * 1000;
      final long flexInMillis=sync.flexTime * 1000;
      if (periodInMillis <= 0) {
        continue;
      }
      final long lastPollTimeAbsolute=status.getPeriodicSyncTime(i);
      long remainingMillis=periodInMillis - (shiftedNowAbsolute % periodInMillis);
      long timeSinceLastRunMillis=(nowAbsolute - lastPollTimeAbsolute);
      boolean runEarly=remainingMillis <= flexInMillis && timeSinceLastRunMillis > periodInMillis - flexInMillis;
      if (isLoggable) {
        Log.v(TAG,"String_Node_Str" + i + "String_Node_Str"+ authorityInfo.authority+ "String_Node_Str"+ "String_Node_Str"+ (periodInMillis)+ "String_Node_Str"+ (flexInMillis)+ "String_Node_Str"+ (remainingMillis)+ "String_Node_Str"+ timeSinceLastRunMillis+ "String_Node_Str"+ lastPollTimeAbsolute+ "String_Node_Str"+ shiftedNowAbsolute+ "String_Node_Str"+ runEarly);
      }
      if (runEarly || remainingMillis == periodInMillis || lastPollTimeAbsolute > nowAbsolute || timeSinceLastRunMillis >= periodInMillis) {
        final Pair<Long,Long> backoff=mSyncStorageEngine.getBackoff(authorityInfo.account,authorityInfo.userId,authorityInfo.authority);
        final RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo;
        syncAdapterInfo=mSyncAdapters.getServiceInfo(SyncAdapterType.newKey(authorityInfo.authority,authorityInfo.account.type),authorityInfo.userId);
        if (syncAdapterInfo == null) {
          continue;
        }
        mSyncStorageEngine.setPeriodicSyncTime(authorityInfo.ident,authorityInfo.periodicSyncs.get(i),nowAbsolute);
        scheduleSyncOperation(new SyncOperation(authorityInfo.account,authorityInfo.userId,SyncOperation.REASON_PERIODIC,SyncStorageEngine.SOURCE_PERIODIC,authorityInfo.authority,extras,0,0,backoff != null ? backoff.first : 0,mSyncStorageEngine.getDelayUntilTime(authorityInfo.account,authorityInfo.userId,authorityInfo.authority),syncAdapterInfo.type.allowParallelSyncs()));
      }
      long nextPollTimeAbsolute;
      if (runEarly) {
        nextPollTimeAbsolute=nowAbsolute + periodInMillis + remainingMillis;
      }
 else {
        nextPollTimeAbsolute=nowAbsolute + remainingMillis;
      }
      if (nextPollTimeAbsolute < earliestFuturePollTime) {
        earliestFuturePollTime=nextPollTimeAbsolute;
      }
    }
  }
  if (earliestFuturePollTime == Long.MAX_VALUE) {
    return Long.MAX_VALUE;
  }
  return SystemClock.elapsedRealtime() + ((earliestFuturePollTime < nowAbsolute) ? 0 : (earliestFuturePollTime - nowAbsolute));
}