Merge changes from topic "cherrypick-checkSessionParams-ixtl2uw7uua" into tm-qpr-dev

* changes:
  [RESTRICT AUTOMERGE] Null is a valid volume uuid.
  [RESTRICT AUTOMERGE] Add a debug workaround for the tests.
This commit is contained in:
TreeHugger Robot
2023-05-04 21:04:38 +00:00
committed by Android (Google) Code Review

View File

@@ -31,6 +31,7 @@ import android.os.Environment;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.storage.IStorageManager; import android.os.storage.IStorageManager;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.os.storage.StorageVolume; import android.os.storage.StorageVolume;
@@ -261,12 +262,12 @@ public class InstallLocationUtils {
// We're left with new installations with either preferring external or auto, so just pick // We're left with new installations with either preferring external or auto, so just pick
// volume with most space // volume with most space
String bestCandidate = !volumePaths.isEmpty() ? volumePaths.keyAt(0) : null;
if (volumePaths.size() == 1) { if (volumePaths.size() == 1) {
if (checkFitOnVolume(storageManager, volumePaths.valueAt(0), params)) { if (checkFitOnVolume(storageManager, volumePaths.valueAt(0), params)) {
return volumePaths.keyAt(0); return bestCandidate;
} }
} else { } else {
String bestCandidate = null;
long bestCandidateAvailBytes = Long.MIN_VALUE; long bestCandidateAvailBytes = Long.MIN_VALUE;
for (String vol : volumePaths.keySet()) { for (String vol : volumePaths.keySet()) {
final String volumePath = volumePaths.get(vol); final String volumePath = volumePaths.get(vol);
@@ -289,6 +290,14 @@ public class InstallLocationUtils {
} }
// For new installations of a predefined size, check property to let it through
// regardless of the actual free space.
if (!volumePaths.isEmpty() && Integer.MAX_VALUE == params.sizeBytes
&& SystemProperties.getBoolean("debug.pm.install_skip_size_check_for_maxint",
false)) {
return bestCandidate;
}
throw new IOException("No special requests, but no room on allowed volumes. " throw new IOException("No special requests, but no room on allowed volumes. "
+ " allow3rdPartyOnInternal? " + allow3rdPartyOnInternal); + " allow3rdPartyOnInternal? " + allow3rdPartyOnInternal);
} }