Add SD card support for AOT
Some low end devices do not have enough space in internal storage and need a SD card for the AndroidOnTap to work. This CL makes AOT to use SD card when it exists. Also it adds a "os.aot.path" system property to overwrite the path for testing. Bug: 128801963 Test: adb shell am start-activity \ -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \ -a android.os.image.action.START_INSTALL \ --es KEY_SYSTEM_URL file:///storage/emulated/0/Download/system.raw.gz \ --el KEY_SYSTEM_SIZE $(du -b system.raw) \ --el KEY_USERDATA_SIZE 8589934592 w/wo the "os.aot.path" system property and logcat Change-Id: I1b35b39b207a68236bc44f8b3c4b952c7dbd5a1e
This commit is contained in:
@@ -18,16 +18,23 @@ package com.android.server;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.gsi.GsiInstallParams;
|
||||
import android.gsi.GsiProgress;
|
||||
import android.gsi.IGsiService;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.os.IBinder.DeathRecipient;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
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.util.Slog;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* DynamicSystemService implements IDynamicSystemService. It provides permission check before
|
||||
* passing requests to gsid
|
||||
@@ -36,7 +43,7 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
|
||||
private static final String TAG = "DynamicSystemService";
|
||||
private static final String NO_SERVICE_ERROR = "no gsiservice";
|
||||
private static final int GSID_ROUGH_TIMEOUT_MS = 8192;
|
||||
|
||||
private static final String PATH_DEFAULT = "/data/gsi";
|
||||
private Context mContext;
|
||||
private volatile IGsiService mGsiService;
|
||||
|
||||
@@ -100,7 +107,32 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
|
||||
|
||||
@Override
|
||||
public boolean startInstallation(long systemSize, long userdataSize) throws RemoteException {
|
||||
return getGsiService().startGsiInstall(systemSize, userdataSize, true) == 0;
|
||||
// priority from high to low: sysprop -> sdcard -> /data
|
||||
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 = sdCard.getPath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (path.isEmpty()) {
|
||||
path = PATH_DEFAULT;
|
||||
}
|
||||
Slog.i(TAG, "startInstallation -> " + path);
|
||||
}
|
||||
GsiInstallParams installParams = new GsiInstallParams();
|
||||
installParams.installDir = path;
|
||||
installParams.gsiSize = systemSize;
|
||||
installParams.userdataSize = userdataSize;
|
||||
return getGsiService().beginGsiInstall(installParams) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user