nus-yam/ex-repair huggingface dataset:
Program: 192670
Project: 192670
Buggy source:
public void setNavigationIconHints(int hints,boolean force){
  if (!force && hints == mNavigationIconHints)   return;
  final boolean backAlt=(hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
  if ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0 && !backAlt) {
    mTransitionListener.onBackAltCleared();
  }
  if (DEBUG) {
    android.widget.Toast.makeText(getContext(),"String_Node_Str" + hints,500).show();
  }
  mNavigationIconHints=hints;
  Drawable backIcon=(backAlt) ? getBackIconWithAlt(mCarMode,mVertical) : getBackIcon(mCarMode,mVertical);
  getBackButton().setImageDrawable(backIcon);
  getRecentsButton().setImageDrawable(mVertical ? mRecentLandIcon : mRecentIcon);
  if (mCarMode) {
    getHomeButton().setImageDrawable(mHomeCarModeIcon);
  }
 else {
    getHomeButton().setImageDrawable(mHomeDefaultIcon);
  }
  final boolean showImeButton=((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0);
  getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE);
  setMenuVisibility(mShowMenu,true);
  setDisabledFlags(mDisabledFlags,true);
}

Fixed version (ground truth):
public void setNavigationIconHints(int hints,boolean force){
  if (!force && hints == mNavigationIconHints)   return;
  final boolean backAlt=(hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
  if ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0 && !backAlt) {
    mTransitionListener.onBackAltCleared();
  }
  if (DEBUG) {
    android.widget.Toast.makeText(getContext(),"String_Node_Str" + hints,500).show();
  }
  mNavigationIconHints=hints;
  Drawable backIcon=(backAlt) ? getBackIconWithAlt(mCarMode,mVertical) : getBackIcon(mCarMode,mVertical);
  getBackButton().setImageDrawable(backIcon);
  updateRecentsIcon();
  if (mCarMode) {
    getHomeButton().setImageDrawable(mHomeCarModeIcon);
  }
 else {
    getHomeButton().setImageDrawable(mHomeDefaultIcon);
  }
  final boolean showImeButton=((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0);
  getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE);
  setMenuVisibility(mShowMenu,true);
  setDisabledFlags(mDisabledFlags,true);
}
Program: 192671
Project: 192671
Buggy source:
private void getIcons(Context ctx){
  mBackIcon=ctx.getDrawable(R.drawable.ic_sysbar_back);
  mBackLandIcon=mBackIcon;
  mBackAltIcon=ctx.getDrawable(R.drawable.ic_sysbar_back_ime);
  mBackAltLandIcon=mBackAltIcon;
  mHomeDefaultIcon=ctx.getDrawable(R.drawable.ic_sysbar_home);
  mRecentIcon=ctx.getDrawable(R.drawable.ic_sysbar_recent);
  mRecentLandIcon=mRecentIcon;
  getCarModeIcons(ctx);
}

Fixed version (ground truth):
private void getIcons(Context ctx){
  mBackIcon=ctx.getDrawable(R.drawable.ic_sysbar_back);
  mBackLandIcon=mBackIcon;
  mBackAltIcon=ctx.getDrawable(R.drawable.ic_sysbar_back_ime);
  mBackAltLandIcon=mBackAltIcon;
  mHomeDefaultIcon=ctx.getDrawable(R.drawable.ic_sysbar_home);
  mRecentIcon=ctx.getDrawable(R.drawable.ic_sysbar_recent);
  mDockedIcon=ctx.getDrawable(R.drawable.ic_sysbar_docked);
  getCarModeIcons(ctx);
}
Program: 192672
Project: 192672
Buggy source:
public List<InputMethodInfo> getEnabledInputMethodListLocked(){
  return createEnabledInputMethodListLocked(getEnabledInputMethodsAndSubtypeListLocked());
}

Fixed version (ground truth):
public ArrayList<InputMethodInfo> getEnabledInputMethodListLocked(){
  return createEnabledInputMethodListLocked(getEnabledInputMethodsAndSubtypeListLocked());
}
Program: 192673
Project: 192673
Buggy source:
private List<InputMethodInfo> createEnabledInputMethodListLocked(List<Pair<String,ArrayList<String>>> imsList){
  final ArrayList<InputMethodInfo> res=new ArrayList<>();
  for (  Pair<String,ArrayList<String>> ims : imsList) {
    InputMethodInfo info=mMethodMap.get(ims.first);
    if (info != null) {
      res.add(info);
    }
  }
  return res;
}

Fixed version (ground truth):
private ArrayList<InputMethodInfo> createEnabledInputMethodListLocked(List<Pair<String,ArrayList<String>>> imsList){
  final ArrayList<InputMethodInfo> res=new ArrayList<>();
  for (  Pair<String,ArrayList<String>> ims : imsList) {
    InputMethodInfo info=mMethodMap.get(ims.first);
    if (info != null) {
      res.add(info);
    }
  }
  return res;
}
Program: 192674
Project: 192674
Buggy source:
private void resetDefaultImeLocked(Context context){
  if (mCurMethodId != null && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))) {
    return;
  }
  InputMethodInfo defIm=null;
  for (  InputMethodInfo imi : mMethodList) {
    if (defIm == null && mSystemReady) {
      final Locale systemLocale=context.getResources().getConfiguration().locale;
      if (InputMethodUtils.isSystemImeThatHasSubtypeOf(imi,context,true,systemLocale,false,InputMethodUtils.SUBTYPE_MODE_ANY)) {
        defIm=imi;
        Slog.i(TAG,"String_Node_Str" + imi.getId());
      }
    }
  }
  if (defIm == null && mMethodList.size() > 0) {
    defIm=InputMethodUtils.getMostApplicableDefaultIME(mSettings.getEnabledInputMethodListLocked());
    if (defIm != null) {
      Slog.i(TAG,"String_Node_Str" + defIm.getId());
    }
 else {
      Slog.i(TAG,"String_Node_Str");
    }
  }
  if (defIm != null) {
    setSelectedInputMethodAndSubtypeLocked(defIm,NOT_A_SUBTYPE_ID,false);
  }
}

