nus-yam/ex-repair huggingface dataset:
Program: 194696
Project: 194696
Buggy source:
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}

Fixed version (ground truth):
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}
Program: 194697
Project: 194697
Buggy source:
void hideRecentsInternal(boolean triggeredFromAltTab,boolean triggeredFromHomeKey){
  if (mBootCompleted) {
    ActivityManager.RunningTaskInfo topTask=mSystemServicesProxy.getTopMostTask();
    if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask,null)) {
      Intent intent=createLocalBroadcastIntent(mContext,ACTION_HIDE_RECENTS_ACTIVITY);
      intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB,triggeredFromAltTab);
      intent.putExtra(EXTRA_TRIGGERED_FROM_HOME_KEY,triggeredFromHomeKey);
      mContext.sendBroadcastAsUser(intent,UserHandle.CURRENT);
    }
  }
}

Fixed version (ground truth):
void hideRecentsInternal(boolean triggeredFromAltTab,boolean triggeredFromHomeKey){
  if (mBootCompleted) {
    Intent intent=createLocalBroadcastIntent(mContext,ACTION_HIDE_RECENTS_ACTIVITY);
    intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB,triggeredFromAltTab);
    intent.putExtra(EXTRA_TRIGGERED_FROM_HOME_KEY,triggeredFromHomeKey);
    mContext.sendBroadcastAsUser(intent,UserHandle.CURRENT);
  }
}
Program: 194698
Project: 194698
Buggy source:
@Override protected void onProviderChanged(int appWidgetId,AppWidgetProviderInfo appWidgetInfo){
  if (mCb == null)   return;
  SystemServicesProxy ssp=RecentsTaskLoader.getInstance().getSystemServicesProxy();
  if (appWidgetId > -1 && appWidgetId == mConfig.searchBarAppWidgetId) {
    ssp.unbindSearchAppWidget(this,appWidgetId);
    mConfig.updateSearchBarAppWidgetId(mContext,-1);
    mCb.refreshSearchWidget();
  }
}

Fixed version (ground truth):
@Override protected void onProviderChanged(int appWidgetId,AppWidgetProviderInfo appWidgetInfo){
  if (mCb == null)   return;
  if (mContext == null)   return;
  SystemServicesProxy ssp=RecentsTaskLoader.getInstance().getSystemServicesProxy();
  if (appWidgetId > -1 && appWidgetId == mConfig.searchBarAppWidgetId) {
    ssp.unbindSearchAppWidget(this,appWidgetId);
    mConfig.updateSearchBarAppWidgetId(mContext,-1);
    mCb.refreshSearchWidget();
  }
}
Program: 194699
Project: 194699
Buggy source:
public TaskStackView(Context context,TaskStack stack){
  super(context);
  setStack(stack);
  mConfig=RecentsConfiguration.getInstance();
  mViewPool=new ViewPool<TaskView,Task>(context,this);
  mInflater=LayoutInflater.from(context);
  mLayoutAlgorithm=new TaskStackViewLayoutAlgorithm(mConfig);
  mFilterAlgorithm=new TaskStackViewFilterAlgorithm(mConfig,this,mViewPool);
  mStackScroller=new TaskStackViewScroller(context,mConfig,mLayoutAlgorithm);
  mStackScroller.setCallbacks(this);
  mTouchHandler=new TaskStackViewTouchHandler(context,this,mConfig,mStackScroller);
  mUIDozeTrigger=new DozeTrigger(mConfig.taskBarDismissDozeDelaySeconds,new Runnable(){
    @Override public void run(){
      List<TaskView> taskViews=getTaskViews();
      int taskViewCount=taskViews.size();
      for (int i=0; i < taskViewCount; i++) {
        TaskView tv=taskViews.get(i);
        tv.startNoUserInteractionAnimation();
      }
    }
  }
);
}

