nus-yam/ex-repair huggingface dataset:
Program: 897
Project: 897
Buggy source:
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}
Program: 898
Project: 898
Buggy source:
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}

Fixed version (ground truth):
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  TaskRecord tr=who.task;
  if (tr.intent != null && (tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotActivity.state == ActivityState.RESUMED || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}
Program: 899
Project: 899
Buggy source:
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}
Program: 900
Project: 900
Buggy source:
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1);
  }
  mRecentTasks.add(0,task);
}

Fixed version (ground truth):
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      tr.disposeThumbnail();
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1).disposeThumbnail();
  }
  mRecentTasks.add(0,task);
}
Program: 901
Project: 901
Buggy source:
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}

Fixed version (ground truth):
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  tr.disposeThumbnail();
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}
Program: 902
Project: 902
Buggy source:
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1);
  }
  mRecentTasks.add(0,task);
}

Fixed version (ground truth):
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      tr.disposeThumbnail();
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1).disposeThumbnail();
  }
  mRecentTasks.add(0,task);
}
Program: 903
Project: 903
Buggy source:
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}

Fixed version (ground truth):
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  tr.disposeThumbnail();
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}
Program: 904
Project: 904
Buggy source:
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1);
  }
  mRecentTasks.add(0,task);
}

Fixed version (ground truth):
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      tr.disposeThumbnail();
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1).disposeThumbnail();
  }
  mRecentTasks.add(0,task);
}
Program: 905
Project: 905
Buggy source:
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}

Fixed version (ground truth):
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  tr.disposeThumbnail();
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}
Program: 906
Project: 906
Buggy source:
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}
Program: 907
Project: 907
Buggy source:
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}

Fixed version (ground truth):
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  TaskRecord tr=who.task;
  if (tr.intent != null && (tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotActivity.state == ActivityState.RESUMED || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}
Program: 908
Project: 908
Buggy source:
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}

Fixed version (ground truth):
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  TaskRecord tr=who.task;
  if (tr.intent != null && (tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotActivity.state == ActivityState.RESUMED || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}
Program: 909
Project: 909
Buggy source:
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onFinishInflate(){
  mRotatedViews[Surface.ROTATION_0]=mRotatedViews[Surface.ROTATION_180]=findViewById(R.id.rot0);
  mRotatedViews[Surface.ROTATION_90]=findViewById(R.id.rot90);
  mRotatedViews[Surface.ROTATION_270]=NAVBAR_ALWAYS_AT_RIGHT ? findViewById(R.id.rot90) : findViewById(R.id.rot270);
  mCurrentView=mRotatedViews[Surface.ROTATION_0];
  final AccessibilityManager accessibilityManager=(AccessibilityManager)mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled()) {
    View camera=getCameraButton();
    View searchLight=getSearchLight();
    if (camera != null || searchLight != null) {
      OnClickListener listener=new OnClickListener(){
        @Override public void onClick(        View v){
          launchForAccessibilityClick(v);
        }
      }
;
      if (camera != null) {
        camera.setOnClickListener(listener);
      }
      if (searchLight != null) {
        searchLight.setOnClickListener(listener);
      }
    }
  }
 else {
    for (int i=0; i < mRotatedViews.length; i++) {
      View cameraButton=mRotatedViews[i].findViewById(R.id.camera_button);
      if (cameraButton != null) {
        cameraButton.setOnTouchListener(mCameraTouchListener);
      }
    }
  }
}
Program: 910
Project: 910
Buggy source:
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}

Fixed version (ground truth):
public final Bitmap screenshotActivities(ActivityRecord who){
  if (who.noDisplay) {
    return null;
  }
  TaskRecord tr=who.task;
  if (tr.intent != null && (tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0) {
    return null;
  }
  Resources res=mService.mContext.getResources();
  int w=mThumbnailWidth;
  int h=mThumbnailHeight;
  if (w < 0) {
    mThumbnailWidth=w=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
    mThumbnailHeight=h=res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
  }
  if (w > 0) {
    if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null || mLastScreenshotActivity.state == ActivityState.RESUMED || mLastScreenshotBitmap.getWidth() != w || mLastScreenshotBitmap.getHeight() != h) {
      mLastScreenshotActivity=who;
      mLastScreenshotBitmap=mWindowManager.screenshotApplications(who.appToken,Display.DEFAULT_DISPLAY,w,h,SCREENSHOT_FORCE_565);
    }
    if (mLastScreenshotBitmap != null) {
      return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(),true);
    }
  }
  return null;
}
Program: 911
Project: 911
Buggy source:
/** 
 * Creates a view into which preview text can be placed.
 */
