nus-yam/ex-repair huggingface dataset:
Program: 192318
Project: 192318
Buggy source:
private void handleDocumentsProvider(ProviderInfo info){
  if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + info.authority);
    mTaskStoppedAuthorities.add(info.authority);
    return;
  }
  boolean cacheHit=false;
  if (mFilterPackage != null && !mFilterPackage.equals(info.packageName)) {
synchronized (mLock) {
      if (mTaskRoots.putAll(info.authority,mRoots.get(info.authority))) {
        if (DEBUG)         Log.d(TAG,"String_Node_Str" + info.authority);
        cacheHit=true;
      }
    }
  }
  if (!cacheHit) {
    mTaskRoots.putAll(info.authority,loadRootsForAuthority(mContext.getContentResolver(),info.authority));
  }
}

Fixed version (ground truth):
private void handleDocumentsProvider(ProviderInfo info){
  if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + info.authority);
    mTaskStoppedAuthorities.add(info.authority);
    return;
  }
  final boolean forceRefresh=Objects.equals(mForceRefreshPackage,info.packageName);
  mTaskRoots.putAll(info.authority,loadRootsForAuthority(mContext.getContentResolver(),info.authority,forceRefresh));
}
Program: 192319
Project: 192319
Buggy source:
/** 
 * Load roots from a stopped authority. Normal   {@link UpdateTask} passesignore stopped applications.
 */
private void loadStoppedAuthority(String authority){
  final ContentResolver resolver=mContext.getContentResolver();
synchronized (mLock) {
    if (!mStoppedAuthorities.contains(authority)) {
      return;
    }
    if (DEBUG) {
      Log.d(TAG,"String_Node_Str" + authority);
    }
    mRoots.putAll(authority,loadRootsForAuthority(resolver,authority));
    mStoppedAuthorities.remove(authority);
  }
}

Fixed version (ground truth):
/** 
 * Load roots from a stopped authority. Normal   {@link UpdateTask} passesignore stopped applications.
 */
private void loadStoppedAuthority(String authority){
  final ContentResolver resolver=mContext.getContentResolver();
synchronized (mLock) {
    if (!mStoppedAuthorities.contains(authority)) {
      return;
    }
    if (DEBUG) {
      Log.d(TAG,"String_Node_Str" + authority);
    }
    mRoots.putAll(authority,loadRootsForAuthority(resolver,authority,true));
    mStoppedAuthorities.remove(authority);
  }
}
Program: 192320
Project: 192320
Buggy source:
private void onDiskScannedLocked(DiskInfo disk){
  int volumeCount=0;
  for (int i=0; i < mVolumes.size(); i++) {
    final VolumeInfo vol=mVolumes.valueAt(i);
    if (Objects.equals(disk.id,vol.getDiskId())) {
      volumeCount++;
    }
  }
  final Intent intent=new Intent(DiskInfo.ACTION_DISK_SCANNED);
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  intent.putExtra(DiskInfo.EXTRA_DISK_ID,disk.id);
  intent.putExtra(DiskInfo.EXTRA_VOLUME_COUNT,volumeCount);
  mHandler.obtainMessage(H_INTERNAL_BROADCAST,intent).sendToTarget();
  final CountDownLatch latch=mDiskScanLatches.remove(disk.id);
  if (latch != null) {
    latch.countDown();
  }
  disk.volumeCount=volumeCount;
  mCallbacks.notifyDiskScanned(disk,volumeCount);
}

Fixed version (ground truth):
private void onDiskScannedLocked(DiskInfo disk){
  int volumeCount=0;
  for (int i=0; i < mVolumes.size(); i++) {
    final VolumeInfo vol=mVolumes.valueAt(i);
    if (Objects.equals(disk.id,vol.getDiskId())) {
      volumeCount++;
    }
  }
  final Intent intent=new Intent(DiskInfo.ACTION_DISK_SCANNED);
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
  intent.putExtra(DiskInfo.EXTRA_DISK_ID,disk.id);
  intent.putExtra(DiskInfo.EXTRA_VOLUME_COUNT,volumeCount);
  mHandler.obtainMessage(H_INTERNAL_BROADCAST,intent).sendToTarget();
  final CountDownLatch latch=mDiskScanLatches.remove(disk.id);
  if (latch != null) {
    latch.countDown();
  }
  disk.volumeCount=volumeCount;
  mCallbacks.notifyDiskScanned(disk,volumeCount);
}
Program: 192322
Project: 192322
Buggy source:
private void invalidateCacheLocked(int userId,String providerPackageName,Uri uri){
  ArrayMap<String,ArrayMap<Pair<String,Uri>,Bundle>> userCache=mCache.get(userId);
  if (userCache == null)   return;
  ArrayMap<Pair<String,Uri>,Bundle> packageCache=userCache.get(providerPackageName);
  if (packageCache == null)   return;
  if (uri != null) {
    for (int i=0; i < packageCache.size(); ) {
      final Uri key=packageCache.keyAt(i).second;
      if (Objects.equals(key,uri)) {
        packageCache.removeAt(i);
      }
 else {
        i++;
      }
    }
  }
 else {
    packageCache.clear();
  }
}

Fixed version (ground truth):
private void invalidateCacheLocked(int userId,String providerPackageName,Uri uri){
  ArrayMap<String,ArrayMap<Pair<String,Uri>,Bundle>> userCache=mCache.get(userId);
  if (userCache == null)   return;
  ArrayMap<Pair<String,Uri>,Bundle> packageCache=userCache.get(providerPackageName);
  if (packageCache == null)   return;
  if (uri != null) {
    for (int i=0; i < packageCache.size(); ) {
      final Pair<String,Uri> key=packageCache.keyAt(i);
      if (key.second != null && key.second.toString().startsWith(uri.toString())) {
        Slog.d(TAG,"String_Node_Str" + key);
        packageCache.removeAt(i);
      }
 else {
        i++;
      }
    }
  }
 else {
    Slog.d(TAG,"String_Node_Str" + providerPackageName);
    packageCache.clear();
  }
}
Program: 192323
Project: 192323
Buggy source:
void becomeActiveLocked(String activeReason,int activeUid){
  if (DEBUG)   Slog.i(TAG,"String_Node_Str" + activeReason);
  if (mState != STATE_ACTIVE || mLightState != STATE_ACTIVE) {
    EventLogTags.writeDeviceIdle(STATE_ACTIVE,activeReason);
    EventLogTags.writeDeviceIdleLight(LIGHT_STATE_ACTIVE,activeReason);
    scheduleReportActiveLocked(activeReason,activeUid);
    mState=STATE_ACTIVE;
    mLightState=LIGHT_STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
    mCurIdleBudget=0;
    mMaintenanceStartTime=0;
    if (mMaintenanceMinCheckScheduled) {
      mAlarmManager.cancel(mMaintenanceMinCheckListener);
      mMaintenanceMinCheckScheduled=false;
    }
    resetIdleManagementLocked();
    resetLightIdleManagementLocked();
    addEvent(EVENT_NORMAL);
  }
}

