diff --git a/README.md b/README.md index ad82917c8..56641240e 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ appium:buildToolsVersion | The version of Android build tools to use. By default appium:skipLogcatCapture | Being set to `true` disables automatic logcat output collection during the test run. `false` by default appium:suppressKillServer | Being set to `true` prevents the driver from ever killing the ADB server explicitly. Could be useful if ADB is connected wirelessly. `false` by default appium:ignoreHiddenApiPolicyError | Being set to `true` ignores a failure while changing hidden API access policies. Could be useful on some devices, where access to these policies has been locked by its vendor. `false` by default. +appium:hideKeyboard | Being set to `true` hides the on-screen keyboard while the session is running. Use it instead of the legacy `appium:unicodeKeyboard` one (which will be dropped in the future). This effect is achieved by assigning a custom "artificial" [input method](https://developer.android.com/develop/ui/views/touch-and-input/creating-input-method). Only use this feature for special/exploratory cases as it violates the way your application under test is normally interacted with by a human. Setting this capability explicitly to `false` enforces `adb shell ime reset` call on session startup, which resets the currently selected/enabled IMEs to the default ones as if the device is initially booted with the current locale. `undefined` by default. appium:mockLocationApp | Sets the package identifier of the app, which is used as a system mock location provider since Appium 1.18.0+. This capability has no effect on emulators. If the value is set to `null` or an empty string, then Appium will skip the mocked location provider setup procedure. Defaults to Appium Setting package identifier (`io.appium.settings`). Termination of a mock location provider application resets the mocked location data. appium:logcatFormat | The log print format, where `format` is one of: `brief` `process` `tag` `thread` `raw` `time` `threadtime` `long`. `threadtime` is the default value. appium:logcatFilterSpecs | Series of `tag[:priority]` where `tag` is a log component tag (or * for all) and priority is: `V Verbose`, `D Debug`, `I Info`, `W Warn`, `E Error`, `F Fatal`, `S Silent (supress all output)`. '*' means '*:d' and `tag` by itself means `tag:v`. If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS. If no filterspec is found, filter defaults to '*:I'. diff --git a/lib/driver.ts b/lib/driver.ts index 999061238..4162b10e6 100644 --- a/lib/driver.ts +++ b/lib/driver.ts @@ -183,6 +183,8 @@ class AndroidUiautomator2Driver _hasSystemPortInCaps: boolean | undefined; + _originalIme: string | null; + mjpegStream?: mjpeg.MJpegStream; override caps: Uiautomator2DriverCaps; @@ -210,6 +212,7 @@ class AndroidUiautomator2Driver this.jwpProxyActive = false; this.jwpProxyAvoid = NO_PROXY; this.apkStrings = {}; // map of language -> strings obj + this._originalIme = null; this.settings = new DeviceSettings( {ignoreUnimportantViews: false, allowInvisibleElements: false}, @@ -485,7 +488,9 @@ class AndroidUiautomator2Driver }; // start an avd, set the language/locale, pick an emulator, etc... - // TODO with multiple devices we'll need to parameterize this + if (this.opts.hideKeyboard) { + this._originalIme = await this.adb.defaultIME(); + } await helpers.initDevice(this.adb, this.opts); // Prepare the device by forwarding the UiAutomator2 port @@ -791,6 +796,13 @@ class AndroidUiautomator2Driver this.log.info('Restoring window animation state'); await this.adb.setAnimationState(true); } + if (this._originalIme) { + try { + await this.adb.setIME(this._originalIme); + } catch (e) { + this.log.warn(`Cannot restore the original IME: ${e.message}`); + } + } await this.adb.stopLogcat(); try { await this.releaseSystemPort(); diff --git a/package.json b/package.json index 532d0d224..9cb2b7509 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ }, "dependencies": { "appium-adb": "^11.0.1", - "appium-android-driver": "^7.1.3", + "appium-android-driver": "^7.2.1", "appium-chromedriver": "^5.6.5", "appium-uiautomator2-server": "^5.12.2", "asyncbox": "^2.3.1",