Lockdown services¶
Every service takes a service provider and is used as an async context manager. They all derive
from LockdownService.
Base class¶
pymobiledevice3.services.lockdown_service.LockdownService ¶
Base class for all services that wrap a single lockdown service on the device.
A subclass binds to a named lockdown service (service_name) and is constructed with a
LockdownServiceProvider (a lockdown client
or an RSD/tunnel provider) that knows how to reach the device. The underlying service
connection is established lazily: it is opened on first use, on an explicit connect
call, or on entering the async context manager, and is closed on close or on exit.
Instances are intended to be used as async context managers::
async with SomeService(lockdown) as service:
...
Attributes:
| Name | Type | Description |
|---|---|---|
service_name |
str
|
name of the wrapped lockdown service. |
lockdown |
LockdownServiceProvider
|
service provider used to start the service and reach the device. |
logger |
Logger
|
logger named after the subclass module. |
Source code in pymobiledevice3/services/lockdown_service.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
service
property
¶
The wrapped service connection.
Returns:
| Type | Description |
|---|---|
Union[ServiceConnection, _LazyServiceConnection]
|
the established |
close
async
¶
Close the underlying service connection (if any) and reset connection state.
Source code in pymobiledevice3/services/lockdown_service.py
connect
async
¶
Start and connect the wrapped service if not already connected.
Does nothing when a connection already exists. Concurrent callers share a single in-flight connection attempt rather than starting the service multiple times; on failure the attempt is reset so it may be retried.
Raises:
| Type | Description |
|---|---|
StartServiceError
|
if the service fails to start. |
Source code in pymobiledevice3/services/lockdown_service.py
Common services¶
pymobiledevice3.services.os_trace.OsTraceService ¶
Bases: LockdownService
Client for the device's com.apple.os_trace_relay service.
Provides API for the following operations:
- List the running processes (pid to process name mapping).
- Stream live syslog entries in binary form, optionally filtered by pid.
- Retrieve the device's stored log archive (the contents of the
/var/db/diagnosticsdirectory), either as a raw PAX-format tar stream or extracted into a.logarchivedirectory consumable bylog/ Console.
The service is reached over the classic lockdown service on SERVICE_NAME, or over the
RemoteServiceDiscovery shim (RSD_SERVICE_NAME) when a non-LockdownClient
provider is supplied.
Source code in pymobiledevice3/services/os_trace.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
get_pid_list
async
¶
Request the device's process list.
Returns:
| Type | Description |
|---|---|
|
The decoded |
Source code in pymobiledevice3/services/os_trace.py
create_archive
async
¶
create_archive(out: IO, size_limit: Optional[int] = None, age_limit: Optional[int] = None, start_time: Optional[int] = None)
Request a log archive from the device and stream its raw bytes into out.
The device returns the archive as a PAX-format tar stream (the contents of
/var/db/diagnostics), which is written to out in chunks until the connection is
terminated. Use collect instead to obtain an extracted .logarchive directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
IO
|
A writable binary file-like object to receive the archive bytes. |
required |
size_limit
|
Optional[int]
|
Optional maximum archive size in bytes. |
None
|
age_limit
|
Optional[int]
|
Optional maximum age, in days, of entries to include. |
None
|
start_time
|
Optional[int]
|
Optional earliest entry time, as a unix timestamp. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the device does not acknowledge the request with a successful status. |
Source code in pymobiledevice3/services/os_trace.py
collect
async
¶
collect(out: str, size_limit: Optional[int] = None, age_limit: Optional[int] = None, start_time: Optional[int] = None) -> None
Collect the device's system logs into a .logarchive that can be inspected later with
tools such as log or Console.
Internally calls create_archive to fetch the tar stream into a temporary file, then
extracts it into the out directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
str
|
Destination directory path into which the archive is extracted. |
required |
size_limit
|
Optional[int]
|
Optional maximum archive size in bytes. |
None
|
age_limit
|
Optional[int]
|
Optional maximum age, in days, of entries to include. |
None
|
start_time
|
Optional[int]
|
Optional earliest entry time, as a unix timestamp. |
None
|
Source code in pymobiledevice3/services/os_trace.py
syslog
async
¶
syslog(pid: int = -1, message_filter: int = OS_TRACE_RELAY_MESSAGE_FILTER_ALL, stream_flags: int = OS_TRACE_RELAY_STREAM_FLAGS_DEFAULT) -> typing.AsyncGenerator[SyslogEntry, None]
Stream live syslog entries from the device.
Starts an activity stream on the device and yields each incoming record, parsed via
parse_syslog_entry, indefinitely until the caller stops iterating or the connection
drops.
:yields: Each decoded log entry as it arrives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pid
|
int
|
Restrict the stream to a single process by pid; |
-1
|
message_filter
|
int
|
Bitmask selecting which message levels to receive; defaults to
|
OS_TRACE_RELAY_MESSAGE_FILTER_ALL
|
stream_flags
|
int
|
Bitmask of |
OS_TRACE_RELAY_STREAM_FLAGS_DEFAULT
|
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the device rejects the stream-start request. |
Source code in pymobiledevice3/services/os_trace.py
pymobiledevice3.services.installation_proxy.InstallationProxyService ¶
Bases: LockdownService
Client for the com.apple.mobile.installation_proxy lockdown service.
Provides access to the device's application installation database: installing, upgrading, uninstalling, archiving/restoring, browsing and looking up apps, as well as uploading carrier bundles (IPCC). Most operations send a plist command over the service connection and stream back progress and status responses.
Source code in pymobiledevice3/services/installation_proxy.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
send_cmd_for_bundle_identifier
async
¶
send_cmd_for_bundle_identifier(bundle_identifier: str, cmd: str = 'Archive', options: Optional[dict] = None, handler: Optional[Callable] = None, *args) -> None
Send a command that targets an installed app by its bundle identifier and wait for completion.
Sends a plist of the form {"Command": cmd, "ApplicationIdentifier": bundle_identifier,
"ClientOptions": options} to the service, then consumes progress/status responses until
the operation completes. Used to back restore and uninstall.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle_identifier
|
str
|
Bundle identifier of the target app, sent as |
required |
cmd
|
str
|
Installation-proxy command name, sent as |
'Archive'
|
options
|
Optional[dict]
|
Command options, sent as |
None
|
handler
|
Optional[Callable]
|
Progress callback invoked as |
None
|
args
|
Extra positional arguments forwarded to |
()
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
AppInstallError
|
If the service reports an error or finishes without a |
Source code in pymobiledevice3/services/installation_proxy.py
upgrade
async
¶
upgrade(ipa_path: str, options: Optional[dict] = None, handler: Optional[Callable] = None, *args) -> None
Upgrade an installed app from a local package.
Delegates to install_from_local with the "Upgrade" command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ipa_path
|
str
|
Local path to the package ( |
required |
options
|
Optional[dict]
|
Command options, sent as |
None
|
handler
|
Optional[Callable]
|
Progress callback invoked as |
None
|
args
|
Extra positional arguments forwarded to |
()
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
AppInstallError
|
If the upgrade fails. |
Source code in pymobiledevice3/services/installation_proxy.py
restore
async
¶
restore(bundle_identifier: str, options: Optional[dict] = None, handler: Optional[Callable] = None, *args) -> None
Restore a previously archived app, identified by its bundle identifier.
Sends the "Restore" command via send_cmd_for_bundle_identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle_identifier
|
str
|
Bundle identifier of the app to restore. |
required |
options
|
Optional[dict]
|
Command options, sent as |
None
|
handler
|
Optional[Callable]
|
Progress callback invoked as |
None
|
args
|
Extra positional arguments forwarded to |
()
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
AppInstallError
|
If the restore fails. |
Source code in pymobiledevice3/services/installation_proxy.py
uninstall
async
¶
uninstall(bundle_identifier: str, options: Optional[dict] = None, handler: Optional[Callable] = None, *args) -> None
Uninstall an app, identified by its bundle identifier.
Sends the "Uninstall" command via send_cmd_for_bundle_identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle_identifier
|
str
|
Bundle identifier of the app to uninstall. |
required |
options
|
Optional[dict]
|
Command options, sent as |
None
|
handler
|
Optional[Callable]
|
Progress callback invoked as |
None
|
args
|
Extra positional arguments forwarded to |
()
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
AppInstallError
|
If the uninstall fails. |
Source code in pymobiledevice3/services/installation_proxy.py
install_from_bytes
async
¶
install_from_bytes(package_bytes: bytes, cmd: str = 'Install', options: Optional[dict] = None, handler: Optional[Callable] = None, *args) -> None
Install an app or carrier bundle from a zipped package held in memory.
The package type is detected from the zip contents (see classify_zip_file): a
.app payload is treated as an .ipa, a .bundle payload as an .ipcc. For
IPCC packages, PackageType is forced to "CarrierBundle" in the options. The bytes
are uploaded to a temporary path under /PublicStaging/pymobiledevice3 via AFC, the
command is dispatched with send_package, and the temporary file is removed
afterwards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_bytes
|
bytes
|
Raw bytes of the |
required |
cmd
|
str
|
Installation-proxy command name, sent as |
'Install'
|
options
|
Optional[dict]
|
Command options, sent as |
None
|
handler
|
Optional[Callable]
|
Progress callback invoked as |
None
|
args
|
Extra positional arguments forwarded to |
()
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
AppInstallError
|
If the bytes are not a valid package, lack a |
Source code in pymobiledevice3/services/installation_proxy.py
install_from_local
async
¶
install_from_local(package_path: Path, cmd: str = 'Install', options: Optional[dict] = None, handler: Optional[Callable] = None, developer: bool = False, *args) -> None
Install an app or carrier bundle from a local path.
Dispatches on package_path: a .ipcc suffix is treated as a carrier bundle
(PackageType forced to "CarrierBundle"); a directory is treated as an unpackaged
app and zipped into an .ipa via create_ipa_contents_from_directory; any other
path is read as .ipa bytes. When developer is set, PackageType is forced to
"Developer". The payload is uploaded to a temporary path under
/PublicStaging/pymobiledevice3 via AFC, the command is dispatched with
send_package, and the temporary file is removed afterwards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_path
|
Path
|
Local path to a |
required |
cmd
|
str
|
Installation-proxy command name, sent as |
'Install'
|
options
|
Optional[dict]
|
Command options, sent as |
None
|
handler
|
Optional[Callable]
|
Progress callback invoked as |
None
|
developer
|
bool
|
When |
False
|
args
|
Extra positional arguments forwarded to |
()
|
Returns:
| Type | Description |
|---|---|
None
|
None. |
Raises:
| Type | Description |
|---|---|
AppInstallError
|
If the installation fails. |
Source code in pymobiledevice3/services/installation_proxy.py
send_package
async
¶
Send an install/upgrade command for a package already staged on the device, and wait for completion.
Sends {"Command": cmd, "ClientOptions": options, "PackagePath": package_path} to the
service, then consumes progress/status responses until the operation completes. Typically
invoked by install_from_local and install_from_bytes after uploading the
package via AFC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
str
|
Installation-proxy command name, sent as |
required |
options
|
Optional[dict]
|
Command options, sent as |
required |
handler
|
Callable
|
Progress callback invoked as |
required |
package_path
|
str
|
On-device path to the staged package, sent as |
required |
args
|
Extra positional arguments forwarded to |
()
|
Returns:
| Type | Description |
|---|---|
|
None. |
Raises:
| Type | Description |
|---|---|
AppInstallError
|
If the service reports an error or finishes without a |
Source code in pymobiledevice3/services/installation_proxy.py
upload_ipcc_from_path
async
¶
Upload a local IPCC (carrier bundle) zip to the device, unpacking it into the remote path.
Reads the file into memory and forwards it to the unpacking uploader, which recreates the
zip's directory tree under remote_path on the device via the given AFC client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Path
|
Local path to the |
required |
remote_path
|
str
|
Destination directory on the device where the bundle is unpacked. |
required |
afc_client
|
AfcService
|
Connected |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in pymobiledevice3/services/installation_proxy.py
upload_ipcc_from_bytes
async
¶
Upload an in-memory IPCC (carrier bundle) zip to the device, unpacking it into the remote path.
Wraps the bytes in a stream and forwards them to the unpacking uploader, which recreates the
zip's directory tree under remote_path on the device via the given AFC client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_bytes
|
bytes
|
Raw bytes of the |
required |
remote_path
|
str
|
Destination directory on the device where the bundle is unpacked. |
required |
afc_client
|
AfcService
|
Connected |
required |
Returns:
| Type | Description |
|---|---|
None
|
None. |
Source code in pymobiledevice3/services/installation_proxy.py
check_capabilities_match
async
¶
check_capabilities_match(capabilities: Optional[dict] = None, options: Optional[dict] = None) -> dict
Ask the device whether it satisfies a set of app capabilities.
Sends the "CheckCapabilitiesMatch" command. When capabilities is provided it is
sent under the Capabilities key; otherwise no capabilities key is sent. Returns the
single LookupResult value from the response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capabilities
|
Optional[dict]
|
Capabilities to check, sent as |
None
|
options
|
Optional[dict]
|
Command options, sent as |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The |
Source code in pymobiledevice3/services/installation_proxy.py
browse
async
¶
Enumerate installed apps via the "Browse" command.
Sends the command and accumulates each response's CurrentList entries until the service
reports a Complete status (or returns an empty response).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
Optional[dict]
|
Command options, sent as |
None
|
attributes
|
Optional[list[str]]
|
When provided, set as the |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
A list of per-app info dictionaries collected from all |
Source code in pymobiledevice3/services/installation_proxy.py
lookup
async
¶
Look up installed apps via the "Lookup" command.
Sends the command and returns the single LookupResult value from the response. The
options dict (e.g. BundleIDs, ApplicationType, ReturnAttributes) determines
which apps and attributes are returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
Optional[dict]
|
Command options, sent as |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The |
Source code in pymobiledevice3/services/installation_proxy.py
get_apps
async
¶
get_apps(application_type: str = 'Any', calculate_sizes: bool = False, bundle_identifiers: Optional[list[str]] = None, show_placeholders: bool = False) -> dict[str, dict]
Retrieve installed apps, keyed by bundle identifier.
Builds a lookup query from the given filters and calls lookup. When
calculate_sizes is set, a second lookup is issued requesting CFBundleIdentifier,
StaticDiskUsage and DynamicDiskUsage, and those size attributes are merged into the
per-app entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
application_type
|
str
|
Value for the |
'Any'
|
calculate_sizes
|
bool
|
When |
False
|
bundle_identifiers
|
Optional[list[str]]
|
When provided, restrict the query to these bundle identifiers via
the |
None
|
show_placeholders
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
A dictionary mapping each bundle identifier to its per-app info dictionary. |
Source code in pymobiledevice3/services/installation_proxy.py
pymobiledevice3.services.afc.AfcService ¶
Bases: LockdownService
Apple File Connection (AFC) Service for iOS device file system access.
This service provides full file system access to the /var/mobile/Media directory on iOS devices. It supports standard file operations including read, write, delete, rename, and directory operations.
The service communicates using a custom binary protocol with operation codes for
different file system operations. AFC responses echo the packet_num from the
request, enabling full concurrent operation: multiple callers may issue operations
simultaneously and a background reader task routes each response to the correct waiter
via a per-packet_num Future.
Attributes: SERVICE_NAME: Service identifier for lockdown-based connections RSD_SERVICE_NAME: Service identifier for RSD-based connections packet_num: Counter for tracking packet sequence numbers
Source code in pymobiledevice3/services/afc.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | |
pull
async
¶
pull(relative_src: str, dst: str, match: Optional[Pattern] = None, callback: Optional[Callable] = None, src_dir: str = '', ignore_errors: bool = False, progress_bar: bool = True) -> None
Pull (download) a file or directory from the device to the local machine.
The source is resolved through any symbolic link before transfer. A regular file is
written to dst; if dst is an existing local directory, the file is placed
inside it under the source's basename. Files larger than MAXIMUM_READ_SIZE (4 MB)
are streamed in chunks. The local file's modification time is set to match the
device's st_mtime. A directory source is copied recursively into a subdirectory
of dst named after the source's basename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_src
|
str
|
Source path on the device, resolved relative to |
required |
dst
|
str
|
Destination path on the local machine. |
required |
match
|
Optional[Pattern]
|
Optional regex; only entries whose basename matches (via |
None
|
callback
|
Optional[Callable]
|
Optional callable invoked as |
None
|
src_dir
|
str
|
Base directory on the device against which |
''
|
ignore_errors
|
bool
|
If True, per-entry errors during directory recursion are logged and skipped instead of propagated. |
False
|
progress_bar
|
bool
|
If True, display a tqdm progress bar while streaming large files. |
True
|
Source code in pymobiledevice3/services/afc.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
exists
async
¶
Check whether a path exists on the device.
Implemented by attempting stat; a missing path is reported as False and any
other AFC error propagates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Path to check. |
required |
Returns:
| Type | Description |
|---|---|
|
True if the path exists, False if it was not found. |
Source code in pymobiledevice3/services/afc.py
wait_exists
async
¶
Block until a path exists on the device.
Polls exists every 0.1 seconds until the path appears. Does not return
until the path exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Path to wait for. |
required |
Source code in pymobiledevice3/services/afc.py
push
async
¶
Push (upload) a file or directory from the local machine to the device.
A regular file is written to remote_path (or, if remote_path is an existing
remote directory, into it under the file's basename). A local directory is copied
recursively into remote_path/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_path
|
Source path on the local machine. |
required | |
remote_path
|
Destination path on the device. |
required | |
callback
|
Optional callable invoked as |
None
|
Source code in pymobiledevice3/services/afc.py
rm_single
async
¶
Remove a single file or empty directory on the device.
Issues a single REMOVE_PATH operation; it does not recurse into a non-empty
directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the file or directory to remove. |
required |
force
|
bool
|
If True, swallow an |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True on success; False if the removal failed and |
Raises:
| Type | Description |
|---|---|
AfcException
|
if the removal fails and |
Source code in pymobiledevice3/services/afc.py
rm
async
¶
Recursively remove a file or directory tree on the device.
For a directory, every entry is removed depth-first and the directory itself is removed
last. The match pattern, when given, filters which top-level entries of filename
are considered (matched against their basename via match); nested entries are always
removed once their parent is selected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the file or directory to remove. |
required |
match
|
Optional[Pattern]
|
Optional regex; only directory entries whose basename matches are removed. None removes all entries. |
None
|
force
|
bool
|
If True, suppress the final |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of paths that could not be deleted (empty on full success). |
Raises:
| Type | Description |
|---|---|
AfcException
|
if any path could not be deleted and |
Source code in pymobiledevice3/services/afc.py
get_device_info
async
¶
Query device file-system information.
Issues a GET_DEVINFO operation and decodes the null-terminated key/value list into
a dictionary (e.g. model, total/free bytes, block size).
Returns:
| Type | Description |
|---|---|
|
Dictionary of device file-system attributes (all values are strings). |
Source code in pymobiledevice3/services/afc.py
listdir
async
¶
List the entries of a directory on the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the directory. |
required |
Returns:
| Type | Description |
|---|---|
|
Entry names in the directory, excluding |
Raises:
| Type | Description |
|---|---|
AfcFileNotFoundError
|
if the path does not exist. |
AfcException
|
if the path is not a directory or cannot be listed. |
Source code in pymobiledevice3/services/afc.py
makedirs
async
¶
Create a directory on the device.
Issues a MAKE_DIR operation, creating any missing parent directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path of the directory to create. |
required |
Returns:
| Type | Description |
|---|---|
|
Raw response payload from the operation (typically empty). |
Raises:
| Type | Description |
|---|---|
AfcException
|
if the directory could not be created. |
Source code in pymobiledevice3/services/afc.py
isdir
async
¶
Check whether a path is a directory.
Stats the path and tests whether its st_ifmt is S_IFDIR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the path is a directory, False otherwise. |
Raises:
| Type | Description |
|---|---|
AfcFileNotFoundError
|
if the path does not exist. |
Source code in pymobiledevice3/services/afc.py
stat
async
¶
Get file or directory metadata.
Issues a GET_FILE_INFO operation and returns the decoded attribute dictionary.
Numeric fields (st_size, st_blocks, st_nlink) are converted to ints;
st_mtime and st_birthtime are converted from device nanosecond timestamps to
datetime. A st_ifmt entry (e.g. S_IFREG, S_IFDIR,
S_IFLNK) describes the file type, and symbolic links also carry a LinkTarget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the file or directory. |
required |
Returns:
| Type | Description |
|---|---|
|
Dictionary of file attributes. |
Raises:
| Type | Description |
|---|---|
AfcFileNotFoundError
|
if the path does not exist (AFC |
AfcException
|
for any other failure status. |
Source code in pymobiledevice3/services/afc.py
os_stat
async
¶
Get file statistics as an stat-style result.
Wraps stat, mapping the AFC st_ifmt to a numeric mode and packing the
attributes into a StatResult namedtuple. st_ino is synthesized from the
normalized path, st_uid/st_gid/st_dev are reported as 0 and st_blksize
as 4096 (AFC does not expose these). st_atime mirrors st_mtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the file or directory. |
required |
Returns:
| Type | Description |
|---|---|
|
A |
Raises:
| Type | Description |
|---|---|
AfcFileNotFoundError
|
if the path does not exist. |
Source code in pymobiledevice3/services/afc.py
link
async
¶
Create a symbolic or hard link on the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Path the link points to. |
required |
source
|
str
|
Path at which the link is created. |
required |
type_
|
|
SYMLINK
|
Returns:
| Type | Description |
|---|---|
|
Raw response payload from the operation (typically empty). |
Raises:
| Type | Description |
|---|---|
AfcException
|
if the link could not be created. |
Source code in pymobiledevice3/services/afc.py
fopen
async
¶
Open a file on the device and return its handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the file. |
required |
mode
|
str
|
Textual open mode; one of |
'r'
|
Returns:
| Type | Description |
|---|---|
int
|
Integer handle usable with |
Raises:
| Type | Description |
|---|---|
ArgumentError
|
if |
AfcException
|
if the file could not be opened. |
Source code in pymobiledevice3/services/afc.py
fclose
async
¶
Close an open file handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
int
|
Handle returned by |
required |
Returns:
| Type | Description |
|---|---|
|
Raw response payload from the operation (typically empty). |
Raises:
| Type | Description |
|---|---|
AfcException
|
if the close operation fails. |
Source code in pymobiledevice3/services/afc.py
rename
async
¶
Rename or move a file or directory on the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Current path of the file or directory. |
required |
target
|
str
|
New path for the file or directory. |
required |
Raises:
| Type | Description |
|---|---|
AfcFileNotFoundError
|
if the operation fails and |
AfcException
|
if the operation fails while |
Source code in pymobiledevice3/services/afc.py
fread
async
¶
Read data from an open file handle.
Automatically handles large reads by splitting into multiple operations. Each chunk send+receive is performed atomically via the demux reader so concurrent callers on the same AfcService instance are safe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
int
|
Handle returned by |
required |
sz
|
int
|
Number of bytes to read. Reads larger than |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The bytes read. |
Raises:
| Type | Description |
|---|---|
AfcException
|
if any read operation returns a non-success status. |
Source code in pymobiledevice3/services/afc.py
fwrite
async
¶
Write data to an open file handle.
Automatically handles large writes by splitting into multiple operations. Each chunk send+receive is performed atomically via the demux reader so concurrent callers on the same AfcService instance are safe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
int
|
Handle returned by |
required |
data
|
bytes
|
Bytes to write. |
required |
chunk_size
|
int
|
Maximum bytes per |
MAXIMUM_WRITE_SIZE
|
Raises:
| Type | Description |
|---|---|
AfcException
|
if any write operation returns a non-success status. |
Source code in pymobiledevice3/services/afc.py
resolve_path
async
¶
Resolve a symbolic link to its target path.
Stats the path; if it is a symbolic link, returns its LinkTarget (joined against
the link's parent directory when the target is relative). Non-links are returned
unchanged. Only a single level of link is resolved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to resolve. |
required |
Returns:
| Type | Description |
|---|---|
|
The link target, or |
Raises:
| Type | Description |
|---|---|
AfcFileNotFoundError
|
if the path does not exist. |
Source code in pymobiledevice3/services/afc.py
get_file_contents
async
¶
Read and return the entire contents of a file.
Resolves any symbolic link, verifies the target is a regular file, then opens it,
reads st_size bytes and closes the handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the file. |
required |
Returns:
| Type | Description |
|---|---|
|
The file contents as bytes. |
Raises:
| Type | Description |
|---|---|
AfcException
|
if the path is not a regular file ( |
AfcFileNotFoundError
|
if the path does not exist. |
Source code in pymobiledevice3/services/afc.py
set_file_contents
async
¶
Write data to a file, creating or truncating it.
Opens the file in 'w' mode (create/truncate), writes data and closes the handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the file. |
required |
data
|
bytes
|
Bytes to write. |
required |
Raises:
| Type | Description |
|---|---|
AfcException
|
if the open or write operation fails. |
Source code in pymobiledevice3/services/afc.py
walk
async
¶
Recursively walk a directory tree, similar to walk.
Yields one (dirpath, dirnames, filenames) tuple per directory, top-down, starting
at dirname. dirnames lists subdirectory names and filenames lists all other
entries. Symbolic links to directories are classified as files (not descended into).
:yields: (dirpath, dirnames, filenames) tuples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dirname
|
str
|
Root directory to walk. |
required |
Source code in pymobiledevice3/services/afc.py
dirlist
async
¶
Recursively yield paths under a directory up to a maximum depth.
Yields root itself first, followed by the full path of every entry found while
walking, pruning descent once a directory's depth (in path separators) reaches
depth.
:yields: Full paths of files and directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str
|
Root directory to list. |
required |
depth
|
int
|
Maximum traversal depth; |
-1
|
Source code in pymobiledevice3/services/afc.py
lock
async
¶
Apply or release an advisory flock-style lock on an open file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
Handle returned by |
required | |
operation
|
Lock operation, one of |
required |
Returns:
| Type | Description |
|---|---|
|
Raw response payload from the operation (typically empty). |
Raises:
| Type | Description |
|---|---|
AfcException
|
if the lock operation fails. |
Source code in pymobiledevice3/services/afc.py
pymobiledevice3.services.diagnostics.DiagnosticsService ¶
Bases: LockdownService
Client for the device's diagnostics_relay lockdown service.
Exposes the diagnostics relay over a plist request/response channel, allowing callers to:
- Query MobileGestalt and IORegistry keys.
- Read diagnostic information reports (e.g. battery, Wi-Fi, generic diagnostics).
- Restart, shut down or put the device to sleep.
Source code in pymobiledevice3/services/diagnostics.py
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | |
mobilegestalt
async
¶
Query MobileGestalt values from the device.
Sends a MobileGestalt request and returns the resolved key/value mapping (with the internal Status
entry stripped out).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Optional[list[str]]
|
MobileGestalt keys to query. If |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of each requested MobileGestalt key to its value. |
Raises:
| Type | Description |
|---|---|
DeprecationError
|
If MobileGestalt is reported as deprecated (iOS >= 17.4). |
PyMobileDevice3Exception
|
If the request or the MobileGestalt query did not complete successfully. |
Source code in pymobiledevice3/services/diagnostics.py
action
async
¶
Send a single diagnostics relay request and return its Diagnostics payload.
This is the low-level primitive used by the action/info helpers below. The given string is sent verbatim as
the request's Request field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
str
|
Request name to send (e.g. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
The response's |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the response status is not |
Source code in pymobiledevice3/services/diagnostics.py
restart
async
¶
Restart the device by sending the Restart request.
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the request did not complete successfully. |
shutdown
async
¶
Shut the device down by sending the Shutdown request.
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the request did not complete successfully. |
sleep
async
¶
Put the device to sleep by sending the Sleep request.
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the request did not complete successfully. |
info
async
¶
Fetch a diagnostics information report from the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diag_type
|
str
|
Diagnostics report type to request; sent as the |
'All'
|
Returns:
| Type | Description |
|---|---|
dict
|
The |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the request did not complete successfully. |
Source code in pymobiledevice3/services/diagnostics.py
ioregistry
async
¶
Query the device's IORegistry.
Sends an IORegistry request, optionally narrowed by plane, entry name and/or entry class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plane
|
Optional[str]
|
IORegistry plane to traverse, sent as |
None
|
name
|
Optional[str]
|
Name of the registry entry to look up, sent as |
None
|
ioclass
|
Optional[str]
|
Class of the registry entry to look up, sent as |
None
|
Returns:
| Type | Description |
|---|---|
|
The |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the response status is not |
Source code in pymobiledevice3/services/diagnostics.py
get_battery
async
¶
Fetch battery/power-source information from the IORegistry.
Convenience wrapper that queries the IORegistry entry of class IOPMPowerSource.
Returns:
| Type | Description |
|---|---|
dict
|
The IORegistry data for the power-source entry, or |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the underlying IORegistry request did not complete successfully. |
Source code in pymobiledevice3/services/diagnostics.py
get_wifi
async
¶
Fetch the Wi-Fi interface information from the IORegistry.
First attempts the entry named AppleBCMWLANSkywalkInterface; if that yields no result, falls back to the
entry of class IO80211Interface.
Returns:
| Type | Description |
|---|---|
dict
|
The IORegistry data for the Wi-Fi interface, or |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If an underlying IORegistry request did not complete successfully. |
Source code in pymobiledevice3/services/diagnostics.py
pymobiledevice3.services.springboard.SpringBoardServicesService ¶
Bases: LockdownService
Client for the com.apple.springboardservices lockdown service.
Exposes SpringBoard operations such as reading and writing the home screen icon layout, fetching application icon and wallpaper images, and querying the interface orientation.
Source code in pymobiledevice3/services/springboard.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
get_icon_state
async
¶
Retrieve the current home screen icon layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format_version
|
str
|
Icon state format version sent to SpringBoard as |
'2'
|
Returns:
| Type | Description |
|---|---|
list
|
Nested list describing the home screen pages, folders and icons. |
Source code in pymobiledevice3/services/springboard.py
set_icon_state
async
¶
Apply a new home screen icon layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
newstate
|
Optional[list]
|
Icon layout in the same structure returned by |
None
|
Source code in pymobiledevice3/services/springboard.py
get_icon_pngdata
async
¶
Retrieve the home screen icon image of an installed application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle_id
|
str
|
Bundle identifier of the application whose icon is requested. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
PNG-encoded icon image bytes, or |
Source code in pymobiledevice3/services/springboard.py
get_interface_orientation
async
¶
Query the current SpringBoard interface orientation.
Returns:
| Type | Description |
|---|---|
InterfaceOrientation
|
The current orientation as an |
Source code in pymobiledevice3/services/springboard.py
get_wallpaper_pngdata
async
¶
Retrieve the current home screen wallpaper image.
Returns:
| Type | Description |
|---|---|
bytes
|
PNG-encoded wallpaper image bytes, or |
Source code in pymobiledevice3/services/springboard.py
get_homescreen_icon_metrics
async
¶
Retrieve the home screen icon layout metrics.
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Mapping of metric names to their numeric values, as reported by SpringBoard. |
Source code in pymobiledevice3/services/springboard.py
get_wallpaper_info
async
¶
Retrieve metadata about a named wallpaper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wallpaper_name
|
str
|
Name of the wallpaper to query. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Mapping describing the wallpaper, as reported by SpringBoard. |
Source code in pymobiledevice3/services/springboard.py
reload_icon_state
async
¶
Re-apply the current icon layout by reading it back and writing it unchanged.
Fetches the current icon state via get_icon_state and immediately sends it back
through set_icon_state, forcing SpringBoard to reload its layout.
Source code in pymobiledevice3/services/springboard.py
get_wallpaper_preview_image
async
¶
Retrieve the preview image for a named wallpaper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wallpaper_name
|
str
|
Name of the wallpaper whose preview image is requested. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
PNG-encoded preview image bytes. |
Source code in pymobiledevice3/services/springboard.py
pymobiledevice3.services.crash_reports.CrashReportsManager ¶
Manage crash reports stored on a device.
Wraps the com.apple.crashreportcopymobile AFC service (for listing, reading, pulling and
erasing reports) and the com.apple.crashreportmover service (for flushing pending reports).
Must be used as an async context manager (async with); the synchronous context manager
protocol is intentionally disabled.
Source code in pymobiledevice3/services/crash_reports.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
aclose
async
¶
clear
async
¶
Delete all crash reports under a path.
Lists the immediate children of path and removes each recursively. A
com.apple.appstored entry that the device may recreate immediately after deletion is
tolerated; any other item that could not be deleted is treated as an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path under the crash reports directory to clear. Defaults to '/'. |
'/'
|
Raises:
| Type | Description |
|---|---|
AfcException
|
If any item other than |
Source code in pymobiledevice3/services/crash_reports.py
ls
async
¶
List file and folder in the crash report's directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to list, relative to the crash report's directory. |
'/'
|
depth
|
int
|
Listing depth, -1 to list infinite. |
1
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of files listed. |
Source code in pymobiledevice3/services/crash_reports.py
parse
async
¶
Parse a crash report file and return the parsed crash report object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to a crash report file. |
'/'
|
Returns:
| Type | Description |
|---|---|
CrashReportBase
|
Parsed crash report object. |
Source code in pymobiledevice3/services/crash_reports.py
parse_latest
async
¶
parse_latest(path: str = '/', match: Optional[list[str]] = None, match_insensitive: Optional[list[str]] = None, count: int = 1) -> list[CrashReportBase]
Parse latest top-level crash report(s) under a path, optionally filtered by basename regex patterns.
Scans the top level of the given path, filters regular files by basename, and returns matches sorted by last modification time (newest first).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path whose top-level entries should be considered. Defaults to '/' |
'/'
|
match
|
Optional[list[str]]
|
Case-sensitive regex patterns over report basename. |
None
|
match_insensitive
|
Optional[list[str]]
|
Case-insensitive regex patterns over report basename. |
None
|
count
|
int
|
Maximum number of latest matching reports to parse. |
1
|
Returns:
| Type | Description |
|---|---|
list[CrashReportBase]
|
Parsed crash report objects ordered from newest to oldest. Result length is between 1 and count. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If count < 1 or if no reports match the filters. All provided patterns must match. |
Source code in pymobiledevice3/services/crash_reports.py
pull
async
¶
pull(out: str, entry: str = '/', erase: bool = False, match: Optional[str] = None, progress_bar: bool = True) -> None
Pull crash reports from the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
str
|
Directory to pull crash reports to. |
required |
entry
|
str
|
File or Folder to pull. |
'/'
|
erase
|
bool
|
Whether to erase the original file from the CrashReports directory. |
False
|
match
|
Optional[str]
|
Regex to match against file and directory names to pull. |
None
|
progress_bar
|
bool
|
Whether to show a progress bar when pulling large files. |
True
|
Source code in pymobiledevice3/services/crash_reports.py
flush
async
¶
Flush pending crash products into the CrashReports directory.
Connects to the com.apple.crashreportmover service, which moves any pending reports into
the CrashReports directory and acknowledges with a ping once done.
Source code in pymobiledevice3/services/crash_reports.py
watch
async
¶
Continuously monitor the syslog and yield each newly created crash report.
Watches the device syslog for osanalyticshelper "Saved type" messages, reads the
referenced .ips or .panic file (retrying until it becomes readable) and yields it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
If provided, only reports whose parsed process name equals this value are yielded; otherwise every new report is yielded. |
None
|
raw
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
AsyncGenerator[str, None]
|
Async generator yielding either raw report strings or parsed crash report objects. |
Source code in pymobiledevice3/services/crash_reports.py
get_new_sysdiagnose
async
¶
get_new_sysdiagnose(out: str, erase: bool = True, *, timeout: Optional[float] = None, callback: Optional[Callable[[float], None]] = None) -> None
Monitor the creation of a newly created sysdiagnose archive and pull it
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
str
|
filename |
required |
erase
|
bool
|
remove after pulling |
True
|
timeout
|
Optional[float]
|
Maximum time in seconds to wait for the completion of sysdiagnose archive If None (default), waits indefinitely |
None
|
callback
|
Optional[Callable[[float], None]]
|
optional callback function (form: func(float)) that accepts the elapsed time so far |
None
|
Source code in pymobiledevice3/services/crash_reports.py
pymobiledevice3.services.mobile_image_mounter.MobileImageMounterService ¶
Bases: LockdownService
Client for the com.apple.mobile.mobile_image_mounter lockdown service.
Provides the low-level operations for mounting and unmounting disk images (such as the
Developer Disk Image) on a device: looking up mounted images, uploading image bytes, mounting
and unmounting, and the personalization queries used for personalized images. Subclasses
specialize the behavior for a specific image type via IMAGE_TYPE.
Implemented device-side in /usr/libexec/mobile_storage_proxy.
Source code in pymobiledevice3/services/mobile_image_mounter.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
raise_if_cannot_mount
async
¶
Verify that an image of this mounter's IMAGE_TYPE can be mounted.
Raises:
| Type | Description |
|---|---|
AlreadyMountedError
|
If an image of this type is already mounted. |
DeveloperModeIsNotEnabledError
|
On iOS 16 and later when Developer Mode is disabled. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
copy_devices
async
¶
List the images currently mounted on the device.
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of dictionaries, one per mounted image entry. |
Raises:
| Type | Description |
|---|---|
MessageNotSupportedError
|
If the device does not support the |
Source code in pymobiledevice3/services/mobile_image_mounter.py
lookup_image
async
¶
Look up the signature of a mounted image by its type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_type
|
str
|
Image type to look up (e.g. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The image signature. If the device returns a list of signatures, the first is returned. |
Raises:
| Type | Description |
|---|---|
NotMountedError
|
If no image of this type is present. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
is_image_mounted
async
¶
Check whether an image of the given type is mounted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_type
|
str
|
Image type to check (e.g. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in pymobiledevice3/services/mobile_image_mounter.py
unmount_image
async
¶
Unmount the image mounted at a given path (available since iOS 14.0).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mount_path
|
str
|
Mount point of the image to unmount (e.g. |
required |
Raises:
| Type | Description |
|---|---|
UnsupportedCommandError
|
If the device does not support the |
NotMountedError
|
If no image is mounted at |
InternalError
|
If the device reports an internal error. |
PyMobileDevice3Exception
|
For any other error reported by the device. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
mount_image
async
¶
Mount an image that has already been uploaded to the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_type
|
str
|
Image type to mount (e.g. |
required |
signature
|
bytes
|
Image signature (or, for personalized images, the IM4M manifest). |
required |
extras
|
Optional[dict]
|
Optional additional fields merged into the |
None
|
Raises:
| Type | Description |
|---|---|
AlreadyMountedError
|
If an image of this type is already mounted. |
DeveloperModeIsNotEnabledError
|
If the device reports Developer Mode is disabled. |
PyMobileDevice3Exception
|
If the mount does not complete successfully. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
upload_image
async
¶
Upload image bytes to the device in preparation for mounting.
Issues a ReceiveBytes command, streams the image bytes once the device acknowledges, and
waits for completion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_type
|
str
|
Image type being uploaded (e.g. |
required |
image
|
bytes
|
Raw image bytes to upload. |
required |
signature
|
bytes
|
Image signature (or, for personalized images, the IM4M manifest). |
required |
Raises:
| Type | Description |
|---|---|
PyMobileDevice3Exception
|
If the device does not acknowledge or does not complete the transfer. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
query_developer_mode_status
async
¶
Query whether Developer Mode is enabled on the device.
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
MessageNotSupportedError
|
If the device does not support this command. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
query_nonce
async
¶
Query the personalization nonce used for image personalization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
personalized_image_type
|
Optional[str]
|
Optional image type to scope the nonce to, sent as
|
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
The personalization nonce bytes. |
Raises:
| Type | Description |
|---|---|
MessageNotSupportedError
|
If the device does not support this command. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
query_personalization_identifiers
async
¶
Query the device identifiers required to personalize an image (board ID, chip ID, etc.).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_type
|
Optional[str]
|
Optional image type to scope the query to, sent as
|
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of personalization identifiers reported by the device. |
Raises:
| Type | Description |
|---|---|
MessageNotSupportedError
|
If the device does not support this command. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
query_personalization_manifest
async
¶
Fetch a personalization manifest already stored on the device for an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_type
|
str
|
Image type whose manifest is requested. |
required |
signature
|
bytes
|
Signature/digest of the image being queried. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The personalization manifest, returned by the device under |
Raises:
| Type | Description |
|---|---|
MissingManifestError
|
If the device has no manifest for the image. |
Source code in pymobiledevice3/services/mobile_image_mounter.py
roll_personalization_nonce
async
¶
Request the device to roll (regenerate) its personalization nonce.
The device may close the connection while handling this command; a resulting
ConnectionTerminatedError is swallowed and treated as success.
Source code in pymobiledevice3/services/mobile_image_mounter.py
roll_cryptex_nonce
async
¶
Request the device to roll (regenerate) its cryptex nonce.
The device may close the connection while handling this command; a resulting
ConnectionTerminatedError is swallowed and treated as success.
Source code in pymobiledevice3/services/mobile_image_mounter.py
pymobiledevice3.services.bt_packet_logger.BtPacketLoggerService ¶
Bases: LockdownService