Skip to content

Commit

Permalink
springboard: refactor and resolve doronz88#993 by @doronz88 in doronz…
Browse files Browse the repository at this point in the history
  • Loading branch information
morellexf13 committed May 13, 2024
1 parent 3484b57 commit a2f6d49
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions pymobiledevice3/services/springboard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import typing
from enum import IntEnum
from typing import Mapping, Optional

from pymobiledevice3.lockdown import LockdownClient
from pymobiledevice3.lockdown_service_provider import LockdownServiceProvider
Expand All @@ -17,39 +17,31 @@ class SpringBoardServicesService(LockdownService):
RSD_SERVICE_NAME = 'com.apple.springboardservices.shim.remote'
SERVICE_NAME = 'com.apple.springboardservices'

def __init__(self, lockdown: LockdownServiceProvider):
def __init__(self, lockdown: LockdownServiceProvider) -> None:
if isinstance(lockdown, LockdownClient):
super().__init__(lockdown, self.SERVICE_NAME)
else:
super().__init__(lockdown, self.RSD_SERVICE_NAME)

def get_icon_state(self, format_version: str = '2'):
def get_icon_state(self, format_version: str = '2') -> Mapping:
cmd = {'command': 'getIconState'}
if format_version:
cmd['formatVersion'] = format_version

return self.service.send_recv_plist(cmd)

def set_icon_state(self, newstate: typing.Mapping = None):
def set_icon_state(self, newstate: Optional[Mapping] = None) -> None:
if newstate is None:
newstate = {}
cmd = {'command': 'setIconState',
'iconState': newstate}

self.service.send_recv_plist(cmd)

def get_icon_pngdata(self, bundle_id: str):
cmd = {'command': 'getIconPNGData',
'bundleId': bundle_id}
self.service.send_plist({'command': 'setIconState', 'iconState': newstate})
self.service.recv_prefixed()

return self.service.send_recv_plist(cmd).get('pngData')
def get_icon_pngdata(self, bundle_id: str) -> bytes:
return self.service.send_recv_plist({'command': 'getIconPNGData',
'bundleId': bundle_id}).get('pngData')

def get_interface_orientation(self):
cmd = {'command': 'getInterfaceOrientation'}
self.service.send_plist(cmd)
res = self.service.recv_plist()
def get_interface_orientation(self) -> InterfaceOrientation:
res = self.service.send_recv_plist({'command': 'getInterfaceOrientation'})
return InterfaceOrientation(res.get('interfaceOrientation'))

def get_wallpaper_pngdata(self):
cmd = {'command': 'getHomeScreenWallpaperPNGData'}
return self.service.send_recv_plist(cmd).get('pngData')
def get_wallpaper_pngdata(self) -> bytes:
return self.service.send_recv_plist({'command': 'getHomeScreenWallpaperPNGData'}).get('pngData')

0 comments on commit a2f6d49

Please sign in to comment.