Fixed version (ground truth):
private void resetDefaultImeLocked(Context context){
  if (mCurMethodId != null && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))) {
    return;
  }
  final List<InputMethodInfo> suitableImes=InputMethodUtils.getDefaultEnabledImes(context,mSystemReady,mSettings.getEnabledInputMethodListLocked());
  if (suitableImes.isEmpty()) {
    Slog.i(TAG,"String_Node_Str");
    return;
  }
  final InputMethodInfo defIm=suitableImes.get(0);
  Slog.i(TAG,"String_Node_Str" + defIm.getId());
  setSelectedInputMethodAndSubtypeLocked(defIm,NOT_A_SUBTYPE_ID,false);
}
Program: 192675
Project: 192675
Buggy source:
public List<InputMethodInfo> getEnabledInputMethodListLocked(){
  return createEnabledInputMethodListLocked(getEnabledInputMethodsAndSubtypeListLocked());
}

Fixed version (ground truth):
public ArrayList<InputMethodInfo> getEnabledInputMethodListLocked(){
  return createEnabledInputMethodListLocked(getEnabledInputMethodsAndSubtypeListLocked());
}
Program: 192676
Project: 192676
Buggy source:
private List<InputMethodInfo> createEnabledInputMethodListLocked(List<Pair<String,ArrayList<String>>> imsList){
  final ArrayList<InputMethodInfo> res=new ArrayList<>();
  for (  Pair<String,ArrayList<String>> ims : imsList) {
    InputMethodInfo info=mMethodMap.get(ims.first);
    if (info != null) {
      res.add(info);
    }
  }
  return res;
}

Fixed version (ground truth):
private ArrayList<InputMethodInfo> createEnabledInputMethodListLocked(List<Pair<String,ArrayList<String>>> imsList){
  final ArrayList<InputMethodInfo> res=new ArrayList<>();
  for (  Pair<String,ArrayList<String>> ims : imsList) {
    InputMethodInfo info=mMethodMap.get(ims.first);
    if (info != null) {
      res.add(info);
    }
  }
  return res;
}
Program: 192677
Project: 192677
Buggy source:
private void resetDefaultImeLocked(Context context){
  if (mCurMethodId != null && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))) {
    return;
  }
  InputMethodInfo defIm=null;
  for (  InputMethodInfo imi : mMethodList) {
    if (defIm == null && mSystemReady) {
      final Locale systemLocale=context.getResources().getConfiguration().locale;
      if (InputMethodUtils.isSystemImeThatHasSubtypeOf(imi,context,true,systemLocale,false,InputMethodUtils.SUBTYPE_MODE_ANY)) {
        defIm=imi;
        Slog.i(TAG,"String_Node_Str" + imi.getId());
      }
    }
  }
  if (defIm == null && mMethodList.size() > 0) {
    defIm=InputMethodUtils.getMostApplicableDefaultIME(mSettings.getEnabledInputMethodListLocked());
    if (defIm != null) {
      Slog.i(TAG,"String_Node_Str" + defIm.getId());
    }
 else {
      Slog.i(TAG,"String_Node_Str");
    }
  }
  if (defIm != null) {
    setSelectedInputMethodAndSubtypeLocked(defIm,NOT_A_SUBTYPE_ID,false);
  }
}

Fixed version (ground truth):
private void resetDefaultImeLocked(Context context){
  if (mCurMethodId != null && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))) {
    return;
  }
  final List<InputMethodInfo> suitableImes=InputMethodUtils.getDefaultEnabledImes(context,mSystemReady,mSettings.getEnabledInputMethodListLocked());
  if (suitableImes.isEmpty()) {
    Slog.i(TAG,"String_Node_Str");
    return;
  }
  final InputMethodInfo defIm=suitableImes.get(0);
  Slog.i(TAG,"String_Node_Str" + defIm.getId());
  setSelectedInputMethodAndSubtypeLocked(defIm,NOT_A_SUBTYPE_ID,false);
}
Program: 192678
Project: 192678
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final View view=inflater.inflate(R.layout.fragment_directory,container,false);
  mMessageBar=MessageBar.create(getChildFragmentManager());
  mProgressBar=view.findViewById(R.id.progressbar);
  mEmptyView=view.findViewById(android.R.id.empty);
  mRecView=(RecyclerView)view.findViewById(R.id.dir_list);
  mRecView.setRecyclerListener(new RecyclerListener(){
    @Override public void onViewRecycled(    ViewHolder holder){
      cancelThumbnailTask(holder.itemView);
    }
  }
);
  mRecView.setItemAnimator(new DirectoryItemAnimator(getActivity()));
  mRecView.setFocusable(false);
  if (DEBUG_ENABLE_DND) {
    setupDragAndDropOnDirectoryView(mRecView);
  }
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final View view=inflater.inflate(R.layout.fragment_directory,container,false);
  mMessageBar=MessageBar.create(getChildFragmentManager());
  mProgressBar=view.findViewById(R.id.progressbar);
  mEmptyView=view.findViewById(android.R.id.empty);
  mRecView=(RecyclerView)view.findViewById(R.id.dir_list);
  mRecView.setRecyclerListener(new RecyclerListener(){
    @Override public void onViewRecycled(    ViewHolder holder){
      cancelThumbnailTask(holder.itemView);
    }
  }
);
  mRecView.setItemAnimator(new DirectoryItemAnimator(getActivity()));
  if (DEBUG_ENABLE_DND) {
    setupDragAndDropOnDirectoryView(mRecView);
  }
  return view;
}
Program: 192679
Project: 192679
Buggy source:
/** 
 * Finds the destination position where the focus should land for a given navigation event.
 * @param view The view that received the event.
 * @param keyCode The key code for the event.
 * @param event
 * @return The adapter position of the destination item. Could be RecyclerView.NO_POSITION.
 */
