nus-yam/ex-repair huggingface dataset:
Program: 193348
Project: 193348
Buggy source:
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}

Fixed version (ground truth):
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.uId,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}
Program: 193349
Project: 193349
Buggy source:
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}

Fixed version (ground truth):
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.uId,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}
Program: 193350
Project: 193350
Buggy source:
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,userId)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,uid,userId)) {
      return false;
    }
  }
  return true;
}
Program: 193351
Project: 193351
Buggy source:
@Override public boolean isAppIdle(String packageName,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,userId,-1);
}

Fixed version (ground truth):
@Override public boolean isAppIdle(String packageName,int uidForAppId,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,uidForAppId,userId,-1);
}
Program: 193352
Project: 193352
Buggy source:
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final String packageName=packages.get(p).packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}

Fixed version (ground truth):
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final PackageInfo pi=packages.get(p);
        final String packageName=pi.packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,UserHandle.getAppId(pi.applicationInfo.uid),userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}
Program: 193353
Project: 193353
Buggy source:
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  return isAppIdleFiltered(packageName,userId,timeNow);
}

Fixed version (ground truth):
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  try {
    ApplicationInfo ai=getContext().getPackageManager().getApplicationInfo(packageName,PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
    return isAppIdleFiltered(packageName,ai.uid,userId,timeNow);
  }
 catch (  PackageManager.NameNotFoundException e) {
  }
  return false;
}
Program: 193354
Project: 193354
Buggy source:
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (packageName.equals("String_Node_Str"))   return false;
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}

Fixed version (ground truth):
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int appId,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (appId < Process.FIRST_APPLICATION_UID) {
    return false;
  }
  if (packageName.equals("String_Node_Str")) {
    return false;
  }
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}
Program: 193355
Project: 193355
Buggy source:
/** 
 * Returns true if the app has not been used for a certain amount of time. How much time? Could be hours, could be days, who knows?
 * @param packageName
 * @param userId
 * @return
 */
public abstract boolean isAppIdle(String packageName,int userId);

Fixed version (ground truth):
/** 
 * Returns true if the app has not been used for a certain amount of time. How much time? Could be hours, could be days, who knows?
 * @param packageName
 * @param uidForAppId The uid of the app, which will be used for its app id
 * @param userId
 * @return
 */
public abstract boolean isAppIdle(String packageName,int uidForAppId,int userId);
Program: 193356
Project: 193356
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 (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,long nowElapsed){
  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) {
    if (app.fgInteractionTime == 0) {
      app.fgInteractionTime=nowElapsed;
      isInteraction=false;
    }
 else {
      isInteraction=nowElapsed > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
    }
  }
 else {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
  if (isInteraction && (!app.reportedInteraction || (nowElapsed - app.interactionEventTime) > USAGE_STATS_INTERACTION_INTERVAL)) {
    app.interactionEventTime=nowElapsed;
    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;
  if (!isInteraction) {
    app.interactionEventTime=0;
  }
}
Program: 193360
Project: 193360
Buggy source:
boolean isAppIdle(String packageName,int userId){
  return !mAppIdleParoleOn && mUsageStats.isAppIdle(packageName,userId);
}

Fixed version (ground truth):
boolean isAppIdle(String packageName,int uidForAppId,int userId){
  return !mAppIdleParoleOn && mUsageStats.isAppIdle(packageName,uidForAppId,userId);
}
Program: 193362
Project: 193362
Buggy source:
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}

Fixed version (ground truth):
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.uId,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}
Program: 193363
Project: 193363
Buggy source:
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}

Fixed version (ground truth):
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.uId,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}
Program: 193364
Project: 193364
Buggy source:
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,userId)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,uid,userId)) {
      return false;
    }
  }
  return true;
}
Program: 193365
Project: 193365
Buggy source:
@Override public boolean isAppIdle(String packageName,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,userId,-1);
}

Fixed version (ground truth):
@Override public boolean isAppIdle(String packageName,int uidForAppId,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,uidForAppId,userId,-1);
}
Program: 193366
Project: 193366
Buggy source:
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final String packageName=packages.get(p).packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}

Fixed version (ground truth):
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final PackageInfo pi=packages.get(p);
        final String packageName=pi.packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,UserHandle.getAppId(pi.applicationInfo.uid),userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}
Program: 193367
Project: 193367
Buggy source:
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  return isAppIdleFiltered(packageName,userId,timeNow);
}

Fixed version (ground truth):
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  try {
    ApplicationInfo ai=getContext().getPackageManager().getApplicationInfo(packageName,PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
    return isAppIdleFiltered(packageName,ai.uid,userId,timeNow);
  }
 catch (  PackageManager.NameNotFoundException e) {
  }
  return false;
}
Program: 193368
Project: 193368
Buggy source:
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (packageName.equals("String_Node_Str"))   return false;
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}

