Refactor TranscodeHelper#shouldTranscode logic

This new design takes us closer to supporting additional media
capabilities and file formats

It is based around representing app media capabilities and file media
support as bit flags. This allows us decide whether to transcode or
not with the following bit manipulations on fileMediaFlags,
appSupportedMediaFlags and appUnsupportedMediaFlags:
-fileMediaflags are a bit mask of media formats contained in a file
-appSupportedMediaFlags are a bit mask of media format capabilities an
app supports
-appUnsupportedMediaFlaga are a bit mask of media format capabilities
app does not support

1. fileFlagsExplicitlySupported: appSupportedMediaFlags & fileMediaFlags
2. fileFlagsNotExplicitlySupported: fileFlagsExplicitlySupported ^
fileMediaFlags
3. fileFlagsExplicitlyUnsupported: fileFlagsNotExplicitlySupported &
appUnsupportedMediaFlags

We can now make a 3-way decision:
if (fileFlagsNotExplicitlySupported == 0) {
  // The app supports all the fileFlags
} else if (fileFlagsExplicitlyUnsupported != 0) {
  // The app does not support some of the file flags
} else {
  // The file contains flags that the app neither explicitly supports
  // or does not support
}

Most of the checks to determine if a file should be transcoded for an
app are expressed as the bit manipulations above and handled in
checkFlags()

Bug: 173491972
Test: atest TranscodeTest

Change-Id: Ib0f4de54db42b789a02147a9b7cc10e739771a4d
2 files changed