private int findTargetPosition(View view,int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_MOVE_HOME:
    return 0;
case KeyEvent.KEYCODE_MOVE_END:
  return mAdapter.getItemCount() - 1;
case KeyEvent.KEYCODE_PAGE_UP:
case KeyEvent.KEYCODE_PAGE_DOWN:
return findPagedTargetPosition(view,keyCode,event);
}
int searchDir=-1;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
searchDir=View.FOCUS_UP;
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
searchDir=View.FOCUS_DOWN;
break;
}
if (inGridMode()) {
int currentPosition=mView.getChildAdapterPosition(view);
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (currentPosition > 0) {
searchDir=View.FOCUS_BACKWARD;
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (currentPosition < mAdapter.getItemCount() - 1) {
searchDir=View.FOCUS_FORWARD;
}
break;
}
}
if (searchDir != -1) {
View targetView=view.focusSearch(searchDir);
if (targetView != null) {
if (targetView.getParent() == mView) {
return mView.getChildAdapterPosition(targetView);
}
}
}
return RecyclerView.NO_POSITION;
}

Fixed version (ground truth):
/** 
 * Finds the destination position where the focus should land for a given navigation event.
 * @param view The view that received the event.
 * @param keyCode The key code for the event.
 * @param event
 * @return The adapter position of the destination item. Could be RecyclerView.NO_POSITION.
 */
private int findTargetPosition(View view,int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_MOVE_HOME:
    return 0;
case KeyEvent.KEYCODE_MOVE_END:
  return mAdapter.getItemCount() - 1;
case KeyEvent.KEYCODE_PAGE_UP:
case KeyEvent.KEYCODE_PAGE_DOWN:
return findPagedTargetPosition(view,keyCode,event);
}
int searchDir=-1;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
searchDir=View.FOCUS_UP;
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
searchDir=View.FOCUS_DOWN;
break;
}
if (inGridMode()) {
int currentPosition=mView.getChildAdapterPosition(view);
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (currentPosition > 0) {
searchDir=View.FOCUS_BACKWARD;
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (currentPosition < mAdapter.getItemCount() - 1) {
searchDir=View.FOCUS_FORWARD;
}
break;
}
}
if (searchDir != -1) {
mView.setFocusable(false);
View targetView=view.focusSearch(searchDir);
mView.setFocusable(true);
if (targetView != null) {
if (targetView.getParent() == mView) {
return mView.getChildAdapterPosition(targetView);
}
}
}
return RecyclerView.NO_POSITION;
}
Program: 192680
Project: 192680
Buggy source:
void onTimeChanged(long oldTime,long newTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
}

