From a543f8cb9bb543ced20d3e49af6d2461c1b0be00 Mon Sep 17 00:00:00 2001 From: leminlimez <59540996+leminlimez@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:07:51 -0400 Subject: [PATCH] resetting file location tweaks --- cli_app.py | 10 +++++++++- devicemanagement/device_manager.py | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/cli_app.py b/cli_app.py index d14837a..94c0128 100644 --- a/cli_app.py +++ b/cli_app.py @@ -1,5 +1,6 @@ from Sparserestore.restore import restore_files, FileToRestore, restore_file from tweaks.tweaks import tweaks, TweakModifyType, FeatureFlagTweak, EligibilityTweak, BasicPlistTweak +from tweaks.basic_plist_locations import FileLocation from devicemanagement.constants import Device from pymobiledevice3.exceptions import PyMobileDevice3Exception @@ -125,7 +126,6 @@ while running: basic_plists = tweak.apply_tweak(basic_plists) else: gestalt_plist = tweak.apply_tweak(gestalt_plist) - # TODO: Improve resetting (make it work with basic plist tweaks) # create the restore file list files_to_restore = [ @@ -147,6 +147,14 @@ while running: contents=plistlib.dumps(plist), restore_path=location.value )) + # reset basic tweaks + if resetting: + empty_data = plistlib.dumps({}) + for location in FileLocation: + files_to_restore.append(FileToRestore( + contents=empty_data, + restore_path=location.value + )) # restore to the device try: restore_files(files=files_to_restore, reboot=True, lockdown_client=device.ld) diff --git a/devicemanagement/device_manager.py b/devicemanagement/device_manager.py index 48f2fb6..e50032f 100644 --- a/devicemanagement/device_manager.py +++ b/devicemanagement/device_manager.py @@ -11,6 +11,7 @@ from devicemanagement.constants import Device, Version from devicemanagement.data_singleton import DataSingleton from tweaks.tweaks import tweaks, FeatureFlagTweak, EligibilityTweak, BasicPlistTweak +from tweaks.basic_plist_locations import FileLocation from Sparserestore.restore import restore_files, FileToRestore def show_error_msg(txt: str): @@ -121,6 +122,12 @@ class DeviceManager: if gestalt_plist != None: gestalt_plist = tweak.apply_tweak(gestalt_plist) + gestalt_data = None + if resetting: + gestalt_data = b"" + elif gestalt_plist != None: + gestalt_data = plistlib.dumps(gestalt_plist) + # Generate backup update_label("Generating backup...") # create the restore file list @@ -131,9 +138,9 @@ class DeviceManager: restore_name="Global.plist" ) ] - if gestalt_plist != None: + if gestalt_data != None: files_to_restore.append(FileToRestore( - contents=plistlib.dumps(gestalt_plist), + contents=gestalt_data, restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/", restore_name="com.apple.MobileGestalt.plist" )) @@ -144,6 +151,14 @@ class DeviceManager: contents=plistlib.dumps(plist), restore_path=location.value )) + # reset basic tweaks + if resetting: + empty_data = plistlib.dumps({}) + for location in FileLocation: + files_to_restore.append(FileToRestore( + contents=empty_data, + restore_path=location.value + )) # restore to the device update_label("Restoring to device...")