Program: 192807
Project: 192807
Buggy source:
/** 
 * Distribute Cell radio energy info and network traffic to apps.
 */
public void updateMobileRadioStateLocked(final long elapsedRealtimeMs,final ModemActivityInfo activityInfo){
  if (DEBUG_ENERGY) {
    Slog.d(TAG,"String_Node_Str" + activityInfo);
  }
  NetworkStats delta=null;
  try {
    if (!ArrayUtils.isEmpty(mMobileIfaces)) {
      delta=getNetworkStatsDeltaLocked(mMobileIfaces,mMobileNetworkStats);
    }
  }
 catch (  IOException e) {
    Slog.wtf(TAG,"String_Node_Str",e);
    return;
  }
  if (!mOnBatteryInternal) {
    return;
  }
  long radioTime=mMobileRadioActivePerAppTimer.getTimeSinceMarkLocked(elapsedRealtimeMs * 1000);
  mMobileRadioActivePerAppTimer.setMark(elapsedRealtimeMs);
  long totalRxPackets=0;
  long totalTxPackets=0;
  if (delta != null) {
    final int size=delta.size();
    for (int i=0; i < size; i++) {
      final NetworkStats.Entry entry=delta.getValues(i,mTmpNetworkStatsEntry);
      if (entry.rxPackets == 0 || entry.txPackets == 0) {
        continue;
      }
      if (DEBUG_ENERGY) {
        Slog.d(TAG,"String_Node_Str" + entry.uid + "String_Node_Str"+ entry.rxBytes+ "String_Node_Str"+ entry.txBytes+ "String_Node_Str"+ entry.rxPackets+ "String_Node_Str"+ entry.txPackets);
      }
      totalRxPackets+=entry.rxPackets;
      totalTxPackets+=entry.txPackets;
      final Uid u=getUidStatsLocked(mapUid(entry.uid));
      u.noteNetworkActivityLocked(NETWORK_MOBILE_RX_DATA,entry.rxBytes,entry.rxPackets);
      u.noteNetworkActivityLocked(NETWORK_MOBILE_TX_DATA,entry.txBytes,entry.txPackets);
      mNetworkByteActivityCounters[NETWORK_MOBILE_RX_DATA].addCountLocked(entry.rxBytes);
      mNetworkByteActivityCounters[NETWORK_MOBILE_TX_DATA].addCountLocked(entry.txBytes);
      mNetworkPacketActivityCounters[NETWORK_MOBILE_RX_DATA].addCountLocked(entry.rxPackets);
      mNetworkPacketActivityCounters[NETWORK_MOBILE_TX_DATA].addCountLocked(entry.txPackets);
    }
    long totalPackets=totalRxPackets + totalTxPackets;
    if (totalPackets > 0) {
      for (int i=0; i < size; i++) {
        final NetworkStats.Entry entry=delta.getValues(i,mTmpNetworkStatsEntry);
        if (entry.rxPackets == 0 && entry.txPackets == 0) {
          continue;
        }
        final Uid u=getUidStatsLocked(mapUid(entry.uid));
        final long appPackets=entry.rxPackets + entry.txPackets;
        final long appRadioTime=(radioTime * appPackets) / totalPackets;
        u.noteMobileRadioActiveTimeLocked(appRadioTime);
        radioTime-=appRadioTime;
        totalPackets-=appPackets;
        if (activityInfo != null) {
          ControllerActivityCounterImpl activityCounter=u.getOrCreateModemControllerActivityLocked();
          if (entry.rxPackets != 0) {
            final long rxMs=(entry.rxPackets * activityInfo.getRxTimeMillis()) / totalRxPackets;
            activityCounter.getRxTimeCounter().addCountLocked(rxMs);
          }
          if (entry.txPackets != 0) {
            for (int lvl=0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
              long txMs=entry.txPackets * activityInfo.getTxTimeMillis()[lvl];
              txMs/=totalTxPackets;
              activityCounter.getTxTimeCounters()[lvl].addCountLocked(txMs);
            }
          }
        }
      }
    }
    if (radioTime > 0) {
      mMobileRadioActiveUnknownTime.addCountLocked(radioTime);
      mMobileRadioActiveUnknownCount.addCountLocked(1);
    }
  }
  if (activityInfo != null) {
    mHasModemReporting=true;
    mModemActivity.getIdleTimeCounter().addCountLocked(activityInfo.getIdleTimeMillis());
    mModemActivity.getRxTimeCounter().addCountLocked(activityInfo.getRxTimeMillis());
    for (int lvl=0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
      mModemActivity.getTxTimeCounters()[lvl].addCountLocked(activityInfo.getTxTimeMillis()[lvl]);
    }
    final double opVolt=mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE) / 1000.0;
    if (opVolt != 0) {
      mModemActivity.getPowerCounter().addCountLocked((long)(activityInfo.getEnergyUsed() / opVolt));
    }
  }
}

Fixed version (ground truth):
/** 
 * Distribute Cell radio energy info and network traffic to apps.
 */
