请求重写支持选择文件

This commit is contained in:
wanghongenpin
2024-01-02 23:06:51 +08:00
parent 4f05f29e25
commit ba7bc832bf
20 changed files with 600 additions and 230 deletions

View File

@@ -34,17 +34,31 @@ import NetworkExtension
override func applicationDidEnterBackground(_ application: UIApplication) {
// timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
// RunLoop.current.add(timer!, forMode: RunLoop.Mode.common)
// bgTask = application.beginBackgroundTask(expirationHandler: nil)
if (!VpnManager.shared.isRunning()) {
return
}
timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
RunLoop.current.add(timer!, forMode: RunLoop.Mode.common)
bgTask = application.beginBackgroundTask(expirationHandler: nil)
}
@objc func timerAction() {
print(UIApplication.shared.backgroundTimeRemaining )
if UIApplication.shared.backgroundTimeRemaining < 60.0 {
let application = UIApplication.shared
bgTask = application.beginBackgroundTask(expirationHandler: nil)
}
print(UIApplication.shared.backgroundTimeRemaining)
let application = UIApplication.shared
if (bgTask != nil) {
application.endBackgroundTask(bgTask!);
bgTask = nil;
}
if (UIApplication.shared.backgroundTimeRemaining < 60 && VpnManager.shared.isRunning()) {
bgTask = application.beginBackgroundTask(expirationHandler: nil)
}
if (application.backgroundTimeRemaining <= 0 || application.applicationState == .active) {
timer?.invalidate();
timer = nil;
}
}
override func applicationWillResignActive(_ application: UIApplication) {

View File

@@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>zh</string>
</array>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
@@ -62,6 +67,6 @@
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSCameraUsageDescription</key>
<string>扫描二维码</string>
<string>扫描二维码</string>
</dict>
</plist>

View File

@@ -164,9 +164,7 @@ extension VpnManager{
}
loadProviderManager{
print("stopVPNTunnel")
$0?.connection.stopVPNTunnel()
}
}