Fixed version (ground truth):
public TaskStackView(Context context,TaskStack stack){
  super(context);
  setStack(stack);
  mConfig=RecentsConfiguration.getInstance();
  mViewPool=new ViewPool<TaskView,Task>(context,this);
  mInflater=LayoutInflater.from(context);
  mLayoutAlgorithm=new TaskStackViewLayoutAlgorithm(mConfig);
  mFilterAlgorithm=new TaskStackViewFilterAlgorithm(mConfig,this,mViewPool);
  mStackScroller=new TaskStackViewScroller(context,mConfig,mLayoutAlgorithm);
  mStackScroller.setCallbacks(this);
  mTouchHandler=new TaskStackViewTouchHandler(context,this,mConfig,mStackScroller);
  mUIDozeTrigger=new DozeTrigger(mConfig.taskBarDismissDozeDelaySeconds,new Runnable(){
    @Override public void run(){
      List<TaskView> taskViews=getTaskViews();
      int taskViewCount=taskViews.size();
      for (int i=0; i < taskViewCount; i++) {
        TaskView tv=taskViews.get(i);
        tv.startNoUserInteractionAnimation();
      }
    }
  }
);
  setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
Program: 194700
Project: 194700
Buggy source:
/** 
 * Ensures that there is a task focused, if nothing is focused, then we will use the task at the center of the visible stack.
 */
public boolean ensureFocusedTask(){
  if (mFocusedTaskIndex < 0) {
    int x=mLayoutAlgorithm.mStackVisibleRect.centerX();
    int y=mLayoutAlgorithm.mStackVisibleRect.centerY();
    List<TaskView> taskViews=getTaskViews();
    int taskViewCount=taskViews.size();
    for (int i=taskViewCount - 1; i >= 0; i--) {
      TaskView tv=taskViews.get(i);
      tv.getHitRect(mTmpRect);
      if (mTmpRect.contains(x,y)) {
        mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
        break;
      }
    }
    if (mFocusedTaskIndex < 0 && taskViewCount > 0) {
      mFocusedTaskIndex=taskViewCount - 1;
    }
  }
  return mFocusedTaskIndex >= 0;
}

Fixed version (ground truth):
/** 
 * Ensures that there is a task focused, if nothing is focused, then we will use the task at the center of the visible stack.
 */
public boolean ensureFocusedTask(boolean findClosestToCenter){
  if (mFocusedTaskIndex < 0) {
    List<TaskView> taskViews=getTaskViews();
    int taskViewCount=taskViews.size();
    if (findClosestToCenter) {
      int x=mLayoutAlgorithm.mStackVisibleRect.centerX();
      int y=mLayoutAlgorithm.mStackVisibleRect.centerY();
      for (int i=taskViewCount - 1; i >= 0; i--) {
        TaskView tv=taskViews.get(i);
        tv.getHitRect(mTmpRect);
        if (mTmpRect.contains(x,y)) {
          mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
          mPrevAccessibilityFocusedIndex=mFocusedTaskIndex;
          break;
        }
      }
    }
    if (mFocusedTaskIndex < 0 && taskViewCount > 0) {
      TaskView tv=taskViews.get(taskViewCount - 1);
      mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
      mPrevAccessibilityFocusedIndex=mFocusedTaskIndex;
    }
  }
  return mFocusedTaskIndex >= 0;
}
Program: 194702
Project: 194702
Buggy source:
/** 
 * Resets the focused task. 
 */
void resetFocusedTask(){
  if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mStack.getTaskCount())) {
    Task t=mStack.getTasks().get(mFocusedTaskIndex);
    TaskView tv=getChildViewForTask(t);
    if (tv != null) {
      tv.unsetFocusedTask();
    }
  }
  mFocusedTaskIndex=-1;
}

Fixed version (ground truth):
/** 
 * Resets the focused task. 
 */
void resetFocusedTask(){
  if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mStack.getTaskCount())) {
    Task t=mStack.getTasks().get(mFocusedTaskIndex);
    TaskView tv=getChildViewForTask(t);
    if (tv != null) {
      tv.unsetFocusedTask();
    }
  }
  mFocusedTaskIndex=-1;
  mPrevAccessibilityFocusedIndex=-1;
}
Program: 194703
Project: 194703
Buggy source:
/** 
 * Focuses the task at the specified index in the stack 
 */
void focusTask(int taskIndex,boolean scrollToNewPosition,final boolean animateFocusedState){
  if (taskIndex == mFocusedTaskIndex)   return;
  if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
    mFocusedTaskIndex=taskIndex;
    Task t=mStack.getTasks().get(taskIndex);
    TaskView tv=getChildViewForTask(t);
    Runnable postScrollRunnable=null;
    if (tv != null) {
      tv.setFocusedTask(animateFocusedState);
    }
 else {
      postScrollRunnable=new Runnable(){
        @Override public void run(){
          Task t=mStack.getTasks().get(mFocusedTaskIndex);
          TaskView tv=getChildViewForTask(t);
          if (tv != null) {
            tv.setFocusedTask(animateFocusedState);
          }
        }
      }
;
    }
    if (scrollToNewPosition) {
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(t) - 0.5f;
      newScroll=mStackScroller.getBoundedStackScroll(newScroll);
      mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,postScrollRunnable);
    }
 else {
      if (postScrollRunnable != null) {
        postScrollRunnable.run();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Focuses the task at the specified index in the stack 
 */
void focusTask(int taskIndex,boolean scrollToNewPosition,final boolean animateFocusedState){
  if (taskIndex == mFocusedTaskIndex)   return;
  if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
    mFocusedTaskIndex=taskIndex;
    mPrevAccessibilityFocusedIndex=taskIndex;
    final Task t=mStack.getTasks().get(mFocusedTaskIndex);
    Runnable postScrollRunnable=new Runnable(){
      @Override public void run(){
        TaskView tv=getChildViewForTask(t);
        if (tv != null) {
          tv.setFocusedTask(animateFocusedState);
          tv.requestAccessibilityFocus();
        }
      }
    }
;
    if (scrollToNewPosition) {
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(t) - 0.5f;
      newScroll=mStackScroller.getBoundedStackScroll(newScroll);
      mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,postScrollRunnable);
    }
 else {
      if (postScrollRunnable != null) {
        postScrollRunnable.run();
      }
    }
  }
}
Program: 194704
Project: 194704
Buggy source:
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}

Fixed version (ground truth):
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}
Program: 194705
Project: 194705
Buggy source:
public TaskStackView(Context context,TaskStack stack){
  super(context);
  setStack(stack);
  mConfig=RecentsConfiguration.getInstance();
  mViewPool=new ViewPool<TaskView,Task>(context,this);
  mInflater=LayoutInflater.from(context);
  mLayoutAlgorithm=new TaskStackViewLayoutAlgorithm(mConfig);
  mFilterAlgorithm=new TaskStackViewFilterAlgorithm(mConfig,this,mViewPool);
  mStackScroller=new TaskStackViewScroller(context,mConfig,mLayoutAlgorithm);
  mStackScroller.setCallbacks(this);
  mTouchHandler=new TaskStackViewTouchHandler(context,this,mConfig,mStackScroller);
  mUIDozeTrigger=new DozeTrigger(mConfig.taskBarDismissDozeDelaySeconds,new Runnable(){
    @Override public void run(){
      List<TaskView> taskViews=getTaskViews();
      int taskViewCount=taskViews.size();
      for (int i=0; i < taskViewCount; i++) {
        TaskView tv=taskViews.get(i);
        tv.startNoUserInteractionAnimation();
      }
    }
  }
);
}

