Skip to content

Commit 4cc3ab4

Browse files
authored
Merge pull request #1336 from doronz88/bugfix/activation
mobile_activation: avoid using unnecessary `create_using_usbmux()`
2 parents 285f644 + 2ce81c2 commit 4cc3ab4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pymobiledevice3/services/mobile_activation.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
import xml.etree.ElementTree as ET
55
from contextlib import closing
66
from pathlib import Path
7+
from typing import Optional
78

89
import click
910
import inquirer3
1011
import requests
12+
from requests.structures import CaseInsensitiveDict
1113

1214
from pymobiledevice3.exceptions import MobileActivationException
13-
from pymobiledevice3.lockdown import create_using_usbmux
1415
from pymobiledevice3.lockdown_service_provider import LockdownServiceProvider
1516

1617
ACTIVATION_USER_AGENT_IOS = 'iOS Device Activator (MobileActivation-20 built on Jan 15 2012 at 19:07:28)'
@@ -136,17 +137,18 @@ def activate_with_session(self, activation_record, headers):
136137
}
137138
if headers:
138139
data['ActivationResponseHeaders'] = dict(headers)
139-
with closing(create_using_usbmux(self.lockdown.udid).start_lockdown_service(self.SERVICE_NAME)) as service:
140+
with closing(self.lockdown.start_lockdown_service(self.SERVICE_NAME)) as service:
140141
return service.send_recv_plist(data)
141142

142-
def send_command(self, command, value=''):
143+
def send_command(self, command: str, value: str = ''):
143144
data = {'Command': command}
144145
if value:
145146
data['Value'] = value
146-
with closing(create_using_usbmux(self.lockdown.udid).start_lockdown_service(self.SERVICE_NAME)) as service:
147+
with closing(self.lockdown.start_lockdown_service(self.SERVICE_NAME)) as service:
147148
return service.send_recv_plist(data)
148149

149-
def post(self, url, data, headers=None):
150+
def post(self, url: str, data: dict, headers: Optional[CaseInsensitiveDict[str, str]] = None) \
151+
-> tuple[bytes, CaseInsensitiveDict[str]]:
150152
if headers is None:
151153
headers = DEFAULT_HEADERS
152154

0 commit comments

Comments
 (0)