Auto-trust Wi-Fi only when requesting access
Delegate may invoked in other scenarios. Do nothing in that case.
This commit is contained in:
parent
0893a686da
commit
fdba9f3815
|
@ -42,6 +42,8 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
||||||
|
|
||||||
private let locationManager = CLLocationManager()
|
private let locationManager = CLLocationManager()
|
||||||
|
|
||||||
|
private var isPendingTrustedWiFi = false
|
||||||
|
|
||||||
private let downloader = FileDownloader(
|
private let downloader = FileDownloader(
|
||||||
temporaryURL: GroupConstants.App.cachesURL.appendingPathComponent("downloaded.tmp"),
|
temporaryURL: GroupConstants.App.cachesURL.appendingPathComponent("downloaded.tmp"),
|
||||||
timeout: AppConstants.Web.timeout
|
timeout: AppConstants.Web.timeout
|
||||||
|
@ -349,6 +351,7 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
||||||
break
|
break
|
||||||
|
|
||||||
case .denied:
|
case .denied:
|
||||||
|
isPendingTrustedWiFi = false
|
||||||
let alert = UIAlertController.asAlert(
|
let alert = UIAlertController.asAlert(
|
||||||
L10n.App.Service.Cells.TrustedAddWifi.caption,
|
L10n.App.Service.Cells.TrustedAddWifi.caption,
|
||||||
L10n.App.Service.Alerts.Location.Message.denied
|
L10n.App.Service.Alerts.Location.Message.denied
|
||||||
|
@ -361,6 +364,7 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
||||||
return
|
return
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
isPendingTrustedWiFi = true
|
||||||
locationManager.delegate = self
|
locationManager.delegate = self
|
||||||
locationManager.requestWhenInUseAuthorization()
|
locationManager.requestWhenInUseAuthorization()
|
||||||
return
|
return
|
||||||
|
@ -1327,8 +1331,10 @@ extension ServiceViewController: ProviderPresetViewControllerDelegate {
|
||||||
|
|
||||||
extension ServiceViewController: CLLocationManagerDelegate {
|
extension ServiceViewController: CLLocationManagerDelegate {
|
||||||
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
|
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
|
||||||
|
guard isPendingTrustedWiFi else {
|
||||||
// can only change when calling this method, re-invoke
|
return
|
||||||
|
}
|
||||||
|
isPendingTrustedWiFi = false
|
||||||
trustCurrentWiFi()
|
trustCurrentWiFi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue