Skip to content

Commit

Permalink
Merge pull request #119 from pur1fying/patch-repair-scan-port
Browse files Browse the repository at this point in the history
fix: wrongly scans default port
  • Loading branch information
Daodanfd5 committed Jul 19, 2024
2 parents 6b0db7d + ecb2599 commit b57f0c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion device_operation/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .stop_simulator import stop_simulator_classic
from . import *
start_simulator_classic('mumu','1')
print(autosearch())
15 changes: 8 additions & 7 deletions device_operation/auto_scan_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ def auto_scan_simulators():
def auto_search_adb_address():
# 正则表达式匹配模板
regex_patterns = {
'MEmu.exe': r'.*MEmu.exe MEmu_(\w+)',
'HD-Player.exe': r'.*HD-Player.exe --instance (\w+)',
'dnplayer.exe': r'.*dnplayer.exe index=(\w+)',
'MuMuPlayer.exe': r'.*MuMuPlayer.exe -v (\w+)'
'MEmu.exe': r'.*MEmu.exe\s+MEmu_(\w+)',
'HD-Player.exe': r'.*HD-Player.exe\s+--instance\s+(\w+)',
'dnplayer.exe': r'.*dnplayer.exe\s+index=(\w+)',
'MuMuPlayer.exe': r'.*MuMuPlayer.exe\s+-v\s+(\w+)'
}


adb_addresses = []
process_list = auto_scan_simulators()

Expand All @@ -80,16 +81,16 @@ def bst_read_install_key(region):
cmdline_no_quotes = cmdline.replace('"', '')
for simulator, pattern in regex_patterns.items():
cmdline = cmdline.replace('"', '')
match = re.search(pattern, cmdline)
match = re.search(pattern, cmdline_no_quotes)
if match:
multi_instance = match.group(1)
if process == 'bluestacks_nxt':
bst_cn_path = bst_read_install_key('cn')
bst_cn_path = bst_read_install_key('_cn')
bst_path = bst_read_install_key('')
player_path = process_native_api("get_exe_path_name", "HD-Player.exe")

if bst_cn_path == player_path:
adb_address = f"""127.0.0.1:{get_bluestacks_nxt_adb_port_id(multi_instance, "cn")}"""
adb_address = f"""127.0.0.1:{get_bluestacks_nxt_adb_port_id(multi_instance, "_cn")}"""
adb_addresses.append(adb_address)
break
elif bst_path == player_path:
Expand Down
2 changes: 1 addition & 1 deletion device_operation/bluestacks_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def bst_read_registry_key(region):
except FileNotFoundError:
return None

bst_cn_path = bst_read_registry_key('cn')
bst_cn_path = bst_read_registry_key('_cn')
bst_path = bst_read_registry_key('')
try:
pid = int(pid)
Expand Down

0 comments on commit b57f0c4

Please sign in to comment.