Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改检查逻辑 #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions driver/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@

from pymobiledevice3.exceptions import NoDeviceConnectedError

def get_usbmux_lockdownclient():
while True:
try:
lockdown = create_using_usbmux()
except NoDeviceConnectedError:
print("请连接设备后按回车...")
input()
else:
break
while True:
lockdown = create_using_usbmux()
if lockdown.all_values.get("PasswordProtected"):
print("请解锁设备后按回车...")
input()
else:
break
return create_using_usbmux()

def get_version(lockdown: LockdownClient):
return lockdown.all_values.get("ProductVersion")

def get_developer_mode_status(lockdown: LockdownClient):
return lockdown.developer_mode_status

def reveal_developer_mode(lockdown: LockdownClient):
AmfiService(lockdown).create_amfi_show_override_path_file()

def enable_developer_mode(lockdown: LockdownClient):
AmfiService(lockdown).enable_developer_mode()
# def get_usbmux_lockdownclient():
# while True:
# try:
# lockdown = create_using_usbmux()
# except NoDeviceConnectedError:
# print("请连接设备后按回车...")
# input()
# else:
# break
# while True:
# lockdown = create_using_usbmux()
# if lockdown.all_values.get("PasswordProtected"):
# print("请解锁设备后按回车...")
# input()
# else:
# break
# return create_using_usbmux()

# def get_version(lockdown: LockdownClient):
# return lockdown.all_values.get("ProductVersion")

# def get_developer_mode_status(lockdown: LockdownClient):
# return lockdown.developer_mode_status

# def reveal_developer_mode(lockdown: LockdownClient):
# AmfiService(lockdown).create_amfi_show_override_path_file()

# def enable_developer_mode(lockdown: LockdownClient):
# AmfiService(lockdown).enable_developer_mode()

def get_serverrsd():
install_driver_if_required()
Expand Down
14 changes: 7 additions & 7 deletions init/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import os

from driver import connect

def init():
from pymobiledevice3.lockdown import LockdownClient
from pymobiledevice3.services.amfi import AmfiService
def init(lockdown: LockdownClient):
# check if root on mac or Administrator on windows

if sys.platform == "win32":
if not ctypes.windll.shell32.IsUserAnAdmin():
print("请以管理员权限运行")
Expand All @@ -18,19 +20,17 @@ def init():
print("仅支持macOS和Windows")
sys.exit(1)

# get lockdown client
lockdown = connect.get_usbmux_lockdownclient()

# check version
version = connect.get_version(lockdown)
version = lockdown.product_version
print(f"Your system version is {version}")
if version.split(".")[0] < "17":
print(f"仅支持17及以上版本")
sys.exit(1)

# check developer mode status
developer_mode_status = connect.get_developer_mode_status(lockdown)
developer_mode_status = lockdown.developer_mode_status
if not developer_mode_status:
connect.reveal_developer_mode(lockdown)
AmfiService(lockdown).create_amfi_show_override_path_file()
print("您未开启开发者模式,请打开设备的 设置-隐私与安全性-开发者模式 来开启,开启后需要重启并输入密码,完成后再次运行此程序")
sys.exit(1)
12 changes: 8 additions & 4 deletions init/tunnel.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import asyncio
import multiprocessing

from pymobiledevice3.exceptions import NoDeviceConnectedError
from driver import connect

import sys
def tunnel_proc(queue: multiprocessing.Queue):
server_rsd = connect.get_serverrsd()
try:
server_rsd = connect.get_serverrsd()
except NoDeviceConnectedError:
print("设备未连接")
sys.exit(1)
asyncio.run(connect.tunnel(server_rsd, queue))


Expand All @@ -16,5 +20,5 @@ def tunnel():

# get the address and port of the tunnel
address, port = queue.get()

print(address, port)
return process, address, port
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():
logger.setLevel(logging.DEBUG)
coloredlogs.install(level=logging.DEBUG)

init.init()
# init.init()
logger.info("init done")

# start the tunnel in another process
Expand All @@ -59,8 +59,9 @@ def main():
loc = route.get_route()
logger.info(f"got route from {config.config.routeConfig}")


with RemoteServiceDiscoveryService((address, port)) as rsd:
init.init(rsd.lockdown)
with DvtSecureSocketProxyService(rsd) as dvt:
try:
print(f"已开始模拟跑步,速度大约为 {config.config.v} m/s")
Expand Down