Fixed version (ground truth):
public TaskStackView(Context context,TaskStack stack){
  super(context);
  setStack(stack);
  mConfig=RecentsConfiguration.getInstance();
  mViewPool=new ViewPool<TaskView,Task>(context,this);
  mInflater=LayoutInflater.from(context);
  mLayoutAlgorithm=new TaskStackViewLayoutAlgorithm(mConfig);
  mFilterAlgorithm=new TaskStackViewFilterAlgorithm(mConfig,this,mViewPool);
  mStackScroller=new TaskStackViewScroller(context,mConfig,mLayoutAlgorithm);
  mStackScroller.setCallbacks(this);
  mTouchHandler=new TaskStackViewTouchHandler(context,this,mConfig,mStackScroller);
  mUIDozeTrigger=new DozeTrigger(mConfig.taskBarDismissDozeDelaySeconds,new Runnable(){
    @Override public void run(){
      List<TaskView> taskViews=getTaskViews();
      int taskViewCount=taskViews.size();
      for (int i=0; i < taskViewCount; i++) {
        TaskView tv=taskViews.get(i);
        tv.startNoUserInteractionAnimation();
      }
    }
  }
);
  setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
Program: 194706
Project: 194706
Buggy source:
/** 
 * Ensures that there is a task focused, if nothing is focused, then we will use the task at the center of the visible stack.
 */
public boolean ensureFocusedTask(){
  if (mFocusedTaskIndex < 0) {
    int x=mLayoutAlgorithm.mStackVisibleRect.centerX();
    int y=mLayoutAlgorithm.mStackVisibleRect.centerY();
    List<TaskView> taskViews=getTaskViews();
    int taskViewCount=taskViews.size();
    for (int i=taskViewCount - 1; i >= 0; i--) {
      TaskView tv=taskViews.get(i);
      tv.getHitRect(mTmpRect);
      if (mTmpRect.contains(x,y)) {
        mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
        break;
      }
    }
    if (mFocusedTaskIndex < 0 && taskViewCount > 0) {
      mFocusedTaskIndex=taskViewCount - 1;
    }
  }
  return mFocusedTaskIndex >= 0;
}

Fixed version (ground truth):
/** 
 * Ensures that there is a task focused, if nothing is focused, then we will use the task at the center of the visible stack.
 */
public boolean ensureFocusedTask(boolean findClosestToCenter){
  if (mFocusedTaskIndex < 0) {
    List<TaskView> taskViews=getTaskViews();
    int taskViewCount=taskViews.size();
    if (findClosestToCenter) {
      int x=mLayoutAlgorithm.mStackVisibleRect.centerX();
      int y=mLayoutAlgorithm.mStackVisibleRect.centerY();
      for (int i=taskViewCount - 1; i >= 0; i--) {
        TaskView tv=taskViews.get(i);
        tv.getHitRect(mTmpRect);
        if (mTmpRect.contains(x,y)) {
          mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
          mPrevAccessibilityFocusedIndex=mFocusedTaskIndex;
          break;
        }
      }
    }
    if (mFocusedTaskIndex < 0 && taskViewCount > 0) {
      TaskView tv=taskViews.get(taskViewCount - 1);
      mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
      mPrevAccessibilityFocusedIndex=mFocusedTaskIndex;
    }
  }
  return mFocusedTaskIndex >= 0;
}
Program: 194708
Project: 194708
Buggy source:
/** 
 * Resets the focused task. 
 */
void resetFocusedTask(){
  if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mStack.getTaskCount())) {
    Task t=mStack.getTasks().get(mFocusedTaskIndex);
    TaskView tv=getChildViewForTask(t);
    if (tv != null) {
      tv.unsetFocusedTask();
    }
  }
  mFocusedTaskIndex=-1;
}

Fixed version (ground truth):
/** 
 * Resets the focused task. 
 */
void resetFocusedTask(){
  if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mStack.getTaskCount())) {
    Task t=mStack.getTasks().get(mFocusedTaskIndex);
    TaskView tv=getChildViewForTask(t);
    if (tv != null) {
      tv.unsetFocusedTask();
    }
  }
  mFocusedTaskIndex=-1;
  mPrevAccessibilityFocusedIndex=-1;
}
Program: 194709
Project: 194709
Buggy source:
/** 
 * Focuses the task at the specified index in the stack 
 */