Fixed version (ground truth):
void becomeActiveLocked(String activeReason,int activeUid){
  if (DEBUG)   Slog.i(TAG,"String_Node_Str" + activeReason);
  if (mState != STATE_ACTIVE || mLightState != STATE_ACTIVE) {
    EventLogTags.writeDeviceIdle(STATE_ACTIVE,activeReason);
    EventLogTags.writeDeviceIdleLight(LIGHT_STATE_ACTIVE,activeReason);
    scheduleReportActiveLocked(activeReason,activeUid);
    mState=STATE_ACTIVE;
    mLightState=LIGHT_STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
    mCurIdleBudget=0;
    mMaintenanceStartTime=0;
    resetIdleManagementLocked();
    resetLightIdleManagementLocked();
    addEvent(EVENT_NORMAL);
  }
}
Program: 192327
Project: 192327
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  decActiveIdleOps();
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED.equals(intent.getAction())) {
    mHandler.sendEmptyMessageDelayed(MSG_FINISH_IDLE_OP,mConstants.MIN_DEEP_MAINTENANCE_TIME);
  }
 else {
    mHandler.sendEmptyMessageDelayed(MSG_FINISH_IDLE_OP,mConstants.MIN_LIGHT_MAINTENANCE_TIME);
  }
}
Program: 192328
Project: 192328
Buggy source:
void exitMaintenanceEarlyIfNeededLocked(){
  if (mState == STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_IDLE_MAINTENANCE) {
    if (mActiveIdleOpCount <= 0 && mDownloadServiceActive == null && !mJobsActive && !mAlarmsActive) {
      final long now=SystemClock.elapsedRealtime();
      if (DEBUG) {
        StringBuilder sb=new StringBuilder();
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(mMaintenanceStartTime,sb);
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(now,sb);
        Slog.d(TAG,sb.toString());
      }
      if (mState == STATE_IDLE_MAINTENANCE) {
        if (now >= (mMaintenanceStartTime + mConstants.MIN_DEEP_MAINTENANCE_TIME)) {
          stepIdleStateLocked("String_Node_Str");
        }
      }
 else {
        if (now >= (mMaintenanceStartTime + mConstants.MIN_LIGHT_MAINTENANCE_TIME)) {
          stepLightIdleStateLocked("String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
void exitMaintenanceEarlyIfNeededLocked(){
  if (mState == STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_PRE_IDLE) {
    if (isOpsInactiveLocked()) {
      final long now=SystemClock.elapsedRealtime();
      if (DEBUG) {
        StringBuilder sb=new StringBuilder();
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(mMaintenanceStartTime,sb);
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(now,sb);
        Slog.d(TAG,sb.toString());
      }
      if (mState == STATE_IDLE_MAINTENANCE) {
        stepIdleStateLocked("String_Node_Str");
      }
 else       if (mLightState == LIGHT_STATE_PRE_IDLE) {
        stepLightIdleStateLocked("String_Node_Str");
      }
 else {
        stepLightIdleStateLocked("String_Node_Str");
      }
    }
  }
}
Program: 192329
Project: 192329
Buggy source:
void decActiveIdleOps(){
synchronized (this) {
    mActiveIdleOpCount--;
    if (mActiveIdleOpCount <= 0) {
      exitMaintenanceEarlyIfNeededLocked();
    }
  }
}

Fixed version (ground truth):
void decActiveIdleOps(){
synchronized (this) {
    mActiveIdleOpCount--;
    if (mActiveIdleOpCount <= 0) {
      exitMaintenanceEarlyIfNeededLocked();
      mActiveIdleWakeLock.release();
    }
  }
}
Program: 192330
Project: 192330
Buggy source:
private static String lightStateToString(int state){
switch (state) {
case LIGHT_STATE_ACTIVE:
    return "String_Node_Str";
case LIGHT_STATE_INACTIVE:
  return "String_Node_Str";
case LIGHT_STATE_IDLE:
return "String_Node_Str";
case LIGHT_STATE_IDLE_MAINTENANCE:
return "String_Node_Str";
case LIGHT_STATE_OVERRIDE:
return "String_Node_Str";
default :
return Integer.toString(state);
}
}

Fixed version (ground truth):
private static String lightStateToString(int state){
switch (state) {
case LIGHT_STATE_ACTIVE:
    return "String_Node_Str";
case LIGHT_STATE_INACTIVE:
  return "String_Node_Str";
case LIGHT_STATE_PRE_IDLE:
return "String_Node_Str";
case LIGHT_STATE_IDLE:
return "String_Node_Str";
case LIGHT_STATE_IDLE_MAINTENANCE:
return "String_Node_Str";
case LIGHT_STATE_OVERRIDE:
return "String_Node_Str";
default :
return Integer.toString(state);
}
}
Program: 192334
Project: 192334
Buggy source:
@Override public void onAlarm(){
synchronized (DeviceIdleController.this) {
    exitMaintenanceEarlyIfNeededLocked();
  }
}

Fixed version (ground truth):
@Override public void onAlarm(){
synchronized (DeviceIdleController.this) {
    stepIdleStateLocked("String_Node_Str");
  }
}
Program: 192335
Project: 192335
Buggy source:
/** 
 * Checks the two objects for equality by delegating to their respective  {@link Object#equals(Object)} methods.
 * @param o the {@link Pair} to which this one is to be checked for equality
 * @return true if the underlying objects of the Pair are both consideredequal
 */
@Override public boolean equals(Object o){
  if (!(o instanceof Pair)) {
    return false;
  }
  Pair<?,?> p=(Pair<?,?>)o;
  return Objects.equal(p.first,first) && Objects.equal(p.second,second);
}

Fixed version (ground truth):
/** 
 * Checks the two objects for equality by delegating to their respective  {@link Object#equals(Object)} methods.
 * @param o the {@link Pair} to which this one is to be checked for equality
 * @return true if the underlying objects of the Pair are both consideredequal
 */
@Override public boolean equals(Object o){
  if (!(o instanceof Pair)) {
    return false;
  }
  Pair<?,?> p=(Pair<?,?>)o;
  return Objects.equals(p.first,first) && Objects.equals(p.second,second);
}
Program: 192336
Project: 192336
Buggy source:
@Override protected Void doInBackground(Void... params){
  final long start=SystemClock.elapsedRealtime();
  if (mFilterPackage != null) {
    if (!waitForFirstLoad()) {
      return null;
    }
  }
  mTaskRoots.put(mRecentsRoot.authority,mRecentsRoot);
  final ContentResolver resolver=mContext.getContentResolver();
  final PackageManager pm=mContext.getPackageManager();
  final Intent intent=new Intent(DocumentsContract.PROVIDER_INTERFACE);
  final List<ResolveInfo> providers=pm.queryIntentContentProviders(intent,0);
  for (  ResolveInfo info : providers) {
    handleDocumentsProvider(info.providerInfo);
  }
  final long delta=SystemClock.elapsedRealtime() - start;
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + mTaskRoots.size() + "String_Node_Str"+ delta+ "String_Node_Str");
synchronized (mLock) {
    mFirstLoadDone=true;
    if (mBootCompletedResult != null) {
      mBootCompletedResult.finish();
      mBootCompletedResult=null;
    }
    mRoots=mTaskRoots;
    mStoppedAuthorities=mTaskStoppedAuthorities;
  }
  mFirstLoad.countDown();
  resolver.notifyChange(sNotificationUri,null,false);
  return null;
}

Fixed version (ground truth):
@Override protected Void doInBackground(Void... params){
  final long start=SystemClock.elapsedRealtime();
  if (mForceRefreshPackage != null) {
    if (!waitForFirstLoad()) {
      return null;
    }
  }
  mTaskRoots.put(mRecentsRoot.authority,mRecentsRoot);
  final ContentResolver resolver=mContext.getContentResolver();
  final PackageManager pm=mContext.getPackageManager();
  final Intent intent=new Intent(DocumentsContract.PROVIDER_INTERFACE);
  final List<ResolveInfo> providers=pm.queryIntentContentProviders(intent,0);
  for (  ResolveInfo info : providers) {
    handleDocumentsProvider(info.providerInfo);
  }
  final long delta=SystemClock.elapsedRealtime() - start;
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + mTaskRoots.size() + "String_Node_Str"+ delta+ "String_Node_Str");
synchronized (mLock) {
    mFirstLoadDone=true;
    if (mBootCompletedResult != null) {
      mBootCompletedResult.finish();
      mBootCompletedResult=null;
    }
    mRoots=mTaskRoots;
    mStoppedAuthorities=mTaskStoppedAuthorities;
  }
  mFirstLoad.countDown();
  resolver.notifyChange(sNotificationUri,null,false);
  return null;
}
Program: 192337
Project: 192337
Buggy source:
/** 
 * Bring up requested provider and query for all active roots.
 */
private Collection<RootInfo> loadRootsForAuthority(ContentResolver resolver,String authority){
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + authority);
synchronized (mObservedAuthorities) {
    if (mObservedAuthorities.add(authority)) {
      final Uri rootsUri=DocumentsContract.buildRootsUri(authority);
      mContext.getContentResolver().registerContentObserver(rootsUri,true,mObserver);
    }
  }
  final Uri rootsUri=DocumentsContract.buildRootsUri(authority);
  if (ENABLE_SYSTEM_CACHE) {
    final Bundle systemCache=resolver.getCache(rootsUri);
    if (systemCache != null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str" + authority);
      return systemCache.getParcelableArrayList(TAG);
    }
  }
  final ArrayList<RootInfo> roots=new ArrayList<>();
  ContentProviderClient client=null;
  Cursor cursor=null;
  try {
    client=DocumentsApplication.acquireUnstableProviderOrThrow(resolver,authority);
    cursor=client.query(rootsUri,null,null,null,null);
    while (cursor.moveToNext()) {
      final RootInfo root=RootInfo.fromRootsCursor(authority,cursor);
      roots.add(root);
    }
  }
 catch (  Exception e) {
    Log.w(TAG,"String_Node_Str" + authority + "String_Node_Str"+ e);
  }
 finally {
    IoUtils.closeQuietly(cursor);
    ContentProviderClient.releaseQuietly(client);
  }
  if (ENABLE_SYSTEM_CACHE) {
    final Bundle systemCache=new Bundle();
    systemCache.putParcelableArrayList(TAG,roots);
    resolver.putCache(rootsUri,systemCache);
  }
  return roots;
}

Fixed version (ground truth):
/** 
 * Bring up requested provider and query for all active roots.
 */
private Collection<RootInfo> loadRootsForAuthority(ContentResolver resolver,String authority,boolean forceRefresh){
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + authority);
synchronized (mObservedAuthorities) {
    if (mObservedAuthorities.add(authority)) {
      final Uri rootsUri=DocumentsContract.buildRootsUri(authority);
      mContext.getContentResolver().registerContentObserver(rootsUri,true,mObserver);
    }
  }
  final Uri rootsUri=DocumentsContract.buildRootsUri(authority);
  if (!forceRefresh) {
    final Bundle systemCache=resolver.getCache(rootsUri);
    if (systemCache != null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str" + authority);
      return systemCache.getParcelableArrayList(TAG);
    }
  }
  final ArrayList<RootInfo> roots=new ArrayList<>();
  ContentProviderClient client=null;
  Cursor cursor=null;
  try {
    client=DocumentsApplication.acquireUnstableProviderOrThrow(resolver,authority);
    cursor=client.query(rootsUri,null,null,null,null);
    while (cursor.moveToNext()) {
      final RootInfo root=RootInfo.fromRootsCursor(authority,cursor);
      roots.add(root);
    }
  }
 catch (  Exception e) {
    Log.w(TAG,"String_Node_Str" + authority + "String_Node_Str"+ e);
  }
 finally {
    IoUtils.closeQuietly(cursor);
    ContentProviderClient.releaseQuietly(client);
  }
  final Bundle systemCache=new Bundle();
  systemCache.putParcelableArrayList(TAG,roots);
  resolver.putCache(rootsUri,systemCache);
  return roots;
}
Program: 192338
Project: 192338
Buggy source:
/** 
 * Only update roots belonging to given package name. Other roots will be copied from cached   {@link #mRoots} values.
 */
public UpdateTask(String filterPackage){
  mFilterPackage=filterPackage;
}

Fixed version (ground truth):
/** 
 * Force update roots belonging to given package name. Other roots will be copied from cached   {@link #mRoots} values.
 */
public UpdateTask(String forceRefreshPackage){
  mForceRefreshPackage=forceRefreshPackage;
}
Program: 192339
Project: 192339
Buggy source:
/** 
 * Return the requested   {@link RootInfo}, but only loading the roots for the requested authority. This is useful when we want to load fast without waiting for all the other roots to come back.
 */
public RootInfo getRootOneshot(String authority,String rootId){
synchronized (mLock) {
    RootInfo root=getRootLocked(authority,rootId);
    if (root == null) {
      mRoots.putAll(authority,loadRootsForAuthority(mContext.getContentResolver(),authority));
      root=getRootLocked(authority,rootId);
    }
    return root;
  }
}

Fixed version (ground truth):
/** 
 * Return the requested   {@link RootInfo}, but only loading the roots for the requested authority. This is useful when we want to load fast without waiting for all the other roots to come back.
 */
public RootInfo getRootOneshot(String authority,String rootId){
synchronized (mLock) {
    RootInfo root=getRootLocked(authority,rootId);
    if (root == null) {
      mRoots.putAll(authority,loadRootsForAuthority(mContext.getContentResolver(),authority,false));
      root=getRootLocked(authority,rootId);
    }
    return root;
  }
}
Program: 192340
Project: 192340
Buggy source:
/** 
 * Load roots from authorities that are in stopped state. Normal  {@link UpdateTask} passes ignore stopped applications.
 */
private void loadStoppedAuthorities(){
  final ContentResolver resolver=mContext.getContentResolver();
synchronized (mLock) {
    for (    String authority : mStoppedAuthorities) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str" + authority);
      mRoots.putAll(authority,loadRootsForAuthority(resolver,authority));
    }
    mStoppedAuthorities.clear();
  }
}

Fixed version (ground truth):
/** 
 * Load roots from authorities that are in stopped state. Normal  {@link UpdateTask} passes ignore stopped applications.
 */
private void loadStoppedAuthorities(){
  final ContentResolver resolver=mContext.getContentResolver();
synchronized (mLock) {
    for (    String authority : mStoppedAuthorities) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str" + authority);
      mRoots.putAll(authority,loadRootsForAuthority(resolver,authority,true));
    }
    mStoppedAuthorities.clear();
  }
}
Program: 192341
Project: 192341
Buggy source:
private void handleDocumentsProvider(ProviderInfo info){
  if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + info.authority);
    mTaskStoppedAuthorities.add(info.authority);
    return;
  }
  boolean cacheHit=false;
  if (mFilterPackage != null && !mFilterPackage.equals(info.packageName)) {
synchronized (mLock) {
      if (mTaskRoots.putAll(info.authority,mRoots.get(info.authority))) {
        if (DEBUG)         Log.d(TAG,"String_Node_Str" + info.authority);
        cacheHit=true;
      }
    }
  }
  if (!cacheHit) {
    mTaskRoots.putAll(info.authority,loadRootsForAuthority(mContext.getContentResolver(),info.authority));
  }
}

