diff --git a/pymobiledevice3/services/dvt/instruments/process_control.py b/pymobiledevice3/services/dvt/instruments/process_control.py index 617760908..546e013cb 100644 --- a/pymobiledevice3/services/dvt/instruments/process_control.py +++ b/pymobiledevice3/services/dvt/instruments/process_control.py @@ -2,6 +2,7 @@ import datetime import typing +from pymobiledevice3.services.dvt.dvt_secure_socket_proxy import DvtSecureSocketProxyService from pymobiledevice3.services.remote_server import MessageAux @@ -24,7 +25,7 @@ def create(cls, message) -> 'OutputReceivedEvent': class ProcessControl: IDENTIFIER = 'com.apple.instruments.server.services.processcontrol' - def __init__(self, dvt): + def __init__(self, dvt: DvtSecureSocketProxyService): self._channel = dvt.make_channel(self.IDENTIFIER) def signal(self, pid: int, sig: int): @@ -44,7 +45,7 @@ def kill(self, pid: int): self._channel.killPid_(MessageAux().append_obj(pid), expects_reply=False) def launch(self, bundle_id: str, arguments=None, kill_existing: bool = True, start_suspended: bool = False, - environment: typing.Mapping = None) -> int: + environment: typing.Mapping = None, extra_options: typing.Mapping = None) -> int: """ Launch a process. :param bundle_id: Bundle id of the process. @@ -52,15 +53,19 @@ def launch(self, bundle_id: str, arguments=None, kill_existing: bool = True, sta :param kill_existing: Whether to kill an existing instance of this process. :param start_suspended: Same as WaitForDebugger. :param environment: Environment variables to pass to process. + :param extra_options: Extra options to pass to process. :return: PID of created process. """ arguments = [] if arguments is None else arguments environment = {} if environment is None else environment + options = { + 'StartSuspendedKey': start_suspended, + 'KillExisting': kill_existing, + } + if extra_options: + options.update(extra_options) args = MessageAux().append_obj('').append_obj(bundle_id).append_obj(environment).append_obj( - arguments).append_obj({ - 'StartSuspendedKey': start_suspended, - 'KillExisting': kill_existing, - }) + arguments).append_obj(options) self._channel.launchSuspendedProcessWithDevicePath_bundleIdentifier_environment_arguments_options_(args) result = self._channel.receive_plist() assert result