mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-08-31 17:49:33 +00:00
Fix pre-emulator-launch-script (#439)
This commit is contained in:
+18
-4
@@ -32,16 +32,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.killEmulator = exports.launchEmulator = void 0;
|
exports.killEmulator = exports.launchEmulator = exports.createAvd = void 0;
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
/**
|
/**
|
||||||
* Creates and launches a new AVD instance with the specified configurations.
|
* Creates a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
function launchEmulator(systemImageApiLevel, target, arch, profile, cores, ramSize, heapSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorBootTimeout, port, emulatorOptions, disableAnimations, disableSpellChecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard) {
|
function createAvd(arch, avdName, cores, diskSize, enableHardwareKeyboard, forceAvdCreation, heapSize, profile, ramSize, sdcardPathOrSize, systemImageApiLevel, target) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Launch Emulator`);
|
console.log(`::group::Create AVD`);
|
||||||
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
||||||
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
||||||
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
||||||
@@ -72,6 +72,20 @@ function launchEmulator(systemImageApiLevel, target, arch, profile, cores, ramSi
|
|||||||
yield exec.exec(`sh -c \\"printf '${configContent}' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini"`);
|
yield exec.exec(`sh -c \\"printf '${configContent}' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.createAvd = createAvd;
|
||||||
|
/**
|
||||||
|
* Launches an existing AVD instance with the specified configurations.
|
||||||
|
*/
|
||||||
|
function launchEmulator(avdName, disableAnimations, disableLinuxHardwareAcceleration, disableSpellChecker, emulatorBootTimeout, emulatorOptions, enableHardwareKeyboard, port) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
|
console.log(`::group::Launch Emulator`);
|
||||||
// turn off hardware acceleration on Linux
|
// turn off hardware acceleration on Linux
|
||||||
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
||||||
console.log('Disabling Linux hardware acceleration.');
|
console.log('Disabling Linux hardware acceleration.');
|
||||||
|
|||||||
+3
-1
@@ -184,6 +184,8 @@ function run() {
|
|||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
// install SDK
|
// install SDK
|
||||||
yield (0, sdk_installer_1.installAndroidSdk)(apiLevel, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
yield (0, sdk_installer_1.installAndroidSdk)(apiLevel, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
|
// create AVD
|
||||||
|
yield (0, emulator_manager_1.createAvd)(arch, avdName, cores, diskSize, enableHardwareKeyboard, forceAvdCreation, heapSize, profile, ramSize, sdcardPathOrSize, systemImageApiLevel, target);
|
||||||
// execute pre emulator launch script if set
|
// execute pre emulator launch script if set
|
||||||
if (preEmulatorLaunchScripts !== undefined) {
|
if (preEmulatorLaunchScripts !== undefined) {
|
||||||
console.log(`::group::Run pre emulator launch script`);
|
console.log(`::group::Run pre emulator launch script`);
|
||||||
@@ -202,7 +204,7 @@ function run() {
|
|||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
yield (0, emulator_manager_1.launchEmulator)(systemImageApiLevel, target, arch, profile, cores, ramSize, heapSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorBootTimeout, port, emulatorOptions, disableAnimations, disableSpellchecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard);
|
yield (0, emulator_manager_1.launchEmulator)(avdName, disableAnimations, disableLinuxHardwareAcceleration, disableSpellchecker, emulatorBootTimeout, emulatorOptions, enableHardwareKeyboard, port);
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
// move to custom working directory if set
|
// move to custom working directory if set
|
||||||
|
|||||||
+32
-18
@@ -2,30 +2,24 @@ import * as exec from '@actions/exec';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and launches a new AVD instance with the specified configurations.
|
* Creates a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
export async function launchEmulator(
|
export async function createAvd(
|
||||||
systemImageApiLevel: string,
|
|
||||||
target: string,
|
|
||||||
arch: string,
|
arch: string,
|
||||||
profile: string,
|
|
||||||
cores: string,
|
|
||||||
ramSize: string,
|
|
||||||
heapSize: string,
|
|
||||||
sdcardPathOrSize: string,
|
|
||||||
diskSize: string,
|
|
||||||
avdName: string,
|
avdName: string,
|
||||||
|
cores: string,
|
||||||
|
diskSize: string,
|
||||||
|
enableHardwareKeyboard: boolean,
|
||||||
forceAvdCreation: boolean,
|
forceAvdCreation: boolean,
|
||||||
emulatorBootTimeout: number,
|
heapSize: string,
|
||||||
port: number,
|
profile: string,
|
||||||
emulatorOptions: string,
|
ramSize: string,
|
||||||
disableAnimations: boolean,
|
sdcardPathOrSize: string,
|
||||||
disableSpellChecker: boolean,
|
systemImageApiLevel: string,
|
||||||
disableLinuxHardwareAcceleration: boolean,
|
target: string
|
||||||
enableHardwareKeyboard: boolean
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Launch Emulator`);
|
console.log(`::group::Create AVD`);
|
||||||
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
||||||
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
||||||
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
||||||
@@ -61,6 +55,26 @@ export async function launchEmulator(
|
|||||||
await exec.exec(`sh -c \\"printf '${configContent}' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini"`);
|
await exec.exec(`sh -c \\"printf '${configContent}' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches an existing AVD instance with the specified configurations.
|
||||||
|
*/
|
||||||
|
export async function launchEmulator(
|
||||||
|
avdName: string,
|
||||||
|
disableAnimations: boolean,
|
||||||
|
disableLinuxHardwareAcceleration: boolean,
|
||||||
|
disableSpellChecker: boolean,
|
||||||
|
emulatorBootTimeout: number,
|
||||||
|
emulatorOptions: string,
|
||||||
|
enableHardwareKeyboard: boolean,
|
||||||
|
port: number
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
console.log(`::group::Launch Emulator`);
|
||||||
|
|
||||||
// turn off hardware acceleration on Linux
|
// turn off hardware acceleration on Linux
|
||||||
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
||||||
|
|||||||
+5
-21
@@ -14,7 +14,7 @@ import {
|
|||||||
checkPort,
|
checkPort,
|
||||||
MIN_PORT,
|
MIN_PORT,
|
||||||
} from './input-validator';
|
} from './input-validator';
|
||||||
import { launchEmulator, killEmulator } from './emulator-manager';
|
import { createAvd, launchEmulator, killEmulator } from './emulator-manager';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import { parseScript } from './script-parser';
|
import { parseScript } from './script-parser';
|
||||||
import { getChannelId } from './channel-id-mapper';
|
import { getChannelId } from './channel-id-mapper';
|
||||||
@@ -191,6 +191,9 @@ async function run() {
|
|||||||
// install SDK
|
// install SDK
|
||||||
await installAndroidSdk(apiLevel, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
await installAndroidSdk(apiLevel, systemImageApiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
|
|
||||||
|
// create AVD
|
||||||
|
await createAvd(arch, avdName, cores, diskSize, enableHardwareKeyboard, forceAvdCreation, heapSize, profile, ramSize, sdcardPathOrSize, systemImageApiLevel, target);
|
||||||
|
|
||||||
// execute pre emulator launch script if set
|
// execute pre emulator launch script if set
|
||||||
if (preEmulatorLaunchScripts !== undefined) {
|
if (preEmulatorLaunchScripts !== undefined) {
|
||||||
console.log(`::group::Run pre emulator launch script`);
|
console.log(`::group::Run pre emulator launch script`);
|
||||||
@@ -209,26 +212,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
await launchEmulator(
|
await launchEmulator(avdName, disableAnimations, disableLinuxHardwareAcceleration, disableSpellchecker, emulatorBootTimeout, emulatorOptions, enableHardwareKeyboard, port);
|
||||||
systemImageApiLevel,
|
|
||||||
target,
|
|
||||||
arch,
|
|
||||||
profile,
|
|
||||||
cores,
|
|
||||||
ramSize,
|
|
||||||
heapSize,
|
|
||||||
sdcardPathOrSize,
|
|
||||||
diskSize,
|
|
||||||
avdName,
|
|
||||||
forceAvdCreation,
|
|
||||||
emulatorBootTimeout,
|
|
||||||
port,
|
|
||||||
emulatorOptions,
|
|
||||||
disableAnimations,
|
|
||||||
disableSpellchecker,
|
|
||||||
disableLinuxHardwareAcceleration,
|
|
||||||
enableHardwareKeyboard
|
|
||||||
);
|
|
||||||
|
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user