Explorar o código

correction for Apple Watch

(cherry picked from commit 47f950334d9febbd8cb8d39ec7ac7ab5de61f680)
avouspierre %!s(int64=3) %!d(string=hai) anos
pai
achega
512de14ad3

+ 62 - 0
Dependencies/rileylink_ios/MinimedKitTests/Mocks/MockPumpManagerDelegate.swift

@@ -0,0 +1,62 @@
+//
+//  MockPumpManagerDelegate.swift
+//  MinimedKitTests
+//
+//  Created by Pete Schwamb on 9/5/22.
+//  Copyright © 2022 Pete Schwamb. All rights reserved.
+//
+
+import Foundation
+import LoopKit
+
+class MockPumpManagerDelegate: PumpManagerDelegate {
+
+    func pumpManagerBLEHeartbeatDidFire(_ pumpManager: PumpManager) {}
+
+    func pumpManagerMustProvideBLEHeartbeat(_ pumpManager: PumpManager) -> Bool {
+        return false
+    }
+
+    func pumpManagerWillDeactivate(_ pumpManager: PumpManager) {}
+
+    func pumpManagerPumpWasReplaced(_ pumpManager: PumpManager) {}
+
+    func pumpManager(_ pumpManager: PumpManager, didUpdatePumpRecordsBasalProfileStartEvents pumpRecordsBasalProfileStartEvents: Bool) {}
+
+    func pumpManager(_ pumpManager: PumpManager, didError error: PumpManagerError) {}
+
+    var reportedPumpEvents: [(events: [NewPumpEvent], lastReconciliation: Date?)] = []
+    
+    func pumpManager(_ pumpManager: PumpManager, hasNewPumpEvents events: [NewPumpEvent], lastReconciliation: Date?, completion: @escaping (Error?) -> Void) {
+        reportedPumpEvents.append((events: events, lastReconciliation: lastReconciliation))
+    }
+
+    func pumpManager(_ pumpManager: PumpManager, didReadReservoirValue units: Double, at date: Date, completion: @escaping (Result<(newValue: ReservoirValue, lastValue: ReservoirValue?, areStoredValuesContinuous: Bool), Error>) -> Void) {}
+
+    func pumpManager(_ pumpManager: PumpManager, didAdjustPumpClockBy adjustment: TimeInterval) {}
+
+    func pumpManagerDidUpdateState(_ pumpManager: PumpManager) {}
+
+    func startDateToFilterNewPumpEvents(for manager: PumpManager) -> Date {
+        return Date()
+    }
+
+    var detectedSystemTimeOffset: TimeInterval = 0
+
+    func deviceManager(_ manager: DeviceManager, logEventForDeviceIdentifier deviceIdentifier: String?, type: DeviceLogEntryType, message: String, completion: ((Error?) -> Void)?) {}
+
+    func pumpManager(_ pumpManager: PumpManager, didUpdate status: PumpManagerStatus, oldStatus: PumpManagerStatus) {}
+
+    func issueAlert(_ alert: Alert) {}
+
+    func retractAlert(identifier: Alert.Identifier) {}
+
+    func doesIssuedAlertExist(identifier: Alert.Identifier, completion: @escaping (Result<Bool, Error>) -> Void) {}
+
+    func lookupAllUnretracted(managerIdentifier: String, completion: @escaping (Result<[PersistedAlert], Error>) -> Void) {}
+
+    func lookupAllUnacknowledgedUnretracted(managerIdentifier: String, completion: @escaping (Result<[PersistedAlert], Error>) -> Void) {}
+
+    func recordRetractedAlert(_ alert: Alert, at date: Date) {}
+
+}

+ 35 - 0
Dependencies/rileylink_ios/MinimedKitTests/Mocks/MockPumpOps.swift

