Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge #5

Merged
merged 7 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Android and iOS build on MacOS

on:
push:
branches: [ master ]
branches: [ develop ]
pull_request:
branches: [ master ]
branches: [ develop ]

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionCode 11
versionName "0.5.4"
versionCode 13
versionName "0.5.8"
}
splits {
abi {
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<application
android:name=".MainApplication"
android:label="@string/app_name"
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
compileSdkVersion = 28
buildToolsVersion = "28.0.3"
targetSdkVersion = 28
minSdkVersion = 16
minSdkVersion = 23
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "11+"
firebaseVersion = "11+"
Expand Down
6 changes: 3 additions & 3 deletions app/locales/en/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import intro from './intro.json';
import locationTracking from './locationTracking.json';
import importFile from './import.json'
import exportFile from './exportscreen.json'
import importFile from './import.json';
import exportFile from './exportscreen.json';
import licensesFile from './licensesscreen.json';
import overlapFile from './overlap.json'
import overlapFile from './overlap.json';

export default {
...intro,
Expand Down
8 changes: 4 additions & 4 deletions app/locales/en/locationTracking.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"not_logging_message":"NOTE: After clicking this button you may be prompted to grant Private Kit access to your location.",
"import":"Import",
"export":"Export",
"news":"news",
"news":"News",
"latest_news":"Latest News",
"url_info":"For more information visit the Private Kit hompage:",
"url_info":"For more information visit the Private Kit homepage:",
"private_kit_url":"privatekit.mit.edu",
"overlap": "CHECK OVERLAP",
}
"overlap": "CHECK OVERLAP"
}
12 changes: 9 additions & 3 deletions app/locales/en/overlap.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"overlap_para_1":"This map shows where your private location trail overlaps with public data from a variety of sources, including official reports from WHO, Ministries of Health, and Chinese local, provincial, and national health authorities. If additional data are available from reliable online reports, they are included.",
"show_overlap": "SHOW ME TRACE OVERLAP",
}
"overlap_title": "Check Overlap",
"overlap_para_1": "Green circles are clusters of your locations, click to zoom. Red markers are your recorded locations.\n\nPress the button to download public information of confirmed cases, shown as faint purple circles.",
"show_overlap": "Check Public Data",
"loading_public_data": "loading data...",
"overlap_no_results_button_label": "Public Data Loaded",
"overlap_found_button_label": "Public Data Loaded",
"nCoV2019_url_info": "For more information on the dataset for this map",
"nCoV2019_url": "github.com/beoutbreakprepared/nCoV2019"
}
125 changes: 125 additions & 0 deletions app/services/BroadcastingService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import {
GetStoreData,
SetStoreData
} from '../helpers/General';

import BackgroundTimer from 'react-native-background-timer';
import UUIDGenerator from 'react-native-uuid-generator';
import Moment from 'moment';

import AndroidBLEAdvertiserModule from 'react-native-ble-advertiser'

var currentUUID = null;

function saveContact(contact) {
// Persist this contact data in our local storage of time/lat/lon values

GetStoreData('CONTACT_DATA')
.then(contactArrayString => {

var contactArray;
if (contactArrayString !== null) {
contactArray = JSON.parse(contactArrayString);
} else {
contactArray = [];
}

// Always work in UTC, not the local time in the contactData
var nowUTC = new Date().toISOString();
var unixtimeUTC = Date.parse(nowUTC);
var unixtimeUTC_28daysAgo = unixtimeUTC - (60 * 60 * 24 * 1000 * 28);

// Save the contact using the current lat-lon and the
// calculated UTC time (maybe a few milliseconds off from
// when the GPS data was collected, but that's unimportant
// for what we are doing.)
console.log('[GPS] Saving point:', contactArray.length);
var lat_lon_time = {
"uuid": contact["uuid"],
"time": unixtimeUTC
};
contactArray.push(lat_lon_time);

SetStoreData('CONTACT_DATA', contactArray);
});
}

function saveMyUUID(me) {
// Persist this contact data in our local storage of time/lat/lon values

GetStoreData('MY_UUIDs')
.then(myUUIDArrayString => {
var myUUIDArray;
if (myUUIDArrayString !== null) {
myUUIDArray = JSON.parse(myUUIDArrayString);
} else {
myUUIDArray = [];
}

// Always work in UTC, not the local time in the contactData
var nowUTC = new Date().toISOString();
var unixtimeUTC = Date.parse(nowUTC);
var unixtimeUTC_28daysAgo = unixtimeUTC - (60 * 60 * 24 * 1000 * 28);

var uuid_time = {
"uuid": me["uuid"],
"time": unixtimeUTC
};
console.log('[GPS] Saving myUUID:', Moment(unixtimeUTC).format('MMM Do, H:mma'), me["uuid"], myUUIDArray.length);
myUUIDArray.push(uuid_time);

SetStoreData('MY_UUIDs', myUUIDArray);
});
}

function loadLastUUIDAndBroadcast() {
GetStoreData('MY_UUIDs')
.then(myUUIDArrayString => {
var myUUIDArray;
if (myUUIDArrayString !== null) {
myUUIDArray = JSON.parse(myUUIDArrayString);
console.log("Loading last uuid ", myUUIDArray[myUUIDArray.length-1].uuid);
currentUUID = myUUIDArray[myUUIDArray.length-1].uuid;
broadcast();
} else {
generateNewUUIDAndBroadcast();
}
});
}

function broadcast() {
// Do not run on iOS for now.
if (Platform.OS === 'android') {
console.log("Broadcasting: ", currentUUID);
AndroidBLEAdvertiserModule.setCompanyId(0xFF);
AndroidBLEAdvertiserModule.broadcastPacket(currentUUID, [12,23,56])
.then((sucess) => {
console.log("Broadcasting Sucessful", sucess);
}).catch(error => console.log("Broadcasting Error", error));
}
}

function generateNewUUIDAndBroadcast() {
UUIDGenerator.getRandomUUID((uuid) => {
currentUUID = uuid;
saveMyUUID({'uuid':uuid});
broadcast();
});
}

export default class BroadcastingServices {
static start() {
loadLastUUIDAndBroadcast();

BackgroundTimer.runBackgroundTimer(() => {
generateNewUUIDAndBroadcast();
}, 1000 * 60 * 60); // Every hour, change UUID

console.log("Starting Bluetooth");
}

static stop(nav) {
console.log("Stopping Bluetooth");
BackgroundTimer.stopBackgroundTimer();
}
}
Loading