private TextView createPreviewTextView(Context context,TypedArray ta){
  final LayoutParams params=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  final Resources res=context.getResources();
  final int minSize=res.getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
  final ColorStateList textColor=ta.getColorStateList(TEXT_COLOR);
  final float textSize=res.getDimension(R.dimen.fastscroll_overlay_text_size);
  final TextView textView=new TextView(context);
  textView.setLayoutParams(params);
  textView.setTextColor(textColor);
  textView.setTextSize(textSize);
  textView.setSingleLine(true);
  textView.setEllipsize(TruncateAt.MIDDLE);
  textView.setGravity(Gravity.CENTER);
  textView.setAlpha(0f);
  textView.setLayoutDirection(mList.getLayoutDirection());
  return textView;
}

Fixed version (ground truth):
/** 
 * Creates a view into which preview text can be placed.
 */
private TextView createPreviewTextView(Context context,TypedArray ta){
  final LayoutParams params=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  final Resources res=context.getResources();
  final int minSize=res.getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
  final ColorStateList textColor=ta.getColorStateList(TEXT_COLOR);
  final float textSize=res.getDimensionPixelSize(R.dimen.fastscroll_overlay_text_size);
  final TextView textView=new TextView(context);
  textView.setLayoutParams(params);
  textView.setTextColor(textColor);
  textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,textSize);
  textView.setSingleLine(true);
  textView.setEllipsize(TruncateAt.MIDDLE);
  textView.setGravity(Gravity.CENTER);
  textView.setAlpha(0f);
  textView.setLayoutDirection(mList.getLayoutDirection());
  return textView;
}
Program: 912
Project: 912
Buggy source:
public void setTextSize(float size){
  final DisplayMetrics metrics=getContext().getResources().getDisplayMetrics();
  final float pixels=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,size,metrics);
  if (mTextPaint.getTextSize() != size) {
    mTextPaint.setTextSize(size);
    mInnerPaddingX=(int)(size * INNER_PADDING_RATIO + 0.5f);
    mHasMeasurements=false;
    forceLayout();
  }
}

Fixed version (ground truth):
/** 
 * Sets the text size in pixels.
 * @param size the text size in pixels
 */
public void setTextSize(float size){
  if (mTextPaint.getTextSize() != size) {
    mTextPaint.setTextSize(size);
    mInnerPaddingX=(int)(size * INNER_PADDING_RATIO + 0.5f);
    mHasMeasurements=false;
    forceLayout();
  }
}
Program: 913
Project: 913
Buggy source:
public SubtitleView(Context context,AttributeSet attrs,int defStyleAttr,int defStyleRes){
  super(context,attrs);
  final TypedArray a=context.obtainStyledAttributes(attrs,android.R.styleable.TextView,defStyleAttr,defStyleRes);
  CharSequence text="String_Node_Str";
  int textSize=15;
  final int n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    int attr=a.getIndex(i);
switch (attr) {
case android.R.styleable.TextView_text:
      text=a.getText(attr);
    break;
case android.R.styleable.TextView_lineSpacingExtra:
  mSpacingAdd=a.getDimensionPixelSize(attr,(int)mSpacingAdd);
break;
case android.R.styleable.TextView_lineSpacingMultiplier:
mSpacingMult=a.getFloat(attr,mSpacingMult);
break;
case android.R.styleable.TextAppearance_textSize:
textSize=a.getDimensionPixelSize(attr,textSize);
break;
}
}
final Resources res=getContext().getResources();
final DisplayMetrics m=res.getDisplayMetrics();
mCornerRadius=res.getDimension(com.android.internal.R.dimen.subtitle_corner_radius);
mOutlineWidth=res.getDimension(com.android.internal.R.dimen.subtitle_outline_width);
mShadowRadius=res.getDimension(com.android.internal.R.dimen.subtitle_shadow_radius);
mShadowOffsetX=res.getDimension(com.android.internal.R.dimen.subtitle_shadow_offset);
mShadowOffsetY=mShadowOffsetX;
mTextPaint=new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setSubpixelText(true);
mPaint=new Paint();
mPaint.setAntiAlias(true);
setText(text);
setTextSize(textSize);
}

