diff options
| author | 2021-02-18 20:14:05 +0800 | |
|---|---|---|
| committer | 2021-02-19 05:47:23 +0000 | |
| commit | 5a276985c27862441a9ddc3a2b06e8a53f47f059 (patch) | |
| tree | 1aa51bdf126ad4874ac09ab1a6d207beea933c6e | |
| parent | 9a90bb9efa170859f920a9fb34ee1efc8f366afe (diff) | |
Support cuttlefish with an emulated 2GB SD
Currently we have an assumption that SD card's size is bigger
than the internal /data so the DSU would always choose SD as the
destination when possible. This assumption is not valid for
cuttlefish which only have an emulated 2G SD
Bug: 179980369
Bug: 171861574
Test: A physical device with a SD card inserted and
CF local instance with an emulated SD
Change-Id: I15c5d38ab316b8d65546d876fe235d0c9c6ed6aa
| -rw-r--r-- | services/core/java/com/android/server/DynamicSystemService.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/DynamicSystemService.java b/services/core/java/com/android/server/DynamicSystemService.java index 88ce2208adcb..e29e894a5cc0 100644 --- a/services/core/java/com/android/server/DynamicSystemService.java +++ b/services/core/java/com/android/server/DynamicSystemService.java @@ -28,6 +28,7 @@ import android.os.ServiceManager; import android.os.SystemProperties; import android.os.UserHandle; import android.os.image.IDynamicSystemService; +import android.os.storage.DiskInfo; import android.os.storage.StorageManager; import android.os.storage.VolumeInfo; import android.util.Slog; @@ -40,6 +41,7 @@ import java.io.File; */ public class DynamicSystemService extends IDynamicSystemService.Stub { private static final String TAG = "DynamicSystemService"; + private static final long MINIMUM_SD_MB = (30L << 10); private static final int GSID_ROUGH_TIMEOUT_MS = 8192; private static final String PATH_DEFAULT = "/data/gsi/"; private Context mContext; @@ -95,6 +97,13 @@ public class DynamicSystemService extends IDynamicSystemService.Stub { if (!volume.isMountedWritable()) { continue; } + DiskInfo disk = volume.getDisk(); + long mega = disk.size >> 20; + Slog.i(TAG, volume.getPath() + ": " + mega + " MB"); + if (mega < MINIMUM_SD_MB) { + Slog.i(TAG, volume.getPath() + ": insufficient storage"); + continue; + } File sd_internal = volume.getInternalPathForUser(userId); if (sd_internal != null) { path = new File(sd_internal, dsuSlot).getPath(); |