Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab2213b0 authored by Howard Chen's avatar Howard Chen
Browse files

Refine the DSU SD card support

This is part of the work to refine the DSU SD card support. This CL
replaces the StorageVolume with the VolumeInfo to make sure the
installation path starts with a prefix expected by gsid.

Bug: 171861574
Test: execute following command on a device with a SD card inserted
   adb shell am start-activity \
    -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \
    -a android.os.image.action.START_INSTALL \
    -d file:///storage/emulated/0/Download/system.raw.gz \
    --el KEY_SYSTEM_SIZE $(du -b system.raw|cut -f1) \
    --el KEY_USERDATA_SIZE 4294967296

Change-Id: I36083d755c77c755a630f9070d75c14c85282866
parent 883c34a4
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -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()) {