Fixed version (ground truth):
void onTimeChanged(long oldTime,long newTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
  refreshAppIdleRollingWindow(newTime);
}
Program: 192681
Project: 192681
Buggy source:
long getBeginIdleTime(String packageName){
  final IntervalStats yearly=mCurrentStats[UsageStatsManager.INTERVAL_YEARLY];
  UsageStats packageUsage;
  if ((packageUsage=yearly.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getBeginIdleTime();
  }
}

Fixed version (ground truth):
long getBeginIdleTime(String packageName){
  UsageStats packageUsage;
  if ((packageUsage=mAppIdleRollingWindow.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getBeginIdleTime();
  }
}
Program: 192682
Project: 192682
Buggy source:
void dump(IndentingPrintWriter pw,final long screenOnTime){
  for (int interval=0; interval < mCurrentStats.length; interval++) {
    pw.print("String_Node_Str");
    pw.print(intervalToString(interval));
    pw.println("String_Node_Str");
    printIntervalStats(pw,mCurrentStats[interval],screenOnTime,true);
  }
}

Fixed version (ground truth):
void dump(IndentingPrintWriter pw,final long screenOnTime){
  for (int interval=0; interval < mCurrentStats.length; interval++) {
    pw.print("String_Node_Str");
    pw.print(intervalToString(interval));
    pw.println("String_Node_Str");
    printIntervalStats(pw,mCurrentStats[interval],screenOnTime,true);
  }
  pw.println("String_Node_Str");
  printIntervalStats(pw,mAppIdleRollingWindow,screenOnTime,true);
}
Program: 192683
Project: 192683
Buggy source:
void setSystemLastUsedTime(String packageName,long lastUsedTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateSystemLastUsedTime(packageName,lastUsedTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void setSystemLastUsedTime(String packageName,long lastUsedTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateSystemLastUsedTime(packageName,lastUsedTime);
  }
  mAppIdleRollingWindow.updateSystemLastUsedTime(packageName,lastUsedTime);
  notifyStatsChanged();
}
Program: 192684
Project: 192684
Buggy source:
@Override public void combine(IntervalStats stats,boolean mutable,List<UsageEvents.Event> accumulatedResult){
  if (stats.events == null) {
    return;
  }
  final int startIndex=stats.events.closestIndexOnOrAfter(beginTime);
  if (startIndex < 0) {
    return;
  }
  final int size=stats.events.size();
  for (int i=startIndex; i < size; i++) {
    if (stats.events.keyAt(i) >= endTime) {
      return;
    }
    final UsageEvents.Event event=stats.events.valueAt(i);
    names.add(event.mPackage);
    if (event.mClass != null) {
      names.add(event.mClass);
    }
    accumulatedResult.add(event);
  }
}

Fixed version (ground truth):
@Override public void combine(IntervalStats stats,boolean mutable,List<IntervalStats> accumulatedResult){
  IntervalStats accum;
  if (accumulatedResult.isEmpty()) {
    accum=new IntervalStats();
    accum.beginTime=stats.beginTime;
    accumulatedResult.add(accum);
  }
 else {
    accum=accumulatedResult.get(0);
  }
  mergePackageStats(accum,stats);
}
Program: 192685
Project: 192685
Buggy source:
void init(final long currentTimeMillis,final long deviceUsageTime){
  mDatabase.init(currentTimeMillis);
  int nullCount=0;
  for (int i=0; i < mCurrentStats.length; i++) {
    mCurrentStats[i]=mDatabase.getLatestUsageStats(i);
    if (mCurrentStats[i] == null) {
      nullCount++;
    }
  }
  if (nullCount > 0) {
    if (nullCount != mCurrentStats.length) {
      Slog.w(TAG,mLogPrefix + "String_Node_Str");
    }
 else {
    }
    loadActiveStats(currentTimeMillis,false,false);
  }
 else {
    mDailyExpiryDate.setTimeInMillis(mCurrentStats[UsageStatsManager.INTERVAL_DAILY].beginTime);
    mDailyExpiryDate.addDays(1);
    mDailyExpiryDate.truncateToDay();
    Slog.i(TAG,mLogPrefix + "String_Node_Str" + sDateFormat.format(mDailyExpiryDate.getTimeInMillis())+ "String_Node_Str"+ mDailyExpiryDate.getTimeInMillis()+ "String_Node_Str");
  }
  for (  IntervalStats stat : mCurrentStats) {
    final int pkgCount=stat.packageStats.size();
    for (int i=0; i < pkgCount; i++) {
      UsageStats pkgStats=stat.packageStats.valueAt(i);
      if (pkgStats.mLastEvent == UsageEvents.Event.MOVE_TO_FOREGROUND || pkgStats.mLastEvent == UsageEvents.Event.CONTINUE_PREVIOUS_DAY) {
        stat.update(pkgStats.mPackageName,stat.lastTimeSaved,UsageEvents.Event.END_OF_DAY);
        notifyStatsChanged();
      }
    }
    stat.updateConfigurationStats(null,stat.lastTimeSaved);
  }
  if (mDatabase.isNewUpdate()) {
    initializeDefaultsForApps(currentTimeMillis,deviceUsageTime,mDatabase.isFirstUpdate());
  }
}

Fixed version (ground truth):
void init(final long currentTimeMillis,final long deviceUsageTime){
  mDatabase.init(currentTimeMillis);
  int nullCount=0;
  for (int i=0; i < mCurrentStats.length; i++) {
    mCurrentStats[i]=mDatabase.getLatestUsageStats(i);
    if (mCurrentStats[i] == null) {
      nullCount++;
    }
  }
  if (nullCount > 0) {
    if (nullCount != mCurrentStats.length) {
      Slog.w(TAG,mLogPrefix + "String_Node_Str");
    }
 else {
    }
    loadActiveStats(currentTimeMillis,false,false);
  }
 else {
    mDailyExpiryDate.setTimeInMillis(mCurrentStats[UsageStatsManager.INTERVAL_DAILY].beginTime);
    mDailyExpiryDate.addDays(1);
    mDailyExpiryDate.truncateToDay();
    Slog.i(TAG,mLogPrefix + "String_Node_Str" + sDateFormat.format(mDailyExpiryDate.getTimeInMillis())+ "String_Node_Str"+ mDailyExpiryDate.getTimeInMillis()+ "String_Node_Str");
  }
  for (  IntervalStats stat : mCurrentStats) {
    final int pkgCount=stat.packageStats.size();
    for (int i=0; i < pkgCount; i++) {
      UsageStats pkgStats=stat.packageStats.valueAt(i);
      if (pkgStats.mLastEvent == UsageEvents.Event.MOVE_TO_FOREGROUND || pkgStats.mLastEvent == UsageEvents.Event.CONTINUE_PREVIOUS_DAY) {
        stat.update(pkgStats.mPackageName,stat.lastTimeSaved,UsageEvents.Event.END_OF_DAY);
        notifyStatsChanged();
      }
    }
    stat.updateConfigurationStats(null,stat.lastTimeSaved);
  }
  if (mDatabase.isNewUpdate()) {
    initializeDefaultsForApps(currentTimeMillis,deviceUsageTime,mDatabase.isFirstUpdate());
  }
  refreshAppIdleRollingWindow(currentTimeMillis);
}
Program: 192686
Project: 192686
Buggy source:
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  if (event.mEventType != Event.CONFIGURATION_CHANGE) {
    mAppIdleRollingWindow.update(event.mPackage,event.mTimeStamp,event.mEventType);
    mAppIdleRollingWindow.updateBeginIdleTime(event.mPackage,deviceUsageTime);
  }
  notifyStatsChanged();
}
Program: 192687
Project: 192687
Buggy source:
long getSystemLastUsedTime(String packageName){
  final IntervalStats yearly=mCurrentStats[UsageStatsManager.INTERVAL_YEARLY];
  UsageStats packageUsage;
  if ((packageUsage=yearly.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}

Fixed version (ground truth):
long getSystemLastUsedTime(String packageName){
  UsageStats packageUsage;
  if ((packageUsage=mAppIdleRollingWindow.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}
Program: 192688
Project: 192688
Buggy source:
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  mAppIdleRollingWindow.updateBeginIdleTime(packageName,beginIdleTime);
  notifyStatsChanged();
}
Program: 192690
Project: 192690
Buggy source:
/** 
 * This should be the only way to get the time from the system.
 */
private long checkAndGetTimeLocked(){
  final long actualSystemTime=System.currentTimeMillis();
  final long actualRealtime=SystemClock.elapsedRealtime();
  final long expectedSystemTime=(actualRealtime - mRealTimeSnapshot) + mSystemTimeSnapshot;
  boolean resetBeginIdleTime=false;
  if (Math.abs(actualSystemTime - expectedSystemTime) > TIME_CHANGE_THRESHOLD_MILLIS) {
    if (Math.abs(actualSystemTime - expectedSystemTime) > mAppIdleDurationMillis) {
      mScreenOnSystemTimeSnapshot=actualSystemTime;
      mScreenOnTime=0;
      resetBeginIdleTime=true;
    }
    final int userCount=mUserState.size();
    for (int i=0; i < userCount; i++) {
      final UserUsageStatsService service=mUserState.valueAt(i);
      service.onTimeChanged(expectedSystemTime,actualSystemTime,resetBeginIdleTime);
    }
    mRealTimeSnapshot=actualRealtime;
    mSystemTimeSnapshot=actualSystemTime;
  }
  return actualSystemTime;
}

Fixed version (ground truth):
/** 
 * This should be the only way to get the time from the system.
 */
private long checkAndGetTimeLocked(){
  final long actualSystemTime=System.currentTimeMillis();
  final long actualRealtime=SystemClock.elapsedRealtime();
  final long expectedSystemTime=(actualRealtime - mRealTimeSnapshot) + mSystemTimeSnapshot;
  boolean resetBeginIdleTime=false;
  if (Math.abs(actualSystemTime - expectedSystemTime) > TIME_CHANGE_THRESHOLD_MILLIS) {
    if (Math.abs(actualSystemTime - expectedSystemTime) > mAppIdleDurationMillis) {
      mScreenOnSystemTimeSnapshot=actualSystemTime;
      mScreenOnTime=0;
      resetBeginIdleTime=true;
    }
    final int userCount=mUserState.size();
    for (int i=0; i < userCount; i++) {
      final UserUsageStatsService service=mUserState.valueAt(i);
      service.onTimeChanged(expectedSystemTime,actualSystemTime,mScreenOnTime,resetBeginIdleTime);
    }
    mRealTimeSnapshot=actualRealtime;
    mSystemTimeSnapshot=actualSystemTime;
  }
  return actualSystemTime;
}
Program: 192691
Project: 192691
Buggy source:
void onTimeChanged(long oldTime,long newTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
  refreshAppIdleRollingWindow(newTime);
}

Fixed version (ground truth):
void onTimeChanged(long oldTime,long newTime,long deviceUsageTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
  refreshAppIdleRollingWindow(newTime,deviceUsageTime);
}
Program: 192692
Project: 192692
Buggy source:
/** 
 * If any of the apps don't have a last-used entry, add one now.
 * @param currentTimeMillis the current time
 * @param firstUpdate if it is the first update, touch all installed apps, otherwise onlytouch the system apps
 */
private void initializeDefaultsForApps(long currentTimeMillis,long deviceUsageTime,boolean firstUpdate){
  PackageManager pm=mContext.getPackageManager();
  List<PackageInfo> packages=pm.getInstalledPackages(0,mUserId);
  final int packageCount=packages.size();
  for (int i=0; i < packageCount; i++) {
    final PackageInfo pi=packages.get(i);
    String packageName=pi.packageName;
    if (pi.applicationInfo != null && (firstUpdate || pi.applicationInfo.isSystemApp()) && getBeginIdleTime(packageName) == -1) {
      for (      IntervalStats stats : mCurrentStats) {
        stats.update(packageName,currentTimeMillis,Event.SYSTEM_INTERACTION);
        stats.updateBeginIdleTime(packageName,deviceUsageTime);
        mStatsChanged=true;
      }
    }
  }
  persistActiveStats();
}

Fixed version (ground truth):
/** 
 * If any of the apps don't have a last-used entry, add one now.
 * @param currentTimeMillis the current time
 * @param firstUpdate if it is the first update, touch all installed apps, otherwise onlytouch the system apps
 */
private void initializeDefaultsForApps(long currentTimeMillis,long deviceUsageTime,boolean firstUpdate){
  PackageManager pm=mContext.getPackageManager();
  List<PackageInfo> packages=pm.getInstalledPackages(0,mUserId);
  final int packageCount=packages.size();
  for (int i=0; i < packageCount; i++) {
    final PackageInfo pi=packages.get(i);
    String packageName=pi.packageName;
    if (pi.applicationInfo != null && (firstUpdate || pi.applicationInfo.isSystemApp()) && getBeginIdleTime(packageName) == -1) {
      for (      IntervalStats stats : mCurrentStats) {
        stats.update(packageName,currentTimeMillis,Event.SYSTEM_INTERACTION);
        stats.updateBeginIdleTime(packageName,deviceUsageTime);
      }
      mAppIdleRollingWindow.update(packageName,currentTimeMillis,Event.SYSTEM_INTERACTION);
      mAppIdleRollingWindow.updateBeginIdleTime(packageName,deviceUsageTime);
      mStatsChanged=true;
    }
  }
  persistActiveStats();
}
Program: 192693
Project: 192693
Buggy source:
private static void mergePackageStats(IntervalStats dst,IntervalStats src){
  dst.endTime=Math.max(dst.endTime,src.endTime);
  final int srcPackageCount=src.packageStats.size();
  for (int i=0; i < srcPackageCount; i++) {
    final String packageName=src.packageStats.keyAt(i);
    final UsageStats srcStats=src.packageStats.valueAt(i);
    final UsageStats dstStats=dst.packageStats.get(packageName);
    if (dstStats == null) {
      dst.packageStats.put(packageName,new UsageStats(srcStats));
    }
 else {
      dstStats.add(src.packageStats.valueAt(i));
    }
  }
}

Fixed version (ground truth):
private static void mergePackageStats(IntervalStats dst,IntervalStats src,final long deviceUsageTime){
  dst.endTime=Math.max(dst.endTime,src.endTime);
  final int srcPackageCount=src.packageStats.size();
  for (int i=0; i < srcPackageCount; i++) {
    final String packageName=src.packageStats.keyAt(i);
    final UsageStats srcStats=src.packageStats.valueAt(i);
    UsageStats dstStats=dst.packageStats.get(packageName);
    if (dstStats == null) {
      dstStats=new UsageStats(srcStats);
      dst.packageStats.put(packageName,dstStats);
    }
 else {
      dstStats.add(src.packageStats.valueAt(i));
    }
    if (dstStats.mBeginIdleTime > deviceUsageTime) {
      dstStats.mBeginIdleTime=deviceUsageTime;
    }
  }
}
Program: 192694
Project: 192694
Buggy source:
@Override public void combine(IntervalStats stats,boolean mutable,List<IntervalStats> accumulatedResult){
  IntervalStats accum;
  if (accumulatedResult.isEmpty()) {
    accum=new IntervalStats();
    accum.beginTime=stats.beginTime;
    accumulatedResult.add(accum);
  }
 else {
    accum=accumulatedResult.get(0);
  }
  mergePackageStats(accum,stats);
}

Fixed version (ground truth):
@Override public void combine(IntervalStats stats,boolean mutable,List<IntervalStats> accumulatedResult){
  IntervalStats accum;
  if (accumulatedResult.isEmpty()) {
    accum=new IntervalStats();
    accum.beginTime=stats.beginTime;
    accumulatedResult.add(accum);
  }
 else {
    accum=accumulatedResult.get(0);
  }
  mergePackageStats(accum,stats,deviceUsageTime);
}
Program: 192696
Project: 192696
Buggy source:
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  if (event.mEventType != Event.CONFIGURATION_CHANGE) {
    mAppIdleRollingWindow.update(event.mPackage,event.mTimeStamp,event.mEventType);
    mAppIdleRollingWindow.updateBeginIdleTime(event.mPackage,deviceUsageTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp,deviceUsageTime);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  if (event.mEventType != Event.CONFIGURATION_CHANGE) {
    mAppIdleRollingWindow.update(event.mPackage,event.mTimeStamp,event.mEventType);
    mAppIdleRollingWindow.updateBeginIdleTime(event.mPackage,deviceUsageTime);
  }
  notifyStatsChanged();
}
Program: 192697
Project: 192697
Buggy source:
/** 
 * App idle operates on a rolling window of time. When we roll over time, we end up with a period of time where in-memory stats are empty and we don't hit the disk for older stats for performance reasons. Suddenly all apps will become idle. Instead, at times we do a deep query to find all the apps that have run in the past few days and keep the cached data up to date.
 * @param currentTimeMillis
 */
void refreshAppIdleRollingWindow(long currentTimeMillis){
  List<IntervalStats> stats=mDatabase.queryUsageStats(UsageStatsManager.INTERVAL_DAILY,currentTimeMillis - (1000 * 60 * 60* 24* 2),currentTimeMillis,sPackageStatsMerger);
  if (stats == null || stats.isEmpty()) {
    mAppIdleRollingWindow=new IntervalStats();
    mergePackageStats(mAppIdleRollingWindow,mCurrentStats[UsageStatsManager.INTERVAL_YEARLY]);
  }
 else {
    mAppIdleRollingWindow=stats.get(0);
  }
}

Fixed version (ground truth):
/** 
 * App idle operates on a rolling window of time. When we roll over time, we end up with a period of time where in-memory stats are empty and we don't hit the disk for older stats for performance reasons. Suddenly all apps will become idle. Instead, at times we do a deep query to find all the apps that have run in the past few days and keep the cached data up to date.
 * @param currentTimeMillis
 */
void refreshAppIdleRollingWindow(final long currentTimeMillis,final long deviceUsageTime){
  List<IntervalStats> stats=mDatabase.queryUsageStats(UsageStatsManager.INTERVAL_DAILY,currentTimeMillis - (1000 * 60 * 60* 24* 2),currentTimeMillis,new StatCombiner<IntervalStats>(){
    @Override public void combine(    IntervalStats stats,    boolean mutable,    List<IntervalStats> accumulatedResult){
      IntervalStats accum;
      if (accumulatedResult.isEmpty()) {
        accum=new IntervalStats();
        accum.beginTime=stats.beginTime;
        accumulatedResult.add(accum);
      }
 else {
        accum=accumulatedResult.get(0);
      }
      mergePackageStats(accum,stats,deviceUsageTime);
    }
  }
);
  if (stats == null || stats.isEmpty()) {
    mAppIdleRollingWindow=new IntervalStats();
    mergePackageStats(mAppIdleRollingWindow,mCurrentStats[UsageStatsManager.INTERVAL_YEARLY],deviceUsageTime);
  }
 else {
    mAppIdleRollingWindow=stats.get(0);
  }
}
Program: 192699
Project: 192699
Buggy source:
@Override public X509Certificate[] getAcceptedIssuers(){
  return mDelegate.getAcceptedIssuers();
}

Fixed version (ground truth):
@Override public X509Certificate[] getAcceptedIssuers(){
synchronized (mIssuersLock) {
    if (mIssuers == null) {
      Set<TrustAnchor> anchors=mNetworkSecurityConfig.getTrustAnchors();
      X509Certificate[] issuers=new X509Certificate[anchors.size()];
      int i=0;
      for (      TrustAnchor anchor : anchors) {
        issuers[i++]=anchor.certificate;
      }
      mIssuers=issuers;
    }
    return mIssuers.clone();
  }
}
Program: 192700
Project: 192700
Buggy source:
@Override public X509Certificate[] getAcceptedIssuers(){
  return mDelegate.getAcceptedIssuers();
}

Fixed version (ground truth):
@Override public X509Certificate[] getAcceptedIssuers(){
synchronized (mIssuersLock) {
    if (mIssuers == null) {
      Set<TrustAnchor> anchors=mNetworkSecurityConfig.getTrustAnchors();
      X509Certificate[] issuers=new X509Certificate[anchors.size()];
      int i=0;
      for (      TrustAnchor anchor : anchors) {
        issuers[i++]=anchor.certificate;
      }
      mIssuers=issuers;
    }
    return mIssuers.clone();
  }
}
Program: 192701
Project: 192701
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final View view=inflater.inflate(R.layout.fragment_directory,container,false);
  mMessageBar=MessageBar.create(getChildFragmentManager());
  mProgressBar=view.findViewById(R.id.progressbar);
  mEmptyView=view.findViewById(android.R.id.empty);
  mRecView=(RecyclerView)view.findViewById(R.id.dir_list);
  mRecView.setRecyclerListener(new RecyclerListener(){
    @Override public void onViewRecycled(    ViewHolder holder){
      cancelThumbnailTask(holder.itemView);
    }
  }
);
  mRecView.setItemAnimator(new DirectoryItemAnimator(getActivity()));
  mRecView.setFocusable(false);
  if (DEBUG_ENABLE_DND) {
    setupDragAndDropOnDirectoryView(mRecView);
  }
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final View view=inflater.inflate(R.layout.fragment_directory,container,false);
  mMessageBar=MessageBar.create(getChildFragmentManager());
  mProgressBar=view.findViewById(R.id.progressbar);
  mEmptyView=view.findViewById(android.R.id.empty);
  mRecView=(RecyclerView)view.findViewById(R.id.dir_list);
  mRecView.setRecyclerListener(new RecyclerListener(){
    @Override public void onViewRecycled(    ViewHolder holder){
      cancelThumbnailTask(holder.itemView);
    }
  }
);
  mRecView.setItemAnimator(new DirectoryItemAnimator(getActivity()));
  if (DEBUG_ENABLE_DND) {
    setupDragAndDropOnDirectoryView(mRecView);
  }
  return view;
}
Program: 192702
Project: 192702
Buggy source:
/** 
 * Finds the destination position where the focus should land for a given navigation event.
 * @param view The view that received the event.
 * @param keyCode The key code for the event.
 * @param event
 * @return The adapter position of the destination item. Could be RecyclerView.NO_POSITION.
 */
private int findTargetPosition(View view,int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_MOVE_HOME:
    return 0;
case KeyEvent.KEYCODE_MOVE_END:
  return mAdapter.getItemCount() - 1;
case KeyEvent.KEYCODE_PAGE_UP:
case KeyEvent.KEYCODE_PAGE_DOWN:
return findPagedTargetPosition(view,keyCode,event);
}
int searchDir=-1;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
searchDir=View.FOCUS_UP;
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
searchDir=View.FOCUS_DOWN;
break;
}
if (inGridMode()) {
int currentPosition=mView.getChildAdapterPosition(view);
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (currentPosition > 0) {
searchDir=View.FOCUS_BACKWARD;
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (currentPosition < mAdapter.getItemCount() - 1) {
searchDir=View.FOCUS_FORWARD;
}
break;
}
}
if (searchDir != -1) {
View targetView=view.focusSearch(searchDir);
if (targetView != null) {
if (targetView.getParent() == mView) {
return mView.getChildAdapterPosition(targetView);
}
}
}
return RecyclerView.NO_POSITION;
}

Fixed version (ground truth):
/** 
 * Finds the destination position where the focus should land for a given navigation event.
 * @param view The view that received the event.
 * @param keyCode The key code for the event.
 * @param event
 * @return The adapter position of the destination item. Could be RecyclerView.NO_POSITION.
 */
private int findTargetPosition(View view,int keyCode,KeyEvent event){
switch (keyCode) {
case KeyEvent.KEYCODE_MOVE_HOME:
    return 0;
case KeyEvent.KEYCODE_MOVE_END:
  return mAdapter.getItemCount() - 1;
case KeyEvent.KEYCODE_PAGE_UP:
case KeyEvent.KEYCODE_PAGE_DOWN:
return findPagedTargetPosition(view,keyCode,event);
}
int searchDir=-1;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
searchDir=View.FOCUS_UP;
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
searchDir=View.FOCUS_DOWN;
break;
}
if (inGridMode()) {
int currentPosition=mView.getChildAdapterPosition(view);
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (currentPosition > 0) {
searchDir=View.FOCUS_BACKWARD;
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (currentPosition < mAdapter.getItemCount() - 1) {
searchDir=View.FOCUS_FORWARD;
}
break;
}
}
if (searchDir != -1) {
mView.setFocusable(false);
View targetView=view.focusSearch(searchDir);
mView.setFocusable(true);
if (targetView != null) {
if (targetView.getParent() == mView) {
return mView.getChildAdapterPosition(targetView);
}
}
}
return RecyclerView.NO_POSITION;
}
Program: 192703
Project: 192703
Buggy source:
@Override public X509Certificate[] getAcceptedIssuers(){
  return mDelegate.getAcceptedIssuers();
}

Fixed version (ground truth):
@Override public X509Certificate[] getAcceptedIssuers(){
synchronized (mIssuersLock) {
    if (mIssuers == null) {
      Set<TrustAnchor> anchors=mNetworkSecurityConfig.getTrustAnchors();
      X509Certificate[] issuers=new X509Certificate[anchors.size()];
      int i=0;
      for (      TrustAnchor anchor : anchors) {
        issuers[i++]=anchor.certificate;
      }
      mIssuers=issuers;
    }
    return mIssuers.clone();
  }
}
Program: 192704
Project: 192704
Buggy source:
public void preloadRecents(){
  SystemServicesProxy ssp=Recents.getSystemServices();
  ActivityManager.RunningTaskInfo topTask=ssp.getTopMostTask();
  MutableBoolean topTaskHome=new MutableBoolean(true);
  RecentsTaskLoader loader=Recents.getTaskLoader();
  sInstanceLoadPlan=loader.createLoadPlan(mContext);
  if (topTask != null && !ssp.isRecentsTopMost(topTask,topTaskHome)) {
    sInstanceLoadPlan.preloadRawTasks(topTaskHome.value);
    loader.preloadTasks(sInstanceLoadPlan,topTask.id,topTaskHome.value);
    TaskStack stack=sInstanceLoadPlan.getTaskStack();
    if (stack.getTaskCount() > 0) {
      preCacheThumbnailTransitionBitmapAsync(topTask,stack,mDummyStackView);
    }
  }
}

Fixed version (ground truth):
public void preloadRecents(){
  SystemServicesProxy ssp=Recents.getSystemServices();
  ActivityManager.RunningTaskInfo topTask=ssp.getTopMostTask();
  MutableBoolean topTaskHome=new MutableBoolean(true);
  if (topTask != null && !ssp.isRecentsTopMost(topTask,topTaskHome)) {
    RecentsTaskLoader loader=Recents.getTaskLoader();
    sInstanceLoadPlan=loader.createLoadPlan(mContext);
    sInstanceLoadPlan.preloadRawTasks(topTaskHome.value);
    loader.preloadTasks(sInstanceLoadPlan,topTask.id,topTaskHome.value);
    TaskStack stack=sInstanceLoadPlan.getTaskStack();
    if (stack.getTaskCount() > 0) {
      preCacheThumbnailTransitionBitmapAsync(topTask,stack,mDummyStackView);
    }
  }
}
Program: 192708
Project: 192708
Buggy source:
public final CharSequence getTitle(){
  return mTitle;
}

Fixed version (ground truth):
public final CharSequence getTitle(){
  return mTitle != null ? mTitle : "String_Node_Str";
}
Program: 192710
Project: 192710
Buggy source:
public TaskStackHorizontalViewAdapter(List tasks){
  mTaskList=new ArrayList<>(tasks);
}

Fixed version (ground truth):
public TaskStackHorizontalViewAdapter(List tasks){
  mTaskList=new ArrayList<Task>(tasks);
}
Program: 192711
Project: 192711
Buggy source:
public TaskStackHorizontalViewAdapter(List tasks){
  mTaskList=new ArrayList<>(tasks);
}

Fixed version (ground truth):
public TaskStackHorizontalViewAdapter(List tasks){
  mTaskList=new ArrayList<Task>(tasks);
}
Program: 192714
Project: 192714
Buggy source:
@Override public void setVisible(boolean visible){
  mView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}

Fixed version (ground truth):
@Override public void setVisible(boolean visible){
  mView.animate().cancel();
  mView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
Program: 192715
Project: 192715
Buggy source:
public void setVisible(boolean visible){
  if (mTransformedView.getVisibility() == View.GONE) {
    return;
  }
  mTransformedView.animate().cancel();
  mTransformedView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
  mTransformedView.setAlpha(visible ? 1.0f : 0.0f);
  if (visible) {
    mTransformedView.setTranslationX(0);
    mTransformedView.setTranslationY(0);
    mTransformedView.setScaleX(1.0f);
    mTransformedView.setScaleY(1.0f);
  }
}

Fixed version (ground truth):
public void setVisible(boolean visible){
  if (mTransformedView.getVisibility() == View.GONE) {
    return;
  }
  mTransformedView.animate().cancel();
  mTransformedView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
  mTransformedView.setAlpha(visible ? 1.0f : 0.0f);
  if (visible) {
    resetTransformedView();
  }
}
Program: 192716
Project: 192716
Buggy source:
public void prepareFadeIn(){
}

Fixed version (ground truth):
public void prepareFadeIn(){
  resetTransformedView();
}
Program: 192717
Project: 192717
Buggy source:
public void reInflateViews(){
  initDimens();
  if (mIsSummaryWithChildren) {
    removeView(mNotificationHeader);
    mNotificationHeader=null;
    recreateNotificationHeader();
    if (mChildrenContainer != null) {
      mChildrenContainer.reInflateViews();
    }
  }
  if (mGuts != null) {
    View oldGuts=mGuts;
    int index=indexOfChild(oldGuts);
    removeView(oldGuts);
    mGuts=(NotificationGuts)LayoutInflater.from(mContext).inflate(R.layout.notification_guts,this,false);
    mGuts.setVisibility(oldGuts.getVisibility());
    addView(mGuts,index);
  }
}

Fixed version (ground truth):
public void reInflateViews(){
  initDimens();
  if (mIsSummaryWithChildren) {
    removeView(mNotificationHeader);
    mNotificationHeader=null;
    recreateNotificationHeader();
    if (mChildrenContainer != null) {
      mChildrenContainer.reInflateViews();
    }
  }
  if (mGuts != null) {
    View oldGuts=mGuts;
    int index=indexOfChild(oldGuts);
    removeView(oldGuts);
    mGuts=(NotificationGuts)LayoutInflater.from(mContext).inflate(R.layout.notification_guts,this,false);
    mGuts.setVisibility(oldGuts.getVisibility());
    addView(mGuts,index);
  }
  mPrivateLayout.reInflateViews();
  mPublicLayout.reInflateViews();
}
Program: 192718
Project: 192718
Buggy source:
public void reset(boolean resetActualHeight){
  if (mContractedChild != null) {
    mContractedChild.animate().cancel();
  }
  if (mExpandedChild != null) {
    mExpandedChild.animate().cancel();
  }
  if (mHeadsUpChild != null) {
    mHeadsUpChild.animate().cancel();
  }
  removeAllViews();
  mContractedChild=null;
  mExpandedChild=null;
  mHeadsUpChild=null;
  mVisibleType=VISIBLE_TYPE_CONTRACTED;
  if (resetActualHeight) {
    mContentHeight=mSmallHeight;
  }
}

Fixed version (ground truth):
public void reset(boolean resetActualHeight){
  if (mContractedChild != null) {
    mContractedChild.animate().cancel();
    removeView(mContractedChild);
  }
  if (mExpandedChild != null) {
    mExpandedChild.animate().cancel();
    removeView(mExpandedChild);
  }
  if (mHeadsUpChild != null) {
    mHeadsUpChild.animate().cancel();
    removeView(mHeadsUpChild);
  }
  mContractedChild=null;
  mExpandedChild=null;
  mHeadsUpChild=null;
  mVisibleType=VISIBLE_TYPE_CONTRACTED;
  if (resetActualHeight) {
    mContentHeight=mSmallHeight;
  }
}