fix applying for cli & gui

This commit is contained in:
leminlimez
2024-09-26 13:05:52 -04:00
parent bf36bc88b8
commit 8362fc6b4a
7 changed files with 43 additions and 12 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,7 +1,9 @@
from . import backup, perform_restore
from pymobiledevice3.lockdown import LockdownClient
import os
class FileToRestore:
# TODO: Depricate this in favor of second init definition
def __init__(self, contents: str, restore_path: str, restore_name: str, owner: int = 501, group: int = 501):
self.contents = contents
self.restore_path = restore_path
@@ -9,6 +11,14 @@ class FileToRestore:
self.owner = owner
self.group = group
def __init__(self, contents: str, restore_path: str, owner: int = 501, group: int = 501):
self.contents = contents
path, file = os.path.split(restore_path)
self.restore_path = path + "/"
self.restore_name = file # TODO: Remove this and handle splitting in the restore_files function
self.owner = owner
self.group = group
# files is a list of FileToRestore objects
def restore_files(files: list, reboot: bool = False, lockdown_client: LockdownClient = None):
# create the files to be backed up

View File

@@ -1,5 +1,5 @@
from Sparserestore.restore import restore_files, FileToRestore, restore_file
from tweaks.tweaks import tweaks, TweakModifyType, FeatureFlagTweak, EligibilityTweak
from tweaks.tweaks import tweaks, TweakModifyType, FeatureFlagTweak, EligibilityTweak, BasicPlistTweak
from devicemanagement.constants import Device
from pymobiledevice3.exceptions import PyMobileDevice3Exception
@@ -48,7 +48,7 @@ while running:
'---' \\ \\ / \\ \\ / `----'
`--`-' `--`-'
""")
print("CLI v2.2")
print("CLI v3.0")
print("by LeminLimez")
print("Thanks @disfordottie for the clock animation and @lrdsnow for EU Enabler\n")
print("Please back up your device before using!")
@@ -102,6 +102,7 @@ while running:
# create the other plists
flag_plist: dict = {}
eligibility_files = None
basic_plists: dict = {}
# verify the device credentials before continuing
if gestalt_plist["CacheExtra"]["qNNddlUK+B/YlooNoymwgA"] != device.version or gestalt_plist["CacheExtra"]["0+nc/Udy4WNG8S+Q7a/s1A"] != device.model:
@@ -120,8 +121,11 @@ while running:
elif isinstance(tweak, EligibilityTweak):
tweak.set_region_code(device.locale[-2:])
eligibility_files = tweak.apply_tweak()
elif isinstance(tweak, BasicPlistTweak):
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 = [
@@ -138,6 +142,11 @@ while running:
]
if eligibility_files != None:
files_to_restore += eligibility_files
for location, plist in basic_plists:
files_to_restore.append(FileToRestore(
contents=plistlib.dumps(plist),
restore_path=location.value
))
# restore to the device
try:
restore_files(files=files_to_restore, reboot=True, lockdown_client=device.ld)
@@ -169,14 +178,18 @@ while running:
if page > 0 and page <= num_tweaks and tweak.is_compatible(device.version):
if tweak.edit_type == TweakModifyType.TEXT:
# text input
# for now it is just for set model, deal with a fix later
print("\n\nSet Model Name")
print("Leave blank to turn off custom name.\n")
name = input("Enter Model Name: ")
if name == "":
inp_txt = ""
print(f"\n\n{tweak.label}")
print("Leave blank to turn off.\n")
if tweak.label == "Set Device Model Name":
inp_txt = "Enter Model Name: "
elif tweak.label == "Set Lock Screen Footnote Text":
inp_txt = "Enter Footnote: "
new_txt = input(inp_txt)
if new_txt == "":
tweak.set_enabled(False)
else:
tweak.set_value(name)
tweak.set_value(new_txt)
elif tweak.edit_type == TweakModifyType.PICKER:
# pick between values
print("\n\nSelect a value.")

View File

@@ -10,7 +10,7 @@ from pymobiledevice3.lockdown import create_using_usbmux
from devicemanagement.constants import Device, Version
from devicemanagement.data_singleton import DataSingleton
from tweaks.tweaks import tweaks, FeatureFlagTweak, EligibilityTweak
from tweaks.tweaks import tweaks, FeatureFlagTweak, EligibilityTweak, BasicPlistTweak
from Sparserestore.restore import restore_files, FileToRestore
def show_error_msg(txt: str):
@@ -105,6 +105,7 @@ class DeviceManager:
# create the other plists
flag_plist: dict = {}
eligibility_files = None
basic_plists: dict = {}
# set the plist keys
if not resetting:
@@ -114,6 +115,8 @@ class DeviceManager:
flag_plist = tweak.apply_tweak(flag_plist)
elif isinstance(tweak, EligibilityTweak):
eligibility_files = tweak.apply_tweak()
elif isinstance(tweak, BasicPlistTweak):
basic_plists = tweak.apply_tweak(basic_plists)
else:
if gestalt_plist != None:
gestalt_plist = tweak.apply_tweak(gestalt_plist)
@@ -136,6 +139,11 @@ class DeviceManager:
))
if eligibility_files:
files_to_restore += eligibility_files
for location, plist in basic_plists:
files_to_restore.append(FileToRestore(
contents=plistlib.dumps(plist),
restore_path=location.value
))
# restore to the device
update_label("Restoring to device...")

View File

@@ -1518,7 +1518,7 @@ QToolButton:pressed {
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Nugget GUI - Version 2.2</string>
<string>Nugget GUI - Version 3.0 (beta 1)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>

View File

@@ -2151,7 +2151,7 @@ class Ui_Nugget(object):
self.toolButton_15.setText(QCoreApplication.translate("Nugget", u"Additional Thanks", None))
self.libiBtn.setText(QCoreApplication.translate("Nugget", u"pymobiledevice3", None))
self.qtBtn.setText(QCoreApplication.translate("Nugget", u"Qt Creator", None))
self.label.setText(QCoreApplication.translate("Nugget", u"Nugget GUI - Version 2.2", None))
self.label.setText(QCoreApplication.translate("Nugget", u"Nugget GUI - Version 3.0 (beta 1)", None))
self.exploreLbl.setText(QCoreApplication.translate("Nugget", u"Explore", None))
self.exploreSubLbl.setText("")
self.statusBarLbl_2.setText(QCoreApplication.translate("Nugget", u"Location Simulation", None))

View File

@@ -39,7 +39,7 @@ tweaks = {
## Springboard Tweaks
"LockScreenFootnote": BasicPlistTweak(
"Lock Screen Footnote Text",
"Set Lock Screen Footnote Text",
FileLocation.footnote,
key="LockScreenFootnote", value="",
edit_type=TweakModifyType.TEXT