Program: 165258
Project: 165258
Buggy source:
@Override public Cursor query(Uri uri,String[] projection,String customSelection,String[] selectionArgs,String sortOrder){
  AppQuerySelection selection=new AppQuerySelection(customSelection,selectionArgs);
  boolean includeSwap=true;
switch (matcher.match(uri)) {
case CODE_LIST:
    includeSwap=false;
  break;
case CODE_SINGLE:
selection=selection.add(querySingle(uri.getLastPathSegment()));
break;
case CAN_UPDATE:
selection=selection.add(queryCanUpdate());
includeSwap=false;
break;
case REPO:
selection=selection.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
break;
case INSTALLED:
selection=selection.add(queryInstalled());
includeSwap=false;
break;
case SEARCH:
selection=selection.add(querySearch(uri.getLastPathSegment()));
includeSwap=false;
break;
case SEARCH_REPO:
selection=selection.add(querySearch(uri.getPathSegments().get(2)));
selection=selection.add(queryRepo(Long.parseLong(uri.getPathSegments().get(1))));
break;
case NO_APKS:
selection=selection.add(queryNoApks());
break;
case APPS:
selection=selection.add(queryApps(uri.getLastPathSegment()));
break;
case IGNORED:
selection=selection.add(queryIgnored());
break;
case CATEGORY:
selection=selection.add(queryCategory(uri.getLastPathSegment()));
includeSwap=false;
break;
case RECENTLY_UPDATED:
sortOrder=getTableName() + "String_Node_Str";
selection=selection.add(queryRecentlyUpdated());
includeSwap=false;
break;
case NEWLY_ADDED:
sortOrder=getTableName() + "String_Node_Str";
selection=selection.add(queryNewlyAdded());
includeSwap=false;
break;
default :
Log.e(TAG,"String_Node_Str" + uri);
throw new UnsupportedOperationException("String_Node_Str" + uri);
}
if (!includeSwap) {
selection=selection.add(queryExcludeSwap());
}
if (AppProvider.DataColumns.NAME.equals(sortOrder)) {
sortOrder=getTableName() + sortOrder + "String_Node_Str";
}
Query query=new Query();
query.addSelection(selection);
query.addFields(projection);
query.addOrderBy(sortOrder);
Cursor cursor=read().rawQuery(query.toString(),selection.getArgs());
cursor.setNotificationUri(getContext().getContentResolver(),uri);
return cursor;
}

Fixed version (ground truth):
@Override public Cursor query(Uri uri,String[] projection,String customSelection,String[] selectionArgs,String sortOrder){
  AppQuerySelection selection=new AppQuerySelection(customSelection,selectionArgs);
  boolean includeSwap=true;
switch (matcher.match(uri)) {
case CODE_LIST:
    includeSwap=false;
  break;
case CODE_SINGLE:
selection=selection.add(querySingle(uri.getLastPathSegment()));
break;
case CAN_UPDATE:
selection=selection.add(queryCanUpdate());
includeSwap=false;
break;
case REPO:
selection=selection.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
break;
case INSTALLED:
selection=selection.add(queryInstalled());
includeSwap=false;
break;
case SEARCH:
selection=selection.add(querySearch(uri.getLastPathSegment()));
includeSwap=false;
break;
case SEARCH_REPO:
selection=selection.add(querySearch(uri.getPathSegments().get(2)));
selection=selection.add(queryRepo(Long.parseLong(uri.getPathSegments().get(1))));
break;
case NO_APKS:
selection=selection.add(queryNoApks());
break;
case APPS:
selection=selection.add(queryApps(uri.getLastPathSegment()));
break;
case IGNORED:
selection=selection.add(queryIgnored());
break;
case CATEGORY:
selection=selection.add(queryCategory(uri.getLastPathSegment()));
includeSwap=false;
break;
case RECENTLY_UPDATED:
sortOrder=getTableName() + "String_Node_Str";
selection=selection.add(queryRecentlyUpdated());
includeSwap=false;
break;
case NEWLY_ADDED:
sortOrder=getTableName() + "String_Node_Str";
selection=selection.add(queryNewlyAdded());
includeSwap=false;
break;
default :
Log.e(TAG,"String_Node_Str" + uri);
throw new UnsupportedOperationException("String_Node_Str" + uri);
}
if (!includeSwap) {
selection=selection.add(queryExcludeSwap());
}
if (AppProvider.DataColumns.NAME.equals(sortOrder)) {
sortOrder=getTableName() + "String_Node_Str" + sortOrder+ "String_Node_Str";
}
Query query=new Query();
query.addSelection(selection);
query.addFields(projection);
query.addOrderBy(sortOrder);
Cursor cursor=read().rawQuery(query.toString(),selection.getArgs());
cursor.setNotificationUri(getContext().getContentResolver(),uri);
return cursor;
}