Program: 198322
Project: 198322
Buggy source:
@Override public void replacePreferredActivity(IntentFilter filter,int match,ComponentName[] set,ComponentName activity,int userId){
  if (filter.countActions() != 1) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (filter.countDataAuthorities() != 0 || filter.countDataPaths() != 0 || filter.countDataSchemes() > 1 || filter.countDataTypes() != 0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  final int callingUid=Binder.getCallingUid();
  enforceCrossUserPermission(callingUid,userId,true,"String_Node_Str");
  final int callingUserId=UserHandle.getUserId(callingUid);
synchronized (mPackages) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) != PackageManager.PERMISSION_GRANTED) {
      if (getUidTargetSdkVersionLockedLPr(callingUid) < Build.VERSION_CODES.FROYO) {
        Slog.w(TAG,"String_Node_Str" + Binder.getCallingUid());
        return;
      }
      mContext.enforceCallingOrSelfPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS,null);
    }
    PreferredIntentResolver pir=mSettings.mPreferredActivities.get(callingUserId);
    if (pir != null) {
      Intent intent=new Intent(filter.getAction(0)).addCategory(filter.getCategory(0));
      if (filter.countDataSchemes() == 1) {
        Uri.Builder builder=new Uri.Builder();
        builder.scheme(filter.getDataScheme(0));
        intent.setData(builder.build());
      }
      List<PreferredActivity> matches=pir.queryIntent(intent,null,true,callingUserId);
      if (DEBUG_PREFERRED) {
        Slog.i(TAG,matches.size() + "String_Node_Str" + intent);
      }
      for (int i=0; i < matches.size(); i++) {
        PreferredActivity pa=matches.get(i);
        if (DEBUG_PREFERRED) {
          Slog.i(TAG,"String_Node_Str" + pa.mPref.mComponent + "String_Node_Str");
          filter.dump(new LogPrinter(Log.INFO,TAG),"String_Node_Str");
        }
        pir.removeFilter(pa);
      }
    }
    addPreferredActivityInternal(filter,match,set,activity,true,callingUserId);
  }
}

Fixed version (ground truth):
@Override public void replacePreferredActivity(IntentFilter filter,int match,ComponentName[] set,ComponentName activity,int userId){
  if (filter.countActions() != 1) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (filter.countDataAuthorities() != 0 || filter.countDataPaths() != 0 || filter.countDataSchemes() > 1 || filter.countDataTypes() != 0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  final int callingUid=Binder.getCallingUid();
  enforceCrossUserPermission(callingUid,userId,true,"String_Node_Str");
synchronized (mPackages) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) != PackageManager.PERMISSION_GRANTED) {
      if (getUidTargetSdkVersionLockedLPr(callingUid) < Build.VERSION_CODES.FROYO) {
        Slog.w(TAG,"String_Node_Str" + Binder.getCallingUid());
        return;
      }
      mContext.enforceCallingOrSelfPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS,null);
    }
    PreferredIntentResolver pir=mSettings.mPreferredActivities.get(userId);
    if (pir != null) {
      ArrayList<PreferredActivity> existing=pir.findFilters(filter);
      if (existing != null && existing.size() == 1) {
        PreferredActivity cur=existing.get(0);
        if (DEBUG_PREFERRED) {
          Slog.i(TAG,"String_Node_Str");
          filter.dump(new LogPrinter(Log.INFO,TAG),"String_Node_Str");
          if (!cur.mPref.mAlways) {
            Slog.i(TAG,"String_Node_Str");
          }
 else {
            Slog.i(TAG,"String_Node_Str" + cur.mPref.mMatch);
            Slog.i(TAG,"String_Node_Str" + Arrays.toString(cur.mPref.mSetComponents));
            Slog.i(TAG,"String_Node_Str" + cur.mPref.mShortComponent);
            Slog.i(TAG,"String_Node_Str" + (match & IntentFilter.MATCH_CATEGORY_MASK));
            Slog.i(TAG,"String_Node_Str" + Arrays.toString(set));
            Slog.i(TAG,"String_Node_Str" + activity.flattenToShortString());
          }
        }
        if (cur.mPref.mAlways && cur.mPref.mComponent.equals(activity) && cur.mPref.mMatch == (match & IntentFilter.MATCH_CATEGORY_MASK) && cur.mPref.sameSet(set)) {
          if (DEBUG_PREFERRED) {
            Slog.i(TAG,"String_Node_Str" + cur.mPref.mShortComponent + "String_Node_Str"+ userId+ "String_Node_Str");
            filter.dump(new LogPrinter(Log.INFO,TAG),"String_Node_Str");
          }
 else {
            Slog.i(TAG,"String_Node_Str" + cur.mPref.mShortComponent + "String_Node_Str"+ userId);
          }
          return;
        }
      }
      if (DEBUG_PREFERRED) {
        Slog.i(TAG,existing.size() + "String_Node_Str");
        filter.dump(new LogPrinter(Log.INFO,TAG),"String_Node_Str");
      }
      for (int i=0; i < existing.size(); i++) {
        PreferredActivity pa=existing.get(i);
        if (DEBUG_PREFERRED) {
          Slog.i(TAG,"String_Node_Str" + pa.mPref.mComponent + "String_Node_Str");
          pa.dump(new LogPrinter(Log.INFO,TAG),"String_Node_Str");
        }
        pir.removeFilter(pa);
      }
    }
    addPreferredActivityInternal(filter,match,set,activity,true,userId,"String_Node_Str");
  }
}