mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Use the legacy device lock reporting on iOS 9
This commit is contained in:
parent
f9529bc7d1
commit
edc839a999
@ -387,6 +387,7 @@ public enum CreateGroupMode {
|
||||
|
||||
public protocol AppLockContext: class {
|
||||
var invalidAttempts: Signal<AccessChallengeAttempts?, NoError> { get }
|
||||
var autolockDeadline: Signal<Int32?, NoError> { get }
|
||||
|
||||
func lock()
|
||||
func unlock()
|
||||
|
@ -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
|
||||
|
@ -375,6 +375,19 @@ final class SharedApplicationContext {
|
||||
let apiHash: String = buildConfig.apiHash
|
||||
let languagesCategory = "ios"
|
||||
|
||||
let autolockDeadine: Signal<Int32?, NoError>
|
||||
if #available(iOS 10.0, *) {
|
||||
autolockDeadine = .single(nil)
|
||||
} else {
|
||||
autolockDeadine = self.context.get()
|
||||
|> mapToSignal { context -> Signal<Int32?, NoError> in
|
||||
guard let context = context else {
|
||||
return .single(nil)
|
||||
}
|
||||
return context.context.sharedContext.appLockContext.autolockDeadline
|
||||
}
|
||||
}
|
||||
|
||||
let networkArguments = NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: PresentationCallManagerImpl.voipMaxLayer, appData: self.deviceToken.get()
|
||||
|> map { token in
|
||||
let data = buildConfig.bundleData(withAppToken: token, signatureDict: signatureDict)
|
||||
@ -384,7 +397,7 @@ final class SharedApplicationContext {
|
||||
Logger.shared.log("data", "can't deserialize")
|
||||
}
|
||||
return data
|
||||
}, autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider())
|
||||
}, autolockDeadine: autolockDeadine, encryptionProvider: OpenSSLEncryptionProvider())
|
||||
|
||||
guard let appGroupUrl = maybeAppGroupUrl else {
|
||||
UIAlertView(title: nil, message: "Error 2", delegate: nil, cancelButtonTitle: "OK").show()
|
||||
|
Loading…
x
Reference in New Issue
Block a user