pymobiledevice3 5.0.1__py3-none-any.whl → 5.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pymobiledevice3 might be problematic. Click here for more details.
- misc/plist_sniffer.py +15 -15
- misc/remotexpc_sniffer.py +29 -28
- pymobiledevice3/__main__.py +128 -102
- pymobiledevice3/_version.py +2 -2
- pymobiledevice3/bonjour.py +26 -49
- pymobiledevice3/ca.py +32 -24
- pymobiledevice3/cli/activation.py +7 -7
- pymobiledevice3/cli/afc.py +19 -19
- pymobiledevice3/cli/amfi.py +4 -4
- pymobiledevice3/cli/apps.py +51 -39
- pymobiledevice3/cli/backup.py +58 -32
- pymobiledevice3/cli/bonjour.py +25 -18
- pymobiledevice3/cli/cli_common.py +112 -81
- pymobiledevice3/cli/companion_proxy.py +4 -4
- pymobiledevice3/cli/completions.py +10 -10
- pymobiledevice3/cli/crash.py +37 -31
- pymobiledevice3/cli/developer.py +602 -520
- pymobiledevice3/cli/diagnostics.py +38 -33
- pymobiledevice3/cli/lockdown.py +79 -74
- pymobiledevice3/cli/mounter.py +85 -68
- pymobiledevice3/cli/notification.py +10 -10
- pymobiledevice3/cli/pcap.py +19 -14
- pymobiledevice3/cli/power_assertion.py +12 -10
- pymobiledevice3/cli/processes.py +10 -10
- pymobiledevice3/cli/profile.py +88 -77
- pymobiledevice3/cli/provision.py +17 -17
- pymobiledevice3/cli/remote.py +186 -110
- pymobiledevice3/cli/restore.py +43 -40
- pymobiledevice3/cli/springboard.py +30 -28
- pymobiledevice3/cli/syslog.py +85 -58
- pymobiledevice3/cli/usbmux.py +21 -20
- pymobiledevice3/cli/version.py +3 -2
- pymobiledevice3/cli/webinspector.py +157 -79
- pymobiledevice3/common.py +1 -1
- pymobiledevice3/exceptions.py +154 -60
- pymobiledevice3/irecv.py +49 -53
- pymobiledevice3/irecv_devices.py +1489 -492
- pymobiledevice3/lockdown.py +394 -241
- pymobiledevice3/lockdown_service_provider.py +5 -7
- pymobiledevice3/osu/os_utils.py +18 -9
- pymobiledevice3/osu/posix_util.py +28 -15
- pymobiledevice3/osu/win_util.py +14 -8
- pymobiledevice3/pair_records.py +19 -19
- pymobiledevice3/remote/common.py +4 -4
- pymobiledevice3/remote/core_device/app_service.py +94 -67
- pymobiledevice3/remote/core_device/core_device_service.py +17 -14
- pymobiledevice3/remote/core_device/device_info.py +5 -5
- pymobiledevice3/remote/core_device/diagnostics_service.py +10 -8
- pymobiledevice3/remote/core_device/file_service.py +47 -33
- pymobiledevice3/remote/remote_service_discovery.py +53 -35
- pymobiledevice3/remote/remotexpc.py +62 -41
- pymobiledevice3/remote/tunnel_service.py +371 -293
- pymobiledevice3/remote/utils.py +12 -11
- pymobiledevice3/remote/xpc_message.py +145 -125
- pymobiledevice3/resources/dsc_uuid_map.py +19 -19
- pymobiledevice3/resources/firmware_notifications.py +16 -16
- pymobiledevice3/restore/asr.py +27 -27
- pymobiledevice3/restore/base_restore.py +90 -47
- pymobiledevice3/restore/consts.py +87 -66
- pymobiledevice3/restore/device.py +11 -11
- pymobiledevice3/restore/fdr.py +46 -46
- pymobiledevice3/restore/ftab.py +19 -19
- pymobiledevice3/restore/img4.py +130 -133
- pymobiledevice3/restore/mbn.py +35 -54
- pymobiledevice3/restore/recovery.py +125 -135
- pymobiledevice3/restore/restore.py +524 -523
- pymobiledevice3/restore/restore_options.py +122 -115
- pymobiledevice3/restore/restored_client.py +25 -22
- pymobiledevice3/restore/tss.py +378 -270
- pymobiledevice3/service_connection.py +50 -46
- pymobiledevice3/services/accessibilityaudit.py +136 -126
- pymobiledevice3/services/afc.py +350 -291
- pymobiledevice3/services/amfi.py +21 -18
- pymobiledevice3/services/companion.py +23 -19
- pymobiledevice3/services/crash_reports.py +60 -46
- pymobiledevice3/services/debugserver_applist.py +3 -3
- pymobiledevice3/services/device_arbitration.py +8 -8
- pymobiledevice3/services/device_link.py +55 -47
- pymobiledevice3/services/diagnostics.py +971 -968
- pymobiledevice3/services/dtfetchsymbols.py +8 -8
- pymobiledevice3/services/dvt/dvt_secure_socket_proxy.py +4 -4
- pymobiledevice3/services/dvt/dvt_testmanaged_proxy.py +4 -4
- pymobiledevice3/services/dvt/instruments/activity_trace_tap.py +85 -74
- pymobiledevice3/services/dvt/instruments/application_listing.py +2 -3
- pymobiledevice3/services/dvt/instruments/condition_inducer.py +7 -6
- pymobiledevice3/services/dvt/instruments/core_profile_session_tap.py +442 -421
- pymobiledevice3/services/dvt/instruments/device_info.py +11 -11
- pymobiledevice3/services/dvt/instruments/energy_monitor.py +1 -1
- pymobiledevice3/services/dvt/instruments/graphics.py +1 -1
- pymobiledevice3/services/dvt/instruments/location_simulation.py +1 -1
- pymobiledevice3/services/dvt/instruments/location_simulation_base.py +10 -10
- pymobiledevice3/services/dvt/instruments/network_monitor.py +17 -17
- pymobiledevice3/services/dvt/instruments/notifications.py +1 -1
- pymobiledevice3/services/dvt/instruments/process_control.py +25 -10
- pymobiledevice3/services/dvt/instruments/screenshot.py +2 -2
- pymobiledevice3/services/dvt/instruments/sysmontap.py +15 -15
- pymobiledevice3/services/dvt/testmanaged/xcuitest.py +40 -50
- pymobiledevice3/services/file_relay.py +10 -10
- pymobiledevice3/services/heartbeat.py +8 -7
- pymobiledevice3/services/house_arrest.py +12 -15
- pymobiledevice3/services/installation_proxy.py +119 -100
- pymobiledevice3/services/lockdown_service.py +12 -5
- pymobiledevice3/services/misagent.py +22 -19
- pymobiledevice3/services/mobile_activation.py +84 -72
- pymobiledevice3/services/mobile_config.py +330 -301
- pymobiledevice3/services/mobile_image_mounter.py +137 -116
- pymobiledevice3/services/mobilebackup2.py +188 -150
- pymobiledevice3/services/notification_proxy.py +11 -11
- pymobiledevice3/services/os_trace.py +69 -51
- pymobiledevice3/services/pcapd.py +306 -306
- pymobiledevice3/services/power_assertion.py +10 -9
- pymobiledevice3/services/preboard.py +4 -4
- pymobiledevice3/services/remote_fetch_symbols.py +16 -14
- pymobiledevice3/services/remote_server.py +176 -146
- pymobiledevice3/services/restore_service.py +16 -16
- pymobiledevice3/services/screenshot.py +13 -10
- pymobiledevice3/services/simulate_location.py +7 -7
- pymobiledevice3/services/springboard.py +15 -15
- pymobiledevice3/services/syslog.py +5 -5
- pymobiledevice3/services/web_protocol/alert.py +3 -3
- pymobiledevice3/services/web_protocol/automation_session.py +180 -176
- pymobiledevice3/services/web_protocol/cdp_screencast.py +44 -36
- pymobiledevice3/services/web_protocol/cdp_server.py +19 -19
- pymobiledevice3/services/web_protocol/cdp_target.py +411 -373
- pymobiledevice3/services/web_protocol/driver.py +47 -45
- pymobiledevice3/services/web_protocol/element.py +74 -63
- pymobiledevice3/services/web_protocol/inspector_session.py +106 -102
- pymobiledevice3/services/web_protocol/selenium_api.py +2 -2
- pymobiledevice3/services/web_protocol/session_protocol.py +15 -10
- pymobiledevice3/services/web_protocol/switch_to.py +11 -12
- pymobiledevice3/services/webinspector.py +127 -116
- pymobiledevice3/tcp_forwarder.py +35 -22
- pymobiledevice3/tunneld/api.py +20 -15
- pymobiledevice3/tunneld/server.py +212 -133
- pymobiledevice3/usbmux.py +183 -138
- pymobiledevice3/utils.py +14 -11
- {pymobiledevice3-5.0.1.dist-info → pymobiledevice3-5.0.2.dist-info}/METADATA +1 -1
- pymobiledevice3-5.0.2.dist-info/RECORD +173 -0
- pymobiledevice3-5.0.1.dist-info/RECORD +0 -173
- {pymobiledevice3-5.0.1.dist-info → pymobiledevice3-5.0.2.dist-info}/WHEEL +0 -0
- {pymobiledevice3-5.0.1.dist-info → pymobiledevice3-5.0.2.dist-info}/entry_points.txt +0 -0
- {pymobiledevice3-5.0.1.dist-info → pymobiledevice3-5.0.2.dist-info}/licenses/LICENSE +0 -0
- {pymobiledevice3-5.0.1.dist-info → pymobiledevice3-5.0.2.dist-info}/top_level.txt +0 -0
|
@@ -7,13 +7,13 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
from pymobiledevice3.exceptions import NotEnoughDiskSpaceError, PyMobileDevice3Exception
|
|
9
9
|
|
|
10
|
-
SIZE_FORMAT =
|
|
11
|
-
CODE_FORMAT =
|
|
12
|
-
CODE_FILE_DATA =
|
|
13
|
-
CODE_ERROR_REMOTE =
|
|
10
|
+
SIZE_FORMAT = ">I"
|
|
11
|
+
CODE_FORMAT = ">B"
|
|
12
|
+
CODE_FILE_DATA = 0xC
|
|
13
|
+
CODE_ERROR_REMOTE = 0xB
|
|
14
14
|
CODE_ERROR_LOCAL = 0x6
|
|
15
15
|
CODE_SUCCESS = 0
|
|
16
|
-
FILE_TRANSFER_TERMINATOR = b
|
|
16
|
+
FILE_TRANSFER_TERMINATOR = b"\x00\x00\x00\x00"
|
|
17
17
|
BULK_OPERATION_ERROR = -13
|
|
18
18
|
APPLE_EPOCH = 978307200
|
|
19
19
|
ERRNO_TO_DEVICE_ERROR = {
|
|
@@ -32,15 +32,15 @@ class DeviceLink:
|
|
|
32
32
|
self.service = service
|
|
33
33
|
self.root_path = root_path
|
|
34
34
|
self._dl_handlers = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
"DLMessageCreateDirectory": self.create_directory,
|
|
36
|
+
"DLMessageUploadFiles": self.upload_files,
|
|
37
|
+
"DLMessageGetFreeDiskSpace": self.get_free_disk_space,
|
|
38
|
+
"DLMessageMoveItems": self.move_items,
|
|
39
|
+
"DLMessageRemoveItems": self.remove_items,
|
|
40
|
+
"DLMessageDownloadFiles": self.download_files,
|
|
41
|
+
"DLContentsOfDirectory": self.contents_of_directory,
|
|
42
|
+
"DLMessageCopyItem": self.copy_item,
|
|
43
|
+
"DLMessagePurgeDiskSpace": self.purge_disk_space,
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
def dl_loop(self, progress_callback=lambda x: None):
|
|
@@ -48,29 +48,34 @@ class DeviceLink:
|
|
|
48
48
|
message = self.receive_message()
|
|
49
49
|
command = message[0]
|
|
50
50
|
|
|
51
|
-
if command in (
|
|
52
|
-
|
|
51
|
+
if command in (
|
|
52
|
+
"DLMessageDownloadFiles",
|
|
53
|
+
"DLMessageMoveFiles",
|
|
54
|
+
"DLMessageMoveItems",
|
|
55
|
+
"DLMessageRemoveFiles",
|
|
56
|
+
"DLMessageRemoveItems",
|
|
57
|
+
):
|
|
53
58
|
progress_callback(message[3])
|
|
54
|
-
elif command ==
|
|
59
|
+
elif command == "DLMessageUploadFiles":
|
|
55
60
|
progress_callback(message[2])
|
|
56
61
|
|
|
57
|
-
if command ==
|
|
58
|
-
if not message[1][
|
|
59
|
-
return message[1].get(
|
|
62
|
+
if command == "DLMessageProcessMessage":
|
|
63
|
+
if not message[1]["ErrorCode"]:
|
|
64
|
+
return message[1].get("Content")
|
|
60
65
|
else:
|
|
61
|
-
raise PyMobileDevice3Exception(f
|
|
66
|
+
raise PyMobileDevice3Exception(f"Device link error: {message[1]}")
|
|
62
67
|
self._dl_handlers[command](message)
|
|
63
68
|
|
|
64
69
|
def version_exchange(self):
|
|
65
70
|
dl_message_version_exchange = self.receive_message()
|
|
66
71
|
version_major = dl_message_version_exchange[1]
|
|
67
|
-
self.service.send_plist([
|
|
72
|
+
self.service.send_plist(["DLMessageVersionExchange", "DLVersionsOk", version_major])
|
|
68
73
|
dl_message_device_ready = self.receive_message()
|
|
69
|
-
if dl_message_device_ready[0] !=
|
|
70
|
-
raise PyMobileDevice3Exception(
|
|
74
|
+
if dl_message_device_ready[0] != "DLMessageDeviceReady":
|
|
75
|
+
raise PyMobileDevice3Exception("Device link didn't return ready state")
|
|
71
76
|
|
|
72
77
|
def send_process_message(self, message):
|
|
73
|
-
self.service.send_plist([
|
|
78
|
+
self.service.send_plist(["DLMessageProcessMessage", message])
|
|
74
79
|
|
|
75
80
|
def download_files(self, message):
|
|
76
81
|
status = {}
|
|
@@ -85,7 +90,7 @@ class DeviceLink:
|
|
|
85
90
|
# https://github.com/doronz88/pymobiledevice3/issues/1165#issuecomment-2376815692
|
|
86
91
|
chunk_size = 128 * 1024 * 1024 # 128 MB
|
|
87
92
|
|
|
88
|
-
with file_path.open(
|
|
93
|
+
with file_path.open("rb") as file_handle:
|
|
89
94
|
while True:
|
|
90
95
|
chunk_data = file_handle.read(chunk_size)
|
|
91
96
|
if not chunk_data:
|
|
@@ -97,15 +102,15 @@ class DeviceLink:
|
|
|
97
102
|
self.service.sendall(buffer)
|
|
98
103
|
except IOError as e:
|
|
99
104
|
status[file] = {
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
"DLFileErrorString": e.strerror,
|
|
106
|
+
"DLFileErrorCode": ctypes.c_uint64(ERRNO_TO_DEVICE_ERROR[e.errno]).value,
|
|
102
107
|
}
|
|
103
108
|
self.service.sendall(struct.pack(SIZE_FORMAT, len(e.strerror) + struct.calcsize(CODE_FORMAT)))
|
|
104
109
|
self.service.sendall(struct.pack(CODE_FORMAT, CODE_ERROR_LOCAL) + e.strerror.encode())
|
|
105
110
|
|
|
106
111
|
self.service.sendall(FILE_TRANSFER_TERMINATOR)
|
|
107
112
|
if status:
|
|
108
|
-
self.status_response(BULK_OPERATION_ERROR,
|
|
113
|
+
self.status_response(BULK_OPERATION_ERROR, "Multi status", status)
|
|
109
114
|
else:
|
|
110
115
|
self.status_response(0)
|
|
111
116
|
|
|
@@ -113,17 +118,17 @@ class DeviceLink:
|
|
|
113
118
|
data = {}
|
|
114
119
|
path = self.root_path / message[1]
|
|
115
120
|
for file in path.iterdir():
|
|
116
|
-
ftype =
|
|
121
|
+
ftype = "DLFileTypeUnknown"
|
|
117
122
|
if file.is_dir():
|
|
118
|
-
ftype =
|
|
123
|
+
ftype = "DLFileTypeDirectory"
|
|
119
124
|
if file.is_file():
|
|
120
|
-
ftype =
|
|
125
|
+
ftype = "DLFileTypeRegular"
|
|
121
126
|
modifications_data = datetime.datetime.fromtimestamp(file.stat().st_mtime - APPLE_EPOCH)
|
|
122
127
|
modifications_data = modifications_data.replace(tzinfo=None)
|
|
123
128
|
data[file.name] = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
"DLFileType": ftype,
|
|
130
|
+
"DLFileSize": file.stat().st_size,
|
|
131
|
+
"DLFileModificationDate": modifications_data,
|
|
127
132
|
}
|
|
128
133
|
self.status_response(0, status_dict=data)
|
|
129
134
|
|
|
@@ -133,20 +138,22 @@ class DeviceLink:
|
|
|
133
138
|
if not device_name:
|
|
134
139
|
break
|
|
135
140
|
file_name = self._prefixed_recv()
|
|
136
|
-
size, = struct.unpack(SIZE_FORMAT, self.service.recvall(struct.calcsize(SIZE_FORMAT)))
|
|
137
|
-
code, = struct.unpack(CODE_FORMAT, self.service.recvall(struct.calcsize(CODE_FORMAT)))
|
|
141
|
+
(size,) = struct.unpack(SIZE_FORMAT, self.service.recvall(struct.calcsize(SIZE_FORMAT)))
|
|
142
|
+
(code,) = struct.unpack(CODE_FORMAT, self.service.recvall(struct.calcsize(CODE_FORMAT)))
|
|
138
143
|
size -= struct.calcsize(CODE_FORMAT)
|
|
139
|
-
with open(self.root_path / file_name,
|
|
144
|
+
with open(self.root_path / file_name, "wb") as fd:
|
|
140
145
|
while size and code == CODE_FILE_DATA:
|
|
141
146
|
fd.write(self.service.recvall(size))
|
|
142
|
-
size, = struct.unpack(SIZE_FORMAT, self.service.recvall(struct.calcsize(SIZE_FORMAT)))
|
|
143
|
-
code, = struct.unpack(CODE_FORMAT, self.service.recvall(struct.calcsize(CODE_FORMAT)))
|
|
147
|
+
(size,) = struct.unpack(SIZE_FORMAT, self.service.recvall(struct.calcsize(SIZE_FORMAT)))
|
|
148
|
+
(code,) = struct.unpack(CODE_FORMAT, self.service.recvall(struct.calcsize(CODE_FORMAT)))
|
|
144
149
|
size -= struct.calcsize(CODE_FORMAT)
|
|
145
150
|
if code == CODE_ERROR_REMOTE:
|
|
146
151
|
# iOS 17 beta devices give this error for: backup_manifest.db
|
|
147
152
|
error_message = self.service.recvall(size).decode()
|
|
148
|
-
warnings.warn(
|
|
149
|
-
|
|
153
|
+
warnings.warn(
|
|
154
|
+
f"Failed to fully upload: {file_name}. Device file name: {device_name}. Reason: {error_message}",
|
|
155
|
+
stacklevel=2,
|
|
156
|
+
)
|
|
150
157
|
continue
|
|
151
158
|
assert code == CODE_SUCCESS
|
|
152
159
|
self.status_response(0)
|
|
@@ -189,10 +196,11 @@ class DeviceLink:
|
|
|
189
196
|
(self.root_path / path).mkdir(parents=True, exist_ok=True)
|
|
190
197
|
self.status_response(0)
|
|
191
198
|
|
|
192
|
-
def status_response(self, status_code, status_str=
|
|
199
|
+
def status_response(self, status_code, status_str="", status_dict=None):
|
|
193
200
|
self.service.send_plist([
|
|
194
|
-
|
|
195
|
-
|
|
201
|
+
"DLMessageStatusResponse",
|
|
202
|
+
ctypes.c_uint64(status_code).value,
|
|
203
|
+
status_str if status_str else "___EmptyParameterString___",
|
|
196
204
|
status_dict if status_dict is not None else {},
|
|
197
205
|
])
|
|
198
206
|
|
|
@@ -200,8 +208,8 @@ class DeviceLink:
|
|
|
200
208
|
return self.service.recv_plist()
|
|
201
209
|
|
|
202
210
|
def disconnect(self):
|
|
203
|
-
self.service.send_plist([
|
|
211
|
+
self.service.send_plist(["DLMessageDisconnect", "___EmptyParameterString___"])
|
|
204
212
|
|
|
205
213
|
def _prefixed_recv(self):
|
|
206
|
-
size, = struct.unpack(SIZE_FORMAT, self.service.recvall(struct.calcsize(SIZE_FORMAT)))
|
|
214
|
+
(size,) = struct.unpack(SIZE_FORMAT, self.service.recvall(struct.calcsize(SIZE_FORMAT)))
|
|
207
215
|
return self.service.recvall(size).decode()
|