@@ -0,0 +1,35 @@
+//
+//  MockPumpOps.swift
+//  MinimedKitTests
+//
+//  Created by Pete Schwamb on 9/5/22.
+//  Copyright © 2022 Pete Schwamb. All rights reserved.
+//
+
+import Foundation
+import MinimedKit
+import RileyLinkBLEKit
+
+class MockPumpOps: PumpOps, PumpOpsSessionDelegate {
+
+    var pumpState: PumpState
+
+    var pumpSettings: PumpSettings
+
+    func pumpOpsSession(_ session: MinimedKit.PumpOpsSession, didChange state: MinimedKit.PumpState) {
+        pumpState = state
+    }
+
+    func pumpOpsSessionDidChangeRadioConfig(_ session: MinimedKit.PumpOpsSession) { }
+
+    public func runSession(withName name: String, using device: RileyLinkDevice, _ block: @escaping (_ session: PumpOpsSession) -> Void) {
+        let minimedPumpMessageSender = MockPumpMessageSender()
+        let session = PumpOpsSession(settings: self.pumpSettings, pumpState: self.pumpState, messageSender: minimedPumpMessageSender, delegate: self)
+        block(session)
+    }
+
+    init(pumpState: PumpState, pumpSettings: PumpSettings) {
+        self.pumpState = pumpState
+        self.pumpSettings = pumpSettings
+    }
+}

+ 75 - 0
Dependencies/rileylink_ios/MinimedKitTests/Mocks/MockRileyLinkDevice.swift

@@ -0,0 +1,75 @@
+//
+//  MockRileyLinkDevice.swift
+//  MinimedKitTests
+//
+//  Created by Pete Schwamb on 9/5/22.
+//  Copyright © 2022 Pete Schwamb. All rights reserved.
+//
+
+import Foundation
+import RileyLinkBLEKit
+import CoreBluetooth
+
+class MockRileyLinkDevice: RileyLinkDevice {
+    var isConnected: Bool = true
+
+    var rlFirmwareDescription: String = "Mock"
+
+    var hasOrangeLinkService: Bool = false
+
+    var hardwareType: RileyLinkHardwareType? = .riley
+
+    var rssi: Int? = nil
+
+    var name: String? = "Mock"
+
+    var deviceURI: String =  "rileylink://Mock"
+
+    var peripheralIdentifier: UUID = UUID()
+
+    var peripheralState: CBPeripheralState = .connected
+
+    func readRSSI() {}
+
+    func setCustomName(_ name: String) {}
+
+    func updateBatteryLevel() {}
+
+    func orangeAction(_ command: OrangeLinkCommand) {}
+
+    func setOrangeConfig(_ config: OrangeLinkConfigurationSetting, isOn: Bool) {}
+
+    func orangeWritePwd() {}
+
+    func orangeClose() {}
+
+    func orangeReadSet() {}
+
+    func orangeReadVDC() {}
+
+    func findDevice() {}
+
+    func setDiagnosticeLEDModeForBLEChip(_ mode: RileyLinkLEDMode) {}
+
+    func readDiagnosticLEDModeForBLEChip(completion: @escaping (RileyLinkLEDMode?) -> Void) {}
+
+    func assertOnSessionQueue() {}
+
+    func sessionQueueAsyncAfter(deadline: DispatchTime, execute: @escaping () -> Void) {}
+
+    func runSession(withName name: String, _ block: @escaping (CommandSession) -> Void) {
+        assertionFailure("MockRileyLinkDevice.runSession should not be called during testing.  Use MockPumpOps for communication stubs.")
+    }
+
+    func getStatus(_ completion: @escaping (RileyLinkDeviceStatus) -> Void) {
+        completion(RileyLinkDeviceStatus(
+            lastIdle: Date(),
+            name: name,
+            version: rlFirmwareDescription,
+            ledOn: false,
+            vibrationOn: false,
+            voltage: 3.0,
+            battery: nil,
+            hasPiezo: false))
+    }
+}

+ 55 - 0
Dependencies/rileylink_ios/MinimedKitTests/Mocks/MockRileyLinkProvider.swift

