Skip to content
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

iOS 11.x #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
#ifndef LASTAPP_HEADERS_H_
#define LASTAPP_HEADERS_H_

@interface SBCoverSheetPresentationManager : NSObject
+ (id)sharedInstance;
- (BOOL)hasBeenDismissedSinceKeybagLock;
@end

@interface SBDeviceApplicationSceneEntity : NSObject // SBApplicationSceneEntity -> SBWorkspaceEntity -> NSObject
- (id)initWithApplicationForMainDisplay:(id)arg1;
@end

@interface SBDisplay : NSObject
- (void)setActivationSetting:(unsigned)setting flag:(BOOL)flag;
- (void)setDeactivationSetting:(unsigned)setting flag:(BOOL)flag;
Expand Down Expand Up @@ -113,6 +122,7 @@

@interface SBUserAgent : NSObject
+ (id)sharedUserAgent;
- (BOOL)deviceIsLocked;
- (BOOL)deviceIsPasscodeLocked;
@end

Expand Down
26 changes: 23 additions & 3 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,18 @@ static inline BOOL isDisplayingPowerDown() {
}

static void saveTopApplication() {
if ([[%c(SBAwayController) sharedAwayController] isLocked]) {
BOOL isLocked = NO;

if (IOS_GTE(11_0)) {
isLocked = ![[%c(SBCoverSheetPresentationManager) sharedInstance] hasBeenDismissedSinceKeybagLock];
} else if (IOS_LT(7_0)) {
SBAwayController *awayCont = [%c(SBAwayController) sharedAwayController];
isLocked = [awayCont isLocked];
} else {
isLocked = [[%c(SBUserAgent) sharedUserAgent] deviceIsLocked];
}

if (isLocked) {
// Ignore lock screen.
return;
}
Expand Down Expand Up @@ -189,7 +200,10 @@ static inline BOOL canInvoke() {
BOOL isLocked = NO;
BOOL isEmergencyCall = NO;

if (IOS_LT(7_0)) {
if (IOS_GTE(11_0)) {
isLocked = ![[%c(SBCoverSheetPresentationManager) sharedInstance] hasBeenDismissedSinceKeybagLock];
isEmergencyCall = [[%c(SBTelephonyManager) sharedTelephonyManager] isEmergencyCallActive];
} else if (IOS_LT(7_0)) {
SBAwayController *awayCont = [%c(SBAwayController) sharedAwayController];
isLocked = [awayCont isLocked];
isEmergencyCall = [awayCont isMakingEmergencyCall];
Expand Down Expand Up @@ -250,7 +264,13 @@ static inline SBApplication *topApplication() {
}

if (toApp) {
if (IOS_GTE(9_0)) {
if (IOS_GTE(11_0)) {
SBMainWorkspace *workspace = [%c(SBMainWorkspace) sharedInstance];
SBDeviceApplicationSceneEntity *app = [[%c(SBDeviceApplicationSceneEntity) alloc] initWithApplicationForMainDisplay:toApp];
SBWorkspaceTransitionRequest *request = [workspace createRequestForApplicationActivation:app options:0];
[workspace executeTransitionRequest:request];
[app release];
} else if (IOS_GTE(9_0)) {
// NOTE: The "createRequest..." method used below does *not* follow the ownership rule;
// the returned object is autoreleased.
SBMainWorkspace *workspace = [%c(SBMainWorkspace) sharedInstance];
Expand Down