Skip to content

Commit fa32a7a

Browse files
KM-17006 connection stats (#367)
* KM-17006: update ui on the main thread * KM-17006: remove broken conditional compilation The protocols are not available on tvOS, but it really doesnt matter if we keep them on the switch.
1 parent e528d19 commit fa32a7a

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

LocalPackages/PIALibrary/Sources/PIALibrary/Daemons/ConnectivityDaemon.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ final class ConnectivityDaemon: Daemon, ConfigurationAccess, DatabaseAccess, Pre
9191
networkObserver.whenUnreachable = { [weak self] in
9292
guard let self else { return }
9393
DispatchQueue.main.async {
94+
guard self.accessedDatabase.transient.vpnStatus != .connecting else {
95+
// while connecting we are unreachable, but expected, skip reporting
96+
return
97+
}
9498
guard self.accessedDatabase.transient.isNetworkReachable else {
9599
return
96100
}

LocalPackages/PIALibrary/Sources/PIALibrary/ServiceQuality/ServiceQualityManager.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,14 @@ public final class ServiceQualityManager: NSObject {
244244
}
245245

246246
private func currentProtocol() -> KPIVpnProtocol {
247-
248247
switch Client.providers.vpnProvider.currentVPNType {
249-
case IKEv2Profile.vpnType:
250-
return KPIVpnProtocol.ipsec
251-
#if (iOS)
252-
case PIATunnelProfile.vpnType:
253-
return KPIVpnProtocol.ovpn
254-
case PIAWGTunnelProfile.vpnType:
255-
return KPIVpnProtocol.wireguard
248+
case IKEv2Profile.vpnType: return .ipsec
249+
#if !os(tvOS)
250+
case PIATunnelProfile.vpnType: return .ovpn
251+
case PIAWGTunnelProfile.vpnType: return .wireguard
256252
#endif
257-
default:
253+
case let other:
254+
log.warning("Unknown VPN type: \(other)")
258255
return KPIVpnProtocol.ipsec
259256
}
260257
}

PIA VPN/UI/Menu/ShowConnectionStatsViewController.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import UIKit
2727

2828
private let log = PIALogger.logger(for: ShowConnectionStatsViewController.self)
2929

30-
class ShowConnectionStatsViewController: AutolayoutViewController {
30+
final class ShowConnectionStatsViewController: AutolayoutViewController {
3131

3232
private var licenseByComponentName: [String: String] = [:]
3333

@@ -51,8 +51,10 @@ class ShowConnectionStatsViewController: AutolayoutViewController {
5151
nc.addObserver(self, selector: #selector(viewHasRotated), name: UIDevice.orientationDidChangeNotification, object: nil)
5252
}
5353

54-
ServiceQualityManager.shared.availableData { data in
55-
self.textData.text = data.joined(separator: "\n\n")
54+
ServiceQualityManager.shared.availableData { [weak self] data in
55+
DispatchQueue.main.async {
56+
self?.textData.text = data.joined(separator: "\n\n")
57+
}
5658
}
5759

5860
viewDataFooter.isHidden = false

0 commit comments

Comments
 (0)