void focusTask(int taskIndex,boolean scrollToNewPosition,final boolean animateFocusedState){
  if (taskIndex == mFocusedTaskIndex)   return;
  if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
    mFocusedTaskIndex=taskIndex;
    Task t=mStack.getTasks().get(taskIndex);
    TaskView tv=getChildViewForTask(t);
    Runnable postScrollRunnable=null;
    if (tv != null) {
      tv.setFocusedTask(animateFocusedState);
    }
 else {
      postScrollRunnable=new Runnable(){
        @Override public void run(){
          Task t=mStack.getTasks().get(mFocusedTaskIndex);
          TaskView tv=getChildViewForTask(t);
          if (tv != null) {
            tv.setFocusedTask(animateFocusedState);
          }
        }
      }
;
    }
    if (scrollToNewPosition) {
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(t) - 0.5f;
      newScroll=mStackScroller.getBoundedStackScroll(newScroll);
      mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,postScrollRunnable);
    }
 else {
      if (postScrollRunnable != null) {
        postScrollRunnable.run();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Focuses the task at the specified index in the stack 
 */
void focusTask(int taskIndex,boolean scrollToNewPosition,final boolean animateFocusedState){
  if (taskIndex == mFocusedTaskIndex)   return;
  if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
    mFocusedTaskIndex=taskIndex;
    mPrevAccessibilityFocusedIndex=taskIndex;
    final Task t=mStack.getTasks().get(mFocusedTaskIndex);
    Runnable postScrollRunnable=new Runnable(){
      @Override public void run(){
        TaskView tv=getChildViewForTask(t);
        if (tv != null) {
          tv.setFocusedTask(animateFocusedState);
          tv.requestAccessibilityFocus();
        }
      }
    }
;
    if (scrollToNewPosition) {
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(t) - 0.5f;
      newScroll=mStackScroller.getBoundedStackScroll(newScroll);
      mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,postScrollRunnable);
    }
 else {
      if (postScrollRunnable != null) {
        postScrollRunnable.run();
      }
    }
  }
}
Program: 194710
Project: 194710
Buggy source:
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}

Fixed version (ground truth):
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}
Program: 194711
Project: 194711
Buggy source:
public TaskStackView(Context context,TaskStack stack){
  super(context);
  setStack(stack);
  mConfig=RecentsConfiguration.getInstance();
  mViewPool=new ViewPool<TaskView,Task>(context,this);
  mInflater=LayoutInflater.from(context);
  mLayoutAlgorithm=new TaskStackViewLayoutAlgorithm(mConfig);
  mFilterAlgorithm=new TaskStackViewFilterAlgorithm(mConfig,this,mViewPool);
  mStackScroller=new TaskStackViewScroller(context,mConfig,mLayoutAlgorithm);
  mStackScroller.setCallbacks(this);
  mTouchHandler=new TaskStackViewTouchHandler(context,this,mConfig,mStackScroller);
  mUIDozeTrigger=new DozeTrigger(mConfig.taskBarDismissDozeDelaySeconds,new Runnable(){
    @Override public void run(){
      List<TaskView> taskViews=getTaskViews();
      int taskViewCount=taskViews.size();
      for (int i=0; i < taskViewCount; i++) {
        TaskView tv=taskViews.get(i);
        tv.startNoUserInteractionAnimation();
      }
    }
  }
);
}

Fixed version (ground truth):
public TaskStackView(Context context,TaskStack stack){
  super(context);
  setStack(stack);
  mConfig=RecentsConfiguration.getInstance();
  mViewPool=new ViewPool<TaskView,Task>(context,this);
  mInflater=LayoutInflater.from(context);
  mLayoutAlgorithm=new TaskStackViewLayoutAlgorithm(mConfig);
  mFilterAlgorithm=new TaskStackViewFilterAlgorithm(mConfig,this,mViewPool);
  mStackScroller=new TaskStackViewScroller(context,mConfig,mLayoutAlgorithm);
  mStackScroller.setCallbacks(this);
  mTouchHandler=new TaskStackViewTouchHandler(context,this,mConfig,mStackScroller);
  mUIDozeTrigger=new DozeTrigger(mConfig.taskBarDismissDozeDelaySeconds,new Runnable(){
    @Override public void run(){
      List<TaskView> taskViews=getTaskViews();
      int taskViewCount=taskViews.size();
      for (int i=0; i < taskViewCount; i++) {
        TaskView tv=taskViews.get(i);
        tv.startNoUserInteractionAnimation();
      }
    }
  }
);
  setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
Program: 194712
Project: 194712
Buggy source:
/** 
 * Ensures that there is a task focused, if nothing is focused, then we will use the task at the center of the visible stack.
 */
public boolean ensureFocusedTask(){
  if (mFocusedTaskIndex < 0) {
    int x=mLayoutAlgorithm.mStackVisibleRect.centerX();
    int y=mLayoutAlgorithm.mStackVisibleRect.centerY();
    List<TaskView> taskViews=getTaskViews();
    int taskViewCount=taskViews.size();
    for (int i=taskViewCount - 1; i >= 0; i--) {
      TaskView tv=taskViews.get(i);
      tv.getHitRect(mTmpRect);
      if (mTmpRect.contains(x,y)) {
        mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
        break;
      }
    }
    if (mFocusedTaskIndex < 0 && taskViewCount > 0) {
      mFocusedTaskIndex=taskViewCount - 1;
    }
  }
  return mFocusedTaskIndex >= 0;
}

Fixed version (ground truth):
/** 
 * Ensures that there is a task focused, if nothing is focused, then we will use the task at the center of the visible stack.
 */
public boolean ensureFocusedTask(boolean findClosestToCenter){
  if (mFocusedTaskIndex < 0) {
    List<TaskView> taskViews=getTaskViews();
    int taskViewCount=taskViews.size();
    if (findClosestToCenter) {
      int x=mLayoutAlgorithm.mStackVisibleRect.centerX();
      int y=mLayoutAlgorithm.mStackVisibleRect.centerY();
      for (int i=taskViewCount - 1; i >= 0; i--) {
        TaskView tv=taskViews.get(i);
        tv.getHitRect(mTmpRect);
        if (mTmpRect.contains(x,y)) {
          mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
          mPrevAccessibilityFocusedIndex=mFocusedTaskIndex;
          break;
        }
      }
    }
    if (mFocusedTaskIndex < 0 && taskViewCount > 0) {
      TaskView tv=taskViews.get(taskViewCount - 1);
      mFocusedTaskIndex=mStack.indexOfTask(tv.getTask());
      mPrevAccessibilityFocusedIndex=mFocusedTaskIndex;
    }
  }
  return mFocusedTaskIndex >= 0;
}
Program: 194714
Project: 194714
Buggy source:
/** 
 * Resets the focused task. 
 */
void resetFocusedTask(){
  if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mStack.getTaskCount())) {
    Task t=mStack.getTasks().get(mFocusedTaskIndex);
    TaskView tv=getChildViewForTask(t);
    if (tv != null) {
      tv.unsetFocusedTask();
    }
  }
  mFocusedTaskIndex=-1;
}

