updates to allow server communication

This commit is contained in:
Zachary Atkins 2021-04-11 00:59:30 -05:00
parent be205fddc8
commit d56bad22d0
6 changed files with 69 additions and 32 deletions

View File

@ -35,7 +35,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.loc_chain_app" applicationId "com.example.loc_chain_app"
minSdkVersion 16 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 30
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName

View File

@ -5,6 +5,7 @@ import 'package:loc_chain_app/widgets/navbar.dart';
import 'package:flutter_udid/flutter_udid.dart'; import 'package:flutter_udid/flutter_udid.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(App()); runApp(App());
(await SharedPreferences.getInstance()) (await SharedPreferences.getInstance())
.setString('userName', await FlutterUdid.consistentUdid); .setString('userName', await FlutterUdid.consistentUdid);
@ -14,11 +15,10 @@ class App extends StatelessWidget {
// This widget is the root of your application. // This widget is the root of your application.
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Connect.stop();
Connect.start(); Connect.start();
return MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'Loc-Chain',
theme: ThemeData( theme: ThemeData(
primarySwatch: Colors.lightBlue, primarySwatch: Colors.lightBlue,
), ),

View File

@ -78,4 +78,6 @@ class _HomePageState extends State<HomePage> {
content: Text(a.toString()), content: Text(a.toString()),
)); ));
} }
Future<void> reportExposure() async {}
} }

View File

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_udid/flutter_udid.dart'; import 'package:flutter_udid/flutter_udid.dart';
import 'package:loc_chain_app/util/keyfile_manager.dart'; import 'package:loc_chain_app/util/keyfile_manager.dart';
@ -19,3 +20,50 @@ class Transaction {
Future<String> generateP2PPayload(String otherUserId) async => Future<String> generateP2PPayload(String otherUserId) async =>
"${await generateHash(otherUserId)}:${KeyFileManager.keyPair.publicKey}"; "${await generateHash(otherUserId)}:${KeyFileManager.keyPair.publicKey}";
} }
class EncounterTransaction {
EncounterTransaction({
required this.combinedHash,
required this.encodedGPSLocation,
required this.partnerPublicKey,
required this.validationSignature,
}) : timestamp = "${DateTime.now().millisecondsSinceEpoch}";
final String combinedHash;
final String timestamp;
final String encodedGPSLocation;
final String partnerPublicKey;
final String validationSignature;
EncounterTransaction.fromJson(Map<String, dynamic> json)
: combinedHash = json['combinedHash'],
timestamp = json['timestamp'],
encodedGPSLocation = json['encodedGPSLocation'],
partnerPublicKey = json['partnerPublicKey'],
validationSignature = json['validationSignature'];
Map<String, dynamic> toJson() => {
"combinedHash": combinedHash,
"timestamp": timestamp,
"encodedGPSLocation": encodedGPSLocation,
"partnerPublicKey": partnerPublicKey,
"validationSignature": validationSignature,
};
}
class ExposureTransaction {
final String clientID;
final String timestamp;
ExposureTransaction({
required this.clientID,
}) : timestamp = "${DateTime.now().millisecondsSinceEpoch}";
ExposureTransaction.fromJson(Map<String, dynamic> json)
: clientID = json['clientID'],
timestamp = json['timestamp'];
Map<String, dynamic> toJson() => {
"clientID": clientID,
"timestamp": timestamp,
};
}

View File

@ -92,34 +92,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.1.0" version: "6.1.0"
firebase_core:
dependency: transitive
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
firebase_database:
dependency: "direct main"
description:
name: firebase_database
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:
@ -156,6 +128,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.3"
loading_animations:
dependency: "direct main"
description:
name: loading_animations
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -177,6 +156,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.1" version: "3.0.1"
openpgp:
dependency: "direct main"
description:
name: openpgp
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0-nullsafety.0"
path: path:
dependency: transitive dependency: transitive
description: description:

View File

@ -34,7 +34,8 @@ dependencies:
sqflite: ^2.0.0+3 sqflite: ^2.0.0+3
dbcrypt: ^2.0.0 dbcrypt: ^2.0.0
flutter_udid: ^2.0.0 flutter_udid: ^2.0.0
firebase_database: ^6.1.2 loading_animations: ^2.2.0
openpgp: ^2.0.0-nullsafety.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: