disabling ota

This commit is contained in:
leminlimez
2024-11-15 18:34:18 -05:00
parent 07e9807a5f
commit 28f8152a80
6 changed files with 73 additions and 12 deletions

View File

@@ -11,9 +11,9 @@ from pymobiledevice3.lockdown import create_using_usbmux
from devicemanagement.constants import Device, Version from devicemanagement.constants import Device, Version
from devicemanagement.data_singleton import DataSingleton from devicemanagement.data_singleton import DataSingleton
from tweaks.tweaks import tweaks, FeatureFlagTweak, EligibilityTweak, AITweak, BasicPlistTweak, RdarFixTweak from tweaks.tweaks import tweaks, FeatureFlagTweak, EligibilityTweak, AITweak, BasicPlistTweak, AdvancedPlistTweak, RdarFixTweak
from tweaks.custom_gestalt_tweaks import CustomGestaltTweaks from tweaks.custom_gestalt_tweaks import CustomGestaltTweaks
from tweaks.basic_plist_locations import FileLocationsList from tweaks.basic_plist_locations import FileLocationsList, RiskyFileLocationsList
from Sparserestore.restore import restore_files, FileToRestore from Sparserestore.restore import restore_files, FileToRestore
def show_error_msg(txt: str, detailed_txt: str = None): def show_error_msg(txt: str, detailed_txt: str = None):
@@ -302,8 +302,8 @@ class DeviceManager:
eligibility_files = tweak.apply_tweak() eligibility_files = tweak.apply_tweak()
elif isinstance(tweak, AITweak): elif isinstance(tweak, AITweak):
ai_file = tweak.apply_tweak() ai_file = tweak.apply_tweak()
elif isinstance(tweak, BasicPlistTweak) or isinstance(tweak, RdarFixTweak): elif isinstance(tweak, BasicPlistTweak) or isinstance(tweak, RdarFixTweak) or isinstance(tweak, AdvancedPlistTweak):
basic_plists = tweak.apply_tweak(basic_plists) basic_plists = tweak.apply_tweak(basic_plists, self.allow_risky_tweaks)
else: else:
if gestalt_plist != None: if gestalt_plist != None:
gestalt_plist = tweak.apply_tweak(gestalt_plist) gestalt_plist = tweak.apply_tweak(gestalt_plist)
@@ -368,6 +368,13 @@ class DeviceManager:
path=location.value, path=location.value,
files_to_restore=files_to_restore files_to_restore=files_to_restore
) )
if self.allow_risky_tweaks:
for location in RiskyFileLocationsList:
self.concat_file(
contents=empty_data,
path=location.value,
files_to_restore=files_to_restore
)
# restore to the device # restore to the device
update_label("Restoring to device...") update_label("Restoring to device...")

View File

@@ -114,6 +114,9 @@ class MainWindow(QtWidgets.QMainWindow):
self.ui.pasteSoundChk.toggled.connect(self.on_pasteSoundChk_clicked) self.ui.pasteSoundChk.toggled.connect(self.on_pasteSoundChk_clicked)
self.ui.notifyPastesChk.toggled.connect(self.on_notifyPastesChk_clicked) self.ui.notifyPastesChk.toggled.connect(self.on_notifyPastesChk_clicked)
## RISKY OPTIONS PAGE ACTIONS
self.ui.disableOTAChk.toggled.connect(self.on_disableOTAChk_clicked)
## APPLY PAGE ACTIONS ## APPLY PAGE ACTIONS
self.ui.applyTweaksBtn.clicked.connect(self.on_applyPageBtn_clicked) self.ui.applyTweaksBtn.clicked.connect(self.on_applyPageBtn_clicked)
self.ui.removeTweaksBtn.clicked.connect(self.on_removeTweaksBtn_clicked) self.ui.removeTweaksBtn.clicked.connect(self.on_removeTweaksBtn_clicked)
@@ -219,6 +222,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.ui.euEnablerPageContent.setDisabled(False) self.ui.euEnablerPageContent.setDisabled(False)
self.ui.springboardOptionsPageContent.setDisabled(False) self.ui.springboardOptionsPageContent.setDisabled(False)
self.ui.internalOptionsPageContent.setDisabled(False) self.ui.internalOptionsPageContent.setDisabled(False)
self.ui.advancedOptionsPageContent.setDisabled(False)
self.ui.resetPairBtn.show() self.ui.resetPairBtn.show()
@@ -321,14 +325,16 @@ class MainWindow(QtWidgets.QMainWindow):
organization_name = self.settings.value("organization_name", "", type=str) organization_name = self.settings.value("organization_name", "", type=str)
self.ui.allowWifiApplyingChk.setChecked(apply_over_wifi) self.ui.allowWifiApplyingChk.setChecked(apply_over_wifi)
self.ui.skipSetupChk.setChecked(skip_setup)
self.ui.autoRebootChk.setChecked(auto_reboot) self.ui.autoRebootChk.setChecked(auto_reboot)
self.ui.showRiskyChk.setChecked(risky_tweaks)
self.ui.skipSetupChk.setChecked(skip_setup)
self.ui.supervisionChk.setChecked(supervised) self.ui.supervisionChk.setChecked(supervised)
self.ui.supervisionOrganization.setText(organization_name) self.ui.supervisionOrganization.setText(organization_name)
self.device_manager.apply_over_wifi = apply_over_wifi self.device_manager.apply_over_wifi = apply_over_wifi
self.device_manager.skip_setup = skip_setup
self.device_manager.auto_reboot = auto_reboot self.device_manager.auto_reboot = auto_reboot
self.device_manager.allow_risky_tweaks = risky_tweaks
self.device_manager.skip_setup = skip_setup
self.device_manager.supervised = supervised self.device_manager.supervised = supervised
self.device_manager.organization_name = organization_name self.device_manager.organization_name = organization_name
except: except:
@@ -668,6 +674,10 @@ class MainWindow(QtWidgets.QMainWindow):
def on_notifyPastesChk_clicked(self, checked: bool): def on_notifyPastesChk_clicked(self, checked: bool):
tweaks["AnnounceAllPastes"].set_enabled(checked) tweaks["AnnounceAllPastes"].set_enabled(checked)
## Risky Options Page
def on_disableOTAChk_clicked(self, checked: bool):
tweaks["DisableOTA"].set_enabled(checked)
## SETTINGS PAGE ## SETTINGS PAGE
def on_allowWifiApplyingChk_toggled(self, checked: bool): def on_allowWifiApplyingChk_toggled(self, checked: bool):

View File

@@ -2892,7 +2892,7 @@ class Ui_Nugget(object):
self.springboardOptionsPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None)) self.springboardOptionsPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None))
self.internalOptionsPageBtn.setText(QCoreApplication.translate("Nugget", u" Internal Options", None)) self.internalOptionsPageBtn.setText(QCoreApplication.translate("Nugget", u" Internal Options", None))
self.internalOptionsPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None)) self.internalOptionsPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None))
self.advancedPageBtn.setText(QCoreApplication.translate("Nugget", u" Advanced Options", None)) self.advancedPageBtn.setText(QCoreApplication.translate("Nugget", u" Risky Options", None))
self.advancedPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None)) self.advancedPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None))
self.applyPageBtn.setText(QCoreApplication.translate("Nugget", u" Apply", None)) self.applyPageBtn.setText(QCoreApplication.translate("Nugget", u" Apply", None))
self.applyPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None)) self.applyPageBtn.setProperty("cls", QCoreApplication.translate("Nugget", u"sidebarBtn", None))
@@ -3035,7 +3035,7 @@ class Ui_Nugget(object):
self.enableWakeVibrateChk.setText(QCoreApplication.translate("Nugget", u"Vibrate on Raise-to-Wake", None)) self.enableWakeVibrateChk.setText(QCoreApplication.translate("Nugget", u"Vibrate on Raise-to-Wake", None))
self.pasteSoundChk.setText(QCoreApplication.translate("Nugget", u"Play Sound on Paste", None)) self.pasteSoundChk.setText(QCoreApplication.translate("Nugget", u"Play Sound on Paste", None))
self.notifyPastesChk.setText(QCoreApplication.translate("Nugget", u"Show Notifications for System Pastes", None)) self.notifyPastesChk.setText(QCoreApplication.translate("Nugget", u"Show Notifications for System Pastes", None))
self.advancedOptionsLbl.setText(QCoreApplication.translate("Nugget", u"Advanced Options", None)) self.advancedOptionsLbl.setText(QCoreApplication.translate("Nugget", u"Risky Options", None))
self.label_17.setText(QCoreApplication.translate("Nugget", u"Disclaimer:\n" self.label_17.setText(QCoreApplication.translate("Nugget", u"Disclaimer:\n"
"\n" "\n"
"The options on this page may be unsafe for your device. Use these options at your own risk. Changing\n" "The options on this page may be unsafe for your device. Use these options at your own risk. Changing\n"

View File

@@ -16,9 +16,15 @@ class FileLocation(Enum):
pasteboard = "/var/Managed Preferences/mobile/com.apple.Pasteboard.plist" pasteboard = "/var/Managed Preferences/mobile/com.apple.Pasteboard.plist"
notes = "/var/Managed Preferences/mobile/com.apple.mobilenotes.plist" notes = "/var/Managed Preferences/mobile/com.apple.mobilenotes.plist"
# Risky Options
ota = "/var/Managed Preferences/mobile/com.apple.MobileAsset.plist"
# support for older versions of python that cannot enumerate over enums # support for older versions of python that cannot enumerate over enums
FileLocationsList: list[FileLocation] = [ FileLocationsList: list[FileLocation] = [
FileLocation.resolution, FileLocation.resolution,
FileLocation.springboard, FileLocation.footnote, FileLocation.springboard, FileLocation.footnote,
FileLocation.globalPreferences, FileLocation.appStore, FileLocation.backboardd, FileLocation.coreMotion, FileLocation.pasteboard, FileLocation.notes FileLocation.globalPreferences, FileLocation.appStore, FileLocation.backboardd, FileLocation.coreMotion, FileLocation.pasteboard, FileLocation.notes
]
RiskyFileLocationsList: list[FileLocation] = [
FileLocation.ota
] ]

View File

@@ -49,13 +49,15 @@ class BasicPlistTweak(Tweak):
value: any = True, value: any = True,
edit_type: TweakModifyType = TweakModifyType.TOGGLE, edit_type: TweakModifyType = TweakModifyType.TOGGLE,
min_version: Version = Version("1.0"), min_version: Version = Version("1.0"),
is_risky: bool = False,
divider_below: bool = False divider_below: bool = False
): ):
super().__init__(label=label, key=key, subkey=None, value=value, edit_type=edit_type, min_version=min_version, divider_below=divider_below) super().__init__(label=label, key=key, subkey=None, value=value, edit_type=edit_type, min_version=min_version, divider_below=divider_below)
self.file_location = file_location self.file_location = file_location
self.is_risky = is_risky
def apply_tweak(self, other_tweaks: dict) -> dict: def apply_tweak(self, other_tweaks: dict, risky_allowed: bool = False) -> dict:
if not self.enabled: if not self.enabled or (self.is_risky and not risky_allowed):
return other_tweaks return other_tweaks
if self.file_location in other_tweaks: if self.file_location in other_tweaks:
other_tweaks[self.file_location][self.key] = self.value other_tweaks[self.file_location][self.key] = self.value
@@ -63,6 +65,27 @@ class BasicPlistTweak(Tweak):
other_tweaks[self.file_location] = {self.key: self.value} other_tweaks[self.file_location] = {self.key: self.value}
return other_tweaks return other_tweaks
class AdvancedPlistTweak(BasicPlistTweak):
def __init__(
self, label: str,
file_location: FileLocation,
keyValues: dict,
edit_type: TweakModifyType = TweakModifyType.TOGGLE,
min_version: Version = Version("1.0"),
is_risky: bool = False,
divider_below: bool = False
):
super().__init__(label=label, file_location=file_location, key=None, value=keyValues, edit_type=edit_type, min_version=min_version, is_risky=is_risky, divider_below=divider_below)
def apply_tweak(self, other_tweaks: dict, risky_allowed: bool = False) -> dict:
if not self.enabled or (self.is_risky and not risky_allowed):
return other_tweaks
plist = {}
for key in self.value:
plist[key] = self.value[key]
other_tweaks[self.file_location] = plist
return other_tweaks
class RdarFixTweak(BasicPlistTweak): class RdarFixTweak(BasicPlistTweak):
def __init__(self, divider_below: bool = False): def __init__(self, divider_below: bool = False):
@@ -97,7 +120,7 @@ class RdarFixTweak(BasicPlistTweak):
def set_di_type(self, type: int): def set_di_type(self, type: int):
self.di_type = type self.di_type = type
def apply_tweak(self, other_tweaks: dict) -> dict: def apply_tweak(self, other_tweaks: dict, risky_allowed: bool = False) -> dict:
if not self.enabled: if not self.enabled:
return other_tweaks return other_tweaks
if self.di_type == -1: if self.di_type == -1:

View File

@@ -1,5 +1,5 @@
from devicemanagement.constants import Version from devicemanagement.constants import Version
from .tweak_classes import MobileGestaltTweak, MobileGestaltMultiTweak, MobileGestaltPickerTweak, FeatureFlagTweak, TweakModifyType, BasicPlistTweak, RdarFixTweak from .tweak_classes import MobileGestaltTweak, MobileGestaltMultiTweak, MobileGestaltPickerTweak, FeatureFlagTweak, TweakModifyType, BasicPlistTweak, AdvancedPlistTweak, RdarFixTweak
from .eligibility_tweak import EligibilityTweak, AITweak from .eligibility_tweak import EligibilityTweak, AITweak
from .basic_plist_locations import FileLocation from .basic_plist_locations import FileLocation
@@ -267,5 +267,20 @@ tweaks = {
"Show Notifications for System Pastes", "Show Notifications for System Pastes",
FileLocation.pasteboard, FileLocation.pasteboard,
"AnnounceAllPastes" "AnnounceAllPastes"
),
## Risky Options
"DisableOTA": AdvancedPlistTweak(
"Disable OTA Updates",
FileLocation.ota,
{
"MobileAssetServerURL-com.apple.MobileAsset.MobileSoftwareUpdate.UpdateBrain": "https://mesu.apple.com/assets/tvOS16DeveloperSeed",
"MobileAssetSUAllowOSVersionChange": False,
"MobileAssetSUAllowSameVersionFullReplacement": False,
"MobileAssetServerURL-com.apple.MobileAsset.RecoveryOSUpdate": "https://mesu.apple.com/assets/tvOS16DeveloperSeed",
"MobileAssetServerURL-com.apple.MobileAsset.RecoveryOSUpdateBrain": "https://mesu.apple.com/assets/tvOS16DeveloperSeed",
"MobileAssetServerURL-com.apple.MobileAsset.SoftwareUpdate": "https://mesu.apple.com/assets/tvOS16DeveloperSeed",
"MobileAssetAssetAudience": "65254ac3-f331-4c19-8559-cbe22f5bc1a6"
}
) )
} }