Commit cd3b19a8 authored by Lily Tsai's avatar Lily Tsai
parents 132f1b9d a6551bc0
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="imageWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="imageAssetPanel">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="actionbar">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipartAsset">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="url" value="jar:file:/snap/android-studio/47/android-studio/plugins/android/lib/android.jar!/images/material_design_icons/communication/ic_email_black_24dp.xml" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="outputName" value="ic_recv" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="outputIconType" value="ACTIONBAR" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -38,7 +38,7 @@ repositories {
maven { url "https://dl.bintray.com/tslilyai/EncounterBasedCommunication" }
}
dependencies {
compile 'org.mpisws:ebclibrary:0.1.0.1'
compile 'org.mpisws:ebclibrary:0.1.0.2'
}
```
......
......@@ -44,7 +44,7 @@ import java.util.List;
**/
public class EncounterBasedCommunication {
public static final long CHANGE_EPOCH_TIME = 15*60000;
public static final long SCAN_BATCH_INTERVAL = (long) (2 * 60000);
public static final long SCAN_BATCH_INTERVAL = (long) (2*60000);
public static final int REQUEST_ENABLE_BT = 1;
public static final int REQUEST_ACCESS_FINE_LOCATION = 2;
private static final String TAG = EncounterBasedCommunication.class.getSimpleName();
......
......@@ -87,14 +87,18 @@ public abstract class ContentProviderBase extends ContentProvider {
final SQLiteDatabase db = dbHelper.getWritableDatabase(GlobalObjectRegistry.getObject(ESCredentials.class).getUserHandle());
final MatchType matchType = codeToModel(matcher.match(uri));
final DBModel dmb = matchType.getModel();
final long rowID = db.insertOrThrow(dmb.getTableName(), null, values);
if (rowID == -1) {
throw new SQLException("Insert failed");
try {
final long rowID = db.insertOrThrow(dmb.getTableName(), null, values);
if (rowID == -1) {
throw new SQLException("Insert failed");
}
final Uri insertedRowURI = ContentUris.withAppendedId(EncounterHistoryAPM.getContentURI(dmb), rowID);
getContext().getContentResolver().notifyChange(insertedRowURI, null);
return insertedRowURI;
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
final Uri insertedRowURI = ContentUris.withAppendedId(EncounterHistoryAPM.getContentURI(dmb), rowID);
getContext().getContentResolver().notifyChange(insertedRowURI, null);
//Log.d(TAG, "Insert done");
return insertedRowURI;
return null;
}
public String addPKIDConditionToWhereClause(final String where, final String pkidString) { // TODO add to whereArgs instead
......
......@@ -62,6 +62,7 @@ public class EncounterHistoryAPM extends AggregatePersistenceModel {
Log.v("PersistenceModel", "Creating table " + model.getTableName());
sb.append("CREATE TABLE IF NOT EXISTS ").append(model.getTableName()).append(" (");
sb.append(Utils.collectionToStringV2(model.getColumns(), ","));
sb.append(model.getUnique());
sb.append(")");
db.execSQL(sb.toString());
}
......
......@@ -4,6 +4,7 @@ import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
......@@ -96,7 +97,11 @@ public class EncounterEntriesBridge extends AbstractEncountersBridge<MEncounterE
values.put(PEncounterEntries.Columns.otherTopicHandle, "");
values.put(PEncounterEntries.Columns.shouldPostNonceToLink, shouldPostNonceToLink);
values.put(PEncounterEntries.Columns.userHandle, userHandle);
context.getContentResolver().insert(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.encounterEntries), values);
try {
context.getContentResolver().insert(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.encounterEntries), values);
} catch (Exception e) {
Log.d(TAG, "Duplicate insert attempted");
}
}
public void updateEndTime(long pkid, long endTime) {
......@@ -253,7 +258,9 @@ public class EncounterEntriesBridge extends AbstractEncountersBridge<MEncounterE
String whereClause = "HEX(" + PEncounterEntries.Columns.encounterID + ") = ?";
String[] selectArgs = new String[] {eid.toString()};
int updatedRows = context.getContentResolver().update(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.encounterEntries), values, whereClause, selectArgs);
Utils.myAssert(updatedRows == 1);
if (updatedRows != 1) {
Log.e(TAG, "UPDATED " + updatedRows + " ROWS WITH EID " + eid.toString());
}
}
public List<MEncounterEntry> getEntriesToPostForLinking() {
......
......@@ -13,4 +13,5 @@ public abstract class DBModel {
public abstract String getTableName();
public abstract List<DBColumn> getColumns();
public abstract List<DBValue> getValues();
public String getUnique() {return "";}
}
......@@ -133,6 +133,11 @@ public class DBEncounterEntries extends DBModel {
return values;
}
@Override
public String getUnique() {
return ", UNIQUE(" + Columns.myNonce + "," + Columns.receivedNonce + ")";
}
/*public static DBEncounterEntries fromString(String values) {
String[] vals = values.split("\n");
......
......@@ -60,7 +60,8 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.+'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.android.support:multidex:1.0.2'
implementation 'net.openid:appauth:0.3.0'
implementation 'org.mpisws:ebclibrary:0.1.0.1'
implementation 'pub.devrel:easypermissions:0.3.0'
......
{
application: {
ebcKey: '2e5a1cc8-5eab-4dbd-8d6d-6a84eab23374'
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ import java.util.UUID;
*/
public class SimulationClientBT {
Context context;
protected static final int NUM_SIMULATED_DEVICES = 50;
protected static final int NUM_SIMULATED_DEVICES = 30;
protected static final int NUM_SIMULATED_EPOCHS = 10;
private static final String TAG = SimulationClientBT.class.getSimpleName();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment