appium-uiautomator2-driver 2.32.2 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/driver.ts CHANGED
@@ -183,6 +183,8 @@ class AndroidUiautomator2Driver
183
183
 
184
184
  _hasSystemPortInCaps: boolean | undefined;
185
185
 
186
+ _originalIme: string | null;
187
+
186
188
  mjpegStream?: mjpeg.MJpegStream;
187
189
 
188
190
  override caps: Uiautomator2DriverCaps;
@@ -210,6 +212,7 @@ class AndroidUiautomator2Driver
210
212
  this.jwpProxyActive = false;
211
213
  this.jwpProxyAvoid = NO_PROXY;
212
214
  this.apkStrings = {}; // map of language -> strings obj
215
+ this._originalIme = null;
213
216
 
214
217
  this.settings = new DeviceSettings(
215
218
  {ignoreUnimportantViews: false, allowInvisibleElements: false},
@@ -485,7 +488,9 @@ class AndroidUiautomator2Driver
485
488
  };
486
489
 
487
490
  // start an avd, set the language/locale, pick an emulator, etc...
488
- // TODO with multiple devices we'll need to parameterize this
491
+ if (this.opts.hideKeyboard) {
492
+ this._originalIme = await this.adb.defaultIME();
493
+ }
489
494
  await helpers.initDevice(this.adb, this.opts);
490
495
 
491
496
  // Prepare the device by forwarding the UiAutomator2 port
@@ -791,6 +796,13 @@ class AndroidUiautomator2Driver
791
796
  this.log.info('Restoring window animation state');
792
797
  await this.adb.setAnimationState(true);
793
798
  }
799
+ if (this._originalIme) {
800
+ try {
801
+ await this.adb.setIME(this._originalIme);
802
+ } catch (e) {
803
+ this.log.warn(`Cannot restore the original IME: ${e.message}`);
804
+ }
805
+ }
794
806
  await this.adb.stopLogcat();
795
807
  try {
796
808
  await this.releaseSystemPort();