Program: 23901
Project: 23901
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){
  if (DBG)   Log.v(TAG,"String_Node_Str" + info.getTypeName());
  int prevNetType=info.getType();
  mNetTrackers[prevNetType].setTeardownRequested(false);
  if (!mNetAttributes[prevNetType].isDefault()) {
    List pids=mNetRequestersPids[prevNetType];
    for (int i=0; i < pids.size(); i++) {
      Integer pid=(Integer)pids.get(i);
      reassessPidDns(pid.intValue(),false);
    }
  }
  Intent intent=new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
  intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO,info);
  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());
  }
  NetworkStateTracker newNet=null;
  if (mNetAttributes[prevNetType].isDefault()) {
    if (DBG)     Log.d(TAG,"String_Node_Str");
    if (mActiveDefaultNetwork == prevNetType) {
      mActiveDefaultNetwork=-1;
    }
    int newType=-1;
    int newPriority=-1;
    for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
      if (checkType == prevNetType) {
        continue;
      }
      if (mNetAttributes[checkType].isDefault()) {
        if (checkType == mNetworkPreference) {
          newType=checkType;
          break;
        }
        if (mRadioAttributes[mNetAttributes[checkType].mRadio].mPriority > newPriority) {
          newType=checkType;
          newPriority=mRadioAttributes[mNetAttributes[newType].mRadio].mPriority;
        }
      }
    }
    if (newType != -1) {
      newNet=mNetTrackers[newType];
      if (newNet.isAvailable()) {
        NetworkInfo switchTo=newNet.getNetworkInfo();
        switchTo.setFailover(true);
        if (!switchTo.isConnectedOrConnecting()) {
          newNet.reconnect();
        }
        if (DBG) {
          if (switchTo.isConnected()) {
            Log.v(TAG,"String_Node_Str" + switchTo.getTypeName());
          }
 else {
            Log.v(TAG,"String_Node_Str" + switchTo.getTypeName());
          }
        }
        intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO,switchTo);
      }
 else {
        newNet.reconnect();
      }
    }
 else {
      intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,true);
    }
  }
  handleConnectivityChange();
  if (DBG)   Log.v(TAG,"String_Node_Str" + info.getTypeName() + (newNet == null || !newNet.isAvailable() ? "String_Node_Str" : "String_Node_Str" + newNet.getNetworkInfo().getTypeName()));
  sendStickyBroadcast(intent);
  if (newNet != null && newNet.getNetworkInfo().isConnected())   sendConnectedBroadcast(newNet.getNetworkInfo());
}

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){
  if (DBG)   Log.v(TAG,"String_Node_Str" + info.getTypeName());
  int prevNetType=info.getType();
  mNetTrackers[prevNetType].setTeardownRequested(false);
  if (!mNetAttributes[prevNetType].isDefault()) {
    List pids=mNetRequestersPids[prevNetType];
    for (int i=0; i < pids.size(); i++) {
      Integer pid=(Integer)pids.get(i);
      reassessPidDns(pid.intValue(),false);
    }
  }
  Intent intent=new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
  intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO,info);
  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());
  }
  NetworkStateTracker newNet=null;
  if (mNetAttributes[prevNetType].isDefault()) {
    if (DBG)     Log.d(TAG,"String_Node_Str");
    if (mActiveDefaultNetwork == prevNetType) {
      mActiveDefaultNetwork=-1;
    }
    int newType=-1;
    int newPriority=-1;
    for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
      if (checkType == prevNetType) {
        continue;
      }
      if (mNetAttributes[checkType].isDefault()) {
        if (checkType == mNetworkPreference) {
          newType=checkType;
          break;
        }
        if (mRadioAttributes[mNetAttributes[checkType].mRadio].mPriority > newPriority) {
          newType=checkType;
          newPriority=mRadioAttributes[mNetAttributes[newType].mRadio].mPriority;
        }
      }
    }
    if (newType != -1) {
      newNet=mNetTrackers[newType];
      if (newNet.isAvailable()) {
        NetworkInfo switchTo=newNet.getNetworkInfo();
        switchTo.setFailover(true);
        if (!switchTo.isConnectedOrConnecting() || newNet.isTeardownRequested()) {
          newNet.reconnect();
        }
        if (DBG) {
          if (switchTo.isConnected()) {
            Log.v(TAG,"String_Node_Str" + switchTo.getTypeName());
          }
 else {
            Log.v(TAG,"String_Node_Str" + switchTo.getTypeName());
          }
        }
        intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO,switchTo);
      }
 else {
        newNet.reconnect();
      }
    }
 else {
      intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,true);
    }
  }
  handleConnectivityChange();
  if (DBG)   Log.v(TAG,"String_Node_Str" + info.getTypeName() + (newNet == null || !newNet.isAvailable() ? "String_Node_Str" : "String_Node_Str" + newNet.getNetworkInfo().getTypeName()));
  sendStickyBroadcast(intent);
  if (newNet != null && newNet.getNetworkInfo().isConnected())   sendConnectedBroadcast(newNet.getNetworkInfo());
}