From 56f3c45eea5cc8af28bbb21f2140da448f7ce5e6 Mon Sep 17 00:00:00 2001 From: doronz88 Date: Sun, 30 Jun 2024 17:50:12 +0300 Subject: [PATCH] springboard: add ios18 features --- pymobiledevice3/cli/springboard.py | 21 ++++++++++++++++++--- pymobiledevice3/services/springboard.py | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/pymobiledevice3/cli/springboard.py b/pymobiledevice3/cli/springboard.py index 56d612e21..5a5f69b35 100644 --- a/pymobiledevice3/cli/springboard.py +++ b/pymobiledevice3/cli/springboard.py @@ -1,3 +1,5 @@ +from typing import IO + import click import IPython @@ -59,8 +61,21 @@ def springboard_orientation(service_provider: LockdownClient): print(SpringBoardServicesService(lockdown=service_provider).get_interface_orientation()) -@springboard.command('wallpaper', cls=Command) +@springboard.command('wallpaper-home-screen', cls=Command) @click.argument('out', type=click.File('wb')) -def springboard_wallpaper(service_provider: LockdownClient, out): - """ get wallpapaer """ +def springboard_wallpaper_home_screen(service_provider: LockdownClient, out: IO) -> None: + """ get homescreen wallpaper """ out.write(SpringBoardServicesService(lockdown=service_provider).get_wallpaper_pngdata()) + + +@springboard.command('wallpaper-preview-image', cls=Command) +@click.argument('wallpaper-name', type=click.Choice(['homescreen', 'lockscreen'])) +@click.argument('out', type=click.File('wb')) +@click.option('-r', '--reload', is_flag=True, help='reload icon state before fetching image') +def springboard_wallpaper_preview_image(service_provider: LockdownClient, wallpaper_name: str, out: IO, + reload: bool) -> None: + """ get the preview image of either the homescreen or the lockscreen """ + with SpringBoardServicesService(lockdown=service_provider) as springboard_service: + if reload: + springboard_service.reload_icon_state() + out.write(springboard_service.get_wallpaper_preview_image(wallpaper_name)) diff --git a/pymobiledevice3/services/springboard.py b/pymobiledevice3/services/springboard.py index 592ef131b..db38c332f 100644 --- a/pymobiledevice3/services/springboard.py +++ b/pymobiledevice3/services/springboard.py @@ -1,5 +1,5 @@ from enum import IntEnum -from typing import List, Optional +from typing import List, Mapping, Optional from pymobiledevice3.lockdown import LockdownClient from pymobiledevice3.lockdown_service_provider import LockdownServiceProvider @@ -45,3 +45,16 @@ def get_interface_orientation(self) -> InterfaceOrientation: def get_wallpaper_pngdata(self) -> bytes: return self.service.send_recv_plist({'command': 'getHomeScreenWallpaperPNGData'}).get('pngData') + + def get_homescreen_icon_metrics(self) -> Mapping[str, float]: + return self.service.send_recv_plist({'command': 'getHomeScreenIconMetrics'}) + + def get_wallpaper_info(self, wallpaper_name: str) -> Mapping: + return self.service.send_recv_plist({'command': 'getWallpaperInfo', 'wallpaperName': wallpaper_name}) + + def reload_icon_state(self) -> None: + self.set_icon_state(self.get_icon_state()) + + def get_wallpaper_preview_image(self, wallpaper_name: str) -> bytes: + return self.service.send_recv_plist({ + 'command': 'getWallpaperPreviewImage', 'wallpaperName': wallpaper_name})['pngData']