Program: 43545
Project: 43545
Buggy source:
public void setPersistent(IBinder token,boolean isPersistent){
  if (checkCallingPermission(android.Manifest.permission.PERSISTENT_ACTIVITY) != PackageManager.PERMISSION_GRANTED) {
    String msg="String_Node_Str" + Binder.getCallingPid() + "String_Node_Str"+ Binder.getCallingUid()+ "String_Node_Str"+ android.Manifest.permission.PERSISTENT_ACTIVITY;
    Log.w(TAG,msg);
    throw new SecurityException(msg);
  }
synchronized (this) {
    int index=indexOfTokenLocked(token,true);
    if (index < 0) {
      return;
    }
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    ProcessRecord app=r.app;
    if (localLOGV)     Log.v(TAG,"String_Node_Str" + isPersistent + "String_Node_Str"+ r);
    if (isPersistent) {
      if (r.persistent) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        return;
      }
      r.persistent=true;
      app.persistentActivities++;
      if (localLOGV)       Log.v(TAG,"String_Node_Str" + app.persistentActivities);
      if (app.persistentActivities > 1) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        return;
      }
      if (app.persistent) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        return;
      }
      final long origId=Binder.clearCallingIdentity();
      updateOomAdjLocked();
      Binder.restoreCallingIdentity(origId);
    }
 else {
      if (!r.persistent) {
        return;
      }
      r.persistent=false;
      final long origId=Binder.clearCallingIdentity();
      decPersistentCountLocked(app);
      Binder.restoreCallingIdentity(origId);
    }
  }
}

Fixed version (ground truth):
public void setPersistent(IBinder token,boolean isPersistent){
  if (checkCallingPermission(android.Manifest.permission.PERSISTENT_ACTIVITY) != PackageManager.PERMISSION_GRANTED) {
    String msg="String_Node_Str" + Binder.getCallingPid() + "String_Node_Str"+ Binder.getCallingUid()+ "String_Node_Str"+ android.Manifest.permission.PERSISTENT_ACTIVITY;
    Log.w(TAG,msg);
    throw new SecurityException(msg);
  }
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index < 0) {
      return;
    }
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    ProcessRecord app=r.app;
    if (localLOGV)     Log.v(TAG,"String_Node_Str" + isPersistent + "String_Node_Str"+ r);
    if (isPersistent) {
      if (r.persistent) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        return;
      }
      r.persistent=true;
      app.persistentActivities++;
      if (localLOGV)       Log.v(TAG,"String_Node_Str" + app.persistentActivities);
      if (app.persistentActivities > 1) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        return;
      }
      if (app.persistent) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        return;
      }
      final long origId=Binder.clearCallingIdentity();
      updateOomAdjLocked();
      Binder.restoreCallingIdentity(origId);
    }
 else {
      if (!r.persistent) {
        return;
      }
      r.persistent=false;
      final long origId=Binder.clearCallingIdentity();
      decPersistentCountLocked(app);
      Binder.restoreCallingIdentity(origId);
    }
  }
}