Fixed version (ground truth):
public SubtitleView(Context context,AttributeSet attrs,int defStyleAttr,int defStyleRes){
  super(context,attrs);
  final TypedArray a=context.obtainStyledAttributes(attrs,android.R.styleable.TextView,defStyleAttr,defStyleRes);
  CharSequence text="String_Node_Str";
  int textSize=15;
  final int n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    int attr=a.getIndex(i);
switch (attr) {
case android.R.styleable.TextView_text:
      text=a.getText(attr);
    break;
case android.R.styleable.TextView_lineSpacingExtra:
  mSpacingAdd=a.getDimensionPixelSize(attr,(int)mSpacingAdd);
break;
case android.R.styleable.TextView_lineSpacingMultiplier:
mSpacingMult=a.getFloat(attr,mSpacingMult);
break;
case android.R.styleable.TextAppearance_textSize:
textSize=a.getDimensionPixelSize(attr,textSize);
break;
}
}
final Resources res=getContext().getResources();
final DisplayMetrics m=res.getDisplayMetrics();
mCornerRadius=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_corner_radius);
mOutlineWidth=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_outline_width);
mShadowRadius=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_shadow_radius);
mShadowOffsetX=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_shadow_offset);
mShadowOffsetY=mShadowOffsetX;
mTextPaint=new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setSubpixelText(true);
mPaint=new Paint();
mPaint.setAntiAlias(true);
setText(text);
setTextSize(textSize);
}
Program: 914
Project: 914
Buggy source:
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1);
  }
  mRecentTasks.add(0,task);
}

Fixed version (ground truth):
final void addRecentTaskLocked(TaskRecord task){
  int N=mRecentTasks.size();
  if (N > 0 && mRecentTasks.get(0) == task) {
    return;
  }
  for (int i=0; i < N; i++) {
    TaskRecord tr=mRecentTasks.get(i);
    if (task.userId == tr.userId && ((task.affinity != null && task.affinity.equals(tr.affinity)) || (task.intent != null && task.intent.filterEquals(tr.intent)))) {
      tr.disposeThumbnail();
      mRecentTasks.remove(i);
      i--;
      N--;
      if (task.intent == null) {
        task=tr;
      }
    }
  }
  if (N >= MAX_RECENT_TASKS) {
    mRecentTasks.remove(N - 1).disposeThumbnail();
  }
  mRecentTasks.add(0,task);
}
Program: 915
Project: 915
Buggy source:
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}

Fixed version (ground truth):
private void cleanUpRemovedTaskLocked(TaskRecord tr,int flags){
  tr.disposeThumbnail();
  mRecentTasks.remove(tr);
  mStackSupervisor.removeTask(tr);
  final boolean killProcesses=(flags & ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
  Intent baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
  ComponentName component=baseIntent.getComponent();
  if (component == null) {
    Slog.w(TAG,"String_Node_Str" + tr);
    return;
  }
  mServices.cleanUpRemovedTaskLocked(tr,component,baseIntent);
  if (killProcesses) {
    final String pkg=component.getPackageName();
    ArrayList<ProcessRecord> procs=new ArrayList<ProcessRecord>();
    ArrayMap<String,SparseArray<ProcessRecord>> pmap=mProcessNames.getMap();
    for (int i=0; i < pmap.size(); i++) {
      SparseArray<ProcessRecord> uids=pmap.valueAt(i);
      for (int j=0; j < uids.size(); j++) {
        ProcessRecord proc=uids.valueAt(j);
        if (proc.userId != tr.userId) {
          continue;
        }
        if (!proc.pkgList.containsKey(pkg)) {
          continue;
        }
        procs.add(proc);
      }
    }
    for (int i=0; i < procs.size(); i++) {
      ProcessRecord pr=procs.get(i);
      if (pr == mHomeProcess) {
        continue;
      }
      if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) {
        killUnneededProcessLocked(pr,"String_Node_Str");
      }
 else {
        pr.waitingToKill="String_Node_Str";
      }
    }
  }
}
Program: 916
Project: 916
Buggy source:
/** 
 * Creates a view into which preview text can be placed.
 */
private TextView createPreviewTextView(Context context,TypedArray ta){
  final LayoutParams params=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  final Resources res=context.getResources();
  final int minSize=res.getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
  final ColorStateList textColor=ta.getColorStateList(TEXT_COLOR);
  final float textSize=res.getDimension(R.dimen.fastscroll_overlay_text_size);
  final TextView textView=new TextView(context);
  textView.setLayoutParams(params);
  textView.setTextColor(textColor);
  textView.setTextSize(textSize);
  textView.setSingleLine(true);
  textView.setEllipsize(TruncateAt.MIDDLE);
  textView.setGravity(Gravity.CENTER);
  textView.setAlpha(0f);
  textView.setLayoutDirection(mList.getLayoutDirection());
  return textView;
}

Fixed version (ground truth):
/** 
 * Creates a view into which preview text can be placed.
 */