public void updateMobileRadioStateLocked(final long elapsedRealtimeMs,final ModemActivityInfo activityInfo){
  if (DEBUG_ENERGY) {
    Slog.d(TAG,"String_Node_Str" + activityInfo);
  }
  NetworkStats delta=null;
  try {
    if (!ArrayUtils.isEmpty(mMobileIfaces)) {
      delta=getNetworkStatsDeltaLocked(mMobileIfaces,mMobileNetworkStats);
    }
  }
 catch (  IOException e) {
    Slog.wtf(TAG,"String_Node_Str",e);
    return;
  }
  if (!mOnBatteryInternal) {
    return;
  }
  long radioTime=mMobileRadioActivePerAppTimer.getTimeSinceMarkLocked(elapsedRealtimeMs * 1000);
  mMobileRadioActivePerAppTimer.setMark(elapsedRealtimeMs);
  long totalRxPackets=0;
  long totalTxPackets=0;
  if (delta != null) {
    final int size=delta.size();
    for (int i=0; i < size; i++) {
      final NetworkStats.Entry entry=delta.getValues(i,mTmpNetworkStatsEntry);
      if (entry.rxPackets == 0 && entry.txPackets == 0) {
        continue;
      }
      if (DEBUG_ENERGY) {
        Slog.d(TAG,"String_Node_Str" + entry.uid + "String_Node_Str"+ entry.rxBytes+ "String_Node_Str"+ entry.txBytes+ "String_Node_Str"+ entry.rxPackets+ "String_Node_Str"+ entry.txPackets);
      }
      totalRxPackets+=entry.rxPackets;
      totalTxPackets+=entry.txPackets;
      final Uid u=getUidStatsLocked(mapUid(entry.uid));
      u.noteNetworkActivityLocked(NETWORK_MOBILE_RX_DATA,entry.rxBytes,entry.rxPackets);
      u.noteNetworkActivityLocked(NETWORK_MOBILE_TX_DATA,entry.txBytes,entry.txPackets);
      mNetworkByteActivityCounters[NETWORK_MOBILE_RX_DATA].addCountLocked(entry.rxBytes);
      mNetworkByteActivityCounters[NETWORK_MOBILE_TX_DATA].addCountLocked(entry.txBytes);
      mNetworkPacketActivityCounters[NETWORK_MOBILE_RX_DATA].addCountLocked(entry.rxPackets);
      mNetworkPacketActivityCounters[NETWORK_MOBILE_TX_DATA].addCountLocked(entry.txPackets);
    }
    long totalPackets=totalRxPackets + totalTxPackets;
    if (totalPackets > 0) {
      for (int i=0; i < size; i++) {
        final NetworkStats.Entry entry=delta.getValues(i,mTmpNetworkStatsEntry);
        if (entry.rxPackets == 0 && entry.txPackets == 0) {
          continue;
        }
        final Uid u=getUidStatsLocked(mapUid(entry.uid));
        final long appPackets=entry.rxPackets + entry.txPackets;
        final long appRadioTime=(radioTime * appPackets) / totalPackets;
        u.noteMobileRadioActiveTimeLocked(appRadioTime);
        radioTime-=appRadioTime;
        totalPackets-=appPackets;
        if (activityInfo != null) {
          ControllerActivityCounterImpl activityCounter=u.getOrCreateModemControllerActivityLocked();
          if (totalRxPackets > 0 && entry.rxPackets > 0) {
            final long rxMs=(entry.rxPackets * activityInfo.getRxTimeMillis()) / totalRxPackets;
            activityCounter.getRxTimeCounter().addCountLocked(rxMs);
          }
          if (totalTxPackets > 0 && entry.txPackets > 0) {
            for (int lvl=0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
              long txMs=entry.txPackets * activityInfo.getTxTimeMillis()[lvl];
              txMs/=totalTxPackets;
              activityCounter.getTxTimeCounters()[lvl].addCountLocked(txMs);
            }
          }
        }
      }
    }
    if (radioTime > 0) {
      mMobileRadioActiveUnknownTime.addCountLocked(radioTime);
      mMobileRadioActiveUnknownCount.addCountLocked(1);
    }
  }
  if (activityInfo != null) {
    mHasModemReporting=true;
    mModemActivity.getIdleTimeCounter().addCountLocked(activityInfo.getIdleTimeMillis());
    mModemActivity.getRxTimeCounter().addCountLocked(activityInfo.getRxTimeMillis());
    for (int lvl=0; lvl < ModemActivityInfo.TX_POWER_LEVELS; lvl++) {
      mModemActivity.getTxTimeCounters()[lvl].addCountLocked(activityInfo.getTxTimeMillis()[lvl]);
    }
    final double opVolt=mPowerProfile.getAveragePower(PowerProfile.POWER_MODEM_CONTROLLER_OPERATING_VOLTAGE) / 1000.0;
    if (opVolt != 0) {
      mModemActivity.getPowerCounter().addCountLocked((long)(activityInfo.getEnergyUsed() / opVolt));
    }
  }
}