Skip to content

Commit

Permalink
fix: 修复Adb配置不能正确导入的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Jun 25, 2024
1 parent 028d15c commit a24d4ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/MaaDebugger/maafw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ async def detect_win32hwnd(class_regex: str, window_regex: str) -> List[Window]:

return windows

async def connect_adb(self, path: Path, address: str) -> bool:
self.controller = AdbController(path, address)
async def connect_adb(self, path: Path, address: str, config: dict) -> bool:
self.controller = AdbController(path, address, config=config)
connected = await self.controller.connect()
if not connected:
print(f"Failed to connect {path} {address}")
Expand Down
20 changes: 18 additions & 2 deletions src/MaaDebugger/webpage/index_page/master_control.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import json
from pathlib import Path

from maa.define import MaaWin32ControllerTypeEnum
Expand Down Expand Up @@ -65,6 +66,14 @@ async def connect_adb_control():
.props("size=30")
.bind_value(app.storage.general, "adb_address")
)
adb_config_input = (
ui.input(
"Extras",
placeholder="eg: {}",
)
.props("size=30")
.bind_value(app.storage.general, "adb_config")
)
ui.button(
"Connect",
on_click=lambda: on_click_connect(),
Expand Down Expand Up @@ -96,8 +105,14 @@ async def on_click_connect():
GlobalStatus.ctrl_connecting = Status.FAILURE
return

try:
config = json.loads(adb_config_input.value)
except json.JSONDecodeError as e:
print("Error parsing extras:", e)
config = {}

connected = await maafw.connect_adb(
Path(adb_path_input.value), adb_address_input.value
Path(adb_path_input.value), adb_address_input.value, config
)
if not connected:
GlobalStatus.ctrl_connecting = Status.FAILURE
Expand All @@ -114,7 +129,7 @@ async def on_click_detect():
devices = await maafw.detect_adb()
options = {}
for d in devices:
v = (d.adb_path, d.address)
v = (d.adb_path, d.address, d.config)
l = d.name + " " + d.address
options[v] = l

Expand All @@ -130,6 +145,7 @@ async def on_click_detect():
def on_change_devices_select(e):
adb_path_input.value = str(e.value[0])
adb_address_input.value = e.value[1]
adb_config_input.value = str(e.value[2])


async def connect_win32_control():
Expand Down

0 comments on commit a24d4ec

Please sign in to comment.