Fixed version (ground truth):
/** 
 * Resets the focused task. 
 */
void resetFocusedTask(){
  if ((0 <= mFocusedTaskIndex) && (mFocusedTaskIndex < mStack.getTaskCount())) {
    Task t=mStack.getTasks().get(mFocusedTaskIndex);
    TaskView tv=getChildViewForTask(t);
    if (tv != null) {
      tv.unsetFocusedTask();
    }
  }
  mFocusedTaskIndex=-1;
  mPrevAccessibilityFocusedIndex=-1;
}
Program: 194715
Project: 194715
Buggy source:
/** 
 * Focuses the task at the specified index in the stack 
 */
void focusTask(int taskIndex,boolean scrollToNewPosition,final boolean animateFocusedState){
  if (taskIndex == mFocusedTaskIndex)   return;
  if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
    mFocusedTaskIndex=taskIndex;
    Task t=mStack.getTasks().get(taskIndex);
    TaskView tv=getChildViewForTask(t);
    Runnable postScrollRunnable=null;
    if (tv != null) {
      tv.setFocusedTask(animateFocusedState);
    }
 else {
      postScrollRunnable=new Runnable(){
        @Override public void run(){
          Task t=mStack.getTasks().get(mFocusedTaskIndex);
          TaskView tv=getChildViewForTask(t);
          if (tv != null) {
            tv.setFocusedTask(animateFocusedState);
          }
        }
      }
;
    }
    if (scrollToNewPosition) {
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(t) - 0.5f;
      newScroll=mStackScroller.getBoundedStackScroll(newScroll);
      mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,postScrollRunnable);
    }
 else {
      if (postScrollRunnable != null) {
        postScrollRunnable.run();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Focuses the task at the specified index in the stack 
 */
void focusTask(int taskIndex,boolean scrollToNewPosition,final boolean animateFocusedState){
  if (taskIndex == mFocusedTaskIndex)   return;
  if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
    mFocusedTaskIndex=taskIndex;
    mPrevAccessibilityFocusedIndex=taskIndex;
    final Task t=mStack.getTasks().get(mFocusedTaskIndex);
    Runnable postScrollRunnable=new Runnable(){
      @Override public void run(){
        TaskView tv=getChildViewForTask(t);
        if (tv != null) {
          tv.setFocusedTask(animateFocusedState);
          tv.requestAccessibilityFocus();
        }
      }
    }
;
    if (scrollToNewPosition) {
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(t) - 0.5f;
      newScroll=mStackScroller.getBoundedStackScroll(newScroll);
      mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,postScrollRunnable);
    }
 else {
      if (postScrollRunnable != null) {
        postScrollRunnable.run();
      }
    }
  }
}
Program: 194716
Project: 194716
Buggy source:
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask()) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}

Fixed version (ground truth):
/** 
 * Handles generic motion events 
 */
public boolean onGenericMotionEvent(MotionEvent ev){
  if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
    int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_SCROLL:
      float vScroll=ev.getAxisValue(MotionEvent.AXIS_VSCROLL);
    if (vScroll > 0) {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(true,false);
      }
    }
 else {
      if (mSv.ensureFocusedTask(true)) {
        mSv.focusNextTask(false,false);
      }
    }
  return true;
}
}
return false;
}
Program: 194719
Project: 194719
Buggy source:
private void maybeUpdateUsageStatsLocked(ProcessRecord app){
  if (DEBUG_USAGE_STATS) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(app.getPackageList()) + "String_Node_Str"+ app.setProcState+ "String_Node_Str"+ app.curProcState);
  }
  if (mUsageStatsService == null) {
    return;
  }
  boolean isInteraction;
  if (!mSleeping) {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
 else {
    if (app.curProcState <= ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
      isInteraction=true;
      app.fgInteractionTime=0;
    }
 else     if (app.curProcState <= ActivityManager.PROCESS_STATE_TOP_SLEEPING) {
      final long now=SystemClock.elapsedRealtime();
      if (app.fgInteractionTime == 0) {
        app.fgInteractionTime=now;
        isInteraction=false;
      }
 else {
        isInteraction=now > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
      }
    }
 else {
      isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
      app.fgInteractionTime=0;
    }
  }
  if (isInteraction && !app.reportedInteraction) {
    String[] packages=app.getPackageList();
    if (packages != null) {
      for (int i=0; i < packages.length; i++) {
        mUsageStatsService.reportEvent(packages[i],app.userId,UsageEvents.Event.SYSTEM_INTERACTION);
      }
    }
  }
  app.reportedInteraction=isInteraction;
}