Fixed version (ground truth):
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int appId,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (appId < Process.FIRST_APPLICATION_UID) {
    return false;
  }
  if (packageName.equals("String_Node_Str")) {
    return false;
  }
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}
Program: 193369
Project: 193369
Buggy source:
/** 
 * Returns true if the app has not been used for a certain amount of time. How much time? Could be hours, could be days, who knows?
 * @param packageName
 * @param userId
 * @return
 */
public abstract boolean isAppIdle(String packageName,int userId);

Fixed version (ground truth):
/** 
 * Returns true if the app has not been used for a certain amount of time. How much time? Could be hours, could be days, who knows?
 * @param packageName
 * @param uidForAppId The uid of the app, which will be used for its app id
 * @param userId
 * @return
 */
public abstract boolean isAppIdle(String packageName,int uidForAppId,int userId);
Program: 193370
Project: 193370
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 (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,long nowElapsed){
  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) {
    if (app.fgInteractionTime == 0) {
      app.fgInteractionTime=nowElapsed;
      isInteraction=false;
    }
 else {
      isInteraction=nowElapsed > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
    }
  }
 else {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
  if (isInteraction && (!app.reportedInteraction || (nowElapsed - app.interactionEventTime) > USAGE_STATS_INTERACTION_INTERVAL)) {
    app.interactionEventTime=nowElapsed;
    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;
  if (!isInteraction) {
    app.interactionEventTime=0;
  }
}
Program: 193374
Project: 193374
Buggy source:
boolean isAppIdle(String packageName,int userId){
  return !mAppIdleParoleOn && mUsageStats.isAppIdle(packageName,userId);
}

Fixed version (ground truth):
boolean isAppIdle(String packageName,int uidForAppId,int userId){
  return !mAppIdleParoleOn && mUsageStats.isAppIdle(packageName,uidForAppId,userId);
}
Program: 193376
Project: 193376
Buggy source:
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}

Fixed version (ground truth):
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.uId,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}
Program: 193377
Project: 193377
Buggy source:
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}

Fixed version (ground truth):
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.uId,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}
Program: 193378
Project: 193378
Buggy source:
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,userId)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,uid,userId)) {
      return false;
    }
  }
  return true;
}
Program: 193379
Project: 193379
Buggy source:
@Override public boolean isAppIdle(String packageName,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,userId,-1);
}

Fixed version (ground truth):
@Override public boolean isAppIdle(String packageName,int uidForAppId,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,uidForAppId,userId,-1);
}
Program: 193380
Project: 193380
Buggy source:
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final String packageName=packages.get(p).packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}

Fixed version (ground truth):
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final PackageInfo pi=packages.get(p);
        final String packageName=pi.packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,UserHandle.getAppId(pi.applicationInfo.uid),userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}
Program: 193381
Project: 193381
Buggy source:
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  return isAppIdleFiltered(packageName,userId,timeNow);
}

Fixed version (ground truth):
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  try {
    ApplicationInfo ai=getContext().getPackageManager().getApplicationInfo(packageName,PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
    return isAppIdleFiltered(packageName,ai.uid,userId,timeNow);
  }
 catch (  PackageManager.NameNotFoundException e) {
  }
  return false;
}
Program: 193382
Project: 193382
Buggy source:
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (packageName.equals("String_Node_Str"))   return false;
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}

Fixed version (ground truth):
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int appId,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (appId < Process.FIRST_APPLICATION_UID) {
    return false;
  }
  if (packageName.equals("String_Node_Str")) {
    return false;
  }
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}
Program: 193383
Project: 193383
Buggy source:
protected final void notifyExpandingFinished(){
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}

Fixed version (ground truth):
protected final void notifyExpandingFinished(){
  endClosing();
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}
Program: 193384
Project: 193384
Buggy source:
protected void onExpandingFinished(){
  endClosing();
  mBar.onExpandingFinished();
}

Fixed version (ground truth):
protected void onExpandingFinished(){
  mBar.onExpandingFinished();
}
Program: 193385
Project: 193385
Buggy source:
protected final void notifyExpandingFinished(){
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}

Fixed version (ground truth):
protected final void notifyExpandingFinished(){
  endClosing();
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}
Program: 193386
Project: 193386
Buggy source:
protected void onExpandingFinished(){
  endClosing();
  mBar.onExpandingFinished();
}

Fixed version (ground truth):
protected void onExpandingFinished(){
  mBar.onExpandingFinished();
}
Program: 193387
Project: 193387
Buggy source:
protected final void notifyExpandingFinished(){
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}

Fixed version (ground truth):
protected final void notifyExpandingFinished(){
  endClosing();
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}
Program: 193388
Project: 193388
Buggy source:
protected void onExpandingFinished(){
  endClosing();
  mBar.onExpandingFinished();
}

Fixed version (ground truth):
protected void onExpandingFinished(){
  mBar.onExpandingFinished();
}
Program: 193389
Project: 193389
Buggy source:
protected final void notifyExpandingFinished(){
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}

