dexopt: Open class loader context dex files for dex2oat

When compiling secondary dex files, the class loader context may contain
files with 'app_data_file' selabel which dex2oat/dexoptanalyzer are not
allowed to open. Extend installd/dexopt to open these files for them and
pass in their file descriptors.

Dexopt of secondary dex files now starts by invoking dexoptanalyzer with
'--flatten-class-loader-context'. In this mode, dexoptanalyzer will only
parse the given class loader context, flatten it and print a
colon-separated list of dex files to standard output. Dexopt captures
the output and splits the string to obtain a list of context dex files.

It then continues by opening these files for dexoptanalyzer under
dropped privileges, passing the FDs using command line arguments, and
later opening the files again for dex2oat.

Bug: 126674985
Test: atest installd_dexopt_test
Change-Id: Ib9017a67c514ed711e1a03cfac313df796af6af9
2 files changed