diff options
| author | 2021-01-27 09:49:43 +0000 | |
|---|---|---|
| committer | 2021-01-27 09:49:43 +0000 | |
| commit | 3b3dd247cd32df70ccaa237a1b63a585d56a4aa4 (patch) | |
| tree | 0967997f68b38dca824f650d792de02d53a8eaf8 | |
| parent | b0247948efb150618d22a095d10dcc6b1ee30cfc (diff) | |
| parent | adf0f11de8f9445fda7784fd5a5371c37eb97d0d (diff) | |
Merge "Refine the DSU SD card support" am: da932b4a45 am: adf0f11de8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1540921
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Iaff78c43d6bb00ce8e2130edab9f4537dd18ad31
| -rw-r--r-- | services/core/java/com/android/server/DynamicSystemService.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/DynamicSystemService.java b/services/core/java/com/android/server/DynamicSystemService.java index f2b63a642c29..88ce2208adcb 100644 --- a/services/core/java/com/android/server/DynamicSystemService.java +++ b/services/core/java/com/android/server/DynamicSystemService.java @@ -22,7 +22,6 @@ import android.gsi.AvbPublicKey; import android.gsi.GsiProgress; import android.gsi.IGsiService; import android.gsi.IGsiServiceCallback; -import android.os.Environment; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; @@ -30,7 +29,7 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.os.image.IDynamicSystemService; import android.os.storage.StorageManager; -import android.os.storage.StorageVolume; +import android.os.storage.VolumeInfo; import android.util.Slog; import java.io.File; @@ -88,16 +87,17 @@ public class DynamicSystemService extends IDynamicSystemService.Stub { String path = SystemProperties.get("os.aot.path"); if (path.isEmpty()) { final int userId = UserHandle.myUserId(); - final StorageVolume[] volumes = - StorageManager.getVolumeList(userId, StorageManager.FLAG_FOR_WRITE); - for (StorageVolume volume : volumes) { - if (volume.isEmulated()) continue; - if (!volume.isRemovable()) continue; - if (!Environment.MEDIA_MOUNTED.equals(volume.getState())) continue; - File sdCard = volume.getPathFile(); - if (sdCard.isDirectory()) { - path = new File(sdCard, dsuSlot).getPath(); - break; + final StorageManager sm = mContext.getSystemService(StorageManager.class); + for (VolumeInfo volume : sm.getVolumes()) { + if (volume.getType() != volume.TYPE_PUBLIC) { + continue; + } + if (!volume.isMountedWritable()) { + continue; + } + File sd_internal = volume.getInternalPathForUser(userId); + if (sd_internal != null) { + path = new File(sd_internal, dsuSlot).getPath(); } } if (path.isEmpty()) { |