Fixed version (ground truth):
private void handleDocumentsProvider(ProviderInfo info){
  if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + info.authority);
    mTaskStoppedAuthorities.add(info.authority);
    return;
  }
  final boolean forceRefresh=Objects.equals(mForceRefreshPackage,info.packageName);
  mTaskRoots.putAll(info.authority,loadRootsForAuthority(mContext.getContentResolver(),info.authority,forceRefresh));
}
Program: 192342
Project: 192342
Buggy source:
/** 
 * Load roots from a stopped authority. Normal   {@link UpdateTask} passesignore stopped applications.
 */
private void loadStoppedAuthority(String authority){
  final ContentResolver resolver=mContext.getContentResolver();
synchronized (mLock) {
    if (!mStoppedAuthorities.contains(authority)) {
      return;
    }
    if (DEBUG) {
      Log.d(TAG,"String_Node_Str" + authority);
    }
    mRoots.putAll(authority,loadRootsForAuthority(resolver,authority));
    mStoppedAuthorities.remove(authority);
  }
}

Fixed version (ground truth):
/** 
 * Load roots from a stopped authority. Normal   {@link UpdateTask} passesignore stopped applications.
 */
private void loadStoppedAuthority(String authority){
  final ContentResolver resolver=mContext.getContentResolver();
synchronized (mLock) {
    if (!mStoppedAuthorities.contains(authority)) {
      return;
    }
    if (DEBUG) {
      Log.d(TAG,"String_Node_Str" + authority);
    }
    mRoots.putAll(authority,loadRootsForAuthority(resolver,authority,true));
    mStoppedAuthorities.remove(authority);
  }
}
Program: 192343
Project: 192343
Buggy source:
private void onDiskScannedLocked(DiskInfo disk){
  int volumeCount=0;
  for (int i=0; i < mVolumes.size(); i++) {
    final VolumeInfo vol=mVolumes.valueAt(i);
    if (Objects.equals(disk.id,vol.getDiskId())) {
      volumeCount++;
    }
  }
  final Intent intent=new Intent(DiskInfo.ACTION_DISK_SCANNED);
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
  intent.putExtra(DiskInfo.EXTRA_DISK_ID,disk.id);
  intent.putExtra(DiskInfo.EXTRA_VOLUME_COUNT,volumeCount);
  mHandler.obtainMessage(H_INTERNAL_BROADCAST,intent).sendToTarget();
  final CountDownLatch latch=mDiskScanLatches.remove(disk.id);
  if (latch != null) {
    latch.countDown();
  }
  disk.volumeCount=volumeCount;
  mCallbacks.notifyDiskScanned(disk,volumeCount);
}

