Introduce RedactingFileDescriptor.

Files on disk can sometimes contain content that should be redacted
based on the permissions of the remote caller.  (For example, EXIF
data containing location information shouldn't be visible to apps
that haven't been granted the location permission.)

This class provides an easy way to "redact" ranges within an
underlying file, without the overhead of making a duplicate copy
of the file, or the limitations of returning a non-seekable FD.

Bug: 110228267
Test: atest android.os.RedactingFileDescriptorTest
Change-Id: I0b3b9f642573f6165e152e7568cdaf55f0af7134
2 files changed