private TextView createPreviewTextView(Context context,TypedArray ta){
  final LayoutParams params=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  final Resources res=context.getResources();
  final int minSize=res.getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
  final ColorStateList textColor=ta.getColorStateList(TEXT_COLOR);
  final float textSize=res.getDimensionPixelSize(R.dimen.fastscroll_overlay_text_size);
  final TextView textView=new TextView(context);
  textView.setLayoutParams(params);
  textView.setTextColor(textColor);
  textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,textSize);
  textView.setSingleLine(true);
  textView.setEllipsize(TruncateAt.MIDDLE);
  textView.setGravity(Gravity.CENTER);
  textView.setAlpha(0f);
  textView.setLayoutDirection(mList.getLayoutDirection());
  return textView;
}
Program: 917
Project: 917
Buggy source:
public void setTextSize(float size){
  final DisplayMetrics metrics=getContext().getResources().getDisplayMetrics();
  final float pixels=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,size,metrics);
  if (mTextPaint.getTextSize() != size) {
    mTextPaint.setTextSize(size);
    mInnerPaddingX=(int)(size * INNER_PADDING_RATIO + 0.5f);
    mHasMeasurements=false;
    forceLayout();
  }
}

Fixed version (ground truth):
/** 
 * Sets the text size in pixels.
 * @param size the text size in pixels
 */
public void setTextSize(float size){
  if (mTextPaint.getTextSize() != size) {
    mTextPaint.setTextSize(size);
    mInnerPaddingX=(int)(size * INNER_PADDING_RATIO + 0.5f);
    mHasMeasurements=false;
    forceLayout();
  }
}
Program: 918
Project: 918
Buggy source:
public SubtitleView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs);
  final Theme theme=context.getTheme();
  final TypedArray a=theme.obtainStyledAttributes(attrs,android.R.styleable.TextView,defStyle,0);
  CharSequence text="String_Node_Str";
  int textSize=15;
  final int n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    int attr=a.getIndex(i);
switch (attr) {
case android.R.styleable.TextView_text:
      text=a.getText(attr);
    break;
case android.R.styleable.TextView_lineSpacingExtra:
  mSpacingAdd=a.getDimensionPixelSize(attr,(int)mSpacingAdd);
break;
case android.R.styleable.TextView_lineSpacingMultiplier:
mSpacingMult=a.getFloat(attr,mSpacingMult);
break;
case android.R.styleable.TextAppearance_textSize:
textSize=a.getDimensionPixelSize(attr,textSize);
break;
}
}
final Resources res=getContext().getResources();
final DisplayMetrics m=res.getDisplayMetrics();
mCornerRadius=res.getDimension(com.android.internal.R.dimen.subtitle_corner_radius);
mOutlineWidth=res.getDimension(com.android.internal.R.dimen.subtitle_outline_width);
mShadowRadius=res.getDimension(com.android.internal.R.dimen.subtitle_shadow_radius);
mShadowOffsetX=res.getDimension(com.android.internal.R.dimen.subtitle_shadow_offset);
mShadowOffsetY=mShadowOffsetX;
mTextPaint=new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setSubpixelText(true);
mPaint=new Paint();
mPaint.setAntiAlias(true);
setText(text);
setTextSize(textSize);
}

Fixed version (ground truth):
public SubtitleView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs);
  final Theme theme=context.getTheme();
  final TypedArray a=theme.obtainStyledAttributes(attrs,android.R.styleable.TextView,defStyle,0);
  CharSequence text="String_Node_Str";
  int textSize=15;
  final int n=a.getIndexCount();
  for (int i=0; i < n; i++) {
    int attr=a.getIndex(i);
switch (attr) {
case android.R.styleable.TextView_text:
      text=a.getText(attr);
    break;
case android.R.styleable.TextView_lineSpacingExtra:
  mSpacingAdd=a.getDimensionPixelSize(attr,(int)mSpacingAdd);
break;
case android.R.styleable.TextView_lineSpacingMultiplier:
mSpacingMult=a.getFloat(attr,mSpacingMult);
break;
case android.R.styleable.TextAppearance_textSize:
textSize=a.getDimensionPixelSize(attr,textSize);
break;
}
}
final Resources res=getContext().getResources();
final DisplayMetrics m=res.getDisplayMetrics();
mCornerRadius=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_corner_radius);
mOutlineWidth=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_outline_width);
mShadowRadius=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_shadow_radius);
mShadowOffsetX=res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_shadow_offset);
mShadowOffsetY=mShadowOffsetX;
mTextPaint=new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setSubpixelText(true);
mPaint=new Paint();
mPaint.setAntiAlias(true);
setText(text);
setTextSize(textSize);
}