@SuppressLint("SetWorldReadable")
  @Override
  public void addRecord(RecordBuilderImpl recordBuilder) throws IOException {
    recordBuilder.checkState();
    if (mAllNames.contains(recordBuilder.getName())) {
      if (recordBuilder.hasExplicitName()) {
        throw new AssertionError(
            "Can't create multiple screenshots with the same name: " + recordBuilder.getName());
      }

      throw new AssertionError(
          "Can't create multiple screenshots from the same test, or "
              + "use .setName() to name each screenshot differently");
    }

    Tiling tiling = recordBuilder.getTiling();

    MetadataRecorder.ScreenshotMetadataRecorder screenshotNode =
        mMetadataRecorder
            .addNewScreenshot()
            .withDescription(recordBuilder.getDescription())
            .withName(recordBuilder.getName())
            .withTestClass(recordBuilder.getTestClass())
            .withTestName(recordBuilder.getTestName())
            .withTileWidth(tiling.getWidth())
            .withTileHeight(tiling.getHeight())
            .withViewHierarchy(getViewHierarchyFilename(recordBuilder.getName()))
            .withAxIssues(getAxIssuesFilename(recordBuilder.getName()))
            .withExtras(recordBuilder.getExtras());

    if (recordBuilder.getError() != null) {
      screenshotNode.withError(recordBuilder.getError());
    } else {
      saveTiling(screenshotNode, recordBuilder);
    }

    if (recordBuilder.getGroup() != null) {
      screenshotNode.withGroup(recordBuilder.getGroup());
    }

    mAllNames.add(recordBuilder.getName());

    screenshotNode.save();
  }
Add the given record to the album. This is called by RecordBuilderImpl#record() and so is an
internal detail.
core/src/main/java/com/facebook/testing/screenshot/internal/AlbumImpl.java