Skip to content

Commit

Permalink
4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveJessyChen committed Nov 4, 2024
1 parent fa87353 commit 1ad50de
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build
com.apple.MobileGestalt.plist
.DS_Store
__pycache__
*.spec
/dist
2 changes: 1 addition & 1 deletion Sparserestore/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def restore_files(files: list, reboot: bool = False, lockdown_client: LockdownCl
perform_restore(backup=back, reboot=reboot, lockdown_client=lockdown_client)


# DEPRICATED
# DEPRECIATED
def restore_file(fp: str, restore_path: str, restore_name: str, reboot: bool = False, lockdown_client: LockdownClient = None):
# open the file and read the contents
contents = open(fp, "rb").read()
Expand Down
4 changes: 3 additions & 1 deletion devicemanagement/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
from pymobiledevice3.lockdown import LockdownClient

class Device:
def __init__(self, uuid: int, name: str, version: str, build: str, model: str, locale: str, ld: LockdownClient):
def __init__(self, uuid: int, name: str, version: str, build: str, model: str, hardware: str, cpu: str, locale: str, ld: LockdownClient):
self.uuid = uuid
self.name = name
self.version = version
self.build = build
self.model = model
self.hardware = hardware
self.cpu = cpu
self.locale = locale
self.ld = ld

Expand Down
41 changes: 39 additions & 2 deletions devicemanagement/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,36 @@ def get_devices(self, settings: QSettings):
If you are on Linux, make sure you have usbmuxd and libimobiledevice installed.
"""
)
self.set_current_device(index=None)
return
# Connect via usbmuxd
for device in connected_devices:
if self.apply_over_wifi or device.is_usb:
try:
ld = create_using_usbmux(serial=device.serial)
vals = ld.all_values
model = vals['ProductType']
hardware = vals['HardwareModel']
cpu = vals['HardwarePlatform']
try:
product_type = settings.value(device.serial + "_model", "", type=str)
hardware_type = settings.value(device.serial + "_hardware", "", type=str)
cpu_type = settings.value(device.serial + "_cpu", "", type=str)
if product_type == "":
# save the new product type
settings.setValue(device.serial + "_model", model)
else:
model = product_type
if hardware_type == "":
# save the new hardware model
settings.setValue(device.serial + "_hardware", hardware)
else:
hardware = hardware_type
if cpu_type == "":
# save the new cpu model
settings.setValue(device.serial + "_cpu", cpu)
else:
cpu = cpu_type
except:
pass
dev = Device(
Expand All @@ -72,6 +88,8 @@ def get_devices(self, settings: QSettings):
version=vals['ProductVersion'],
build=vals['BuildVersion'],
model=model,
hardware=hardware,
cpu=cpu,
locale=ld.locale,
ld=ld
)
Expand All @@ -80,6 +98,9 @@ def get_devices(self, settings: QSettings):
except Exception as e:
print(f"ERROR with lockdown device with UUID {device.serial}")
show_error_msg(type(e).__name__ + ": " + repr(e))
connected_devices.remove(device)
else:
connected_devices.remove(device)

if len(connected_devices) > 0:
self.set_current_device(index=0)
Expand All @@ -94,6 +115,8 @@ def set_current_device(self, index: int = None):
self.data_singleton.gestalt_path = None
self.current_device_index = 0
tweaks["SpoofModel"].value[0] = "Placeholder"
tweaks["SpoofHardware"].value[0] = "Placeholder"
tweaks["SpoofCPU"].value[0] = "Placeholder"
else:
self.data_singleton.current_device = self.devices[index]
if Version(self.devices[index].version) < Version("17.0"):
Expand All @@ -102,6 +125,8 @@ def set_current_device(self, index: int = None):
else:
self.data_singleton.device_available = True
tweaks["SpoofModel"].value[0] = self.data_singleton.current_device.model
tweaks["SpoofHardware"].value[0] = self.data_singleton.current_device.hardware
tweaks["SpoofCPU"].value[0] = self.data_singleton.current_device.cpu
self.current_device_index = index

def get_current_device_name(self) -> str:
Expand Down Expand Up @@ -150,8 +175,12 @@ def add_skip_setup(self, files_to_restore: list[FileToRestore]):
# add the 2 skip setup files
cloud_config_plist: dict = {
"SkipSetup": ["WiFi", "Location", "Restore", "SIMSetup", "Android", "AppleID", "IntendedUser", "TOS", "Siri", "ScreenTime", "Diagnostics", "SoftwareUpdate", "Passcode", "Biometric", "Payment", "Zoom", "DisplayTone", "MessagingActivationUsingPhoneNumber", "HomeButtonSensitivity", "CloudStorage", "ScreenSaver", "TapToSetup", "Keyboard", "PreferredLanguage", "SpokenLanguage", "WatchMigration", "OnBoarding", "TVProviderSignIn", "TVHomeScreenSync", "Privacy", "TVRoom", "iMessageAndFaceTime", "AppStore", "Safety", "Multitasking", "ActionButton", "TermsOfAddress", "AccessibilityAppearance", "Welcome", "Appearance", "RestoreCompleted", "UpdateCompleted"],
"AllowPairing": True,
"ConfigurationWasApplied": True,
"CloudConfigurationUIComplete": True,
"IsSupervised": False
"ConfigurationSource": 0,
"PostSetupProfileWasInstalled": True,
"IsSupervised": False,
}
files_to_restore.append(FileToRestore(
contents=plistlib.dumps(cloud_config_plist),
Expand Down Expand Up @@ -309,6 +338,12 @@ def apply_changes(self, resetting: bool = False, update_label=lambda x: None):
detailsBox.setText("Find My must be disabled in order to use this tool.")
detailsBox.setDetailedText("Disable Find My from Settings (Settings -> [Your Name] -> Find My) and then try again.")
detailsBox.exec()
elif "SessionInactive" in str(e):
detailsBox = QMessageBox()
detailsBox.setIcon(QMessageBox.Critical)
detailsBox.setWindowTitle("Error!")
detailsBox.setText("The session was terminated. Refresh the device list and try again.")
detailsBox.exec()
else:
print(traceback.format_exc())
update_label("Failed to restore")
Expand All @@ -319,8 +354,10 @@ def reset_mobilegestalt(self, settings: QSettings, update_label=lambda x: None):
# restore to the device
update_label("Restoring to device...")
try:
# remove the saved device model
# remove the saved device model, hardware, and cpu
settings.setValue(self.data_singleton.current_device.uuid + "_model", "")
settings.setValue(self.data_singleton.current_device.uuid + "_hardware", "")
settings.setValue(self.data_singleton.current_device.uuid + "_cpu", "")
domain, file_path = self.get_domain_for_path("/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist")
restore_files(files=[FileToRestore(
contents=b"",
Expand Down
53 changes: 46 additions & 7 deletions gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def __init__(self, device_manager: DeviceManager):
self.ui.regionCodeTxt.textEdited.connect(self.on_regionCodeTxt_textEdited)

self.ui.enableAIChk.toggled.connect(self.on_enableAIChk_toggled)
self.ui.eligFileChk.toggled.connect(self.on_eligFileChk_toggled)
self.ui.experimentalChk.toggled.connect(self.on_experimentalChk_toggled)
self.ui.languageTxt.hide() # to be removed later
self.ui.languageLbl.hide() # to be removed later
self.ui.languageTxt.textEdited.connect(self.on_languageTxt_textEdited)
self.ui.spoofedModelDrp.activated.connect(self.on_spoofedModelDrp_activated)

Expand Down Expand Up @@ -233,12 +237,7 @@ def change_selected_device(self, index):
self.ui.dynamicIslandDrp.removeItem(5)
except:
pass
rdar_title = tweaks["RdarFix"].get_rdar_title()
if rdar_title == "hide":
self.ui.rdarFixChk.hide()
else:
self.ui.rdarFixChk.show()
self.ui.rdarFixChk.setText(f"{rdar_title} (modifies resolution)")
self.set_rdar_fix_label()
device_ver = Version(self.device_manager.data_singleton.current_device.version)
# toggle option visibility for the minimum versions
for version in MinTweakVersions.keys():
Expand Down Expand Up @@ -274,6 +273,10 @@ def change_selected_device(self, index):
self.ui.euEnablerPageBtn.show()
else:
self.ui.euEnablerPageBtn.hide()

# hide the ai content if not on
if device_ver >= Version("18.1") and not tweaks["AIGestalt"].enabled:
self.ui.aiEnablerContent.hide()
else:
self.device_manager.set_current_device(index=None)

Expand Down Expand Up @@ -398,12 +401,22 @@ def on_bigNuggetBtn_clicked(self):


## MOBILE GESTALT PAGE
def set_rdar_fix_label(self):
rdar_title = tweaks["RdarFix"].get_rdar_title()
if rdar_title == "hide":
self.ui.rdarFixChk.hide()
else:
self.ui.rdarFixChk.show()
self.ui.rdarFixChk.setText(f"{rdar_title} (modifies resolution)")

def on_dynamicIslandDrp_activated(self, index: int):
if index == 0:
tweaks["DynamicIsland"].set_enabled(False)
tweaks["RdarFix"].set_di_type(-1)
else:
tweaks["DynamicIsland"].set_selected_option(index - 1)
tweaks["RdarFix"].set_di_type(tweaks["DynamicIsland"].value[tweaks["DynamicIsland"].get_selected_option()])
self.set_rdar_fix_label()
def on_rdarFixChk_clicked(self, checked: bool):
tweaks["RdarFix"].set_enabled(checked)

Expand Down Expand Up @@ -531,17 +544,37 @@ def on_regionCodeTxt_textEdited(self, text: str):
tweaks["EUEnabler"].set_region_code(text)

def on_enableAIChk_toggled(self, checked: bool):
tweaks["AIEligibility"].set_enabled(checked)
# tweaks["AIEligibility"].set_enabled(checked)
tweaks["AIGestalt"].set_enabled(checked)
# change the visibility of stuff
if checked:
self.ui.aiEnablerContent.show()
else:
self.ui.aiEnablerContent.hide()

def on_eligFileChk_toggled(self, checked: bool):
tweaks["AIEligibility"].set_enabled(checked)
if checked:
self.ui.languageTxt.show()
self.ui.languageLbl.show()
else:
self.ui.languageTxt.hide()
self.ui.languageLbl.hide()
def on_experimentalChk_toggled(self, checked: bool):
tweaks["AIExperiment"].set_enabled(checked)

def on_languageTxt_textEdited(self, text: str):
tweaks["AIEligibility"].set_language_code(text)

def on_spoofedModelDrp_activated(self, index: int):
tweaks["SpoofModel"].set_selected_option(index)
tweaks["SpoofHardware"].set_selected_option(index)
if index == 0:
tweaks["SpoofCPU"].set_selected_option(0)
elif index == 1 or index == 2:
tweaks["SpoofCPU"].set_selected_option(1)
else:
tweaks["SpoofCPU"].set_selected_option(2)


## SPRINGBOARD OPTIONS PAGE
Expand Down Expand Up @@ -620,6 +653,9 @@ def on_chooseGestaltBtn_clicked(self):
if selected_file == "" or selected_file == None:
self.device_manager.data_singleton.gestalt_path = None
self.ui.gestaltLocationLbl.setText("None")
# show the warning labels
self.ui.mgaWarningLbl.show()
self.ui.mgaWarningLbl2.show()
else:
# verify that the gestalt is correct and compatible
with open(selected_file, 'rb') as in_fp:
Expand All @@ -645,6 +681,9 @@ def on_chooseGestaltBtn_clicked(self):
dialog.exec()
self.device_manager.data_singleton.gestalt_path = selected_file
self.ui.gestaltLocationLbl.setText(selected_file)
# hide the warning labels
self.ui.mgaWarningLbl.hide()
self.ui.mgaWarningLbl2.hide()

def update_label(self, txt: str):
self.ui.statusLbl.setText(txt)
Expand Down
43 changes: 0 additions & 43 deletions main_app.spec

This file was deleted.

Loading

0 comments on commit 1ad50de

Please sign in to comment.