Program: 187373
Project: 187373
Buggy source:
/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (this.getIntent().hasExtra(MessageService.notificationIntent)) {
    Prephase3Activity.selectedNumber=this.getIntent().getStringExtra(MessageService.notificationIntent);
  }
 else   if (this.getIntent().hasExtra(Prephase3Activity.selectedNumberIntent)) {
    Prephase3Activity.selectedNumber=this.getIntent().getStringExtra(Prephase3Activity.selectedNumberIntent);
  }
 else {
    finish();
  }
  setContentView(R.layout.messageviewer);
  getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  MessageService.dba=new DBAccessor(this);
  Prephase3Activity.messageViewActive=true;
  boolean isTrusted=MessageService.dba.isTrustedContact(Prephase3Activity.selectedNumber);
  messageEvent=new MessageBoxWatcher(this,R.id.word_count,isTrusted);
  list2=(ListView)findViewById(R.id.message_list);
  msgList2=MessageService.dba.getSMSList(Prephase3Activity.selectedNumber);
  int unreadCount=MessageService.dba.getUnreadMessageCount(Prephase3Activity.selectedNumber);
  Toast.makeText(this,String.valueOf(unreadCount),Toast.LENGTH_SHORT).show();
  messages=new MessageAdapter(this,R.layout.listview_full_item_row,msgList2,unreadCount);
  list2.setAdapter(messages);
  list2.setItemsCanFocus(false);
  if (MessageService.dba.getUnreadMessageCount(Prephase3Activity.selectedNumber) > 0) {
    MessageService.dba.updateMessageCount(Prephase3Activity.selectedNumber,0);
    if (MessageService.mNotificationManager != null) {
      MessageService.mNotificationManager.cancel(MessageService.INDEX);
    }
  }
  contact_name=MessageService.dba.getRow(Prephase3Activity.selectedNumber).getName();
  list2.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final int item_num=position;
      AlertDialog.Builder popup_builder=new AlertDialog.Builder(MessageView.this);
      popup_builder.setTitle(contact_name).setItems(options,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          final String[] messageValue=(String[])list2.getItemAtPosition(item_num);
          Toast.makeText(MessageView.this,messageValue[1],Toast.LENGTH_SHORT).show();
          if (which == 0) {
            if (messageValue[0].equals("String_Node_Str")) {
              sendMessage(Prephase3Activity.selectedNumber,messageValue[1]);
            }
          }
 else           if (which == 1) {
            MessageService.dba.deleteMessage(Long.valueOf(messageValue[3]));
            updateList(MessageView.this);
          }
 else           if (which == 2) {
          }
 else           if (which == 3) {
            phoneBox=new AutoCompleteTextView(getBaseContext());
            List<String> contact=null;
            if (tc == null) {
              tc=MessageService.dba.getAllRows();
            }
            if (tc != null) {
              if (contact == null) {
                contact=SMSUtility.contactDisplayMaker(tc);
              }
            }
 else {
              contact=null;
            }
            ArrayAdapter<String> adapter=new ArrayAdapter<String>(getBaseContext(),R.layout.auto_complete_list_item,contact);
            phoneBox.setAdapter(adapter);
            AlertDialog.Builder contact_builder=new AlertDialog.Builder(MessageView.this);
            contact_builder.setTitle("String_Node_Str").setCancelable(true).setView(phoneBox).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
              public void onClick(              DialogInterface dialog,              int which){
                String[] info=phoneBox.getText().toString().split("String_Node_Str");
                boolean invalid=false;
                if (info != null) {
                  if (info.length == 2 && info[1] != null) {
                    if (SMSUtility.isANumber(info[1])) {
                      sendMessage(info[1],messageValue[1]);
                    }
 else {
                      invalid=true;
                    }
                  }
 else {
                    String num=phoneBox.getText().toString();
                    if (SMSUtility.isANumber(num)) {
                      sendMessage(num,messageValue[1]);
                    }
 else {
                      invalid=true;
                    }
                  }
                }
                if (invalid) {
                  Toast.makeText(getBaseContext(),"String_Node_Str",Toast.LENGTH_SHORT).show();
                }
              }
            }
);
            AlertDialog contact_alert=contact_builder.create();
            popup_alert.cancel();
            contact_alert.show();
          }
        }
      }
).setCancelable(true);
      popup_alert=popup_builder.create();
      popup_alert.show();
    }
  }
);
  sendSMS=(Button)findViewById(R.id.send);
  messageBox=(EditText)findViewById(R.id.message);
  InputFilter[] FilterArray=new InputFilter[1];
  if (isTrusted) {
    FilterArray[0]=new InputFilter.LengthFilter(SMSUtility.ENCRYPTED_MESSAGE_LENGTH);
  }
 else {
    FilterArray[0]=new InputFilter.LengthFilter(SMSUtility.MESSAGE_LENGTH);
  }
  messageBox.setFilters(FilterArray);
  messageBox.addTextChangedListener(messageEvent);
  sendSMS.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      sendMessage(Prephase3Activity.selectedNumber,messageBox.getText().toString());
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (this.getIntent().hasExtra(MessageService.notificationIntent)) {
    Prephase3Activity.selectedNumber=this.getIntent().getStringExtra(MessageService.notificationIntent);
  }
 else   if (this.getIntent().hasExtra(Prephase3Activity.selectedNumberIntent)) {
    Prephase3Activity.selectedNumber=this.getIntent().getStringExtra(Prephase3Activity.selectedNumberIntent);
  }
 else {
    finish();
  }
  setContentView(R.layout.messageviewer);
  getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  MessageService.dba=new DBAccessor(this);
  Prephase3Activity.messageViewActive=true;
  boolean isTrusted=MessageService.dba.isTrustedContact(Prephase3Activity.selectedNumber);
  messageEvent=new MessageBoxWatcher(this,R.id.word_count,isTrusted);
  list2=(ListView)findViewById(R.id.message_list);
  msgList2=MessageService.dba.getSMSList(Prephase3Activity.selectedNumber);
  int unreadCount=MessageService.dba.getUnreadMessageCount(Prephase3Activity.selectedNumber);
  Toast.makeText(this,String.valueOf(unreadCount),Toast.LENGTH_SHORT).show();
  messages=new MessageAdapter(this,R.layout.listview_full_item_row,msgList2,unreadCount);
  list2.setAdapter(messages);
  list2.setItemsCanFocus(false);
  if (MessageService.dba.getUnreadMessageCount(Prephase3Activity.selectedNumber) > 0) {
    MessageService.dba.updateMessageCount(Prephase3Activity.selectedNumber,0);
    if (MessageService.mNotificationManager != null) {
      MessageService.mNotificationManager.cancel(MessageService.INDEX);
    }
  }
  contact_name=MessageService.dba.getRow(Prephase3Activity.selectedNumber).getName();
  list2.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final int item_num=position;
      AlertDialog.Builder popup_builder=new AlertDialog.Builder(MessageView.this);
      popup_builder.setTitle(contact_name).setItems(options,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          final String[] messageValue=(String[])list2.getItemAtPosition(item_num);
          if (which == 0) {
            MessageService.dba.deleteMessage(Long.valueOf(messageValue[3]));
            updateList(MessageView.this);
          }
 else           if (which == 1) {
            Toast.makeText(getBaseContext(),"String_Node_Str",Toast.LENGTH_SHORT).show();
          }
 else           if (which == 2) {
            phoneBox=new AutoCompleteTextView(getBaseContext());
            List<String> contact=null;
            if (tc == null) {
              tc=MessageService.dba.getAllRows();
            }
            if (tc != null) {
              if (contact == null) {
                contact=SMSUtility.contactDisplayMaker(tc);
              }
            }
 else {
              contact=null;
            }
            ArrayAdapter<String> adapter=new ArrayAdapter<String>(getBaseContext(),R.layout.auto_complete_list_item,contact);
            phoneBox.setAdapter(adapter);
            AlertDialog.Builder contact_builder=new AlertDialog.Builder(MessageView.this);
            contact_builder.setTitle("String_Node_Str").setCancelable(true).setView(phoneBox).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
              public void onClick(              DialogInterface dialog,              int which){
                String[] info=phoneBox.getText().toString().split("String_Node_Str");
                boolean invalid=false;
                if (info != null) {
                  if (info.length == 2 && info[1] != null) {
                    if (SMSUtility.isANumber(info[1])) {
                      sendMessage(info[1],messageValue[1]);
                    }
 else {
                      invalid=true;
                    }
                  }
 else {
                    String num=phoneBox.getText().toString();
                    if (SMSUtility.isANumber(num)) {
                      sendMessage(num,messageValue[1]);
                    }
 else {
                      invalid=true;
                    }
                  }
                }
                if (invalid) {
                  Toast.makeText(getBaseContext(),"String_Node_Str",Toast.LENGTH_SHORT).show();
                }
              }
            }
);
            AlertDialog contact_alert=contact_builder.create();
            popup_alert.cancel();
            contact_alert.show();
          }
        }
      }
).setCancelable(true);
      popup_alert=popup_builder.create();
      popup_alert.show();
    }
  }
);
  sendSMS=(Button)findViewById(R.id.send);
  messageBox=(EditText)findViewById(R.id.message);
  InputFilter[] FilterArray=new InputFilter[1];
  if (isTrusted) {
    FilterArray[0]=new InputFilter.LengthFilter(SMSUtility.ENCRYPTED_MESSAGE_LENGTH);
  }
 else {
    FilterArray[0]=new InputFilter.LengthFilter(SMSUtility.MESSAGE_LENGTH);
  }
  messageBox.setFilters(FilterArray);
  messageBox.addTextChangedListener(messageEvent);
  sendSMS.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      sendMessage(Prephase3Activity.selectedNumber,messageBox.getText().toString());
    }
  }
);
}