Skip to content

Instantly share code, notes, and snippets.

@farfromrefug
Created November 9, 2014 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farfromrefug/46dd16e3dad3839e1db5 to your computer and use it in GitHub Desktop.
Save farfromrefug/46dd16e3dad3839e1db5 to your computer and use it in GitHub Desktop.
static void runBlockWithLocked(LockedActionBlock block)
{
if ([[objc_getClass("SBDeviceLockController") sharedController] isPasscodeLocked]) {
SBLockScreenManager *manager = (SBLockScreenManager *)[objc_getClass("SBLockScreenManager") sharedInstance];
if ([manager isUILocked])
{
if ([objc_getClass("SBControlCenterController") sharedInstance]) [(SBControlCenterController *)[objc_getClass("SBControlCenterController") sharedInstance] dismissAnimated:YES];
void (^action)() = ^() {
Log(@"runBlockWithLocked test");
block();
};
SBLockScreenViewControllerBase *controller = [(SBLockScreenManager *)[objc_getClass("SBLockScreenManager") sharedInstance] lockScreenViewController];
SBUnlockActionContext *context = [[objc_getClass("SBUnlockActionContext") alloc] initWithLockLabel:nil shortLockLabel:nil unlockAction:action identifier:nil];
[context setDeactivateAwayController:YES];
[controller setUnlockActionContext:context];
[controller setPasscodeLockVisible:YES animated:YES completion:nil];
return;
}
}
block();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment