summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-10-26 05:25:32 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2011-10-26 06:53:59 -0700
commit0625b5c3d39b782fb95441ebfd68a9adc4efcb64 (patch)
tree498d04c280874c1c3c444cfeaa34fd501b1c7012
parente95025382fd9ff98d7d32e4484828eaca18d10a6 (diff)
Added an insane number of code comments.
-rw-r--r--MobileSafety.mm29
1 files changed, 29 insertions, 0 deletions
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<char>(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<UIView *>(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;
}