Fixed version (ground truth):
private void onDiskScannedLocked(DiskInfo disk){
  int volumeCount=0;
  for (int i=0; i < mVolumes.size(); i++) {
    final VolumeInfo vol=mVolumes.valueAt(i);
    if (Objects.equals(disk.id,vol.getDiskId())) {
      volumeCount++;
    }
  }
  final Intent intent=new Intent(DiskInfo.ACTION_DISK_SCANNED);
  intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
  intent.putExtra(DiskInfo.EXTRA_DISK_ID,disk.id);
  intent.putExtra(DiskInfo.EXTRA_VOLUME_COUNT,volumeCount);
  mHandler.obtainMessage(H_INTERNAL_BROADCAST,intent).sendToTarget();
  final CountDownLatch latch=mDiskScanLatches.remove(disk.id);
  if (latch != null) {
    latch.countDown();
  }
  disk.volumeCount=volumeCount;
  mCallbacks.notifyDiskScanned(disk,volumeCount);
}
Program: 192345
Project: 192345
Buggy source:
private void invalidateCacheLocked(int userId,String providerPackageName,Uri uri){
  ArrayMap<String,ArrayMap<Pair<String,Uri>,Bundle>> userCache=mCache.get(userId);
  if (userCache == null)   return;
  ArrayMap<Pair<String,Uri>,Bundle> packageCache=userCache.get(providerPackageName);
  if (packageCache == null)   return;
  if (uri != null) {
    for (int i=0; i < packageCache.size(); ) {
      final Uri key=packageCache.keyAt(i).second;
      if (Objects.equals(key,uri)) {
        packageCache.removeAt(i);
      }
 else {
        i++;
      }
    }
  }
 else {
    packageCache.clear();
  }
}

