Program: 25681
Project: 25681
Buggy source:
@Override protected void onPostExecute(Object result){
  if (holder.position == position && xAppInfo != null) {
    if (xAppInfo.getIcon(ActivityMain.this) instanceof BitmapDrawable) {
      Bitmap icon=((BitmapDrawable)xAppInfo.getIcon(ActivityMain.this)).getBitmap();
      TypedArray arrayHeight=getTheme().obtainStyledAttributes(new int[]{android.R.attr.listPreferredItemHeightSmall});
      int height=(int)Math.round(arrayHeight.getDimension(0,32) * getResources().getDisplayMetrics().density + 0.5f);
      arrayHeight.recycle();
      icon=Bitmap.createScaledBitmap(icon,height,height,true);
      int borderSize=(int)Math.round(getResources().getDisplayMetrics().density + 0.5f);
      Bitmap bitmap=Bitmap.createBitmap(icon.getWidth() + 2 * borderSize,icon.getHeight() + 2 * borderSize,icon.getConfig());
      TypedArray arrayColor=getTheme().obtainStyledAttributes(new int[]{android.R.attr.colorActivatedHighlight});
      int textColor=arrayColor.getColor(0,0xFF00FF);
      arrayColor.recycle();
      Canvas canvas=new Canvas(bitmap);
      Paint paint=new Paint();
      paint.setColor(textColor);
      paint.setStyle(Style.STROKE);
      paint.setStrokeWidth(borderSize);
      canvas.drawRect(0,0,bitmap.getWidth(),bitmap.getHeight(),paint);
      paint=new Paint(Paint.FILTER_BITMAP_FLAG);
      canvas.drawBitmap(icon,borderSize,borderSize,paint);
      holder.imgIcon.setImageBitmap(bitmap);
    }
    holder.imgIcon.setVisibility(View.VISIBLE);
    holder.tvName.setTypeface(null,used ? Typeface.BOLD_ITALIC : Typeface.NORMAL);
    holder.imgUsed.setVisibility(used ? View.VISIBLE : View.INVISIBLE);
    holder.imgGranted.setVisibility(granted ? View.VISIBLE : View.INVISIBLE);
    holder.imgInternet.setVisibility(xAppInfo.hasInternet(ActivityMain.this) ? View.VISIBLE : View.INVISIBLE);
    holder.imgFrozen.setVisibility(xAppInfo.isFrozen(ActivityMain.this) ? View.VISIBLE : View.INVISIBLE);
    if (allRestricted)     holder.imgCBName.setImageBitmap(mCheck[2]);
 else     if (someRestricted)     holder.imgCBName.setImageBitmap(mCheck[1]);
 else     holder.imgCBName.setImageBitmap(mCheck[0]);
    holder.imgCBName.setVisibility(View.VISIBLE);
    holder.rlName.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      final View view){
        boolean allRestricted=true;
        boolean someRestricted=false;
        for (        boolean restricted : PrivacyManager.getRestricted(view.getContext(),xAppInfo.getUid(),mRestrictionName)) {
          allRestricted=(allRestricted && restricted);
          someRestricted=(someRestricted || restricted);
        }
        if (mRestrictionName == null && someRestricted) {
          AlertDialog.Builder alertDialogBuilder=new AlertDialog.Builder(ActivityMain.this);
          alertDialogBuilder.setTitle(getString(R.string.menu_clear_all));
          alertDialogBuilder.setMessage(getString(R.string.msg_sure));
          alertDialogBuilder.setIcon(Util.getThemed(ActivityMain.this,R.attr.icon_launcher));
          alertDialogBuilder.setPositiveButton(getString(android.R.string.ok),new DialogInterface.OnClickListener(){
            @Override public void onClick(            DialogInterface dialog,            int which){
              boolean restart=PrivacyManager.deleteRestrictions(view.getContext(),xAppInfo.getUid());
              holder.imgCBName.setImageBitmap(mCheck[0]);
              if (restart)               Toast.makeText(view.getContext(),getString(R.string.msg_restart),Toast.LENGTH_SHORT).show();
            }
          }
);
          alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel),new DialogInterface.OnClickListener(){
            @Override public void onClick(            DialogInterface dialog,            int which){
            }
          }
);
          AlertDialog alertDialog=alertDialogBuilder.create();
          alertDialog.show();
        }
 else {
          boolean restart=false;
          for (          String restrictionName : listRestriction)           restart=restart || PrivacyManager.setRestricted(null,view.getContext(),xAppInfo.getUid(),restrictionName,null,!someRestricted);
          allRestricted=true;
          someRestricted=false;
          for (          boolean restricted : PrivacyManager.getRestricted(view.getContext(),xAppInfo.getUid(),mRestrictionName)) {
            allRestricted=(allRestricted && restricted);
            someRestricted=(someRestricted || restricted);
          }
          if (allRestricted)           holder.imgCBName.setImageBitmap(mCheck[2]);
 else           if (someRestricted)           holder.imgCBName.setImageBitmap(mCheck[1]);
 else           holder.imgCBName.setImageBitmap(mCheck[0]);
          if (restart)           Toast.makeText(view.getContext(),getString(R.string.msg_restart),Toast.LENGTH_SHORT).show();
        }
      }
    }
);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Object result){
  if (holder.position == position && xAppInfo != null) {
    if (xAppInfo.getIcon(ActivityMain.this) instanceof BitmapDrawable) {
      Bitmap icon=((BitmapDrawable)xAppInfo.getIcon(ActivityMain.this)).getBitmap();
      TypedArray arrayHeight=getTheme().obtainStyledAttributes(new int[]{android.R.attr.listPreferredItemHeightSmall});
      int height=(int)Math.round(arrayHeight.getDimension(0,32) * getResources().getDisplayMetrics().density + 0.5f);
      arrayHeight.recycle();
      icon=Bitmap.createScaledBitmap(icon,height,height,true);
      int borderSize=(int)Math.round(getResources().getDisplayMetrics().density + 0.5f);
      Bitmap bitmap=Bitmap.createBitmap(icon.getWidth() + 2 * borderSize,icon.getHeight() + 2 * borderSize,icon.getConfig());
      TypedArray arrayColor=getTheme().obtainStyledAttributes(new int[]{android.R.attr.colorActivatedHighlight});
      int textColor=arrayColor.getColor(0,0xFF00FF);
      arrayColor.recycle();
      Canvas canvas=new Canvas(bitmap);
      Paint paint=new Paint();
      paint.setColor(textColor);
      paint.setStyle(Style.STROKE);
      paint.setStrokeWidth(borderSize);
      canvas.drawRect(0,0,bitmap.getWidth(),bitmap.getHeight(),paint);
      paint=new Paint(Paint.FILTER_BITMAP_FLAG);
      canvas.drawBitmap(icon,borderSize,borderSize,paint);
      holder.imgIcon.setImageBitmap(bitmap);
    }
    holder.imgIcon.setVisibility(View.VISIBLE);
    holder.tvName.setTypeface(null,used ? Typeface.BOLD_ITALIC : Typeface.NORMAL);
    holder.imgUsed.setVisibility(used ? View.VISIBLE : View.INVISIBLE);
    holder.imgGranted.setVisibility(granted ? View.VISIBLE : View.INVISIBLE);
    holder.imgInternet.setVisibility(xAppInfo.hasInternet(ActivityMain.this) ? View.VISIBLE : View.INVISIBLE);
    holder.imgFrozen.setVisibility(xAppInfo.isFrozen(ActivityMain.this) ? View.VISIBLE : View.INVISIBLE);
    if (allRestricted)     holder.imgCBName.setImageBitmap(mCheck[2]);
 else     if (someRestricted)     holder.imgCBName.setImageBitmap(mCheck[1]);
 else     holder.imgCBName.setImageBitmap(mCheck[0]);
    holder.imgCBName.setVisibility(View.VISIBLE);
    holder.rlName.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      final View view){
        boolean allRestricted=true;
        boolean someRestricted=false;
        for (        boolean restricted : PrivacyManager.getRestricted(view.getContext(),xAppInfo.getUid(),mRestrictionName)) {
          allRestricted=(allRestricted && restricted);
          someRestricted=(someRestricted || restricted);
        }
        if (mRestrictionName == null && someRestricted) {
          AlertDialog.Builder alertDialogBuilder=new AlertDialog.Builder(ActivityMain.this);
          alertDialogBuilder.setTitle(getString(R.string.menu_clear_all));
          alertDialogBuilder.setMessage(getString(R.string.msg_sure));
          alertDialogBuilder.setIcon(Util.getThemed(ActivityMain.this,R.attr.icon_launcher));
          alertDialogBuilder.setPositiveButton(getString(android.R.string.ok),new DialogInterface.OnClickListener(){
            @Override public void onClick(            DialogInterface dialog,            int which){
              boolean restart=PrivacyManager.deleteRestrictions(view.getContext(),xAppInfo.getUid());
              holder.imgCBName.setImageBitmap(mCheck[0]);
              if (restart)               Toast.makeText(view.getContext(),getString(R.string.msg_restart),Toast.LENGTH_SHORT).show();
            }
          }
);
          alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel),new DialogInterface.OnClickListener(){
            @Override public void onClick(            DialogInterface dialog,            int which){
            }
          }
);
          AlertDialog alertDialog=alertDialogBuilder.create();
          alertDialog.show();
        }
 else {
          boolean restart=false;
          for (          String restrictionName : listRestriction)           restart=PrivacyManager.setRestricted(null,view.getContext(),xAppInfo.getUid(),restrictionName,null,!someRestricted) || restart;
          allRestricted=true;
          someRestricted=false;
          for (          boolean restricted : PrivacyManager.getRestricted(view.getContext(),xAppInfo.getUid(),mRestrictionName)) {
            allRestricted=(allRestricted && restricted);
            someRestricted=(someRestricted || restricted);
          }
          if (allRestricted)           holder.imgCBName.setImageBitmap(mCheck[2]);
 else           if (someRestricted)           holder.imgCBName.setImageBitmap(mCheck[1]);
 else           holder.imgCBName.setImageBitmap(mCheck[0]);
          if (restart)           Toast.makeText(view.getContext(),getString(R.string.msg_restart),Toast.LENGTH_SHORT).show();
        }
      }
    }
);
  }
}