Skip to content

Commit

Permalink
Add vm-heap-size option
Browse files Browse the repository at this point in the history
  • Loading branch information
AfzalivE committed Feb 26, 2021
1 parent 325f63a commit 5e12798
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. |
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion lib/emulator-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}'` : '';
Expand All @@ -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`);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/emulator-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function launchEmulator(
profile: string,
cores: string,
ramSize: string,
vmHeapSize: string,
sdcardPathOrSize: string,
avdName: string,
emulatorOptions: string,
Expand All @@ -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`);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -153,6 +156,7 @@ async function run() {
profile,
cores,
ramSize,
vmHeapSize,
sdcardPathOrSize,
avdName,
emulatorOptions,
Expand Down

0 comments on commit 5e12798

Please sign in to comment.