Fixed version (ground truth):
private void invalidateCacheLocked(int userId,String providerPackageName,Uri uri){
  ArrayMap<String,ArrayMap<Pair<String,Uri>,Bundle>> userCache=mCache.get(userId);
  if (userCache == null)   return;
  ArrayMap<Pair<String,Uri>,Bundle> packageCache=userCache.get(providerPackageName);
  if (packageCache == null)   return;
  if (uri != null) {
    for (int i=0; i < packageCache.size(); ) {
      final Pair<String,Uri> key=packageCache.keyAt(i);
      if (key.second != null && key.second.toString().startsWith(uri.toString())) {
        Slog.d(TAG,"String_Node_Str" + key);
        packageCache.removeAt(i);
      }
 else {
        i++;
      }
    }
  }
 else {
    Slog.d(TAG,"String_Node_Str" + providerPackageName);
    packageCache.clear();
  }
}
Program: 192346
Project: 192346
Buggy source:
void becomeActiveLocked(String activeReason,int activeUid){
  if (DEBUG)   Slog.i(TAG,"String_Node_Str" + activeReason);
  if (mState != STATE_ACTIVE || mLightState != STATE_ACTIVE) {
    EventLogTags.writeDeviceIdle(STATE_ACTIVE,activeReason);
    EventLogTags.writeDeviceIdleLight(LIGHT_STATE_ACTIVE,activeReason);
    scheduleReportActiveLocked(activeReason,activeUid);
    mState=STATE_ACTIVE;
    mLightState=LIGHT_STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
    mCurIdleBudget=0;
    mMaintenanceStartTime=0;
    if (mMaintenanceMinCheckScheduled) {
      mAlarmManager.cancel(mMaintenanceMinCheckListener);
      mMaintenanceMinCheckScheduled=false;
    }
    resetIdleManagementLocked();
    resetLightIdleManagementLocked();
    addEvent(EVENT_NORMAL);
  }
}

