-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for iOS 11 #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
#define CoreFoundationiOS7 847.20 | ||
#define CoreFoundationiOS10 1348.00 | ||
#define CoreFoundationiOS11 1443.00 | ||
|
||
static BOOL shouldShowPicker = NO; | ||
|
||
|
@@ -88,8 +89,8 @@ static BOOL isLongHoldEnabled() | |
return; | ||
} | ||
|
||
//It does not work well on lock screen on iOS10. | ||
if (kCFCoreFoundationVersionNumber >= CoreFoundationiOS10 && [[objc_getClass("SBUserAgent") sharedUserAgent] deviceIsLocked]) return; | ||
//It does not work well on lock screen on iOS10 and iOS 11. | ||
if (((kCFCoreFoundationVersionNumber >= CoreFoundationiOS10 && kCFCoreFoundationVersionNumber < CoreFoundationiOS11) && [[objc_getClass("SBUserAgent") sharedUserAgent] deviceIsLocked]) || (kCFCoreFoundationVersionNumber >= CoreFoundationiOS11 && [[objc_getClass("SBUserAgent") alloc] deviceIsLocked])) return; | ||
|
||
if (event) | ||
{ | ||
|
@@ -269,10 +270,13 @@ static BOOL isLongHoldEnabled() | |
- (void)scan | ||
{ | ||
//Only on 7 and later | ||
if (kCFCoreFoundationVersionNumber >= CoreFoundationiOS7) | ||
if (kCFCoreFoundationVersionNumber >= CoreFoundationiOS7 && kCFCoreFoundationVersionNumber < CoreFoundationiOS11) | ||
{ | ||
[[objc_getClass("WFWiFiManager") sharedInstance] setValue:[NSNumber numberWithInt:-130] forKey:@"_rssiThreshold"]; | ||
} | ||
} | ||
else if (kCFCoreFoundationVersionNumber >= CoreFoundationiOS11) { | ||
[[objc_getClass("WPScanRequest") alloc] setRssiThreshold:[NSNumber numberWithInt:-130]]; | ||
} | ||
%orig; | ||
} | ||
|
||
|
@@ -490,6 +494,58 @@ static char wipiHoldGestureRecognizer; | |
%end | ||
%end | ||
|
||
@interface CCUIConnectivityWifiViewController : UIViewController | ||
@property (nonatomic, retain) UILongPressGestureRecognizer *longPressRecognizer; | ||
@property (nonatomic, retain) UIButton *button; | ||
- (void)_wipi_longHoldAction; | ||
@end | ||
|
||
%group ControlCenter11 | ||
%hook CCUIConnectivityWifiViewController | ||
%property (nonatomic, retain) UILongPressGestureRecognizer *longPressRecognizer; | ||
|
||
%new | ||
- (void)longPressRecognized:(UILongPressGestureRecognizer *)sender { | ||
if (sender.state == UIGestureRecognizerStateBegan) { | ||
if ([self valueForKey:@"_parentViewController"]) { | ||
if ([[self valueForKey:@"_parentViewController"] valueForKey:@"_expanded"]) { | ||
if ([[[self valueForKey:@"_parentViewController"] valueForKey:@"_expanded"] boolValue] == YES) { | ||
[self _wipi_longHoldAction]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
- (id)init { | ||
CCUIConnectivityWifiViewController *controller = %orig; | ||
if (controller) { | ||
controller.longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressRecognized:)]; | ||
controller.longPressRecognizer.minimumPressDuration = 0.9; | ||
} | ||
return controller; | ||
|
||
} | ||
|
||
- (void)viewDidLoad { | ||
%orig; | ||
if (self.longPressRecognizer && self.button) { | ||
[self.button addGestureRecognizer:self.longPressRecognizer]; | ||
} | ||
} | ||
|
||
%new | ||
- (void)_wipi_longHoldAction | ||
{ | ||
if (isLongHoldEnabled()) | ||
{ | ||
[[LAActivator sharedInstance] sendEvent:nil toListenerWithName:@"com.bensge.wipi"]; | ||
} | ||
} | ||
|
||
%end | ||
%end | ||
|
||
/* | ||
* Hook setup code | ||
*/ | ||
|
@@ -568,6 +624,16 @@ void initFlipSwitch() | |
%end | ||
%end | ||
|
||
static BOOL didHook = NO; | ||
static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { | ||
if ([((__bridge NSDictionary *)userInfo)[NSLoadedClasses] containsObject:@"CCUIConnectivityAirDropViewController"]) { // The Network Bundle is Loaded | ||
if (!didHook) { | ||
didHook = YES; | ||
%init(ControlCenter11); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove the notification observer afterwards? Just to clean things up and not leave the notification listener active forever There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can delete it. It is necessary to prepare another method. |
||
} | ||
} | ||
} | ||
|
||
/* | ||
* ------------- | ||
* | Constructor | | ||
|
@@ -591,6 +657,28 @@ void initFlipSwitch() | |
%init(ControlCenter, BUTTONCLASS=(objc_getClass("SBControlCenterButton") ?: objc_getClass("CCUIControlCenterPushButton"))); | ||
} | ||
|
||
BOOL shouldInit = NO; | ||
if (!NSClassFromString(@"APTableCell")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain the logic here? This is not obvious to me. Why do you load the AirPort Settings bundle, if it succeeds, wait for the network bundle to be loaded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with the notification method above, you need to prepare another method. |
||
NSString *fullPath = [NSString stringWithFormat:@"/System/Library/PreferenceBundles/AirPortSettings.bundle"]; | ||
NSBundle *bundle; | ||
bundle = [NSBundle bundleWithPath:fullPath]; | ||
BOOL didLoad = [bundle load]; | ||
if (didLoad) { | ||
shouldInit = YES; | ||
} | ||
} else { | ||
shouldInit = YES; | ||
} | ||
|
||
if (shouldInit && kCFCoreFoundationVersionNumber >= CoreFoundationiOS11) | ||
{ | ||
CFNotificationCenterAddObserver( | ||
CFNotificationCenterGetLocalCenter(), NULL, | ||
notificationCallback, | ||
(CFStringRef)NSBundleDidLoadNotification, | ||
NULL, CFNotificationSuspensionBehaviorCoalesce); | ||
} | ||
|
||
loadSettings(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this method actually affect the wifi scan initiated by the system or does this only change this instance of
WPScanRequest
? I would assume the latterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no change on the normal Wi-Fi setting screen. Valid only when scanning with WiPi.