2424from pymobiledevice3 .services .afc import AfcService
2525from pymobiledevice3 .services .amfi import AmfiService
2626from pymobiledevice3 .remote .remote_service_discovery import RemoteServiceDiscoveryService
27- from pymobiledevice3 .services .dvt .dvt_secure_socket_proxy import DvtSecureSocketProxyService
27+ from pymobiledevice3 .services .dvt .instruments . dvt_provider import DvtProvider
2828from pymobiledevice3 .services .dvt .instruments .process_control import ProcessControl
2929from pymobiledevice3 .services .os_trace import OsTraceService
3030from http .server import HTTPServer , SimpleHTTPRequestHandler
@@ -178,7 +178,7 @@ async def async_connection():
178178 loop = asyncio .get_running_loop ()
179179
180180 def run_blocking_callback ():
181- with DvtSecureSocketProxyService (rsd ) as dvt :
181+ with DvtProvider (rsd ) as dvt :
182182 apply_bookrestore_files (files , rsd , dvt , current_device_uuid_callback , progress , transfer_mode , do_full_reboot )
183183
184184 await loop .run_in_executor (None , run_blocking_callback )
@@ -265,7 +265,7 @@ def generate_bldbmanager(files: list[FileToRestore], out_file: str, afc: AfcServ
265265 zassetpath = f'{ file .restore_path } .zassetpath'
266266 media_folder = file_name #f'{nugget_media_folder}/{file_name}'
267267 zplistpath = f'/var/mobile/Media/{ media_folder } '
268- afc .set_file_contents (media_folder , file .contents )
268+ asyncio . run ( afc .set_file_contents (media_folder , file .contents ) )
269269 else :
270270 zdownloadid = ""
271271 zassetpath = file .restore_path
@@ -283,7 +283,7 @@ def generate_bldbmanager(files: list[FileToRestore], out_file: str, afc: AfcServ
283283 # return the number of files in the thing
284284 return z_id
285285
286- def apply_bookrestore_files (files : list [FileToRestore ], lockdown_client : LockdownClient , dvt : DvtSecureSocketProxyService ,
286+ def apply_bookrestore_files (files : list [FileToRestore ], lockdown_client : LockdownClient , dvt : DvtProvider ,
287287 current_device_uuid_callback = lambda x : None , progress_callback = lambda x : None ,
288288 transfer_mode : BookRestoreFileTransferMethod = BookRestoreFileTransferMethod .LocalHost ,
289289 do_full_reboot : bool = False ):
@@ -369,13 +369,13 @@ def apply_bookrestore_files(files: list[FileToRestore], lockdown_client: Lockdow
369369 """ )
370370 connection .commit ()
371371
372- procs = OsTraceService (lockdown = lockdown_client ).get_pid_list ().get ("Payload" )
372+ procs = asyncio . run ( OsTraceService (lockdown = lockdown_client ).get_pid_list () ).get ("Payload" )
373373 pid_bookassetd = next ((pid for pid , p in procs .items () if p ['ProcessName' ] == 'bookassetd' ), None )
374374 pid_books = next ((pid for pid , p in procs .items () if p ['ProcessName' ] == 'Books' ), None )
375375 if pid_bookassetd :
376- pc .signal (pid_bookassetd , 19 )
376+ asyncio . run ( pc .signal (pid_bookassetd , 19 ) )
377377 if pid_books :
378- pc .kill (pid_books )
378+ asyncio . run ( pc .kill (pid_books ) )
379379
380380 progress_callback ("Uploading files..." )
381381
@@ -389,7 +389,7 @@ def apply_bookrestore_files(files: list[FileToRestore], lockdown_client: Lockdow
389389 _ , file_name = os .path .split (file .restore_path )
390390 print (f"including { file .restore_path } " )
391391 media_folder = file_name
392- afc .set_file_contents (media_folder , file .contents )
392+ asyncio . run ( afc .set_file_contents (media_folder , file .contents ) )
393393
394394 def fast_upload (local_path , remote_path ):
395395 content = b''
@@ -399,7 +399,7 @@ def fast_upload(local_path, remote_path):
399399 content = f .read ()
400400 except OSError :
401401 content = b''
402- afc .set_file_contents (remote_path , content )
402+ asyncio . run ( afc .set_file_contents (remote_path , content ) )
403403
404404 fast_upload (temp_db_path , "Downloads/downloads.28.sqlitedb" )
405405 fast_upload (temp_db_path + "-shm" , "Downloads/downloads.28.sqlitedb-shm" )
@@ -418,10 +418,10 @@ def fast_upload(local_path, remote_path):
418418 except Exception :
419419 pass
420420
421- procs = OsTraceService (lockdown = lockdown_client ).get_pid_list ().get ("Payload" )
421+ procs = asyncio . run ( OsTraceService (lockdown = lockdown_client ).get_pid_list () ).get ("Payload" )
422422 pid_itunesstored = next ((pid for pid , p in procs .items () if p ['ProcessName' ] == 'itunesstored' ), None )
423423 if pid_itunesstored :
424- pc .kill (pid_itunesstored )
424+ asyncio . run ( pc .kill (pid_itunesstored ) )
425425
426426 timeout = time .time () + 120
427427 progress_callback ("Waiting for itunesstored to finish download..." + "\n " + "(This might take a minute)" )
@@ -435,12 +435,12 @@ def fast_upload(local_path, remote_path):
435435 pid_bookassetd = next ((pid for pid , p in procs .items () if p ['ProcessName' ] == 'bookassetd' ), None )
436436 pid_books = next ((pid for pid , p in procs .items () if p ['ProcessName' ] == 'Books' ), None )
437437 if pid_bookassetd :
438- pc .kill (pid_bookassetd )
438+ asyncio . run ( pc .kill (pid_bookassetd ) )
439439 if pid_books :
440- pc .kill (pid_books )
440+ asyncio . run ( pc .kill (pid_books ) )
441441
442442 try :
443- pc .launch ("com.apple.iBooks" )
443+ asyncio . run ( pc .launch ("com.apple.iBooks" ) )
444444 except Exception as e :
445445 raise NuggetException ("Error launching Books app" , detailed_text = repr (e ))
446446
@@ -461,7 +461,7 @@ def fast_upload(local_path, remote_path):
461461 # respring anyway even if it is not detected that all files overwrote
462462 break
463463 # raise Exception("Timed out waiting for file, please try again.")
464- pc .kill (pid_bookassetd )
464+ asyncio . run ( pc .kill (pid_bookassetd ) )
465465 if transfer_mode == BookRestoreFileTransferMethod .LocalHost :
466466 close_dl_connection ()
467467 remove_db_files (temp_dl_manager )
@@ -471,9 +471,9 @@ def fast_upload(local_path, remote_path):
471471 reboot_device (True , lockdown_client = lockdown_client )
472472 else :
473473 progress_callback ("Respringing" )
474- procs = OsTraceService (lockdown = lockdown_client ).get_pid_list ().get ("Payload" )
474+ procs = asyncio . run ( OsTraceService (lockdown = lockdown_client ).get_pid_list () ).get ("Payload" )
475475 pid = next ((pid for pid , p in procs .items () if p ['ProcessName' ] == 'backboardd' ), None )
476- pc .kill (pid )
476+ asyncio . run ( pc .kill (pid ) )
477477
478478def perform_bookrestore (files : list [FileToRestore ], lockdown_client : LockdownClient ,
479479 current_device_books_uuid_callback = lambda x : None , progress_callback = lambda x : None ,
@@ -482,7 +482,7 @@ def perform_bookrestore(files: list[FileToRestore], lockdown_client: LockdownCli
482482 if not lockdown_client .developer_mode_status :
483483 # enable developer mode
484484 progress_callback ("Enabling Developer Mode..." )
485- AmfiService (lockdown = lockdown_client ).reveal_developer_mode_option_in_ui ()
485+ asyncio . run ( AmfiService (lockdown = lockdown_client ).reveal_developer_mode_option_in_ui () )
486486 raise NuggetException ("You must enable developer mode on your device. You can do it in the Settings app.\n \n Click \" Show Details\" for more information." ,
487487 detailed_text = "BookRestore tweaks with the AFC method require developer mode to apply.\n \n You can enable this at the bottom of Settings > Privacy & Security > Developer Mode on your iPhone or iPad." )
488488 if os .name == 'nt' :
0 commit comments