Fixed version (ground truth):
void becomeActiveLocked(String activeReason,int activeUid){
  if (DEBUG)   Slog.i(TAG,"String_Node_Str" + activeReason);
  if (mState != STATE_ACTIVE || mLightState != STATE_ACTIVE) {
    EventLogTags.writeDeviceIdle(STATE_ACTIVE,activeReason);
    EventLogTags.writeDeviceIdleLight(LIGHT_STATE_ACTIVE,activeReason);
    scheduleReportActiveLocked(activeReason,activeUid);
    mState=STATE_ACTIVE;
    mLightState=LIGHT_STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
    mCurIdleBudget=0;
    mMaintenanceStartTime=0;
    resetIdleManagementLocked();
    resetLightIdleManagementLocked();
    addEvent(EVENT_NORMAL);
  }
}
Program: 192350
Project: 192350
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  decActiveIdleOps();
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED.equals(intent.getAction())) {
    mHandler.sendEmptyMessageDelayed(MSG_FINISH_IDLE_OP,mConstants.MIN_DEEP_MAINTENANCE_TIME);
  }
 else {
    mHandler.sendEmptyMessageDelayed(MSG_FINISH_IDLE_OP,mConstants.MIN_LIGHT_MAINTENANCE_TIME);
  }
}
Program: 192351
Project: 192351
Buggy source:
void exitMaintenanceEarlyIfNeededLocked(){
  if (mState == STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_IDLE_MAINTENANCE) {
    if (mActiveIdleOpCount <= 0 && mDownloadServiceActive == null && !mJobsActive && !mAlarmsActive) {
      final long now=SystemClock.elapsedRealtime();
      if (DEBUG) {
        StringBuilder sb=new StringBuilder();
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(mMaintenanceStartTime,sb);
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(now,sb);
        Slog.d(TAG,sb.toString());
      }
      if (mState == STATE_IDLE_MAINTENANCE) {
        if (now >= (mMaintenanceStartTime + mConstants.MIN_DEEP_MAINTENANCE_TIME)) {
          stepIdleStateLocked("String_Node_Str");
        }
      }
 else {
        if (now >= (mMaintenanceStartTime + mConstants.MIN_LIGHT_MAINTENANCE_TIME)) {
          stepLightIdleStateLocked("String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
void exitMaintenanceEarlyIfNeededLocked(){
  if (mState == STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_IDLE_MAINTENANCE || mLightState == LIGHT_STATE_PRE_IDLE) {
    if (isOpsInactiveLocked()) {
      final long now=SystemClock.elapsedRealtime();
      if (DEBUG) {
        StringBuilder sb=new StringBuilder();
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(mMaintenanceStartTime,sb);
        sb.append("String_Node_Str");
        TimeUtils.formatDuration(now,sb);
        Slog.d(TAG,sb.toString());
      }
      if (mState == STATE_IDLE_MAINTENANCE) {
        stepIdleStateLocked("String_Node_Str");
      }
 else       if (mLightState == LIGHT_STATE_PRE_IDLE) {
        stepLightIdleStateLocked("String_Node_Str");
      }
 else {
        stepLightIdleStateLocked("String_Node_Str");
      }
    }
  }
}
Program: 192352
Project: 192352
Buggy source:
void decActiveIdleOps(){
synchronized (this) {
    mActiveIdleOpCount--;
    if (mActiveIdleOpCount <= 0) {
      exitMaintenanceEarlyIfNeededLocked();
    }
  }
}

Fixed version (ground truth):
void decActiveIdleOps(){
synchronized (this) {
    mActiveIdleOpCount--;
    if (mActiveIdleOpCount <= 0) {
      exitMaintenanceEarlyIfNeededLocked();
      mActiveIdleWakeLock.release();
    }
  }
}
Program: 192353
Project: 192353
Buggy source:
private static String lightStateToString(int state){
switch (state) {
case LIGHT_STATE_ACTIVE:
    return "String_Node_Str";
case LIGHT_STATE_INACTIVE:
  return "String_Node_Str";
case LIGHT_STATE_IDLE:
return "String_Node_Str";
case LIGHT_STATE_IDLE_MAINTENANCE:
return "String_Node_Str";
case LIGHT_STATE_OVERRIDE:
return "String_Node_Str";
default :
return Integer.toString(state);
}
}

Fixed version (ground truth):
private static String lightStateToString(int state){
switch (state) {
case LIGHT_STATE_ACTIVE:
    return "String_Node_Str";
case LIGHT_STATE_INACTIVE:
  return "String_Node_Str";
case LIGHT_STATE_PRE_IDLE:
return "String_Node_Str";
case LIGHT_STATE_IDLE:
return "String_Node_Str";
case LIGHT_STATE_IDLE_MAINTENANCE:
return "String_Node_Str";
case LIGHT_STATE_OVERRIDE:
return "String_Node_Str";
default :
return Integer.toString(state);
}
}
Program: 192357
Project: 192357
Buggy source:
@Override public void onAlarm(){
synchronized (DeviceIdleController.this) {
    exitMaintenanceEarlyIfNeededLocked();
  }
}

Fixed version (ground truth):
@Override public void onAlarm(){
synchronized (DeviceIdleController.this) {
    stepIdleStateLocked("String_Node_Str");
  }
}
Program: 192358
Project: 192358
Buggy source:
@Override public void run(){
  updateAnimators();
}

Fixed version (ground truth):
@Override public void run(){
  updateAnimators();
  setPosition(mLastPosition);
}
Program: 192359
Project: 192359
Buggy source:
public void setPosition(float position){
  if (mFirstPageAnimator == null)   return;
  if (mOnKeyguard) {
    return;
  }
  if (mOnFirstPage && mAllowFancy) {
    mQuickQsPanel.setAlpha(1);
    mFirstPageAnimator.setPosition(position);
    mFirstPageDelayedAnimator.setPosition(position);
    mTranslationXAnimator.setPosition(position);
    mTranslationYAnimator.setPosition(position);
    mLastRowAnimator.setPosition(position);
  }
 else {
    mNonfirstPageAnimator.setPosition(position);
  }
}

Fixed version (ground truth):
public void setPosition(float position){
  if (mFirstPageAnimator == null)   return;
  if (mOnKeyguard) {
    return;
  }
  mLastPosition=position;
  if (mOnFirstPage && mAllowFancy) {
    mQuickQsPanel.setAlpha(1);
    mFirstPageAnimator.setPosition(position);
    mFirstPageDelayedAnimator.setPosition(position);
    mTranslationXAnimator.setPosition(position);
    mTranslationYAnimator.setPosition(position);
    mLastRowAnimator.setPosition(position);
  }
 else {
    mNonfirstPageAnimator.setPosition(position);
  }
}
Program: 192360
Project: 192360
Buggy source:
private void clearAnimationState(){
  final int N=mAllViews.size();
  mQuickQsPanel.setAlpha(0);
  mQuickQsPanel.setVisibility(View.INVISIBLE);
  for (int i=0; i < N; i++) {
    View v=mAllViews.get(i);
    v.setAlpha(1);
    v.setTranslationX(1);
    v.setTranslationY(1);
  }
  final int N2=mTopFiveQs.size();
  for (int i=0; i < N2; i++) {
    mTopFiveQs.get(i).setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
private void clearAnimationState(){
  final int N=mAllViews.size();
  mQuickQsPanel.setAlpha(0);
  mQuickQsPanel.setVisibility(View.VISIBLE);
  for (int i=0; i < N; i++) {
    View v=mAllViews.get(i);
    v.setAlpha(1);
    v.setTranslationX(1);
    v.setTranslationY(1);
  }
  final int N2=mTopFiveQs.size();
  for (int i=0; i < N2; i++) {
    mTopFiveQs.get(i).setVisibility(View.VISIBLE);
  }
}
Program: 192361
Project: 192361
Buggy source:
/** 
 * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. To re-enable everything, pass   {@link #DISABLE_NONE}. Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags.
 */
@Override public void disable2(int what,IBinder token,String pkg){
  disableForUser(what,token,pkg,mCurrentUserId);
}

Fixed version (ground truth):
/** 
 * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. To re-enable everything, pass   {@link #DISABLE_NONE}. Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags.
 */
@Override public void disable2(int what,IBinder token,String pkg){
  disable2ForUser(what,token,pkg,mCurrentUserId);
}
Program: 192362
Project: 192362
Buggy source:
/** 
 * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. To re-enable everything, pass   {@link #DISABLE_NONE}. Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags.
 */
@Override public void disable2(int what,IBinder token,String pkg){
  disableForUser(what,token,pkg,mCurrentUserId);
}

Fixed version (ground truth):
/** 
 * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. To re-enable everything, pass   {@link #DISABLE_NONE}. Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags.
 */
@Override public void disable2(int what,IBinder token,String pkg){
  disable2ForUser(what,token,pkg,mCurrentUserId);
}
Program: 192363
Project: 192363
Buggy source:
boolean matches(byte[] packet,int length){
  if (length != mPacket.limit())   return false;
  ByteBuffer a=ByteBuffer.wrap(packet);
  ByteBuffer b=mPacket;
  for (  Pair<Integer,Integer> nonLifetime : mNonLifetimes) {
    a.clear();
    b.clear();
    a.position(nonLifetime.first);
    b.position(nonLifetime.first);
    a.limit(nonLifetime.first + nonLifetime.second);
    b.limit(nonLifetime.first + nonLifetime.second);
    if (a.compareTo(b) != 0)     return false;
  }
  return true;
}

Fixed version (ground truth):
boolean matches(byte[] packet,int length){
  if (length != mPacket.capacity())   return false;
  byte[] referencePacket=mPacket.array();
  for (  Pair<Integer,Integer> nonLifetime : mNonLifetimes) {
    for (int i=nonLifetime.first; i < (nonLifetime.first + nonLifetime.second); i++) {
      if (packet[i] != referencePacket[i])       return false;
    }
  }
  return true;
}
Program: 192364
Project: 192364
Buggy source:
@GuardedBy("String_Node_Str") long generateFilterLocked(ApfGenerator gen) throws IllegalInstructionException {
  String nextFilterLabel="String_Node_Str" + getUniqueNumberLocked();
  gen.addLoadFromMemory(Register.R0,gen.PACKET_SIZE_MEMORY_SLOT);
  gen.addJumpIfR0NotEquals(mPacket.limit(),nextFilterLabel);
  int filterLifetime=(int)(currentLifetime() / FRACTION_OF_LIFETIME_TO_FILTER);
  gen.addLoadFromMemory(Register.R0,gen.FILTER_AGE_MEMORY_SLOT);
  gen.addJumpIfR0GreaterThan(filterLifetime,nextFilterLabel);
  for (int i=0; i < mNonLifetimes.size(); i++) {
    Pair<Integer,Integer> nonLifetime=mNonLifetimes.get(i);
    if (nonLifetime.second != 0) {
      gen.addLoadImmediate(Register.R0,nonLifetime.first);
      gen.addJumpIfBytesNotEqual(Register.R0,Arrays.copyOfRange(mPacket.array(),nonLifetime.first,nonLifetime.first + nonLifetime.second),nextFilterLabel);
    }
    if ((i + 1) < mNonLifetimes.size()) {
      Pair<Integer,Integer> nextNonLifetime=mNonLifetimes.get(i + 1);
      int offset=nonLifetime.first + nonLifetime.second;
      if (offset == ICMP6_RA_CHECKSUM_OFFSET) {
        continue;
      }
      int length=nextNonLifetime.first - offset;
switch (length) {
case 4:
        gen.addLoad32(Register.R0,offset);
      break;
case 2:
    gen.addLoad16(Register.R0,offset);
  break;
default :
throw new IllegalStateException("String_Node_Str" + length);
}
gen.addJumpIfR0LessThan(filterLifetime,nextFilterLabel);
}
}
gen.addJump(gen.DROP_LABEL);
gen.defineLabel(nextFilterLabel);
return filterLifetime;
}

Fixed version (ground truth):
@GuardedBy("String_Node_Str") long generateFilterLocked(ApfGenerator gen) throws IllegalInstructionException {
  String nextFilterLabel="String_Node_Str" + getUniqueNumberLocked();
  gen.addLoadFromMemory(Register.R0,gen.PACKET_SIZE_MEMORY_SLOT);
  gen.addJumpIfR0NotEquals(mPacket.capacity(),nextFilterLabel);
  int filterLifetime=(int)(currentLifetime() / FRACTION_OF_LIFETIME_TO_FILTER);
  gen.addLoadFromMemory(Register.R0,gen.FILTER_AGE_MEMORY_SLOT);
  gen.addJumpIfR0GreaterThan(filterLifetime,nextFilterLabel);
  for (int i=0; i < mNonLifetimes.size(); i++) {
    Pair<Integer,Integer> nonLifetime=mNonLifetimes.get(i);
    if (nonLifetime.second != 0) {
      gen.addLoadImmediate(Register.R0,nonLifetime.first);
      gen.addJumpIfBytesNotEqual(Register.R0,Arrays.copyOfRange(mPacket.array(),nonLifetime.first,nonLifetime.first + nonLifetime.second),nextFilterLabel);
    }
    if ((i + 1) < mNonLifetimes.size()) {
      Pair<Integer,Integer> nextNonLifetime=mNonLifetimes.get(i + 1);
      int offset=nonLifetime.first + nonLifetime.second;
      if (offset == ICMP6_RA_CHECKSUM_OFFSET) {
        continue;
      }
      int length=nextNonLifetime.first - offset;
switch (length) {
case 4:
        gen.addLoad32(Register.R0,offset);
      break;
case 2:
    gen.addLoad16(Register.R0,offset);
  break;
default :
throw new IllegalStateException("String_Node_Str" + length);
}
gen.addJumpIfR0LessThan(filterLifetime,nextFilterLabel);
}
}
gen.addJump(gen.DROP_LABEL);
gen.defineLabel(nextFilterLabel);
return filterLifetime;
}
Program: 192365
Project: 192365
Buggy source:
static void dumpCommandHelp(PrintWriter pw){
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
}

Fixed version (ground truth):
static void dumpCommandHelp(PrintWriter pw){
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
}
Program: 192368
Project: 192368
Buggy source:
public int getAppStartMode(int uid,String packageName){
synchronized (this) {
    return checkAllowBackgroundLocked(uid,packageName,-1);
  }
}

Fixed version (ground truth):
public int getAppStartMode(int uid,String packageName){
synchronized (this) {
    return checkAllowBackgroundLocked(uid,packageName,-1,true);
  }
}
Program: 192369
Project: 192369
Buggy source:
int checkAllowBackgroundLocked(int uid,String packageName,int callingPid){
  UidRecord uidRec=mActiveUids.get(uid);
  if (!mLenientBackgroundCheck) {
    if (uidRec == null || uidRec.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND) {
      if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
        return ActivityManager.APP_START_MODE_DELAYED;
      }
    }
  }
 else   if (uidRec == null || uidRec.idle) {
    if (callingPid >= 0) {
      ProcessRecord proc;
synchronized (mPidsSelfLocked) {
        proc=mPidsSelfLocked.get(callingPid);
      }
      if (proc != null && proc.curProcState < ActivityManager.PROCESS_STATE_RECEIVER) {
        return ActivityManager.APP_START_MODE_NORMAL;
      }
    }
    if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
      return ActivityManager.APP_START_MODE_DELAYED;
    }
  }
  return ActivityManager.APP_START_MODE_NORMAL;
}

Fixed version (ground truth):
int checkAllowBackgroundLocked(int uid,String packageName,int callingPid,boolean allowWhenForeground){
  UidRecord uidRec=mActiveUids.get(uid);
  if (!mLenientBackgroundCheck) {
    if (!allowWhenForeground || uidRec == null || uidRec.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND) {
      if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
        return ActivityManager.APP_START_MODE_DELAYED;
      }
    }
  }
 else   if (uidRec == null || uidRec.idle) {
    if (callingPid >= 0) {
      ProcessRecord proc;
synchronized (mPidsSelfLocked) {
        proc=mPidsSelfLocked.get(callingPid);
      }
      if (proc != null && proc.curProcState < ActivityManager.PROCESS_STATE_RECEIVER) {
        return ActivityManager.APP_START_MODE_NORMAL;
      }
    }
    if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
      return ActivityManager.APP_START_MODE_DELAYED;
    }
  }
  return ActivityManager.APP_START_MODE_NORMAL;
}
Program: 192372
Project: 192372
Buggy source:
static void dumpCommandHelp(PrintWriter pw){
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
}

Fixed version (ground truth):
static void dumpCommandHelp(PrintWriter pw){
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
  pw.println("String_Node_Str");
}
Program: 192375
Project: 192375
Buggy source:
public int getAppStartMode(int uid,String packageName){
synchronized (this) {
    return checkAllowBackgroundLocked(uid,packageName,-1);
  }
}

Fixed version (ground truth):
public int getAppStartMode(int uid,String packageName){
synchronized (this) {
    return checkAllowBackgroundLocked(uid,packageName,-1,true);
  }
}
Program: 192376
Project: 192376
Buggy source:
int checkAllowBackgroundLocked(int uid,String packageName,int callingPid){
  UidRecord uidRec=mActiveUids.get(uid);
  if (!mLenientBackgroundCheck) {
    if (uidRec == null || uidRec.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND) {
      if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
        return ActivityManager.APP_START_MODE_DELAYED;
      }
    }
  }
 else   if (uidRec == null || uidRec.idle) {
    if (callingPid >= 0) {
      ProcessRecord proc;
synchronized (mPidsSelfLocked) {
        proc=mPidsSelfLocked.get(callingPid);
      }
      if (proc != null && proc.curProcState < ActivityManager.PROCESS_STATE_RECEIVER) {
        return ActivityManager.APP_START_MODE_NORMAL;
      }
    }
    if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
      return ActivityManager.APP_START_MODE_DELAYED;
    }
  }
  return ActivityManager.APP_START_MODE_NORMAL;
}

Fixed version (ground truth):
int checkAllowBackgroundLocked(int uid,String packageName,int callingPid,boolean allowWhenForeground){
  UidRecord uidRec=mActiveUids.get(uid);
  if (!mLenientBackgroundCheck) {
    if (!allowWhenForeground || uidRec == null || uidRec.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND) {
      if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
        return ActivityManager.APP_START_MODE_DELAYED;
      }
    }
  }
 else   if (uidRec == null || uidRec.idle) {
    if (callingPid >= 0) {
      ProcessRecord proc;
synchronized (mPidsSelfLocked) {
        proc=mPidsSelfLocked.get(callingPid);
      }
      if (proc != null && proc.curProcState < ActivityManager.PROCESS_STATE_RECEIVER) {
        return ActivityManager.APP_START_MODE_NORMAL;
      }
    }
    if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,uid,packageName) != AppOpsManager.MODE_ALLOWED) {
      return ActivityManager.APP_START_MODE_DELAYED;
    }
  }
  return ActivityManager.APP_START_MODE_NORMAL;
}
Program: 192380
Project: 192380
Buggy source:
public final void onBusEvent(ConfigurationChangedEvent event){
  mLayoutAlgorithm.reloadOnConfigurationChange(getContext());
  mLayoutAlgorithm.initialize(mWindowRect,mStackBounds,TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack));
}

