UNPKG

appium-android-driver

Version:

Android UiAutomator and Chrome support for Appium

69 lines 2.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isIMEActivated = isIMEActivated; exports.availableIMEEngines = availableIMEEngines; exports.getActiveIMEEngine = getActiveIMEEngine; exports.activateIMEEngine = activateIMEEngine; exports.deactivateIMEEngine = deactivateIMEEngine; const driver_1 = require("appium/driver"); /** * Checks if an IME (Input Method Editor) is activated. * * @returns Promise that resolves to `true` (IME is always activated on Android devices). */ async function isIMEActivated() { // IME is always activated on Android devices return true; } /** * Gets the list of available IME engines. * * @returns Promise that resolves to an array of IME engine identifiers. */ async function availableIMEEngines() { this.log.debug('Retrieving available IMEs'); const engines = await this.adb.availableIMEs(); this.log.debug(`Engines: ${JSON.stringify(engines)}`); return engines; } /** * Gets the currently active IME engine. * * @returns Promise that resolves to the active IME engine identifier. */ async function getActiveIMEEngine() { this.log.debug('Retrieving current default IME'); return String(await this.adb.defaultIME()); } /** * Activates an IME engine. * * @param imeId The IME engine identifier to activate. * @returns Promise that resolves when the IME is activated. * @throws {errors.IMENotAvailableError} If the IME is not available. */ async function activateIMEEngine(imeId) { this.log.debug(`Attempting to activate IME ${imeId}`); const availableEngines = await this.adb.availableIMEs(); if (availableEngines.indexOf(imeId) === -1) { this.log.debug('IME not found, failing'); throw new driver_1.errors.IMENotAvailableError(); } this.log.debug('Found installed IME, attempting to activate'); await this.adb.enableIME(imeId); await this.adb.setIME(imeId); } /** * Deactivates the currently active IME engine. * * @returns Promise that resolves when the IME is deactivated. */ async function deactivateIMEEngine() { const currentEngine = await this.getActiveIMEEngine(); // XXX: this allowed 'null' to be passed into `adb.shell` if (currentEngine) { this.log.debug(`Attempting to deactivate ${currentEngine}`); await this.adb.disableIME(currentEngine); } } //# sourceMappingURL=ime.js.map