Fixed version (ground truth):
private void maybeUpdateUsageStatsLocked(ProcessRecord app){
  if (DEBUG_USAGE_STATS) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(app.getPackageList()) + "String_Node_Str"+ app.setProcState+ "String_Node_Str"+ app.curProcState);
  }
  if (mUsageStatsService == null) {
    return;
  }
  boolean isInteraction;
  if (app.curProcState <= ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
    isInteraction=true;
    app.fgInteractionTime=0;
  }
 else   if (app.curProcState <= ActivityManager.PROCESS_STATE_TOP_SLEEPING) {
    final long now=SystemClock.elapsedRealtime();
    if (app.fgInteractionTime == 0) {
      app.fgInteractionTime=now;
      isInteraction=false;
    }
 else {
      isInteraction=now > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
    }
  }
 else {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
  if (isInteraction && !app.reportedInteraction) {
    String[] packages=app.getPackageList();
    if (packages != null) {
      for (int i=0; i < packages.length; i++) {
        mUsageStatsService.reportEvent(packages[i],app.userId,UsageEvents.Event.SYSTEM_INTERACTION);
      }
    }
  }
  app.reportedInteraction=isInteraction;
}
Program: 194720
Project: 194720
Buggy source:
void startRunningVoiceLocked(IVoiceInteractionSession session,int targetUid){
  mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
  if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
    if (mRunningVoice == null) {
      mVoiceWakeLock.acquire();
      updateSleepIfNeededLocked();
    }
    mRunningVoice=session;
  }
}

Fixed version (ground truth):
void startRunningVoiceLocked(IVoiceInteractionSession session,int targetUid){
  mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
  if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
    boolean wasRunningVoice=mRunningVoice != null;
    mRunningVoice=session;
    if (!wasRunningVoice) {
      mVoiceWakeLock.acquire();
      updateSleepIfNeededLocked();
    }
  }
}
Program: 194721
Project: 194721
Buggy source:
@Override public boolean onHandleForceStop(Intent intent,String[] packages,int uid,boolean doit){
  return super.onHandleForceStop(intent,packages,uid,doit);
}

Fixed version (ground truth):
@Override public boolean onHandleForceStop(Intent intent,String[] packages,int uid,boolean doit){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + uid + "String_Node_Str"+ doit);
  int userHandle=UserHandle.getUserId(uid);
  ComponentName curInteractor=getCurInteractor(userHandle);
  ComponentName curRecognizer=getCurRecognizer(userHandle);
  boolean hit=false;
  for (  String pkg : packages) {
    if (curInteractor != null && pkg.equals(curInteractor.getPackageName())) {
      hit=true;
      break;
    }
 else     if (curRecognizer != null && pkg.equals(curRecognizer.getPackageName())) {
      hit=true;
      break;
    }
  }
  if (hit && doit) {
synchronized (VoiceInteractionManagerService.this) {
      mSoundTriggerHelper.stopAllRecognitions();
      if (mImpl != null) {
        mImpl.shutdownLocked();
        mImpl=null;
      }
      setCurInteractor(null,userHandle);
      setCurRecognizer(null,userHandle);
      initForUser(userHandle);
      switchImplementationIfNeededLocked(true);
    }
  }
  return hit;
}
Program: 194722
Project: 194722
Buggy source:
@Override public void onSomePackagesChanged(){
  int userHandle=getChangingUserId();
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + userHandle);
  ComponentName curInteractor=getCurInteractor(userHandle);
  ComponentName curRecognizer=getCurRecognizer(userHandle);
  if (curRecognizer == null) {
    if (anyPackagesAppearing()) {
      curRecognizer=findAvailRecognizer(null,userHandle);
      if (curRecognizer != null) {
        setCurRecognizer(curRecognizer,userHandle);
      }
    }
    return;
  }
  if (curInteractor != null) {
    int change=isPackageDisappearing(curInteractor.getPackageName());
    if (change == PACKAGE_PERMANENT_CHANGE) {
      setCurInteractor(null,userHandle);
      setCurRecognizer(null,userHandle);
      initForUser(userHandle);
      return;
    }
    change=isPackageAppearing(curInteractor.getPackageName());
    if (change != PACKAGE_UNCHANGED) {
      if (mImpl != null && curInteractor.getPackageName().equals(mImpl.mComponent.getPackageName())) {
        switchImplementationIfNeededLocked(true);
      }
    }
    return;
  }
  int change=isPackageDisappearing(curRecognizer.getPackageName());
  if (change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE) {
    setCurRecognizer(findAvailRecognizer(null,userHandle),userHandle);
  }
 else   if (isPackageModified(curRecognizer.getPackageName())) {
    setCurRecognizer(findAvailRecognizer(curRecognizer.getPackageName(),userHandle),userHandle);
  }
}

