shadows/framework/src/main/java/org/robolectric/shadows/ShadowResources.java
@Implementation
  protected AssetFileDescriptor openRawResourceFd(int id) throws Resources.NotFoundException {
    if (isLegacyAssetManager()) {
      InputStream inputStream = openRawResource(id);
      if (!(inputStream instanceof FileInputStream)) {
        // todo fixme
        return null;
      }

      FileInputStream fis = (FileInputStream) inputStream;
      try {
        return new AssetFileDescriptor(ParcelFileDescriptor.dup(fis.getFD()), 0,
            fis.getChannel().size());
      } catch (IOException e) {
        throw newNotFoundException(id);
      }
    } else {
      return directlyOn(realResources, Resources.class).openRawResourceFd(id);
    }
  }
@Implementation
  protected AssetFileDescriptor openRawResourceFd(int id) throws Resources.NotFoundException {
    if (isLegacyAssetManager()) {
      InputStream inputStream = openRawResource(id);
      if (!(inputStream instanceof FileInputStream)) {
        // todo fixme
        return null;
      }

      FileInputStream fis = (FileInputStream) inputStream;
      try {
        return new AssetFileDescriptor(ParcelFileDescriptor.dup(fis.getFD()), 0,
            fis.getChannel().size());
      } catch (IOException e) {
        throw newNotFoundException(id);
      }
    } else {
      return directlyOn(realResources, Resources.class).openRawResourceFd(id);
    }
  }
@ Implementation protected AssetFileDescriptor openRawResourceFd ( int id ) throws Resources . NotFoundException { if ( isLegacyAssetManager ( ) ) { InputStream inputStream = openRawResource ( id ) ; if ( ! ( inputStream instanceof FileInputStream ) ) { // todo fixme return null ; } FileInputStream fis = ( FileInputStream ) inputStream ; try { return new AssetFileDescriptor ( ParcelFileDescriptor . dup ( fis . getFD ( ) ) , 0 , fis . getChannel ( ) . size ( ) ) ; } catch ( IOException e ) { throw newNotFoundException ( id ) ; } } else { return directlyOn ( realResources , Resources . class ) . openRawResourceFd ( id ) ; } }
Since {@link AssetFileDescriptor}s are not yet supported by Robolectric, {@code null} will be
returned if the resource is found. If the resource cannot be found, {@link
Resources.NotFoundException} will be thrown.
Since {