appium-android-driver
Version:
Android UiAutomator and Chrome support for Appium
66 lines • 2.12 kB
JavaScript
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");
/**
* @this {import('../driver').AndroidDriver}
* @returns {Promise<boolean>}
*/
async function isIMEActivated() {
// IME is always activated on Android devices
return true;
}
/**
* @this {import('../driver').AndroidDriver}
* @returns {Promise<string[]>}
*/
async function availableIMEEngines() {
this.log.debug('Retrieving available IMEs');
let engines = await this.adb.availableIMEs();
this.log.debug(`Engines: ${JSON.stringify(engines)}`);
return engines;
}
/**
* @this {import('../driver').AndroidDriver}
* @returns {Promise<string>}
*/
async function getActiveIMEEngine() {
this.log.debug('Retrieving current default IME');
return String(await this.adb.defaultIME());
}
/**
* @this {import('../driver').AndroidDriver}
* @param {string} imeId
* @returns {Promise<void>}
*/
async function activateIMEEngine(imeId) {
this.log.debug(`Attempting to activate IME ${imeId}`);
let 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);
}
/**
* @this {import('../driver').AndroidDriver}
* @returns {Promise<void>}
*/
async function deactivateIMEEngine() {
let 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);
}
}
/**
* @typedef {import('appium-adb').ADB} ADB
*/
//# sourceMappingURL=ime.js.map
;