Fixed version (ground truth):
@Override public void onSomePackagesChanged(){
  int userHandle=getChangingUserId();
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + userHandle);
synchronized (VoiceInteractionManagerService.this) {
    ComponentName curInteractor=getCurInteractor(userHandle);
    ComponentName curRecognizer=getCurRecognizer(userHandle);
    if (curRecognizer == null) {
      if (anyPackagesAppearing()) {
        curRecognizer=findAvailRecognizer(null,userHandle);
        if (curRecognizer != null) {
          setCurRecognizer(curRecognizer,userHandle);
        }
      }
      return;
    }
    if (curInteractor != null) {
      int change=isPackageDisappearing(curInteractor.getPackageName());
      if (change == PACKAGE_PERMANENT_CHANGE) {
        setCurInteractor(null,userHandle);
        setCurRecognizer(null,userHandle);
        initForUser(userHandle);
        return;
      }
      change=isPackageAppearing(curInteractor.getPackageName());
      if (change != PACKAGE_UNCHANGED) {
        if (mImpl != null && curInteractor.getPackageName().equals(mImpl.mComponent.getPackageName())) {
          switchImplementationIfNeededLocked(true);
        }
      }
      return;
    }
    int change=isPackageDisappearing(curRecognizer.getPackageName());
    if (change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE) {
      setCurRecognizer(findAvailRecognizer(null,userHandle),userHandle);
    }
 else     if (isPackageModified(curRecognizer.getPackageName())) {
      setCurRecognizer(findAvailRecognizer(curRecognizer.getPackageName(),userHandle),userHandle);
    }
  }
}
Program: 194723
Project: 194723
Buggy source:
private void maybeUpdateUsageStatsLocked(ProcessRecord app){
  if (DEBUG_USAGE_STATS) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(app.getPackageList()) + "String_Node_Str"+ app.setProcState+ "String_Node_Str"+ app.curProcState);
  }
  if (mUsageStatsService == null) {
    return;
  }
  boolean isInteraction;
  if (!mSleeping) {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
 else {
    if (app.curProcState <= ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
      isInteraction=true;
      app.fgInteractionTime=0;
    }
 else     if (app.curProcState <= ActivityManager.PROCESS_STATE_TOP_SLEEPING) {
      final long now=SystemClock.elapsedRealtime();
      if (app.fgInteractionTime == 0) {
        app.fgInteractionTime=now;
        isInteraction=false;
      }
 else {
        isInteraction=now > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
      }
    }
 else {
      isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
      app.fgInteractionTime=0;
    }
  }
  if (isInteraction && !app.reportedInteraction) {
    String[] packages=app.getPackageList();
    if (packages != null) {
      for (int i=0; i < packages.length; i++) {
        mUsageStatsService.reportEvent(packages[i],app.userId,UsageEvents.Event.SYSTEM_INTERACTION);
      }
    }
  }
  app.reportedInteraction=isInteraction;
}

Fixed version (ground truth):
private void maybeUpdateUsageStatsLocked(ProcessRecord app){
  if (DEBUG_USAGE_STATS) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(app.getPackageList()) + "String_Node_Str"+ app.setProcState+ "String_Node_Str"+ app.curProcState);
  }
  if (mUsageStatsService == null) {
    return;
  }
  boolean isInteraction;
  if (app.curProcState <= ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
    isInteraction=true;
    app.fgInteractionTime=0;
  }
 else   if (app.curProcState <= ActivityManager.PROCESS_STATE_TOP_SLEEPING) {
    final long now=SystemClock.elapsedRealtime();
    if (app.fgInteractionTime == 0) {
      app.fgInteractionTime=now;
      isInteraction=false;
    }
 else {
      isInteraction=now > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
    }
  }
 else {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
  if (isInteraction && !app.reportedInteraction) {
    String[] packages=app.getPackageList();
    if (packages != null) {
      for (int i=0; i < packages.length; i++) {
        mUsageStatsService.reportEvent(packages[i],app.userId,UsageEvents.Event.SYSTEM_INTERACTION);
      }
    }
  }
  app.reportedInteraction=isInteraction;
}
Program: 194724
Project: 194724
Buggy source:
void startRunningVoiceLocked(IVoiceInteractionSession session,int targetUid){
  mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
  if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
    if (mRunningVoice == null) {
      mVoiceWakeLock.acquire();
      updateSleepIfNeededLocked();
    }
    mRunningVoice=session;
  }
}

Fixed version (ground truth):
void startRunningVoiceLocked(IVoiceInteractionSession session,int targetUid){
  mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
  if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
    boolean wasRunningVoice=mRunningVoice != null;
    mRunningVoice=session;
    if (!wasRunningVoice) {
      mVoiceWakeLock.acquire();
      updateSleepIfNeededLocked();
    }
  }
}
Program: 194725
Project: 194725
Buggy source:
@Override public boolean onHandleForceStop(Intent intent,String[] packages,int uid,boolean doit){
  return super.onHandleForceStop(intent,packages,uid,doit);
}

Fixed version (ground truth):
@Override public boolean onHandleForceStop(Intent intent,String[] packages,int uid,boolean doit){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + uid + "String_Node_Str"+ doit);
  int userHandle=UserHandle.getUserId(uid);
  ComponentName curInteractor=getCurInteractor(userHandle);
  ComponentName curRecognizer=getCurRecognizer(userHandle);
  boolean hit=false;
  for (  String pkg : packages) {
    if (curInteractor != null && pkg.equals(curInteractor.getPackageName())) {
      hit=true;
      break;
    }
 else     if (curRecognizer != null && pkg.equals(curRecognizer.getPackageName())) {
      hit=true;
      break;
    }
  }
  if (hit && doit) {
synchronized (VoiceInteractionManagerService.this) {
      mSoundTriggerHelper.stopAllRecognitions();
      if (mImpl != null) {
        mImpl.shutdownLocked();
        mImpl=null;
      }
      setCurInteractor(null,userHandle);
      setCurRecognizer(null,userHandle);
      initForUser(userHandle);
      switchImplementationIfNeededLocked(true);
    }
  }
  return hit;
}
Program: 194726
Project: 194726
Buggy source:
@Override public void onSomePackagesChanged(){
  int userHandle=getChangingUserId();
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + userHandle);
  ComponentName curInteractor=getCurInteractor(userHandle);
  ComponentName curRecognizer=getCurRecognizer(userHandle);
  if (curRecognizer == null) {
    if (anyPackagesAppearing()) {
      curRecognizer=findAvailRecognizer(null,userHandle);
      if (curRecognizer != null) {
        setCurRecognizer(curRecognizer,userHandle);
      }
    }
    return;
  }
  if (curInteractor != null) {
    int change=isPackageDisappearing(curInteractor.getPackageName());
    if (change == PACKAGE_PERMANENT_CHANGE) {
      setCurInteractor(null,userHandle);
      setCurRecognizer(null,userHandle);
      initForUser(userHandle);
      return;
    }
    change=isPackageAppearing(curInteractor.getPackageName());
    if (change != PACKAGE_UNCHANGED) {
      if (mImpl != null && curInteractor.getPackageName().equals(mImpl.mComponent.getPackageName())) {
        switchImplementationIfNeededLocked(true);
      }
    }
    return;
  }
  int change=isPackageDisappearing(curRecognizer.getPackageName());
  if (change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE) {
    setCurRecognizer(findAvailRecognizer(null,userHandle),userHandle);
  }
 else   if (isPackageModified(curRecognizer.getPackageName())) {
    setCurRecognizer(findAvailRecognizer(curRecognizer.getPackageName(),userHandle),userHandle);
  }
}

