mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-03 10:59:32 +00:00
Allow increasing main storage size (sdcard is separate storage) (#219)
* Allow increasing disk size - Issue #184 * Fix checkDiskSize validator * Fix lint errors * Size modifier without a number is unacceptable "G" is not the same as "1G" * Implement checkDiskSize validator tests
This commit is contained in:
committed by
GitHub
parent
62d97062b0
commit
4e0dd2c343
@@ -14,6 +14,7 @@ export async function launchEmulator(
|
||||
cores: string,
|
||||
ramSize: string,
|
||||
sdcardPathOrSize: string,
|
||||
diskSize: string,
|
||||
avdName: string,
|
||||
forceAvdCreation: boolean,
|
||||
emulatorOptions: string,
|
||||
@@ -45,6 +46,10 @@ export async function launchEmulator(
|
||||
await exec.exec(`sh -c \\"printf 'hw.keyboard=yes\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||
}
|
||||
|
||||
if (diskSize) {
|
||||
await exec.exec(`sh -c \\"printf 'disk.dataPartition.size=${diskSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||
}
|
||||
|
||||
//turn off hardware acceleration on Linux
|
||||
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
||||
console.log('Disabling Linux hardware acceleration.');
|
||||
|
||||
@@ -69,3 +69,20 @@ export function checkEmulatorBuild(emulatorBuild: string): void {
|
||||
function isValidBoolean(value: string): boolean {
|
||||
return value === 'true' || value === 'false';
|
||||
}
|
||||
|
||||
export function checkDiskSize(diskSize: string): void {
|
||||
// Disk size can be empty - the default value
|
||||
if (diskSize) {
|
||||
// Can also be number of bytes
|
||||
if (isNaN(Number(diskSize)) || !Number.isInteger(Number(diskSize))) {
|
||||
// Disk size can have a size multiplier at the end K, M or G
|
||||
const diskSizeUpperCase = diskSize.toUpperCase();
|
||||
if (diskSizeUpperCase.endsWith('K') || diskSizeUpperCase.endsWith('M') || diskSizeUpperCase.endsWith('G')) {
|
||||
const diskSizeNoModifier: string = diskSize.slice(0, -1);
|
||||
if (0 == diskSizeNoModifier.length || isNaN(Number(diskSizeNoModifier)) || !Number.isInteger(Number(diskSizeNoModifier))) {
|
||||
throw new Error(`Unexpected disk size: '${diskSize}'.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -10,7 +10,8 @@ import {
|
||||
checkDisableLinuxHardwareAcceleration,
|
||||
checkForceAvdCreation,
|
||||
checkChannel,
|
||||
checkEnableHardwareKeyboard
|
||||
checkEnableHardwareKeyboard,
|
||||
checkDiskSize
|
||||
} from './input-validator';
|
||||
import { launchEmulator, killEmulator } from './emulator-manager';
|
||||
import * as exec from '@actions/exec';
|
||||
@@ -63,6 +64,10 @@ async function run() {
|
||||
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
||||
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
||||
|
||||
const diskSize = core.getInput('disk-size');
|
||||
checkDiskSize(diskSize);
|
||||
console.log(`Disk size: ${diskSize}`);
|
||||
|
||||
// custom name used for creating the AVD
|
||||
const avdName = core.getInput('avd-name');
|
||||
console.log(`AVD name: ${avdName}`);
|
||||
@@ -156,6 +161,7 @@ async function run() {
|
||||
cores,
|
||||
ramSize,
|
||||
sdcardPathOrSize,
|
||||
diskSize,
|
||||
avdName,
|
||||
forceAvdCreation,
|
||||
emulatorOptions,
|
||||
|
||||
Reference in New Issue
Block a user