iOS逆向工程之获取屏幕是否锁屏,解锁屏幕

// 头文件相关函数
@interface SBLockScreenManager : XXUnknownSuperclass  {
    BOOL _isUILocked; // 读取这个变量可以判断当前是否锁屏状态
}
+ (id)sharedInstance;
- (void)unlockUIFromSource:(int)source withOptions:(id)options;
- (void)lockUIFromSource:(int)source withOptions:(id)options;
- (_Bool)attemptUnlockWithPasscode:(id)arg1; // 密码解锁
@end

实验:
PiaoYuns-iPad:~ root# cycript -p SpringBoard
cy# var lockScreenManager = [SBLockScreenManager sharedInstance]
#""
cy# [lockScreenManager unlockUIFromSource: 0 withOptions: nil]
cy# [lockScreenManager lockUIFromSource: 1 withOptions: nil]
cy# [lockScreenManager isUILocked]
true
cy# [lockScreenManager  attemptUnlockWithPasscode: @"1111"]
false
cy# [lockScreenManager  attemptUnlockWithPasscode: @"8888"]
true

// Tweaks判断是否锁屏状态
static bool isLocked() {    
    if (%c(SBLockScreenManager)){
        SBLockScreenManager * lockScreenManager = (SBLockScreenManager*) [%c(SBLockScreenManager) sharedInstance];
        return [lockScreenManager isUILocked];
    }
    return NO;
}

你可能感兴趣的:(iOS逆向工程之获取屏幕是否锁屏,解锁屏幕)