Merge "Refine the DSU SD card support" am: da932b4a45

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1540921

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2fb1cea8aa1b83ee9218cfca9f88c02d3607ff4b
This commit is contained in:
Howard Chen
2021-01-27 09:14:43 +00:00
committed by Automerger Merge Worker

View File

@@ -22,7 +22,6 @@ import android.gsi.AvbPublicKey;
import android.gsi.GsiProgress; import android.gsi.GsiProgress;
import android.gsi.IGsiService; import android.gsi.IGsiService;
import android.gsi.IGsiServiceCallback; import android.gsi.IGsiServiceCallback;
import android.os.Environment;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
@@ -30,7 +29,7 @@ import android.os.SystemProperties;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.image.IDynamicSystemService; import android.os.image.IDynamicSystemService;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.os.storage.StorageVolume; import android.os.storage.VolumeInfo;
import android.util.Slog; import android.util.Slog;
import java.io.File; import java.io.File;
@@ -88,16 +87,17 @@ public class DynamicSystemService extends IDynamicSystemService.Stub {
String path = SystemProperties.get("os.aot.path"); String path = SystemProperties.get("os.aot.path");
if (path.isEmpty()) { if (path.isEmpty()) {
final int userId = UserHandle.myUserId(); final int userId = UserHandle.myUserId();
final StorageVolume[] volumes = final StorageManager sm = mContext.getSystemService(StorageManager.class);
StorageManager.getVolumeList(userId, StorageManager.FLAG_FOR_WRITE); for (VolumeInfo volume : sm.getVolumes()) {
for (StorageVolume volume : volumes) { if (volume.getType() != volume.TYPE_PUBLIC) {
if (volume.isEmulated()) continue; continue;
if (!volume.isRemovable()) continue; }
if (!Environment.MEDIA_MOUNTED.equals(volume.getState())) continue; if (!volume.isMountedWritable()) {
File sdCard = volume.getPathFile(); continue;
if (sdCard.isDirectory()) { }
path = new File(sdCard, dsuSlot).getPath(); File sd_internal = volume.getInternalPathForUser(userId);
break; if (sd_internal != null) {
path = new File(sd_internal, dsuSlot).getPath();
} }
} }
if (path.isEmpty()) { if (path.isEmpty()) {