Program: 152420
Project: 152420
Buggy source:
public AssetFileDescriptor openAssetFileLocal(Uri uri,String mode) throws FileNotFoundException {
  final boolean writing=mode.contains("String_Node_Str");
  final SQLiteDatabase db=mDbHelper.get().getDatabase(writing);
  int match=sUriMatcher.match(uri);
switch (match) {
case CONTACTS_ID_PHOTO:
{
      long contactId=Long.parseLong(uri.getPathSegments().get(1));
      return openPhotoAssetFile(db,uri,mode,Data._ID + "String_Node_Str" + Contacts.PHOTO_ID+ "String_Node_Str"+ RawContacts.CONTACT_ID+ "String_Node_Str",new String[]{String.valueOf(contactId)});
    }
case CONTACTS_ID_DISPLAY_PHOTO:
{
    if (!mode.equals("String_Node_Str")) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    long contactId=Long.parseLong(uri.getPathSegments().get(1));
    Cursor c=db.query(Tables.CONTACTS,new String[]{Contacts.PHOTO_FILE_ID},Contacts._ID + "String_Node_Str",new String[]{String.valueOf(contactId)},null,null,null);
    try {
      if (c.moveToFirst()) {
        long photoFileId=c.getLong(0);
        return openDisplayPhotoForRead(photoFileId);
      }
 else {
        throw new FileNotFoundException(uri.toString());
      }
    }
  finally {
      c.close();
    }
  }
case PROFILE_DISPLAY_PHOTO:
{
  if (!mode.equals("String_Node_Str")) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Cursor c=db.query(Tables.CONTACTS,new String[]{Contacts.PHOTO_FILE_ID},null,null,null,null,null);
  try {
    if (c.moveToFirst()) {
      long photoFileId=c.getLong(0);
      return openDisplayPhotoForRead(photoFileId);
    }
 else {
      throw new FileNotFoundException(uri.toString());
    }
  }
  finally {
    c.close();
  }
}
case CONTACTS_LOOKUP_PHOTO:
case CONTACTS_LOOKUP_ID_PHOTO:
case CONTACTS_LOOKUP_DISPLAY_PHOTO:
case CONTACTS_LOOKUP_ID_DISPLAY_PHOTO:
{
if (!mode.equals("String_Node_Str")) {
  throw new IllegalArgumentException("String_Node_Str");
}
List<String> pathSegments=uri.getPathSegments();
int segmentCount=pathSegments.size();
if (segmentCount < 4) {
  throw new IllegalArgumentException(mDbHelper.get().exceptionMessage("String_Node_Str",uri));
}
boolean forDisplayPhoto=(match == CONTACTS_LOOKUP_ID_DISPLAY_PHOTO || match == CONTACTS_LOOKUP_DISPLAY_PHOTO);
String lookupKey=pathSegments.get(2);
String[] projection=new String[]{Contacts.PHOTO_ID,Contacts.PHOTO_FILE_ID};
if (segmentCount == 5) {
  long contactId=Long.parseLong(pathSegments.get(3));
  SQLiteQueryBuilder lookupQb=new SQLiteQueryBuilder();
  setTablesAndProjectionMapForContacts(lookupQb,uri,projection);
  Cursor c=queryWithContactIdAndLookupKey(lookupQb,db,uri,projection,null,null,null,null,null,Contacts._ID,contactId,Contacts.LOOKUP_KEY,lookupKey,null);
  if (c != null) {
    try {
      c.moveToFirst();
      if (forDisplayPhoto) {
        long photoFileId=c.getLong(c.getColumnIndex(Contacts.PHOTO_FILE_ID));
        return openDisplayPhotoForRead(photoFileId);
      }
 else {
        long photoId=c.getLong(c.getColumnIndex(Contacts.PHOTO_ID));
        return openPhotoAssetFile(db,uri,mode,Data._ID + "String_Node_Str",new String[]{String.valueOf(photoId)});
      }
    }
  finally {
      c.close();
    }
  }
}
SQLiteQueryBuilder qb=new SQLiteQueryBuilder();
setTablesAndProjectionMapForContacts(qb,uri,projection);
long contactId=lookupContactIdByLookupKey(db,lookupKey);
Cursor c=qb.query(db,projection,Contacts._ID + "String_Node_Str",new String[]{String.valueOf(contactId)},null,null,null);
try {
  c.moveToFirst();
  if (forDisplayPhoto) {
    long photoFileId=c.getLong(c.getColumnIndex(Contacts.PHOTO_FILE_ID));
    return openDisplayPhotoForRead(photoFileId);
  }
 else {
    long photoId=c.getLong(c.getColumnIndex(Contacts.PHOTO_ID));
    return openPhotoAssetFile(db,uri,mode,Data._ID + "String_Node_Str",new String[]{String.valueOf(photoId)});
  }
}
  finally {
  c.close();
}
}
case RAW_CONTACTS_ID_DISPLAY_PHOTO:
{
long rawContactId=Long.parseLong(uri.getPathSegments().get(1));
boolean writeable=!mode.equals("String_Node_Str");
SQLiteQueryBuilder qb=new SQLiteQueryBuilder();
String[] projection=new String[]{Data._ID,Photo.PHOTO_FILE_ID};
setTablesAndProjectionMapForData(qb,uri,projection,false);
long photoMimetypeId=mDbHelper.get().getMimeTypeId(Photo.CONTENT_ITEM_TYPE);
Cursor c=qb.query(db,projection,Data.RAW_CONTACT_ID + "String_Node_Str" + DataColumns.MIMETYPE_ID+ "String_Node_Str",new String[]{String.valueOf(rawContactId),String.valueOf(photoMimetypeId)},null,null,Data.IS_PRIMARY + "String_Node_Str");
long dataId=0;
long photoFileId=0;
try {
if (c.getCount() >= 1) {
  c.moveToFirst();
  dataId=c.getLong(0);
  photoFileId=c.getLong(1);
}
}
  finally {
c.close();
}
if (writeable) {
return openDisplayPhotoForWrite(rawContactId,dataId,uri,mode);
}
 else {
return openDisplayPhotoForRead(photoFileId);
}
}
case DISPLAY_PHOTO_ID:
{
long photoFileId=ContentUris.parseId(uri);
if (!mode.equals("String_Node_Str")) {
throw new IllegalArgumentException("String_Node_Str");
}
return openDisplayPhotoForRead(photoFileId);
}
case DATA_ID:
{
long dataId=Long.parseLong(uri.getPathSegments().get(1));
long photoMimetypeId=mDbHelper.get().getMimeTypeId(Photo.CONTENT_ITEM_TYPE);
return openPhotoAssetFile(db,uri,mode,Data._ID + "String_Node_Str" + DataColumns.MIMETYPE_ID+ "String_Node_Str"+ photoMimetypeId,new String[]{String.valueOf(dataId)});
}
case PROFILE_AS_VCARD:
{
final ByteArrayOutputStream localStream=new ByteArrayOutputStream();
outputRawContactsAsVCard(uri,localStream,null,null);
return buildAssetFileDescriptor(localStream);
}
case CONTACTS_AS_VCARD:
{
final ByteArrayOutputStream localStream=new ByteArrayOutputStream();
outputRawContactsAsVCard(uri,localStream,null,null);
return buildAssetFileDescriptor(localStream);
}
case CONTACTS_AS_MULTI_VCARD:
{
final String lookupKeys=uri.getPathSegments().get(2);
final String[] loopupKeyList=lookupKeys.split("String_Node_Str");
final StringBuilder inBuilder=new StringBuilder();
Uri queryUri=Contacts.CONTENT_URI;
int index=0;
for (String lookupKey : loopupKeyList) {
if (index == 0) {
inBuilder.append("String_Node_Str");
}
 else {
inBuilder.append("String_Node_Str");
}
long contactId=lookupContactIdByLookupKey(db,lookupKey);
inBuilder.append(contactId);
index++;
}
inBuilder.append(')');
final String selection=Contacts._ID + "String_Node_Str" + inBuilder.toString();
final ByteArrayOutputStream localStream=new ByteArrayOutputStream();
outputRawContactsAsVCard(queryUri,localStream,selection,null);
return buildAssetFileDescriptor(localStream);
}
default :
throw new FileNotFoundException(mDbHelper.get().exceptionMessage("String_Node_Str",uri));
}
}

Fixed version (ground truth):
public AssetFileDescriptor openAssetFileLocal(Uri uri,String mode) throws FileNotFoundException {
  final long ident=Binder.clearCallingIdentity();
  try {
    return openAssetFileInner(uri,mode);
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}