mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-01-18 16:56:33 +00:00
COVIDSafe code from version 1.4 (updates) (#4)
This commit is contained in:
parent
b2e0c5b34c
commit
6b262be150
15 changed files with 140 additions and 144 deletions
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
Pods
|
||||
|
||||
build/
|
||||
DerivedData/
|
||||
|
||||
.bundle
|
||||
.build
|
||||
.DS_Store
|
||||
|
||||
*.mode1v3
|
||||
*.pbxuser
|
||||
*.swp
|
||||
*.xcuserstate
|
||||
*.xccurrentversion
|
||||
*.xccheckout
|
||||
*.xcbkptlist
|
||||
*.xcscmblueprint
|
||||
xcuserdata
|
||||
|
||||
# Ruby Bundler
|
||||
vendor
|
|
@ -82,6 +82,16 @@
|
|||
59AF2E9A2435533A00ACCAF2 /* CovidCertificates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59AF2E982435533A00ACCAF2 /* CovidCertificates.swift */; };
|
||||
59AF2E9C2435581600ACCAF2 /* CovidNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59AF2E9B2435581600ACCAF2 /* CovidNetworking.swift */; };
|
||||
59AF2E9D2435581600ACCAF2 /* CovidNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59AF2E9B2435581600ACCAF2 /* CovidNetworking.swift */; };
|
||||
59AF2E9F243560FD00ACCAF2 /* AmazonRootCA1.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2E9E243560FD00ACCAF2 /* AmazonRootCA1.cer */; };
|
||||
59AF2EA0243560FD00ACCAF2 /* AmazonRootCA1.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2E9E243560FD00ACCAF2 /* AmazonRootCA1.cer */; };
|
||||
59AF2EA82435801400ACCAF2 /* SFSRootCAG2.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA42435801300ACCAF2 /* SFSRootCAG2.cer */; };
|
||||
59AF2EA92435801400ACCAF2 /* SFSRootCAG2.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA42435801300ACCAF2 /* SFSRootCAG2.cer */; };
|
||||
59AF2EAA2435801400ACCAF2 /* AmazonRootCA3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA52435801300ACCAF2 /* AmazonRootCA3.cer */; };
|
||||
59AF2EAB2435801400ACCAF2 /* AmazonRootCA3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA52435801300ACCAF2 /* AmazonRootCA3.cer */; };
|
||||
59AF2EAC2435801400ACCAF2 /* AmazonRootCA4.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA62435801400ACCAF2 /* AmazonRootCA4.cer */; };
|
||||
59AF2EAD2435801400ACCAF2 /* AmazonRootCA4.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA62435801400ACCAF2 /* AmazonRootCA4.cer */; };
|
||||
59AF2EAE2435801400ACCAF2 /* AmazonRootCA2.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA72435801400ACCAF2 /* AmazonRootCA2.cer */; };
|
||||
59AF2EAF2435801400ACCAF2 /* AmazonRootCA2.cer in Resources */ = {isa = PBXBuildFile; fileRef = 59AF2EA72435801400ACCAF2 /* AmazonRootCA2.cer */; };
|
||||
59AF2EB22435A38100ACCAF2 /* CovidRequestRetrier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59AF2EB12435A38100ACCAF2 /* CovidRequestRetrier.swift */; };
|
||||
59AF2EB32435A38100ACCAF2 /* CovidRequestRetrier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59AF2EB12435A38100ACCAF2 /* CovidRequestRetrier.swift */; };
|
||||
59B7417024514126006E1EEA /* RegistrationConsentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59B7416F24514126006E1EEA /* RegistrationConsentViewController.swift */; };
|
||||
|
@ -309,6 +319,11 @@
|
|||
59ACB575242F404500E63E3C /* DataUploadS3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataUploadS3.swift; sourceTree = "<group>"; };
|
||||
59AF2E982435533A00ACCAF2 /* CovidCertificates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CovidCertificates.swift; sourceTree = "<group>"; };
|
||||
59AF2E9B2435581600ACCAF2 /* CovidNetworking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CovidNetworking.swift; sourceTree = "<group>"; };
|
||||
59AF2E9E243560FD00ACCAF2 /* AmazonRootCA1.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = AmazonRootCA1.cer; sourceTree = "<group>"; };
|
||||
59AF2EA42435801300ACCAF2 /* SFSRootCAG2.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = SFSRootCAG2.cer; sourceTree = "<group>"; };
|
||||
59AF2EA52435801300ACCAF2 /* AmazonRootCA3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = AmazonRootCA3.cer; sourceTree = "<group>"; };
|
||||
59AF2EA62435801400ACCAF2 /* AmazonRootCA4.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = AmazonRootCA4.cer; sourceTree = "<group>"; };
|
||||
59AF2EA72435801400ACCAF2 /* AmazonRootCA2.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = AmazonRootCA2.cer; sourceTree = "<group>"; };
|
||||
59AF2EB12435A38100ACCAF2 /* CovidRequestRetrier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CovidRequestRetrier.swift; sourceTree = "<group>"; };
|
||||
59B7416F24514126006E1EEA /* RegistrationConsentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistrationConsentViewController.swift; sourceTree = "<group>"; };
|
||||
59F25D68245B917A002A7ED8 /* Spinner_home.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Spinner_home.json; sourceTree = "<group>"; };
|
||||
|
@ -578,6 +593,11 @@
|
|||
59AF2EB02435801900ACCAF2 /* RootCAs */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
59AF2EA72435801400ACCAF2 /* AmazonRootCA2.cer */,
|
||||
59AF2EA52435801300ACCAF2 /* AmazonRootCA3.cer */,
|
||||
59AF2EA62435801400ACCAF2 /* AmazonRootCA4.cer */,
|
||||
59AF2EA42435801300ACCAF2 /* SFSRootCAG2.cer */,
|
||||
59AF2E9E243560FD00ACCAF2 /* AmazonRootCA1.cer */,
|
||||
);
|
||||
path = RootCAs;
|
||||
sourceTree = "<group>";
|
||||
|
@ -914,18 +934,22 @@
|
|||
5B92D6BB243018040049877B /* UploadData.storyboard in Resources */,
|
||||
5B92D6BD243018040049877B /* JMCTarget.json in Resources */,
|
||||
5B92D6BF243018040049877B /* NewFeedbackFlow.storyboard in Resources */,
|
||||
59AF2EA92435801400ACCAF2 /* SFSRootCAG2.cer in Resources */,
|
||||
0BDE12302431DCE6003BC44C /* Questions.storyboard in Resources */,
|
||||
59F25D6A245B917A002A7ED8 /* Spinner_home.json in Resources */,
|
||||
5B92D6C2243018040049877B /* Localizable.strings in Resources */,
|
||||
5B92D6C7243018040049877B /* CovidSafe-config.plist in Resources */,
|
||||
59AF2EA0243560FD00ACCAF2 /* AmazonRootCA1.cer in Resources */,
|
||||
5B92D6C8243018040049877B /* NewFeedbackFlow.strings in Resources */,
|
||||
5961ABEE2474E464004040DF /* spinner_migrating_db.json in Resources */,
|
||||
59AF2EAD2435801400ACCAF2 /* AmazonRootCA4.cer in Resources */,
|
||||
59F25D6F245BED80002A7ED8 /* Debug.storyboard in Resources */,
|
||||
5B92D6C9243018040049877B /* LaunchScreen.storyboard in Resources */,
|
||||
59AF2EAF2435801400ACCAF2 /* AmazonRootCA2.cer in Resources */,
|
||||
5B92D6CB243018040049877B /* Assets.xcassets in Resources */,
|
||||
5B92D6CC243018040049877B /* Feedback.strings in Resources */,
|
||||
5B337AB0245AA26300537620 /* Spinner_upload.json in Resources */,
|
||||
59AF2EAB2435801400ACCAF2 /* AmazonRootCA3.cer in Resources */,
|
||||
5B92D6CF243018040049877B /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -938,12 +962,16 @@
|
|||
B6932CE724260E2B003D1810 /* UploadData.storyboard in Resources */,
|
||||
A767D313242DF1B000DC9E2A /* JMCTarget.json in Resources */,
|
||||
1B86118E24303E7D00EA4B6B /* Questions.storyboard in Resources */,
|
||||
59AF2EA82435801400ACCAF2 /* SFSRootCAG2.cer in Resources */,
|
||||
A767D312242DF1B000DC9E2A /* NewFeedbackFlow.storyboard in Resources */,
|
||||
59F25D69245B917A002A7ED8 /* Spinner_home.json in Resources */,
|
||||
30BE1CAD23F119FD005DCE4F /* Localizable.strings in Resources */,
|
||||
5B92D663243011B40049877B /* CovidSafe-config.plist in Resources */,
|
||||
59AF2E9F243560FD00ACCAF2 /* AmazonRootCA1.cer in Resources */,
|
||||
A767D30F242DF1B000DC9E2A /* NewFeedbackFlow.strings in Resources */,
|
||||
59AF2EAC2435801400ACCAF2 /* AmazonRootCA4.cer in Resources */,
|
||||
5DD41D4723DCB03D00FD4AB0 /* LaunchScreen.storyboard in Resources */,
|
||||
59AF2EAE2435801400ACCAF2 /* AmazonRootCA2.cer in Resources */,
|
||||
5DD41D4423DCB03D00FD4AB0 /* Assets.xcassets in Resources */,
|
||||
A767D30E242DF1B000DC9E2A /* Feedback.strings in Resources */,
|
||||
5B337AAF245AA26300537620 /* Spinner_upload.json in Resources */,
|
||||
|
|
|
@ -79,3 +79,5 @@ extension Encounter {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,15 +10,63 @@ import CoreData
|
|||
|
||||
extension EncounterRecord {
|
||||
|
||||
func saveToCoreData() {
|
||||
func saveRemoteCentralToCoreData() throws {
|
||||
// remote blob will be modelC rssi txPower msg if v1. If v2 then remoteBlob will just be msg
|
||||
// localblob will be modelP
|
||||
var localBlob = EncounterBlob()
|
||||
localBlob.modelP = self.modelP
|
||||
var remoteBlob = EncounterBlob()
|
||||
remoteBlob.modelC = self.modelC
|
||||
remoteBlob.rssi = self.rssi
|
||||
remoteBlob.txPower = self.txPower
|
||||
remoteBlob.msg = self.msg
|
||||
|
||||
var encryptedLocalBlob: String
|
||||
var encryptedRemoteBlob: String
|
||||
let localJson = try JSONEncoder().encode(localBlob)
|
||||
encryptedLocalBlob = try Crypto.encrypt(dataToEncrypt: localJson)
|
||||
if v == 1 {
|
||||
let remoteJson = try JSONEncoder().encode(remoteBlob)
|
||||
encryptedRemoteBlob = try Crypto.encrypt(dataToEncrypt: remoteJson)
|
||||
} else {
|
||||
encryptedRemoteBlob = self.msg!
|
||||
}
|
||||
|
||||
saveToCoreData(remoteBlob: encryptedRemoteBlob, localBlob: encryptedLocalBlob)
|
||||
}
|
||||
|
||||
func saveRemotePeripheralToCoreData() throws {
|
||||
var remoteBlob = EncounterBlob()
|
||||
remoteBlob.modelP = self.modelP
|
||||
remoteBlob.msg = self.msg
|
||||
var localBlob = EncounterBlob()
|
||||
localBlob.modelC = self.modelC
|
||||
localBlob.rssi = self.rssi
|
||||
localBlob.txPower = self.txPower
|
||||
|
||||
var encryptedLocalBlob: String
|
||||
var encryptedRemoteBlob: String
|
||||
let localJson = try JSONEncoder().encode(localBlob)
|
||||
encryptedLocalBlob = try Crypto.encrypt(dataToEncrypt: localJson)
|
||||
if v == 1 {
|
||||
let remoteJson = try JSONEncoder().encode(remoteBlob)
|
||||
encryptedRemoteBlob = try Crypto.encrypt(dataToEncrypt: remoteJson)
|
||||
} else {
|
||||
encryptedRemoteBlob = self.msg!
|
||||
}
|
||||
|
||||
saveToCoreData(remoteBlob: encryptedRemoteBlob, localBlob: encryptedLocalBlob)
|
||||
}
|
||||
|
||||
private func saveToCoreData(remoteBlob: String, localBlob: String) {
|
||||
DispatchQueue.main.async {
|
||||
guard let persistentContainer = EncounterDB.shared.persistentContainer else {
|
||||
return
|
||||
}
|
||||
let managedContext = appDelegate.persistentContainer.viewContext
|
||||
let managedContext = persistentContainer.viewContext
|
||||
let entity = NSEntityDescription.entity(forEntityName: "Encounter", in: managedContext)!
|
||||
let encounter = Encounter(entity: entity, insertInto: managedContext)
|
||||
encounter.set(encounterStruct: self)
|
||||
encounter.set(encounterStruct: self, remoteBlob: remoteBlob, localBlob: localBlob)
|
||||
do {
|
||||
try managedContext.save()
|
||||
} catch {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// Encounter+Event.swift
|
||||
// CovidSafe
|
||||
//
|
||||
// Copyright © 2020 Australian Government. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import CoreData
|
||||
|
||||
extension Encounter {
|
||||
|
||||
enum Event: String, CaseIterable {
|
||||
case scanningStarted = "Scanning started"
|
||||
case scanningStopped = "Scanning stopped"
|
||||
|
||||
case appStarted = "App started"
|
||||
case appEnteredForeground = "App entered foreground"
|
||||
case appEnteredBackground = "App entered background"
|
||||
case appTerminating = "App about to terminate"
|
||||
}
|
||||
|
||||
static func timestamp(for event: Event) {
|
||||
DispatchQueue.main.async {
|
||||
guard let appDelegate =
|
||||
UIApplication.shared.delegate as? AppDelegate else {
|
||||
return
|
||||
}
|
||||
let managedContext = appDelegate.persistentContainer.viewContext
|
||||
let entity = NSEntityDescription.entity(forEntityName: "Encounter", in: managedContext)!
|
||||
let encounter = Encounter(entity: entity, insertInto: managedContext)
|
||||
encounter.msg = event.rawValue
|
||||
encounter.timestamp = Date()
|
||||
encounter.v = nil
|
||||
do {
|
||||
try managedContext.save()
|
||||
} catch {
|
||||
print("Could not save. \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright © 2020 Australian Government All rights reserved.
|
||||
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIDevice {
|
||||
|
|
|
@ -49,6 +49,7 @@ public struct FeedbackSettings {
|
|||
getReporterInfoAsynchronously: ((@escaping (_ usernameOrEmail: String?, _ avatarImageURL: URL?) -> Void) -> Void)? = nil
|
||||
) throws {
|
||||
let target = try defaultFeedbackSettings?.JIRATarget ?? JMCTarget.createTargetFromJSONOnDisk()
|
||||
|
||||
self.init(
|
||||
JIRATarget: target,
|
||||
issueType: issueType,
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
<array>
|
||||
<string>bluetooth-central</string>
|
||||
<string>bluetooth-peripheral</string>
|
||||
<string>remote-notification</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
|
|
|
@ -244,3 +244,4 @@ class OTPViewController: UIViewController, RegistrationHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,46 +9,8 @@ import UIKit
|
|||
import UserNotifications
|
||||
|
||||
class OnboardingStep2ViewController: UIViewController {
|
||||
|
||||
@IBAction func allowPermissionsBtn(_ sender: UIButton) {
|
||||
requestAllPermissions()
|
||||
}
|
||||
|
||||
@IBAction func onBackTapped(_ sender: UIButton) {
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
// Show the navigation bar on other view controllers
|
||||
|
||||
}
|
||||
|
||||
func requestAllPermissions() {
|
||||
UNUserNotificationCenter.current() // 1
|
||||
.requestAuthorization(options: [.alert, .sound, .badge]) { // 2
|
||||
granted, error in
|
||||
BluetraceManager.shared.turnOn()
|
||||
UserDefaults.standard.set(true, forKey: "allowedPermissions")
|
||||
print("Permissions granted: \(granted)") // 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
// Get the new view controller using segue.destination.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -6,24 +6,41 @@
|
|||
//
|
||||
|
||||
import UIKit
|
||||
import SafariServices
|
||||
|
||||
class OnboardingStep2bViewController: UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
BluetraceManager.shared.turnOn()
|
||||
UserDefaults.standard.set(true, forKey: "turnedOnBluetooth")
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
// Get the new view controller using segue.destination.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@IBAction func learnMoreTapped(_ sender: Any) {
|
||||
guard let url = URL(string: "https://www.covidsafe.gov.au/help-topics.html#bluetooth-pairing-request") else {
|
||||
return
|
||||
}
|
||||
|
||||
let safariVC = SFSafariViewController(url: url)
|
||||
present(safariVC, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
@IBAction func continueBtnTapped(_ sender: UIButton) {
|
||||
requestAllPermissions()
|
||||
}
|
||||
|
||||
func requestAllPermissions() {
|
||||
|
||||
UNUserNotificationCenter.current() // 1
|
||||
.requestAuthorization(options: [.alert, .sound, .badge]) { // 2
|
||||
granted, error in
|
||||
|
||||
UserDefaults.standard.set(true, forKey: "allowedPermissions")
|
||||
print("Permissions granted: \(granted)") // 3
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.performSegue(withIdentifier: "showHomeSegue", sender: self)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
//
|
||||
// OnboardingStep2cViewController.swift
|
||||
// CovidSafe
|
||||
//
|
||||
// Copyright © 2020 Australian Government. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class OnboardingStep2cViewController: UIViewController {
|
||||
|
||||
@IBAction func enabledBluetoothBtn(_ sender: UIButton) {
|
||||
UserDefaults.standard.set(true, forKey: "turnedOnBluetooth")
|
||||
|
||||
DispatchQueue.main.async {
|
||||
UNUserNotificationCenter.current().getNotificationSettings(completionHandler: { [weak self] settings in
|
||||
DispatchQueue.main.async {
|
||||
if settings.authorizationStatus == .authorized && BluetraceManager.shared.isBluetoothAuthorized() && BluetraceManager.shared.isBluetoothOn() {
|
||||
self?.performSegue(withIdentifier: "showFullySetUpFromTurnOnBtSegue", sender: self)
|
||||
} else {
|
||||
self?.performSegue(withIdentifier: "showHomeFromTurnOnBtSegue", sender: self)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
// Get the new view controller using segue.destination.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
|
@ -28,3 +28,4 @@ class Question2ViewController: UIViewController {
|
|||
messageTextView.addLink("https://www.health.gov.au/news/health-alerts/novel-coronavirus-2019-ncov-health-alert/how-to-protect-yourself-and-others-from-coronavirus-covid-19/self-isolation-self-quarantine-for-coronavirus-covid-19", enclosedIn: "*")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -184,3 +184,4 @@ class UploadDataStep2VC: UIViewController, CodeInputViewDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue