From 0625b5c3d39b782fb95441ebfd68a9adc4efcb64 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 26 Oct 2011 05:25:32 -0700 Subject: Added an insane number of code comments. --- MobileSafety.mm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/MobileSafety.mm b/MobileSafety.mm index d866387..3510a7f 100644 --- a/MobileSafety.mm +++ b/MobileSafety.mm @@ -95,6 +95,7 @@ void SafeModeAlertItem$alertSheet$buttonClicked$(id self, SEL sel, id sheet, int break; case 2: + // XXX: there are better ways of restarting SpringBoard that would actually save state exit(0); break; @@ -108,12 +109,14 @@ void SafeModeAlertItem$alertSheet$buttonClicked$(id self, SEL sel, id sheet, int void SafeModeAlertItem$configure$requirePasscodeForActions$(id self, SEL sel, BOOL configure, BOOL require) { UIAlertView *sheet([self alertSheet]); + [sheet setDelegate:self]; [sheet setBodyText:@"We apologize for the inconvenience, but SpringBoard has just crashed.\n\nMobileSubstrate /did not/ cause this problem: it has protected you from it.\n\nYour device is now running in Safe Mode. All extensions that support this safety system are disabled.\n\nReboot (or restart SpringBoard) to return to the normal mode. To return to this dialog touch the status bar.\n\nTap \"Help\" below for more tips."]; [sheet addButtonWithTitle:@"OK"]; [sheet addButtonWithTitle:@"Restart"]; [sheet addButtonWithTitle:@"Help"]; [sheet setNumberOfRows:1]; + if ([sheet respondsToSelector:@selector(setForceHorizontalButtonsLayout:)]) [sheet setForceHorizontalButtonsLayout:YES]; } @@ -140,6 +143,9 @@ static void MSAlert() { [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$SafeModeAlertItem alloc] init] autorelease]]; } + +// XXX: on iOS 5.0, we really would prefer avoiding + MSInstanceMessageHook2(void, SBStatusBar, touchesEnded,withEvent, id, touches, id, event) { MSAlert(); MSOldCall(touches, event); @@ -155,6 +161,9 @@ MSInstanceMessageHook2(void, UIStatusBar, touchesBegan,withEvent, void *, touche MSOldCall(touches, event); } + +// this fairly complex code came from Grant, to solve the "it Safe Mode"-in-bar bug + MSInstanceMessageHook0(void, SBStatusBarDataManager, _updateTimeString) { char *_data(&MSHookIvar(self, "_data")); if (_data == NULL) @@ -178,6 +187,7 @@ MSInstanceMessageHook0(void, SBStatusBarDataManager, _updateTimeString) { strcpy(timeString, "Exit Safe Mode"); } + static bool alerted_; static void AlertIfNeeded() { @@ -187,14 +197,28 @@ static void AlertIfNeeded() { MSAlert(); } + +// on iOS 4.3 and above we can use this advertisement, which seems to check every time the user unlocks +// XXX: verify that this still works on iOS 5.0 + MSClassMessageHook0(void, AAAccountManager, showMobileMeOfferIfNecessary) { AlertIfNeeded(); } + +// -[SBIconController showInfoAlertIfNeeded] explains how to drag icons around the iPhone home screen +// it used to be shown to users when they unlocked their screen for the first time, and happened every unlock +// however, as of iOS 4.3, it got relegated to only appearing once the user installed an app or web clip + MSInstanceMessageHook0(void, SBIconController, showInfoAlertIfNeeded) { AlertIfNeeded(); } + +// the icon state, including crazy configurations like Five Icon Dock, is stored in SpringBoard's defaults +// unfortunately, SpringBoard on iOS 2.0 and 2.1 (maybe 2.2 as well) buffer overrun with more than 4 icons +// there is a third party package called IconSupport that remedies this, but not everyone is using it yet + MSInstanceMessageHook0(int, SBButtonBar, maxIconColumns) { static int max; if (max == 0) { @@ -212,6 +236,7 @@ MSInstanceMessageHook0(int, SBButtonBar, maxIconColumns) { } return max; } + MSInstanceMessageHook0(id, SBUIController, init) { if ((self = MSOldCall()) != nil) { UIView *&_contentLayer(MSHookIvar(self, "_contentLayer")); @@ -250,6 +275,10 @@ MSInstanceMessageHook0(void, SBStatusBarTimeView, tile) { _textRect.origin.y = (frame.size.height - size.height) / 2; } + +// notification widgets ("wee apps" or "bulletin board sections") are capable of crashing SpringBoard +// unfortunately, which ones are in use are stored in SpringBoard's defaults, so we need to turn them off + MSInstanceMessageHook0(BOOL, BBSectionInfo, showsInNotificationCenter) { return NO; } -- cgit v1.2.3