From 8a9f0075537fee7d04af065b805f9bd361418395 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Tue, 20 Dec 2022 15:52:46 -0800 Subject: Add a debug workaround for the tests. Bug: 261373611 Test: atest InstallSessionParamsUnitTest Change-Id: I8c05bcce1b8f4e5c7a7c0168323995516093fa38 --- .../com/android/internal/content/InstallLocationUtils.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/content/InstallLocationUtils.java b/core/java/com/android/internal/content/InstallLocationUtils.java index c456cf3a4bb6..4d9c09e92617 100644 --- a/core/java/com/android/internal/content/InstallLocationUtils.java +++ b/core/java/com/android/internal/content/InstallLocationUtils.java @@ -31,6 +31,7 @@ import android.os.Environment; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.SystemProperties; import android.os.storage.IStorageManager; import android.os.storage.StorageManager; 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 // volume with most space + String bestCandidate = !volumePaths.isEmpty() ? volumePaths.keyAt(0) : null; if (volumePaths.size() == 1) { if (checkFitOnVolume(storageManager, volumePaths.valueAt(0), params)) { - return volumePaths.keyAt(0); + return bestCandidate; } } else { - String bestCandidate = null; long bestCandidateAvailBytes = Long.MIN_VALUE; for (String vol : volumePaths.keySet()) { 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 (bestCandidate != null && 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. " + " allow3rdPartyOnInternal? " + allow3rdPartyOnInternal); } -- cgit v1.2.3-59-g8ed1b