mirror of
https://github.com/leminlimez/Nugget.git
synced 2025-04-08 04:23:05 +08:00
resetting file location tweaks
This commit is contained in:
10
cli_app.py
10
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)
|
||||
|
||||
@@ -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...")
|
||||
|
||||
Reference in New Issue
Block a user