mirror of
https://github.com/sui-feng-cb/AzurLaneAutoScript1.git
synced 2026-07-14 19:27:17 +08:00
Fix: u2's set_fastinput_ime may fail silently (#5806)
This commit is contained in:
@@ -21,6 +21,7 @@ EQUIPMENT_PREVIEW = list([
|
|||||||
|
|
||||||
class EquipmentCodeHandler(StorageHandler):
|
class EquipmentCodeHandler(StorageHandler):
|
||||||
last_code: str = None
|
last_code: str = None
|
||||||
|
FASTINPUT_IME = 'com.github.uiautomator/.FastInputIME'
|
||||||
|
|
||||||
def equipment_code_supported(self):
|
def equipment_code_supported(self):
|
||||||
method = self.config.Emulator_ControlMethod
|
method = self.config.Emulator_ControlMethod
|
||||||
@@ -161,10 +162,21 @@ class EquipmentCodeHandler(StorageHandler):
|
|||||||
|
|
||||||
def set_fastinput_ime(self):
|
def set_fastinput_ime(self):
|
||||||
d = self.device.u2
|
d = self.device.u2
|
||||||
|
failed = False
|
||||||
try:
|
try:
|
||||||
d.set_fastinput_ime(True)
|
for command in ('enable', 'set'):
|
||||||
except Exception:
|
result = d.shell(['ime', command, self.FASTINPUT_IME])
|
||||||
logger.warning("FastInputIME not enabled, trying to enable it")
|
exit_code = getattr(result, 'exit_code', 0)
|
||||||
|
output = getattr(result, 'output', result)
|
||||||
|
if exit_code:
|
||||||
|
failed = True
|
||||||
|
logger.warning(f"Unable to {command} FastInputIME: {output.strip()}")
|
||||||
|
except Exception as e:
|
||||||
|
failed = True
|
||||||
|
logger.warning(f"Unable to set FastInputIME: {e}")
|
||||||
|
|
||||||
|
if failed:
|
||||||
|
logger.warning("FastInputIME not enabled by adb shell, trying to enable it in settings")
|
||||||
self.fastinput_ime_enable()
|
self.fastinput_ime_enable()
|
||||||
|
|
||||||
def _code_input(self, code):
|
def _code_input(self, code):
|
||||||
@@ -174,7 +186,7 @@ class EquipmentCodeHandler(StorageHandler):
|
|||||||
for _ in self.loop():
|
for _ in self.loop():
|
||||||
name, shown = d.current_ime()
|
name, shown = d.current_ime()
|
||||||
if shown:
|
if shown:
|
||||||
if name != 'com.github.uiautomator/.FastInputIME':
|
if name != self.FASTINPUT_IME:
|
||||||
self.set_fastinput_ime()
|
self.set_fastinput_ime()
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user