Fixed version (ground truth):
@Override public void onSomePackagesChanged(){
  int userHandle=getChangingUserId();
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + userHandle);
synchronized (VoiceInteractionManagerService.this) {
    ComponentName curInteractor=getCurInteractor(userHandle);
    ComponentName curRecognizer=getCurRecognizer(userHandle);
    if (curRecognizer == null) {
      if (anyPackagesAppearing()) {
        curRecognizer=findAvailRecognizer(null,userHandle);
        if (curRecognizer != null) {
          setCurRecognizer(curRecognizer,userHandle);
        }
      }
      return;
    }
    if (curInteractor != null) {
      int change=isPackageDisappearing(curInteractor.getPackageName());
      if (change == PACKAGE_PERMANENT_CHANGE) {
        setCurInteractor(null,userHandle);
        setCurRecognizer(null,userHandle);
        initForUser(userHandle);
        return;
      }
      change=isPackageAppearing(curInteractor.getPackageName());
      if (change != PACKAGE_UNCHANGED) {
        if (mImpl != null && curInteractor.getPackageName().equals(mImpl.mComponent.getPackageName())) {
          switchImplementationIfNeededLocked(true);
        }
      }
      return;
    }
    int change=isPackageDisappearing(curRecognizer.getPackageName());
    if (change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE) {
      setCurRecognizer(findAvailRecognizer(null,userHandle),userHandle);
    }
 else     if (isPackageModified(curRecognizer.getPackageName())) {
      setCurRecognizer(findAvailRecognizer(curRecognizer.getPackageName(),userHandle),userHandle);
    }
  }
}
Program: 194727
Project: 194727
Buggy source:
private void maybeUpdateUsageStatsLocked(ProcessRecord app){
  if (DEBUG_USAGE_STATS) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(app.getPackageList()) + "String_Node_Str"+ app.setProcState+ "String_Node_Str"+ app.curProcState);
  }
  if (mUsageStatsService == null) {
    return;
  }
  boolean isInteraction;
  if (!mSleeping) {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
 else {
    if (app.curProcState <= ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
      isInteraction=true;
      app.fgInteractionTime=0;
    }
 else     if (app.curProcState <= ActivityManager.PROCESS_STATE_TOP_SLEEPING) {
      final long now=SystemClock.elapsedRealtime();
      if (app.fgInteractionTime == 0) {
        app.fgInteractionTime=now;
        isInteraction=false;
      }
 else {
        isInteraction=now > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
      }
    }
 else {
      isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
      app.fgInteractionTime=0;
    }
  }
  if (isInteraction && !app.reportedInteraction) {
    String[] packages=app.getPackageList();
    if (packages != null) {
      for (int i=0; i < packages.length; i++) {
        mUsageStatsService.reportEvent(packages[i],app.userId,UsageEvents.Event.SYSTEM_INTERACTION);
      }
    }
  }
  app.reportedInteraction=isInteraction;
}

Fixed version (ground truth):
private void maybeUpdateUsageStatsLocked(ProcessRecord app){
  if (DEBUG_USAGE_STATS) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(app.getPackageList()) + "String_Node_Str"+ app.setProcState+ "String_Node_Str"+ app.curProcState);
  }
  if (mUsageStatsService == null) {
    return;
  }
  boolean isInteraction;
  if (app.curProcState <= ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
    isInteraction=true;
    app.fgInteractionTime=0;
  }
 else   if (app.curProcState <= ActivityManager.PROCESS_STATE_TOP_SLEEPING) {
    final long now=SystemClock.elapsedRealtime();
    if (app.fgInteractionTime == 0) {
      app.fgInteractionTime=now;
      isInteraction=false;
    }
 else {
      isInteraction=now > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
    }
  }
 else {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
  if (isInteraction && !app.reportedInteraction) {
    String[] packages=app.getPackageList();
    if (packages != null) {
      for (int i=0; i < packages.length; i++) {
        mUsageStatsService.reportEvent(packages[i],app.userId,UsageEvents.Event.SYSTEM_INTERACTION);
      }
    }
  }
  app.reportedInteraction=isInteraction;
}
Program: 194728
Project: 194728
Buggy source:
void startRunningVoiceLocked(IVoiceInteractionSession session,int targetUid){
  mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
  if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
    if (mRunningVoice == null) {
      mVoiceWakeLock.acquire();
      updateSleepIfNeededLocked();
    }
    mRunningVoice=session;
  }
}

Fixed version (ground truth):
void startRunningVoiceLocked(IVoiceInteractionSession session,int targetUid){
  mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
  if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
    boolean wasRunningVoice=mRunningVoice != null;
    mRunningVoice=session;
    if (!wasRunningVoice) {
      mVoiceWakeLock.acquire();
      updateSleepIfNeededLocked();
    }
  }
}