Skip to content

Commit

Permalink
Use LocalAuthentication.framework for auto lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Jan 9, 2020
1 parent bf7ba98 commit c7a2df1
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 427 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "Frameworks/UICKeyChainStore"]
path = Frameworks/UICKeyChainStore
url = https://github.com/kishikawakatsumi/UICKeyChainStore.git
[submodule "Frameworks/PasscodeLock"]
path = Frameworks/PasscodeLock
url = https://github.com/blinksh/SwiftPasscodeLock.git
[submodule "Frameworks/ios_system"]
path = Frameworks/ios_system
url = https://github.com/holzschu/ios_system.git
Expand Down
127 changes: 4 additions & 123 deletions Blink.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions Blink/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#import "AppDelegate.h"
#import "BKiCloudSyncHandler.h"
#import "BKTouchIDAuthManager.h"
#import "BlinkPaths.h"
#import "BKDefaults.h"
#import "BKPubKey.h"
Expand Down Expand Up @@ -77,8 +76,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
dispatch_async(bgQueue, ^{
[BlinkPaths linkICloudDriveIfNeeded];
});

[[BKTouchIDAuthManager sharedManager] registerforDeviceLockNotif];

sideLoading = false; // Turn off extra commands from iOS system
initializeEnvironment(); // initialize environment variables for iOS system
Expand Down
1 change: 0 additions & 1 deletion Blink/Blink-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#import "BlinkPaths.h"
#import "DeviceInfo.h"
#import "LayoutManager.h"
#import "BKTouchIDAuthManager.h"
#import "BKUserConfigurationManager.h"
#import "Session.h"
#import "MCPSession.h"
Expand Down
68 changes: 49 additions & 19 deletions Blink/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,31 @@ struct StuckView: View {
}
}

struct LockView: View {
var scene: UIScene

var body: some View {
VStack {
Image(systemName: "lock.shield.fill")
.font(.system(size: 70))
.accentColor(Color(UIColor.blinkTint))
.padding()
Text("Autolocked")
.font(.headline)
.padding()

if scene.session.role == .windowApplication {
Button(action: { LocalAuth.shared.unlock(scene: self.scene) }, label: { Text("Unlock") })
.padding()
}
}
}
}

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow? = nil
var _ctrl = DummyVC()
var _lockCtrl: UIViewController? = nil
var _spCtrl = SpaceController()

func scene(
Expand All @@ -94,29 +116,50 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}

func sceneDidBecomeActive(_ scene: UIScene) {

if LocalAuth.shared.lockRequired {
if let lockCtrl = _lockCtrl {
if window?.rootViewController != lockCtrl {
window?.rootViewController = lockCtrl
}
} else {
let ctrl = UIHostingController(rootView: LockView(scene: scene))
window?.rootViewController = ctrl
_lockCtrl = ctrl
LocalAuth.shared.unlock(scene: scene)
}
return
} else {
_lockCtrl = nil
}

if window?.rootViewController != _spCtrl {
window?.rootViewController = _spCtrl
}

guard let term = _spCtrl.currentTerm()
else {
return
}


term.resumeIfNeeded()
term.view?.setNeedsLayout()
let spCtrl = _spCtrl

let input = SmarterTermInput.shared
if let key = input.stuckKey() {
debugPrint("BK:", "stuck!!!")
input.setTrackingModifierFlags([])
let ctrl = UIHostingController(rootView: StuckView(keyCode: key, dismissAction: {
self._spCtrl.onStuckOpCommand()
spCtrl.onStuckOpCommand()
}))
ctrl.modalPresentationStyle = .formSheet
_spCtrl.stuckKeyCode = key
_spCtrl.present(ctrl, animated: false)
spCtrl.stuckKeyCode = key
spCtrl.present(ctrl, animated: false)
return;
} else {
_spCtrl.stuckKeyCode = nil
spCtrl.stuckKeyCode = nil
}
if
term.termDevice.view?.isFocused() == false,
Expand All @@ -125,35 +168,22 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
if !SmarterTermInput.shared.isRealFirstResponder,
scene.activationState == .foregroundActive {
self._spCtrl.focusOnShellAction()
spCtrl.focusOnShellAction()
}
}
} else if input.window == self.window {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
if term.termDevice.view?.isFocused() == false,
scene.activationState == .foregroundActive {
self._spCtrl.focusOnShellAction()
spCtrl.focusOnShellAction()
}
}
} else {
SmarterTermInput.shared.reportStateReset()
}
}

func sceneWillResignActive(_ scene: UIScene) {
// debugPrint("BK:", "sceneWillResignActive")
}

func sceneWillEnterForeground(_ scene: UIScene) {
// debugPrint("BK:", "sceneWillEnterForeground")
}

func sceneDidEnterBackground(_ scene: UIScene) {
// debugPrint("BK:", "sceneDidEnterBackground")
}

func stateRestorationActivity(for scene: UIScene) -> NSUserActivity? {
// debugPrint("BK:", "stateRestorationActivity")
_setDummyVC()
return _spCtrl.stateRestorationActivity()
}
Expand Down
5 changes: 0 additions & 5 deletions Blink/SpaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,6 @@ public class SpaceController: UIViewController {
func _registerForNotifications() {
let nc = NotificationCenter.default

nc.addObserver(self,
selector: #selector(_focusOnShell),
name: NSNotification.Name.BKUserAuthenticated,
object: nil)

nc.addObserver(self,
selector: #selector(_didBecomeKeyWindow),
name: UIWindow.didBecomeKeyNotification,
Expand Down
1 change: 0 additions & 1 deletion Frameworks/PasscodeLock
Submodule PasscodeLock deleted from 52201b
46 changes: 0 additions & 46 deletions Settings/Security/BKTouchIDAuthManager.h

This file was deleted.

150 changes: 0 additions & 150 deletions Settings/Security/BKTouchIDAuthManager.m

This file was deleted.

Loading

0 comments on commit c7a2df1

Please sign in to comment.