@@ -0,0 +1,55 @@
+//
+//  MockRileyLinkProvider.swift
+//  MinimedKitTests
+//
+//  Created by Pete Schwamb on 9/5/22.
+//  Copyright © 2022 Pete Schwamb. All rights reserved.
+//
+
+import Foundation
+import RileyLinkBLEKit
+
+class MockRileyLinkProvider: RileyLinkDeviceProvider {
+
+    init(devices: [RileyLinkDevice]) {
+        self.devices = devices
+    }
+
+    var devices: [RileyLinkDevice]
+
+    var delegate: RileyLinkDeviceProviderDelegate?
+
+    var idleListeningState: RileyLinkBluetoothDevice.IdleListeningState = .disabled
+
+    var idleListeningEnabled: Bool = false
+
+    var timerTickEnabled: Bool = false
+
+    var connectingCount: Int = 0
+
+    func deprioritize(_ device: RileyLinkDevice, completion: (() -> Void)?) {
+    }
+
+    func assertIdleListening(forcingRestart: Bool) {
+    }
+
+    func getDevices(_ completion: @escaping ([RileyLinkDevice]) -> Void) {
+        completion(devices)
+    }
+
+    func connect(_ device: RileyLinkDevice) {
+    }
+
+    func disconnect(_ device: RileyLinkDevice) {
+    }
+
+    func setScanningEnabled(_ enabled: Bool) {
+    }
+
+    func shouldConnect(to deviceID: String) -> Bool {
+        return false
+    }
+
+    var debugDescription: String = "MockRileyLinkProvider"
+
+}

+ 4 - 0
FreeAPS.xcodeproj/project.pbxproj

@@ -284,6 +284,7 @@
 		CD78BB94E43B249D60CC1A1B /* NotificationsConfigRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22963BD06A9C83959D4914E4 /* NotificationsConfigRootView.swift */; };
 		CE48C86428CA69D5007C0598 /* OmniBLEPumpManagerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE48C86328CA69D5007C0598 /* OmniBLEPumpManagerExtensions.swift */; };
 		CE48C86628CA6B48007C0598 /* OmniPodManagerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE48C86528CA6B48007C0598 /* OmniPodManagerExtensions.swift */; };
+		CE6B025528F347C3000C5502 /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE6B025428F347C3000C5502 /* HealthKit.framework */; };
 		CE82E02528E867BA00473A9C /* AlertStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE82E02428E867BA00473A9C /* AlertStorage.swift */; };
 		CE82E02728E869DF00473A9C /* AlertEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE82E02628E869DF00473A9C /* AlertEntry.swift */; };
 		CEB434DC28B8F5B900B70274 /* MKRingProgressView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEB434DB28B8F5B900B70274 /* MKRingProgressView.framework */; };
@@ -787,6 +788,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				CE6B025528F347C3000C5502 /* HealthKit.framework in Frameworks */,
 				38E8755827567AE400975559 /* SwiftDate in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1308,6 +1310,8 @@
 				3871F39B25ED892B0013ECB5 /* TempTarget.swift */,
 				3811DE8E25C9D80400A708ED /* User.swift */,
 				E0D4F80427513ECF00BDF1FE /* HealthKitSample.swift */,
+				CEEF74AD28C4D41D00314CB5 /* TDD.swift */,
+				CEEF74AF28C4D43700314CB5 /* TDD_averages.swift */,
 				CE82E02628E869DF00473A9C /* AlertEntry.swift */,
 			);
 			path = Models;

+ 0 - 45
FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -11,24 +11,6 @@
         }
       },
       {
-        "package": "swift-algorithms",
-        "repositoryURL": "https://github.com/apple/swift-algorithms",
-        "state": {
-          "branch": null,
-          "revision": "2327673b0e9c7e90e6b1826376526ec3627210e4",
-          "version": "0.2.1"
-        }
-      },
-      {
-        "package": "swift-numerics",
-        "repositoryURL": "https://github.com/apple/swift-numerics",
-        "state": {
-          "branch": null,
-          "revision": "6583ac70c326c3ee080c1d42d9ca3361dca816cd",
-          "version": "0.1.0"
-        }
-      },
-      {
         "package": "SwiftCharts",
         "repositoryURL": "https://github.com/ivanschuetz/SwiftCharts",
         "state": {
@@ -36,33 +18,6 @@
           "revision": "c354c1945bb35a1f01b665b22474f6db28cba4a2",
           "version": null
         }
-      },
-      {
-        "package": "SwiftDate",
-        "repositoryURL": "https://github.com/malcommac/SwiftDate",
-        "state": {
-          "branch": null,
-          "revision": "6190d0cefff3013e77ed567e6b074f324e5c5bf5",
-          "version": "6.3.1"
-        }
-      },
-      {
-        "package": "SwiftMessages",
-        "repositoryURL": "https://github.com/SwiftKickMobile/SwiftMessages",
-        "state": {
-          "branch": null,
-          "revision": "1e49de7b3780b69927bc3e61903d8ec0693a3dc5",
-          "version": "9.0.5"
-        }
-      },
-      {
-        "package": "Swinject",
-        "repositoryURL": "https://github.com/Swinject/Swinject",
-        "state": {
-          "branch": null,
-          "revision": "f10b6e9ebff440f985c43008f7c2d097639fcb81",
-          "version": "2.8.1"
-        }
       }
     ]
   },