Fixed version (ground truth):
public final void onBusEvent(ConfigurationChangedEvent event){
  mStableLayoutAlgorithm.reloadOnConfigurationChange(getContext());
  mLayoutAlgorithm.reloadOnConfigurationChange(getContext());
  mLayoutAlgorithm.initialize(mWindowRect,mStackBounds,TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack));
}
Program: 192381
Project: 192381
Buggy source:
/** 
 * Lays out a TaskView.
 */
private void layoutTaskView(TaskView tv){
  if (tv.getBackground() != null) {
    tv.getBackground().getPadding(mTmpRect);
  }
 else {
    mTmpRect.setEmpty();
  }
  Rect taskRect=mLayoutAlgorithm.mTaskRect;
  tv.cancelTransformAnimation();
  tv.layout(taskRect.left - mTmpRect.left,taskRect.top - mTmpRect.top,taskRect.right + mTmpRect.right,taskRect.bottom + mTmpRect.bottom);
}

Fixed version (ground truth):
/** 
 * Lays out a TaskView.
 */
private void layoutTaskView(TaskView tv){
  if (tv.getBackground() != null) {
    tv.getBackground().getPadding(mTmpRect);
  }
 else {
    mTmpRect.setEmpty();
  }
  Rect taskRect=mStableLayoutAlgorithm.mTaskRect;
  tv.cancelTransformAnimation();
  tv.layout(taskRect.left - mTmpRect.left,taskRect.top - mTmpRect.top,taskRect.right + mTmpRect.right,taskRect.bottom + mTmpRect.bottom);
}