Skip to content

Commit

Permalink
Fix: 彻底修复实体机无法正常使用的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MRSlouzk committed Sep 22, 2023
1 parent e68182e commit 1740814
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
被控端: Android 手机/Android 模拟器以及其他支持 Adb(安卓调试桥) 的 Android 平台
> 不保证较低版本平台兼容性, 具体兼容性有待测试
### 推荐配置
蓝叠5国际版 64bit或蓝叠 Pie 64bit,分辨率`1280*720`(DPI: 240)或`1920*1080`(DPI: 240),界面缩放`100%`,经测试可以顺利运行。
其他模拟器与配置不保证可正常运行,如果有问题请在[discussion | 模拟器识图问题收集区](https://github.com/ACGN-Alliance/BlueArchive-Starter-cli/issues/13)反馈,如果可以的话之后会进行适配,谢谢~

## 下载
最新版本: [v1.0.3](https://github.com/ACGN-Alliance/BlueArchive-Starter-cli/releases/tag/v1.0.3)
[Release](https://github.com/ACGN-Alliance/BlueArchive-Starter-cli/releases)

> 因为Windows下使用`--onefile`打包有概率报毒,因此将dll与pyd文件拆开了
Expand Down
9 changes: 6 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from script import script
from utils import adb

__version__ = "1.0.3"
__version__ = "1.0.5"

device_now = ""
adb_con: Optional[adb.ADB] = None # adb类变量
Expand Down Expand Up @@ -91,22 +91,25 @@ def notice():
- 游戏宽高比设置为`16:9`
- 如果加入了社团请先退出, 否则会导致操作失败
- 扫描并连接实体机时, 请留意手机上的rsa确认对话框并点击确认
- 用户名不能使用非法字符,中文因为adb的限制也不能使用
"""
print(notice)
input("按任意键以继续...")


def on_device_selected():
global adb_con, all_device_lst, device_now, port

pname = ""
if "emulator" in device_now:
port = int(device_now.split("-")[1]) + 1
elif "127.0.0.1" in device_now or "localhost" in device_now:
port = int(device_now.split(":")[1])
else:
# is_physic = True
pname = device_now
port = 5555

adb_con = adb.ADB(device_name=f"localhost:{port}")
adb_con = adb.ADB(device_name=f"localhost:{port}", physic_device_name=pname)
print(f"已选择设备: {device_now}")

@exception_handle
Expand Down
6 changes: 4 additions & 2 deletions utils/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(
device_name: str = "",
delay: int | float = 1,
scan_mode: bool = False,
is_physic_device: bool = False
physic_device_name: str = ""
):
"""
初始化针对特定Android设备的ADB接口。
Expand All @@ -39,12 +39,14 @@ def __init__(
else:
self.adb_path = "./platform-tools/adb"

if not is_physic_device:
if not physic_device_name:
subprocess.run(
[self.adb_path, "connect", device_name],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
else:
self.device_name = physic_device_name

if not scan_mode:
self.screen_width, self.screen_height = self._get_screen_resolution()
Expand Down

0 comments on commit 1740814

Please sign in to comment.