Fixed version (ground truth):
protected final void notifyExpandingFinished(){
  endClosing();
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}
Program: 193390
Project: 193390
Buggy source:
protected void onExpandingFinished(){
  endClosing();
  mBar.onExpandingFinished();
}

Fixed version (ground truth):
protected void onExpandingFinished(){
  mBar.onExpandingFinished();
}
Program: 193391
Project: 193391
Buggy source:
protected final void notifyExpandingFinished(){
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}

Fixed version (ground truth):
protected final void notifyExpandingFinished(){
  endClosing();
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}
Program: 193392
Project: 193392
Buggy source:
protected void onExpandingFinished(){
  endClosing();
  mBar.onExpandingFinished();
}

Fixed version (ground truth):
protected void onExpandingFinished(){
  mBar.onExpandingFinished();
}
Program: 193393
Project: 193393
Buggy source:
/** 
 * Returns true if the app has not been used for a certain amount of time. How much time? Could be hours, could be days, who knows?
 * @param packageName
 * @param userId
 * @return
 */
public abstract boolean isAppIdle(String packageName,int userId);

Fixed version (ground truth):
/** 
 * Returns true if the app has not been used for a certain amount of time. How much time? Could be hours, could be days, who knows?
 * @param packageName
 * @param uidForAppId The uid of the app, which will be used for its app id
 * @param userId
 * @return
 */
public abstract boolean isAppIdle(String packageName,int uidForAppId,int userId);
Program: 193394
Project: 193394
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 (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,long nowElapsed){
  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) {
    if (app.fgInteractionTime == 0) {
      app.fgInteractionTime=nowElapsed;
      isInteraction=false;
    }
 else {
      isInteraction=nowElapsed > app.fgInteractionTime + SERVICE_USAGE_INTERACTION_TIME;
    }
  }
 else {
    isInteraction=app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
    app.fgInteractionTime=0;
  }
  if (isInteraction && (!app.reportedInteraction || (nowElapsed - app.interactionEventTime) > USAGE_STATS_INTERACTION_INTERVAL)) {
    app.interactionEventTime=nowElapsed;
    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;
  if (!isInteraction) {
    app.interactionEventTime=0;
  }
}
Program: 193398
Project: 193398
Buggy source:
boolean isAppIdle(String packageName,int userId){
  return !mAppIdleParoleOn && mUsageStats.isAppIdle(packageName,userId);
}

Fixed version (ground truth):
boolean isAppIdle(String packageName,int uidForAppId,int userId){
  return !mAppIdleParoleOn && mUsageStats.isAppIdle(packageName,uidForAppId,userId);
}
Program: 193400
Project: 193400
Buggy source:
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}

Fixed version (ground truth):
void setAppIdleParoleOn(boolean isAppIdleParoleOn){
  boolean changed=false;
synchronized (mTrackedTasks) {
    if (mAppIdleParoleOn == isAppIdleParoleOn) {
      return;
    }
    mAppIdleParoleOn=isAppIdleParoleOn;
    for (    JobStatus task : mTrackedTasks) {
      String packageName=task.job.getService().getPackageName();
      final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,task.uId,task.getUserId());
      if (DEBUG) {
        Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
      }
      if (task.appNotIdleConstraintSatisfied.get() == appIdle) {
        task.appNotIdleConstraintSatisfied.set(!appIdle);
        changed=true;
      }
    }
  }
  if (changed) {
    mStateChangedListener.onControllerStateChanged();
  }
}
Program: 193401
Project: 193401
Buggy source:
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}

Fixed version (ground truth):
@Override public void maybeStartTrackingJob(JobStatus jobStatus){
synchronized (mTrackedTasks) {
    mTrackedTasks.add(jobStatus);
    String packageName=jobStatus.job.getService().getPackageName();
    final boolean appIdle=!mAppIdleParoleOn && mUsageStatsInternal.isAppIdle(packageName,jobStatus.uId,jobStatus.getUserId());
    if (DEBUG) {
      Slog.d(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ appIdle);
    }
    jobStatus.appNotIdleConstraintSatisfied.set(!appIdle);
  }
}
Program: 193402
Project: 193402
Buggy source:
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,userId)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isUidIdle(int uid){
  final String[] packages=mContext.getPackageManager().getPackagesForUid(uid);
  final int userId=UserHandle.getUserId(uid);
  for (  String packageName : packages) {
    if (!mUsageStats.isAppIdle(packageName,uid,userId)) {
      return false;
    }
  }
  return true;
}
Program: 193403
Project: 193403
Buggy source:
@Override public boolean isAppIdle(String packageName,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,userId,-1);
}

Fixed version (ground truth):
@Override public boolean isAppIdle(String packageName,int uidForAppId,int userId){
  return UsageStatsService.this.isAppIdleFiltered(packageName,uidForAppId,userId,-1);
}