Program: 199275
Project: 199275
Buggy source:
/** 
 * Handle a   {@code DISCONNECTED} event. If this pertains to the non-activenetwork, we ignore it. If it is for the active network, we send out a broadcast. But first, we check whether it might be possible to connect to a different network.
 * @param info the {@code NetworkInfo} for the network
 */
private void handleDisconnect(NetworkInfo info){
  int prevNetType=info.getType();
  mNetTrackers[prevNetType].setTeardownRequested(false);
  int thisNetId=mNetTrackers[prevNetType].getNetwork().netId;
  if (mNetConfigs[prevNetType].isDefault()) {
    removeDataActivityTracking(prevNetType);
  }
  if (!mNetConfigs[prevNetType].isDefault()) {
    List<Integer> pids=mNetRequestersPids[prevNetType];
    for (    Integer pid : pids) {
      reassessPidDns(pid.intValue(),false);
    }
  }
  Intent intent=new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
  intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO,new NetworkInfo(info));
  intent.putExtra(ConnectivityManager.EXTRA_NETWORK_TYPE,info.getType());
  if (info.isFailover()) {
    intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER,true);
    info.setFailover(false);
  }
  if (info.getReason() != null) {
    intent.putExtra(ConnectivityManager.EXTRA_REASON,info.getReason());
  }
  if (info.getExtraInfo() != null) {
    intent.putExtra(ConnectivityManager.EXTRA_EXTRA_INFO,info.getExtraInfo());
  }
  if (mNetConfigs[prevNetType].isDefault()) {
    tryFailover(prevNetType);
    if (mActiveDefaultNetwork != -1) {
      NetworkInfo switchTo=mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
      intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO,switchTo);
    }
 else {
      mDefaultInetConditionPublished=0;
      intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,true);
    }
  }
  intent.putExtra(ConnectivityManager.EXTRA_INET_CONDITION,mDefaultInetConditionPublished);
  boolean doReset=true;
  LinkProperties linkProperties=mNetTrackers[prevNetType].getLinkProperties();
  if (linkProperties != null) {
    String oldIface=linkProperties.getInterfaceName();
    if (TextUtils.isEmpty(oldIface) == false) {
      for (      NetworkStateTracker networkStateTracker : mNetTrackers) {
        if (networkStateTracker == null)         continue;
        NetworkInfo networkInfo=networkStateTracker.getNetworkInfo();
        if (networkInfo.isConnected() && networkInfo.getType() != prevNetType) {
          LinkProperties l=networkStateTracker.getLinkProperties();
          if (l == null)           continue;
          if (oldIface.equals(l.getInterfaceName())) {
            doReset=false;
            break;
          }
        }
      }
    }
  }
  handleConnectivityChange(prevNetType,doReset);
  final Intent immediateIntent=new Intent(intent);
  immediateIntent.setAction(CONNECTIVITY_ACTION_IMMEDIATE);
  sendStickyBroadcast(immediateIntent);
  sendStickyBroadcastDelayed(intent,getConnectivityChangeDelay());
  if (mActiveDefaultNetwork != -1) {
    sendConnectedBroadcastDelayed(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo(),getConnectivityChangeDelay());
  }
  try {
  }
 catch (  Exception e) {
    loge("String_Node_Str" + e);
  }
 finally {
    mNetTrackers[prevNetType].setNetId(INVALID_NET_ID);
  }
}

Fixed version (ground truth):
/** 
 * Handle a   {@code DISCONNECTED} event. If this pertains to the non-activenetwork, we ignore it. If it is for the active network, we send out a broadcast. But first, we check whether it might be possible to connect to a different network.
 * @param info the {@code NetworkInfo} for the network
 */
private void handleDisconnect(NetworkInfo info){
  int prevNetType=info.getType();
  mNetTrackers[prevNetType].setTeardownRequested(false);
  int thisNetId=mNetTrackers[prevNetType].getNetwork().netId;
  if (!mNetConfigs[prevNetType].isDefault()) {
    List<Integer> pids=mNetRequestersPids[prevNetType];
    for (    Integer pid : pids) {
      reassessPidDns(pid.intValue(),false);
    }
  }
  Intent intent=new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
  intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO,new NetworkInfo(info));
  intent.putExtra(ConnectivityManager.EXTRA_NETWORK_TYPE,info.getType());
  if (info.isFailover()) {
    intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER,true);
    info.setFailover(false);
  }
  if (info.getReason() != null) {
    intent.putExtra(ConnectivityManager.EXTRA_REASON,info.getReason());
  }
  if (info.getExtraInfo() != null) {
    intent.putExtra(ConnectivityManager.EXTRA_EXTRA_INFO,info.getExtraInfo());
  }
  if (mNetConfigs[prevNetType].isDefault()) {
    tryFailover(prevNetType);
    if (mActiveDefaultNetwork != -1) {
      NetworkInfo switchTo=mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
      intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO,switchTo);
    }
 else {
      mDefaultInetConditionPublished=0;
      intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,true);
    }
  }
  intent.putExtra(ConnectivityManager.EXTRA_INET_CONDITION,mDefaultInetConditionPublished);
  boolean doReset=true;
  LinkProperties linkProperties=mNetTrackers[prevNetType].getLinkProperties();
  if (linkProperties != null) {
    String oldIface=linkProperties.getInterfaceName();
    if (TextUtils.isEmpty(oldIface) == false) {
      for (      NetworkStateTracker networkStateTracker : mNetTrackers) {
        if (networkStateTracker == null)         continue;
        NetworkInfo networkInfo=networkStateTracker.getNetworkInfo();
        if (networkInfo.isConnected() && networkInfo.getType() != prevNetType) {
          LinkProperties l=networkStateTracker.getLinkProperties();
          if (l == null)           continue;
          if (oldIface.equals(l.getInterfaceName())) {
            doReset=false;
            break;
          }
        }
      }
    }
  }
  final Intent immediateIntent=new Intent(intent);
  immediateIntent.setAction(CONNECTIVITY_ACTION_IMMEDIATE);
  sendStickyBroadcast(immediateIntent);
  sendStickyBroadcastDelayed(intent,getConnectivityChangeDelay());
  if (mActiveDefaultNetwork != -1) {
    sendConnectedBroadcastDelayed(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo(),getConnectivityChangeDelay());
  }
  try {
  }
 catch (  Exception e) {
    loge("String_Node_Str" + e);
  }
 finally {
    mNetTrackers[prevNetType].setNetId(INVALID_NET_ID);
  }
}