BIN=BIN
FreeAPS/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon117x117@2x.png


BIN=BIN
FreeAPS/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon129x129@2x.png


BIN=BIN
FreeAPS/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon33x33@2x.png


BIN=BIN
FreeAPS/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon46x46@2x.png


BIN=BIN
FreeAPS/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon51x51@2x.png


BIN=BIN
FreeAPS/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon54x54@2x.png


+ 6 - 0
FreeAPS/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json

@@ -241,6 +241,7 @@
       "size" : "29x29"
     },
     {
+      "filename" : "AppIcon33x33@2x.png",
       "idiom" : "watch",
       "role" : "notificationCenter",
       "scale" : "2x",
@@ -264,6 +265,7 @@
       "subtype" : "40mm"
     },
     {
+      "filename" : "AppIcon46x46@2x.png",
       "idiom" : "watch",
       "role" : "appLauncher",
       "scale" : "2x",
@@ -279,6 +281,7 @@
       "subtype" : "44mm"
     },
     {
+      "filename" : "AppIcon51x51@2x.png",
       "idiom" : "watch",
       "role" : "appLauncher",
       "scale" : "2x",
@@ -286,6 +289,7 @@
       "subtype" : "45mm"
     },
     {
+      "filename" : "AppIcon54x54@2x.png",
       "idiom" : "watch",
       "role" : "appLauncher",
       "scale" : "2x",
@@ -317,6 +321,7 @@
       "subtype" : "44mm"
     },
     {
+      "filename" : "AppIcon117x117@2x.png",
       "idiom" : "watch",
       "role" : "quickLook",
       "scale" : "2x",
@@ -324,6 +329,7 @@
       "subtype" : "45mm"
     },
     {
+      "filename" : "AppIcon129x129@2x.png",
       "idiom" : "watch",
       "role" : "quickLook",
       "scale" : "2x",

+ 6 - 0
FreeAPSWatch WatchKit Extension/FreeAPSWatch WatchKit Extension.entitlements

@@ -2,6 +2,12 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>com.apple.developer.healthkit.background-delivery</key>
+	<true/>
+	<key>com.apple.developer.healthkit.access</key>
+	<array/>
+	<key>com.apple.developer.healthkit</key>
+	<true/>
 	<key>com.apple.security.application-groups</key>
 	<array>
 		<string>$(APP_GROUP_ID)</string>

+ 6 - 0
FreeAPSWatch WatchKit Extension/Info.plist

@@ -2,6 +2,12 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>NSHealthUpdateUsageDescription</key>
+	<string>Bla bla Update Health</string>
+	<key>NSHealthShareUsageDescription</key>
+	<string>Bla bla Share Health</string>
+	<key>NSHealthClinicalHealthRecordsShareUsageDescription</key>
+	<string>Bla bla Record Health</string>
 	<key>NSExtension</key>
 	<dict>
 		<key>NSExtensionAttributes</key>

+ 14 - 0
FreeAPSWatch/Assets.xcassets/AppIcon.appiconset/Contents.json

@@ -70,6 +70,13 @@
     },
     {
       "idiom" : "watch",
+      "role" : "appLauncher",
+      "scale" : "2x",
+      "size" : "54x54",
+      "subtype" : "49mm"
+    },
+    {
+      "idiom" : "watch",
       "role" : "quickLook",
       "scale" : "2x",
       "size" : "86x86",
@@ -97,6 +104,13 @@
       "subtype" : "45mm"
     },
     {
+      "idiom" : "watch",
+      "role" : "quickLook",
+      "scale" : "2x",
+      "size" : "129x129",
+      "subtype" : "49mm"
+    },
+    {
       "idiom" : "watch-marketing",
       "scale" : "1x",
       "size" : "1024x1024"