Skip to content

Commit

Permalink
cli: dvt: add process-id-for-bundle-id
Browse files Browse the repository at this point in the history
  • Loading branch information
0xepsil0n authored Aug 11, 2024
1 parent 6351c95 commit 5a965fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pymobiledevice3/cli/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ def kill(service_provider: LockdownClient, pid):
ProcessControl(dvt).kill(pid)


@dvt.command(cls=Command)
@click.argument('app_bundle_identifier')
def process_id_for_bundle_id(service_provider: LockdownServiceProvider, app_bundle_identifier: str) -> None:
""" Get PID of a bundle identifier (only returns a valid value if its running). """
with DvtSecureSocketProxyService(lockdown=service_provider) as dvt:
print(ProcessControl(dvt).process_identifier_for_bundle_identifier(app_bundle_identifier))


def get_matching_processes(service_provider: LockdownServiceProvider, name: Optional[str] = None,
bundle_identifier: Optional[str] = None) \
-> List[MatchedProcessByPid]:
Expand Down
4 changes: 4 additions & 0 deletions pymobiledevice3/services/dvt/instruments/process_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def kill(self, pid: int):
"""
self._channel.killPid_(MessageAux().append_obj(pid), expects_reply=False)

def process_identifier_for_bundle_identifier(self, app_bundle_identifier: str) -> int:
self._channel.processIdentifierForBundleIdentifier_(MessageAux().append_obj(app_bundle_identifier), expects_reply=True)
return self._channel.receive_plist()

def launch(self, bundle_id: str, arguments=None, kill_existing: bool = True, start_suspended: bool = False,
environment: typing.Mapping = None, extra_options: typing.Mapping = None) -> int:
"""
Expand Down

0 comments on commit 5a965fb

Please sign in to comment.