@@ -29,8 +29,6 @@ final class DeviceDataManager {
29
29
/// Remember the launch date of the app for diagnostic reporting
30
30
private let launchDate = Date ( )
31
31
32
- private( set) var testingScenariosManager : TestingScenariosManager ?
33
-
34
32
/// The last error recorded by a device manager
35
33
/// Should be accessed only on the main queue
36
34
private( set) var lastError : ( date: Date , error: Error ) ?
@@ -417,10 +415,6 @@ final class DeviceDataManager {
417
415
directory: FileManager . default. exportsDirectoryURL,
418
416
historicalDuration: Bundle . main. localCacheDuration)
419
417
420
- if FeatureFlags . scenariosEnabled {
421
- testingScenariosManager = LocalTestingScenariosManager ( deviceManager: self )
422
- }
423
-
424
418
loopManager. delegate = self
425
419
426
420
alertManager. alertStore. delegate = self
@@ -658,64 +652,6 @@ final class DeviceDataManager {
658
652
self . getHealthStoreAuthorization ( completion)
659
653
}
660
654
}
661
-
662
- func generateDiagnosticReport( _ completion: @escaping ( _ report: String ) -> Void ) {
663
- self . loopManager. generateDiagnosticReport { ( loopReport) in
664
-
665
- let logDurationHours = 84.0
666
-
667
- self . alertManager. getStoredEntries ( startDate: Date ( ) - . hours( logDurationHours) ) { ( alertReport) in
668
- self . deviceLog. getLogEntries ( startDate: Date ( ) - . hours( logDurationHours) ) { ( result) in
669
- let deviceLogReport : String
670
- switch result {
671
- case . failure( let error) :
672
- deviceLogReport = " Error fetching entries: \( error) "
673
- case . success( let entries) :
674
- deviceLogReport = entries. map { " * \( $0. timestamp) \( $0. managerIdentifier) \( $0. deviceIdentifier ?? " " ) \( $0. type) \( $0. message) " } . joined ( separator: " \n " )
675
- }
676
-
677
- let report = [
678
- " ## Build Details " ,
679
- " * appNameAndVersion: \( Bundle . main. localizedNameAndVersion) " ,
680
- " * profileExpiration: \( Bundle . main. profileExpirationString) " ,
681
- " * gitRevision: \( Bundle . main. gitRevision ?? " N/A " ) " ,
682
- " * gitBranch: \( Bundle . main. gitBranch ?? " N/A " ) " ,
683
- " * workspaceGitRevision: \( Bundle . main. workspaceGitRevision ?? " N/A " ) " ,
684
- " * workspaceGitBranch: \( Bundle . main. workspaceGitBranch ?? " N/A " ) " ,
685
- " * sourceRoot: \( Bundle . main. sourceRoot ?? " N/A " ) " ,
686
- " * buildDateString: \( Bundle . main. buildDateString ?? " N/A " ) " ,
687
- " * xcodeVersion: \( Bundle . main. xcodeVersion ?? " N/A " ) " ,
688
- " " ,
689
- " ## FeatureFlags " ,
690
- " \( FeatureFlags) " ,
691
- " " ,
692
- alertReport,
693
- " " ,
694
- " ## DeviceDataManager " ,
695
- " * launchDate: \( self . launchDate) " ,
696
- " * lastError: \( String ( describing: self . lastError) ) " ,
697
- " " ,
698
- " cacheStore: \( String ( reflecting: self . cacheStore) ) " ,
699
- " " ,
700
- self . cgmManager != nil ? String ( reflecting: self . cgmManager!) : " cgmManager: nil " ,
701
- " " ,
702
- self . pumpManager != nil ? String ( reflecting: self . pumpManager!) : " pumpManager: nil " ,
703
- " " ,
704
- " ## Device Communication Log " ,
705
- deviceLogReport,
706
- " " ,
707
- String ( reflecting: self . watchManager!) ,
708
- " " ,
709
- String ( reflecting: self . statusExtensionManager!) ,
710
- " " ,
711
- loopReport,
712
- ] . joined ( separator: " \n " )
713
-
714
- completion ( report)
715
- }
716
- }
717
- }
718
- }
719
655
}
720
656
721
657
private extension DeviceDataManager {
@@ -1285,9 +1221,6 @@ extension DeviceDataManager {
1285
1221
}
1286
1222
1287
1223
insulinDeliveryStore. purgeAllDoseEntries ( healthKitPredicate: devicePredicate) { error in
1288
- if error == nil {
1289
- insulinDeliveryStore. test_lastImmutableBasalEndDate = nil
1290
- }
1291
1224
completion ? ( error)
1292
1225
}
1293
1226
}
@@ -1658,40 +1591,6 @@ fileprivate extension FileManager {
1658
1591
extension GlucoseStore : CGMStalenessMonitorDelegate { }
1659
1592
1660
1593
1661
- //MARK: - SupportInfoProvider protocol conformance
1662
-
1663
- extension DeviceDataManager : SupportInfoProvider {
1664
-
1665
- private var branchNameIfNotReleaseBranch : String ? {
1666
- return Bundle . main. gitBranch. filter { branch in
1667
- return branch != " " &&
1668
- branch != " main " &&
1669
- branch != " master " &&
1670
- !branch. starts ( with: " release/ " )
1671
- }
1672
- }
1673
-
1674
- public var localizedAppNameAndVersion : String {
1675
- if let branch = branchNameIfNotReleaseBranch {
1676
- return Bundle . main. localizedNameAndVersion + " ( \( branch) ) "
1677
- }
1678
- return Bundle . main. localizedNameAndVersion
1679
- }
1680
-
1681
- public var pumpStatus : PumpManagerStatus ? {
1682
- return pumpManager? . status
1683
- }
1684
-
1685
- public var cgmStatus : CGMManagerStatus ? {
1686
- return cgmManager? . cgmManagerStatus
1687
- }
1688
-
1689
- public func generateIssueReport( completion: @escaping ( String ) -> Void ) {
1690
- generateDiagnosticReport ( completion)
1691
- }
1692
-
1693
- }
1694
-
1695
1594
//MARK: TherapySettingsViewModelDelegate
1696
1595
struct CancelTempBasalFailedError : LocalizedError {
1697
1596
let reason : Error ?
@@ -1792,8 +1691,66 @@ extension DeviceDataManager {
1792
1691
}
1793
1692
}
1794
1693
1795
- extension DeviceDataManager {
1694
+ extension DeviceDataManager : DeviceSupportDelegate {
1796
1695
var availableSupports : [ SupportUI ] { [ cgmManager, pumpManager] . compactMap { $0 as? SupportUI } }
1696
+
1697
+ func generateDiagnosticReport( _ completion: @escaping ( _ report: String ) -> Void ) {
1698
+ self . loopManager. generateDiagnosticReport { ( loopReport) in
1699
+
1700
+ let logDurationHours = 84.0
1701
+
1702
+ self . alertManager. getStoredEntries ( startDate: Date ( ) - . hours( logDurationHours) ) { ( alertReport) in
1703
+ self . deviceLog. getLogEntries ( startDate: Date ( ) - . hours( logDurationHours) ) { ( result) in
1704
+ let deviceLogReport : String
1705
+ switch result {
1706
+ case . failure( let error) :
1707
+ deviceLogReport = " Error fetching entries: \( error) "
1708
+ case . success( let entries) :
1709
+ deviceLogReport = entries. map { " * \( $0. timestamp) \( $0. managerIdentifier) \( $0. deviceIdentifier ?? " " ) \( $0. type) \( $0. message) " } . joined ( separator: " \n " )
1710
+ }
1711
+
1712
+ let report = [
1713
+ " ## Build Details " ,
1714
+ " * appNameAndVersion: \( Bundle . main. localizedNameAndVersion) " ,
1715
+ " * profileExpiration: \( Bundle . main. profileExpirationString) " ,
1716
+ " * gitRevision: \( Bundle . main. gitRevision ?? " N/A " ) " ,
1717
+ " * gitBranch: \( Bundle . main. gitBranch ?? " N/A " ) " ,
1718
+ " * workspaceGitRevision: \( Bundle . main. workspaceGitRevision ?? " N/A " ) " ,
1719
+ " * workspaceGitBranch: \( Bundle . main. workspaceGitBranch ?? " N/A " ) " ,
1720
+ " * sourceRoot: \( Bundle . main. sourceRoot ?? " N/A " ) " ,
1721
+ " * buildDateString: \( Bundle . main. buildDateString ?? " N/A " ) " ,
1722
+ " * xcodeVersion: \( Bundle . main. xcodeVersion ?? " N/A " ) " ,
1723
+ " " ,
1724
+ " ## FeatureFlags " ,
1725
+ " \( FeatureFlags) " ,
1726
+ " " ,
1727
+ alertReport,
1728
+ " " ,
1729
+ " ## DeviceDataManager " ,
1730
+ " * launchDate: \( self . launchDate) " ,
1731
+ " * lastError: \( String ( describing: self . lastError) ) " ,
1732
+ " " ,
1733
+ " cacheStore: \( String ( reflecting: self . cacheStore) ) " ,
1734
+ " " ,
1735
+ self . cgmManager != nil ? String ( reflecting: self . cgmManager!) : " cgmManager: nil " ,
1736
+ " " ,
1737
+ self . pumpManager != nil ? String ( reflecting: self . pumpManager!) : " pumpManager: nil " ,
1738
+ " " ,
1739
+ " ## Device Communication Log " ,
1740
+ deviceLogReport,
1741
+ " " ,
1742
+ String ( reflecting: self . watchManager!) ,
1743
+ " " ,
1744
+ String ( reflecting: self . statusExtensionManager!) ,
1745
+ " " ,
1746
+ loopReport,
1747
+ ] . joined ( separator: " \n " )
1748
+
1749
+ completion ( report)
1750
+ }
1751
+ }
1752
+ }
1753
+ }
1797
1754
}
1798
1755
1799
1756
extension DeviceDataManager : DeviceStatusProvider { }
0 commit comments