apexd: better allocation strategy for ApexImageManager

ApexImageManager uses different allocation methods to store APEX files
in the backing storage.
- Use a (logically) single backing file and allocate free space to each
  APEX if the allocation alignment is big.
- Create a backing file for each APEX otherwise.

This change improves the former case so that APEXes are stored with less
fregmentation. The idea is to allocate the largest extent from the list
of free extents.

Added test case illustrates the basic idea and how it reduces the
fragmentation.

Bug: 427371267
Flag: com.android.apex.flags.mount_before_data
Test: ApexTestCases
Change-Id: I744049ed2a743951ec3691ef79d2d72e5092bd90
4 files changed