Skip to content

Instantly share code, notes, and snippets.

@devbug
Created November 25, 2014 19:05
Show Gist options
  • Save devbug/a89009dbfbcb4bd8e6c2 to your computer and use it in GitHub Desktop.
Save devbug/a89009dbfbcb4bd8e6c2 to your computer and use it in GitHub Desktop.
app activation with bypassing passcode lock on iOS 7.x (CCToggles)
// ...
- (SBWorkspace *)sbWorkspace {
return g_sbWorkspace;
}
- (BOOL)launchApplication:(NSString *)identifier {
return [self launchApplication:identifier url:nil];
}
- (BOOL)launchApplication:(NSString *)identifier url:(NSURL *)url {
if (identifier == nil) return NO;
SBApplication *app = [[%c(SBApplicationController) sharedInstanceIfExists] applicationWithDisplayIdentifier:identifier];
if (!app) return NO;
BOOL isOver71 = (kCFCoreFoundationVersionNumber >= 847.24);
if ([app shouldLaunchPNGless])
[app setActivationSetting:0x9 flag:YES];
if ([%c(SBAssistantController) isAssistantVisible])
[app setActivationSetting:(isOver71 ? 0x24 : 0x25) flag:YES];
if ([[%c(SBNotificationCenterController) sharedInstanceIfExists] isVisible])
[app setActivationSetting:(isOver71 ? 0x23 : 0x24) flag:YES];
[app setActivationSetting:(isOver71 ? 0x29 : 0x2B) flag:YES];
[app setActivationSetting:0x4 value:url];
[[%c(SBUIController) sharedInstance] activateApplicationAnimated:app];
return YES;
}
- (BOOL)launchApplicationWithBypassPasscodeLockIfPossibleAndNecessary:(NSString *)identifier {
return [self launchApplicationWithBypassPasscodeLockIfPossibleAndNecessary:identifier url:nil];
}
- (BOOL)launchApplicationWithBypassPasscodeLockIfPossibleAndNecessary:(NSString *)identifier url:(NSURL *)url {
if (identifier == nil) return NO;
SBApplication *app = [[%c(SBApplicationController) sharedInstanceIfExists] applicationWithDisplayIdentifier:identifier];
if (!app) return NO;
if (deviceIsLocked()) {
SpringBoard *springboard = (SpringBoard *)[UIApplication sharedApplication];
//if ([app showsProgress] && ![app isLaunchableDuringSetup]) return NO;
if ([app isAnyTerminationAssertionHeld]) return NO;
if ([springboard isDisplayIdentifierRestrictionDisabled:identifier]) return NO;
SBWorkspaceEvent *event = [%c(SBWorkspaceEvent) eventWithLabel:(CFStringRef)[NSString stringWithFormat:@"ActivateApplication = %@", identifier] handler:^{
BOOL isOver71 = (kCFCoreFoundationVersionNumber >= 847.24);
if ([app shouldLaunchPNGless])
[app setActivationSetting:0x9 flag:YES];
if ([%c(SBAssistantController) isAssistantVisible])
[app setActivationSetting:(isOver71 ? 0x24 : 0x25) flag:YES];
if ([[%c(SBNotificationCenterController) sharedInstanceIfExists] isVisible])
[app setActivationSetting:(isOver71 ? 0x23 : 0x24) flag:YES];
[app setActivationSetting:(isOver71 ? 0x29 : 0x2B) flag:YES];
[app setActivationSetting:0x4 value:url];
SBWorkspace *sbWorkspace = [self sbWorkspace];
[sbWorkspace setCurrentTransaction:[sbWorkspace _selectTransactionForAppActivationToApp:app activationHandler:nil]];
}];
SBWorkspaceEventQueue *eventQueue = [%c(SBWorkspaceEventQueue) sharedInstance];
[eventQueue executeOrAppendEvent:event];
}
else {
return [self launchApplication:identifier url:url];
}
return YES;
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment