Program: 27268
Project: 27268
Buggy source:
private Builder(){
  mAlertDialog=new AlertDialog.Builder(mContext).create();
  mAlertDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  mAlertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
  mAlertDialog.show();
  mAlertDialogWindow=mAlertDialog.getWindow();
  View contv=LayoutInflater.from(mContext).inflate(R.layout.layout_materialdialog,null);
  contv.setFocusable(true);
  contv.setFocusableInTouchMode(true);
  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);
  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 (mPositiveButton != null) {
    mButtonLayout.addView(mPositiveButton);
  }
  if (mLayoutParams != null && mNegativeButton != null) {
    if (mButtonLayout.getChildCount() > 0) {
      mLayoutParams.setMargins(dip2px(12),0,0,dip2px(BUTTON_BOTTOM));
      mNegativeButton.setLayoutParams(mLayoutParams);
      mButtonLayout.addView(mNegativeButton,1);
    }
 else {
      mNegativeButton.setLayoutParams(mLayoutParams);
      mButtonLayout.addView(mNegativeButton);
    }
  }
  if (mBackgroundResId != 0) {
    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.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  mAlertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
  mAlertDialog.show();
  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);
  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 (mPositiveButton != null) {
    mButtonLayout.addView(mPositiveButton);
  }
  if (mLayoutParams != null && mNegativeButton != null) {
    if (mButtonLayout.getChildCount() > 0) {
      mLayoutParams.setMargins(dip2px(12),0,0,dip2px(BUTTON_BOTTOM));
      mNegativeButton.setLayoutParams(mLayoutParams);
      mButtonLayout.addView(mNegativeButton,1);
    }
 else {
      mNegativeButton.setLayoutParams(mLayoutParams);
      mButtonLayout.addView(mNegativeButton);
    }
  }
  if (mBackgroundResId != 0) {
    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);
  }
}