mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Use the legacy device lock reporting on iOS 9
This commit is contained in:
@@ -80,6 +80,7 @@ public final class AppLockContextImpl: AppLockContext {
|
||||
private let currentState = Promise<LockState>()
|
||||
|
||||
private let autolockTimeout = ValuePromise<Int32?>(nil, ignoreRepeated: true)
|
||||
private let autolockReportTimeout = ValuePromise<Int32?>(nil, ignoreRepeated: true)
|
||||
|
||||
private let isCurrentlyLockedPromise = Promise<Bool>()
|
||||
public var isCurrentlyLocked: Signal<Bool, NoError> {
|
||||
@@ -148,10 +149,24 @@ public final class AppLockContextImpl: AppLockContext {
|
||||
}
|
||||
|
||||
strongSelf.autolockTimeout.set(nil)
|
||||
strongSelf.autolockReportTimeout.set(nil)
|
||||
} else {
|
||||
if let autolockTimeout = passcodeSettings.autolockTimeout, !appInForeground {
|
||||
shouldDisplayCoveringView = true
|
||||
}
|
||||
|
||||
if !appInForeground {
|
||||
if let autolockTimeout = passcodeSettings.autolockTimeout {
|
||||
strongSelf.autolockReportTimeout.set(autolockTimeout)
|
||||
} else if state.isManuallyLocked {
|
||||
strongSelf.autolockReportTimeout.set(1)
|
||||
} else {
|
||||
strongSelf.autolockReportTimeout.set(nil)
|
||||
}
|
||||
} else {
|
||||
strongSelf.autolockReportTimeout.set(nil)
|
||||
}
|
||||
|
||||
strongSelf.autolockTimeout.set(passcodeSettings.autolockTimeout)
|
||||
|
||||
if isLocked(passcodeSettings: passcodeSettings, state: state, isApplicationActive: appInForeground) {
|
||||
@@ -296,6 +311,18 @@ public final class AppLockContextImpl: AppLockContext {
|
||||
}
|
||||
}
|
||||
|
||||
public var autolockDeadline: Signal<Int32?, NoError> {
|
||||
return self.autolockReportTimeout.get()
|
||||
|> distinctUntilChanged
|
||||
|> map { value -> Int32? in
|
||||
if let value = value {
|
||||
return Int32(Date().timeIntervalSince1970) + value
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func lock() {
|
||||
self.updateLockState { state in
|
||||
var state = state
|
||||
|
||||
Reference in New Issue
Block a user