Program: 27267
Project: 27267
Buggy source:
private Builder(){
  mAlertDialog=new AlertDialog.Builder(mContext).create();
  mAlertDialog.show();
  mAlertDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  mAlertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
  mAlertDialogWindow=mAlertDialog.getWindow();
  View contv=LayoutInflater.from(mContext).inflate(R.layout.layout_materialdialog,null);
  contv.setFocusable(true);
  contv.setFocusableInTouchMode(true);
  mAlertDialogWindow.setBackgroundDrawableResource(R.drawable.material_dialog_window);
  mAlertDialogWindow.setContentView(contv);
  WindowManager.LayoutParams params=new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.TYPE_PHONE,WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,PixelFormat.TRANSLUCENT);
  mTitleView=(TextView)mAlertDialogWindow.findViewById(R.id.title);
  mMessageView=(TextView)mAlertDialogWindow.findViewById(R.id.message);
  mButtonLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.buttonLayout);
  mPositiveButton=(Button)mButtonLayout.findViewById(R.id.btn_p);
  mNegativeButton=(Button)mButtonLayout.findViewById(R.id.btn_n);
  if (mView != null) {
    LinearLayout linearLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.contentView);
    linearLayout.removeAllViews();
    linearLayout.addView(mView);
  }
  if (mTitleResId != 0) {
    setTitle(mTitleResId);
  }
  if (mTitle != null) {
    setTitle(mTitle);
  }
  if (mTitle == null && mTitleResId == 0) {
    mTitleView.setVisibility(View.GONE);
  }
  if (mMessageResId != 0) {
    setMessage(mMessageResId);
  }
  if (mMessage != null) {
    setMessage(mMessage);
  }
  if (pId != -1) {
    mPositiveButton.setVisibility(View.VISIBLE);
    mPositiveButton.setText(pId);
    mPositiveButton.setOnClickListener(pListener);
    if (isLollipop()) {
      mPositiveButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (nId != -1) {
    mNegativeButton.setVisibility(View.VISIBLE);
    mNegativeButton.setText(nId);
    mNegativeButton.setOnClickListener(nListener);
    if (isLollipop()) {
      mNegativeButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (!isNullOrEmpty(pText)) {
    mPositiveButton.setVisibility(View.VISIBLE);
    mPositiveButton.setText(pText);
    mPositiveButton.setOnClickListener(pListener);
    if (isLollipop()) {
      mPositiveButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (!isNullOrEmpty(nText)) {
    mNegativeButton.setVisibility(View.VISIBLE);
    mNegativeButton.setText(nText);
    mNegativeButton.setOnClickListener(nListener);
    if (isLollipop()) {
      mNegativeButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (isNullOrEmpty(pText) && pId == -1) {
    mPositiveButton.setVisibility(View.GONE);
  }
  if (isNullOrEmpty(nText) && nId == -1) {
    mNegativeButton.setVisibility(View.GONE);
  }
  if (mBackgroundResId != -1) {
    LinearLayout linearLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.material_background);
    linearLayout.setBackgroundResource(mBackgroundResId);
  }
  if (mBackgroundDrawable != null) {
    LinearLayout linearLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.material_background);
    linearLayout.setBackground(mBackgroundDrawable);
  }
  if (mMessageContentView != null) {
    this.setContentView(mMessageContentView);
  }
  mAlertDialog.setCanceledOnTouchOutside(mCancel);
  if (mOnDismissListener != null) {
    mAlertDialog.setOnDismissListener(mOnDismissListener);
  }
}

Fixed version (ground truth):
private Builder(){
  mAlertDialog=new AlertDialog.Builder(mContext).create();
  mAlertDialog.show();
  mAlertDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  mAlertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE);
  mAlertDialogWindow=mAlertDialog.getWindow();
  View contv=LayoutInflater.from(mContext).inflate(R.layout.layout_materialdialog,null);
  contv.setFocusable(true);
  contv.setFocusableInTouchMode(true);
  mAlertDialogWindow.setBackgroundDrawableResource(R.drawable.material_dialog_window);
  mAlertDialogWindow.setContentView(contv);
  WindowManager.LayoutParams params=new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.TYPE_PHONE,WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,PixelFormat.TRANSLUCENT);
  mTitleView=(TextView)mAlertDialogWindow.findViewById(R.id.title);
  mMessageView=(TextView)mAlertDialogWindow.findViewById(R.id.message);
  mButtonLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.buttonLayout);
  mPositiveButton=(Button)mButtonLayout.findViewById(R.id.btn_p);
  mNegativeButton=(Button)mButtonLayout.findViewById(R.id.btn_n);
  if (mView != null) {
    LinearLayout linearLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.contentView);
    linearLayout.removeAllViews();
    linearLayout.addView(mView);
  }
  if (mTitleResId != 0) {
    setTitle(mTitleResId);
  }
  if (mTitle != null) {
    setTitle(mTitle);
  }
  if (mTitle == null && mTitleResId == 0) {
    mTitleView.setVisibility(View.GONE);
  }
  if (mMessageResId != 0) {
    setMessage(mMessageResId);
  }
  if (mMessage != null) {
    setMessage(mMessage);
  }
  if (pId != -1) {
    mPositiveButton.setVisibility(View.VISIBLE);
    mPositiveButton.setText(pId);
    mPositiveButton.setOnClickListener(pListener);
    if (isLollipop()) {
      mPositiveButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (nId != -1) {
    mNegativeButton.setVisibility(View.VISIBLE);
    mNegativeButton.setText(nId);
    mNegativeButton.setOnClickListener(nListener);
    if (isLollipop()) {
      mNegativeButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (!isNullOrEmpty(pText)) {
    mPositiveButton.setVisibility(View.VISIBLE);
    mPositiveButton.setText(pText);
    mPositiveButton.setOnClickListener(pListener);
    if (isLollipop()) {
      mPositiveButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (!isNullOrEmpty(nText)) {
    mNegativeButton.setVisibility(View.VISIBLE);
    mNegativeButton.setText(nText);
    mNegativeButton.setOnClickListener(nListener);
    if (isLollipop()) {
      mNegativeButton.setBackgroundResource(android.R.color.transparent);
    }
  }
  if (isNullOrEmpty(pText) && pId == -1) {
    mPositiveButton.setVisibility(View.GONE);
  }
  if (isNullOrEmpty(nText) && nId == -1) {
    mNegativeButton.setVisibility(View.GONE);
  }
  if (mBackgroundResId != -1) {
    LinearLayout linearLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.material_background);
    linearLayout.setBackgroundResource(mBackgroundResId);
  }
  if (mBackgroundDrawable != null) {
    LinearLayout linearLayout=(LinearLayout)mAlertDialogWindow.findViewById(R.id.material_background);
    linearLayout.setBackground(mBackgroundDrawable);
  }
  if (mMessageContentView != null) {
    this.setContentView(mMessageContentView);
  }
  mAlertDialog.setCanceledOnTouchOutside(mCancel);
  if (mOnDismissListener != null) {
    mAlertDialog.setOnDismissListener(mOnDismissListener);
  }
}