Reduce calls to installd when resolving volume
Optimizes PackageHelper#resolveInstallVolume to aggressively avoid
querying volume storage statistics unless absolutely neeeded.
The previous implementation queries storage data for each volume on the
device before evaluating which volume to select. The new implementation
defers querying storage stats for a given volume until it is absolutely
neccessary.
For example, if the application is already installed to a particular
volume, only that volume needs to be queried for available space.
In addition, querying for available space on a volume is done in two
steps. The first step does not take into account freeable cache; only
if this pessimistic assessment of available space fails do we call
installd to obtain cache information.
Bug: 138450974
Test: atest frameworks/base/core/tests/coretests/src/android/content/pm/PackageHelperTests.java
&& atest cts/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java
Change-Id: I403318de364d41019cb3d43e93b91cdd06fe1b9c
1 file changed