This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
SpringBoard.xm
202 lines (175 loc) · 6.22 KB
/
SpringBoard.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#import <UIKit/UIKit.h>
#import <substrate.h>
#import <SpringBoard/SBApplication.h>
#include <mach/mach.h>
#include <libkern/OSCacheControl.h>
#include <stdbool.h>
#include <dlfcn.h>
#include <sys/sysctl.h>
#import <notify.h>
#import "RACompatibilitySystem.h"
#import "headers.h"
#import "RAWidgetSectionManager.h"
#import "RASettings.h"
#import "RASwipeOverManager.h"
#import "RAMissionControlManager.h"
#import "RADesktopManager.h"
#import "RADesktopWindow.h"
#import "Asphaleia2.h"
#import "RASnapshotProvider.h"
extern BOOL overrideDisableForStatusBar;
%hook SBUIController
- (_Bool)clickedMenuButton
{
if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver])
{
[[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver];
return YES;
}
if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive)
{
overrideDisableForStatusBar = NO;
[[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated];
return YES;
}
if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl])
{
[[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES];
return YES;
}
return %orig;
}
/*- (_Bool)handleMenuDoubleTap
{
if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver])
{
[[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver];
}
//if (RAMissionControlManager.sharedInstance.isShowingMissionControl)
//{
// [RAMissionControlManager.sharedInstance hideMissionControl:YES];
//}
return %orig;
}*/
// This should help fix the problems where closing an app with Tage or the iPad Gesture would cause the app to suspend(?) and lock up the device.
- (void)_suspendGestureBegan
{
%orig;
[UIApplication.sharedApplication._accessibilityFrontMostApplication clearDeactivationSettings];
}
%end
%hook SpringBoard
-(void) _performDeferredLaunchWork
{
%orig;
[RADesktopManager sharedInstance]; // load desktop (and previous windows!)
// No applications show in the mission control until they have been launched by the user.
// This prevents always-running apps like Mail or Pebble from perpetually showing in Mission Control.
//[[%c(RAMissionControlManager) sharedInstance] setInhibitedApplications:[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers]];
}
%end
%hook SBApplicationController
%new -(SBApplication*) RA_applicationWithBundleIdentifier:(__unsafe_unretained NSString*)bundleIdentifier
{
if ([self respondsToSelector:@selector(applicationWithBundleIdentifier:)])
return [self applicationWithBundleIdentifier:bundleIdentifier];
else if ([self respondsToSelector:@selector(applicationWithDisplayIdentifier:)])
return [self applicationWithDisplayIdentifier:bundleIdentifier];
[RACompatibilitySystem showWarning:@"Unable to find valid -[SBApplicationController applicationWithBundleIdentifier:] replacement"];
return nil;
}
%end
%hook SBToAppsWorkspaceTransaction
- (void)_willBegin
{
@autoreleasepool {
NSArray *apps = nil;
if ([self respondsToSelector:@selector(toApplications)])
apps = [self toApplications];
else
apps = [MSHookIvar<NSArray*>(self, "_toApplications") copy];
for (SBApplication *app in apps)
{
dispatch_async(dispatch_get_main_queue(), ^{
[RADesktopManager.sharedInstance removeAppWithIdentifier:app.bundleIdentifier animated:NO forceImmediateUnload:YES];
});
}
}
%orig;
}
// On iOS 8.3 and above, on the iPad, if a FBWindowContextWhatever creates a hosting context / enabled hosting, all the other hosted windows stop.
// This fixes that.
-(void)_didComplete
{
%orig;
//if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
// can't hurt to check all devices - especially if it changes/has changed to include phones.
// however this was presumably done in preparation for the iOS 9 multitasking
[RAHostedAppView iPad_iOS83_fixHosting];
}
%end
/*
%hook SBRootFolderView
- (_Bool)_hasMinusPages
{
return RADesktopManager.sharedInstance.currentDesktop.hostedWindows.count > 0 ? YES : %orig;
}
- (unsigned long long)_minusPageCount
{
return RADesktopManager.sharedInstance.currentDesktop.hostedWindows.count > 0 ? 1 : %orig;
}
%end
*/
%hook SpringBoard
-(void)noteInterfaceOrientationChanged:(int)arg1 duration:(float)arg2
{
%orig;
[RASnapshotProvider.sharedInstance forceReloadEverything];
}
%end
%hook SBApplication
- (void)didActivateWithTransactionID:(unsigned long long)arg1
{
dispatch_async(dispatch_get_main_queue(), ^{
[RASnapshotProvider.sharedInstance forceReloadOfSnapshotForIdentifier:self.bundleIdentifier];
});
%orig;
}
%end
%hook SBLockScreenManager
- (void)_postLockCompletedNotification:(_Bool)arg1
{
%orig;
if (arg1)
{
if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver])
[[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver];
}
}
%end
%hook UIScreen
%new -(CGRect) RA_interfaceOrientedBounds
{
if ([self respondsToSelector:@selector(_interfaceOrientedBounds)])
return [self _interfaceOrientedBounds];
return [self bounds];
}
%end
void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
[[UIApplication sharedApplication] _relaunchSpringBoardNow];
}
void reset_settings_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
[RASettings.sharedInstance resetSettings];
}
%ctor
{
if (IS_SPRINGBOARD)
{
%init;
LOAD_ASPHALEIA;
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, respring_notification, CFSTR("com.efrederickson.reachapp.respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, reset_settings_notification, CFSTR("com.efrederickson.reachapp.resetSettings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}
}