From 5e127981fc4ea59100c821d7f737ba71e689954b Mon Sep 17 00:00:00 2001 From: Afzal Najam Date: Fri, 26 Feb 2021 00:12:24 -0500 Subject: [PATCH] Add vm-heap-size option --- README.md | 1 + action.yml | 2 ++ lib/emulator-manager.js | 5 ++++- lib/main.js | 4 +++- src/emulator-manager.ts | 5 +++++ src/main.ts | 4 ++++ 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c87862be5..c0f1c5605 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ jobs: | `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `avdmanager list` and refer to the results under "Available Android Virtual Devices". | | `cores` | Optional | N/A | Number of cores to use for the emulator (`hw.cpu.ncore` in config.ini). | | `ram-size` | Optional | N/A | Size of RAM to use for this AVD, in MB (`hw.ramSize` in config.ini). - e.g. `2048` | +| `vm-heap-size` | Optional | N/A | Size of VM heap for apps in this AVD, in MB (`vm.heapSize` in config.ini). - e.g. `512` | | `sdcard-path-or-size` | Optional | N/A | Path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`. | | `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. | | `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. | diff --git a/action.yml b/action.yml index 19d6dc5cf..6de143526 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,8 @@ inputs: description: 'the number of cores to use for the emulator' ram-size: description: 'the size of RAM for this AVD in MB' + vm-heap-size: + description: 'the VM heap size for this AVD in MB' sdcard-path-or-size: description: 'path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`' avd-name: diff --git a/lib/emulator-manager.js b/lib/emulator-manager.js index 7cea876e4..29a775079 100644 --- a/lib/emulator-manager.js +++ b/lib/emulator-manager.js @@ -35,7 +35,7 @@ let ENABLE_LOGCAT = false; /** * Creates and launches a new AVD instance with the specified configurations. */ -function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations, disableSpellChecker, disableAutofill, longPressTimeout, enableHwKeyboard, enableLogcat) { +function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, vmHeapSize, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations, disableSpellChecker, disableAutofill, longPressTimeout, enableHwKeyboard, enableLogcat) { return __awaiter(this, void 0, void 0, function* () { // create a new AVD const profileOption = profile.trim() !== '' ? `--device '${profile}'` : ''; @@ -48,6 +48,9 @@ function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardP if (ramSize) { yield exec.exec(`sh -c \\"printf 'hw.ramSize=${ramSize}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`); } + if (vmHeapSize) { + yield exec.exec(`sh -c \\"printf 'vm.heapSize=${vmHeapSize}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`); + } if (enableHwKeyboard) { yield exec.exec(`sh -c \\"printf 'hw.keyboard=yes\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`); } diff --git a/lib/main.js b/lib/main.js index 257ab863a..ac0c12fd4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -68,6 +68,8 @@ function run() { console.log(`Cores: ${cores}`); const ramSize = core.getInput('ram-size'); console.log(`RAM size: ${ramSize}`); + const vmHeapSize = core.getInput('vm-heap-size'); + console.log(`VM heap size: ${vmHeapSize}`); // SD card path or size used for creating the AVD const sdcardPathOrSize = core.getInput('sdcard-path-or-size'); console.log(`SD card path or size: ${sdcardPathOrSize}`); @@ -142,7 +144,7 @@ function run() { // install SDK yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion); // launch an emulator - yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations, disableSpellchecker, disableAutofill, longPressTimeout, enableHwKeyboard, enableLogcat); + yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, cores, ramSize, vmHeapSize, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations, disableSpellchecker, disableAutofill, longPressTimeout, enableHwKeyboard, enableLogcat); // execute the custom script try { // move to custom working directory if set diff --git a/src/emulator-manager.ts b/src/emulator-manager.ts index a41096d82..079a6c77c 100644 --- a/src/emulator-manager.ts +++ b/src/emulator-manager.ts @@ -13,6 +13,7 @@ export async function launchEmulator( profile: string, cores: string, ramSize: string, + vmHeapSize: string, sdcardPathOrSize: string, avdName: string, emulatorOptions: string, @@ -39,6 +40,10 @@ export async function launchEmulator( await exec.exec(`sh -c \\"printf 'hw.ramSize=${ramSize}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`); } + if (vmHeapSize) { + await exec.exec(`sh -c \\"printf 'vm.heapSize=${vmHeapSize}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`); + } + if (enableHwKeyboard) { await exec.exec(`sh -c \\"printf 'hw.keyboard=yes\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`); } diff --git a/src/main.ts b/src/main.ts index 3fadc5421..c349227ec 100644 --- a/src/main.ts +++ b/src/main.ts @@ -57,6 +57,9 @@ async function run() { const ramSize = core.getInput('ram-size'); console.log(`RAM size: ${ramSize}`); + const vmHeapSize = core.getInput('vm-heap-size'); + console.log(`VM heap size: ${vmHeapSize}`); + // SD card path or size used for creating the AVD const sdcardPathOrSize = core.getInput('sdcard-path-or-size'); console.log(`SD card path or size: ${sdcardPathOrSize}`); @@ -153,6 +156,7 @@ async function run() { profile, cores, ramSize, + vmHeapSize, sdcardPathOrSize, avdName, emulatorOptions,