Add support for enabling hardware keyboard.

This commit is contained in:
Yang
2021-12-25 02:02:09 +11:00
parent a86d743e55
commit cc46524d3f
9 changed files with 70 additions and 8 deletions
+9 -2
View File
@@ -19,7 +19,8 @@ export async function launchEmulator(
emulatorOptions: string,
disableAnimations: boolean,
disableSpellChecker: boolean,
disableLinuxHardwareAcceleration: boolean
disableLinuxHardwareAcceleration: boolean,
enableHardwareKeyboard: boolean
): Promise<void> {
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
@@ -40,6 +41,10 @@ export async function launchEmulator(
await exec.exec(`sh -c \\"printf 'hw.ramSize=${ramSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
}
if (enableHardwareKeyboard) {
await exec.exec(`sh -c \\"printf 'hw.keyboard=yes\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.');
@@ -63,7 +68,6 @@ export async function launchEmulator(
await waitForDevice();
await exec.exec(`adb shell input keyevent 82`);
// disable animations
if (disableAnimations) {
console.log('Disabling animations.');
await exec.exec(`adb shell settings put global window_animation_scale 0.0`);
@@ -73,6 +77,9 @@ export async function launchEmulator(
if (disableSpellChecker) {
await exec.exec(`adb shell settings put secure spell_checker_enabled 0`);
}
if (enableHardwareKeyboard) {
await exec.exec(`adb shell settings put secure show_ime_with_hard_keyboard 0`);
}
}
/**
+6
View File
@@ -54,6 +54,12 @@ export function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAccele
}
}
export function checkEnableHardwareKeyboard(enableHardwareKeyboard: string): void {
if (!isValidBoolean(enableHardwareKeyboard)) {
throw new Error(`Input for input.enable-hw-keyboard should be either 'true' or 'false'.`);
}
}
export function checkEmulatorBuild(emulatorBuild: string): void {
if (isNaN(Number(emulatorBuild)) || !Number.isInteger(Number(emulatorBuild))) {
throw new Error(`Unexpected emulator build: '${emulatorBuild}'.`);
+10 -2
View File
@@ -9,7 +9,8 @@ import {
checkDisableSpellchecker,
checkDisableLinuxHardwareAcceleration,
checkForceAvdCreation,
checkChannel
checkChannel,
checkEnableHardwareKeyboard
} from './input-validator';
import { launchEmulator, killEmulator } from './emulator-manager';
import * as exec from '@actions/exec';
@@ -94,6 +95,12 @@ async function run() {
const disableLinuxHardwareAcceleration = disableLinuxHardwareAccelerationInput === 'true';
console.log(`disable Linux hardware acceleration: ${disableLinuxHardwareAcceleration}`);
// enable hardware keyboard
const enableHardwareKeyboardInput = core.getInput('enable-hw-keyboard');
checkEnableHardwareKeyboard(enableHardwareKeyboardInput);
const enableHardwareKeyboard = enableHardwareKeyboardInput === 'true';
console.log(`enable hardware keyboard: ${enableHardwareKeyboard}`);
// emulator build
const emulatorBuildInput = core.getInput('emulator-build');
if (emulatorBuildInput) {
@@ -154,7 +161,8 @@ async function run() {
emulatorOptions,
disableAnimations,
disableSpellchecker,
disableLinuxHardwareAcceleration
disableLinuxHardwareAcceleration,
enableHardwareKeyboard
);
// execute the custom script