Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
encounters
EncounterBasedCommunication
Commits
825cf046
Commit
825cf046
authored
Jul 10, 2018
by
Lily Tsai
Browse files
get rid of timestamp
parent
b48e97b3
Changes
5
Hide whitespace changes
Inline
Side-by-side
ebc_enclave_messaging
@
9b0f5500
Compare
52542068
...
9b0f5500
Subproject commit
525420689192984227bf975cb9a61c32276029a5
Subproject commit
9b0f55007d93bbe13e48f2750d0b887c880a8add
ebclibrary/src/main/java/org/mpisws/encounters/clients/SDDRClient.java
View file @
825cf046
...
@@ -6,7 +6,6 @@ import android.util.Log;
...
@@ -6,7 +6,6 @@ import android.util.Log;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.mpisws.database.DBEncounterInfo
;
import
org.mpisws.database.DBEncounterInfo
;
import
org.mpisws.database.DBTimestamp
;
import
org.mpisws.encounters.encounterhistory.bridges.EncounterEntriesBridge
;
import
org.mpisws.encounters.encounterhistory.bridges.EncounterEntriesBridge
;
import
org.mpisws.encounters.lib.time.TimeInterval
;
import
org.mpisws.encounters.lib.time.TimeInterval
;
import
org.mpisws.helpers.ThreadPoolManager
;
import
org.mpisws.helpers.ThreadPoolManager
;
...
@@ -101,9 +100,11 @@ public class SDDRClient implements EncounterBasedCommunication.ISDDRClient {
...
@@ -101,9 +100,11 @@ public class SDDRClient implements EncounterBasedCommunication.ISDDRClient {
Log
.
d
(
TAG
,
"Issuing credentials"
);
Log
.
d
(
TAG
,
"Issuing credentials"
);
int
ret
=
CloudAgentHelpers
.
issueSetCredentialsRequest
(
Preferences
.
getInstance
().
getUserHandle
(),
Preferences
.
getInstance
().
getAuthorizationToken
());
int
ret
=
CloudAgentHelpers
.
issueSetCredentialsRequest
(
Preferences
.
getInstance
().
getUserHandle
(),
Preferences
.
getInstance
().
getAuthorizationToken
());
Log
.
d
(
TAG
,
"Issued Credentials: "
+
ret
);
Log
.
d
(
TAG
,
"Issued Credentials: "
+
ret
);
List
<
MLocation
>
locations
=
new
LocationBridge
(
context
).
getLocationsSinceTime
(
Preferences
.
getInstance
().
getDBTimestamp
().
getLocationsDBTimestamp
());
// get all locations and encounters that have completed past the given time stamp (as well as ongoing encounters)
List
<
MLocation
>
locations
=
new
LocationBridge
(
context
).
getLocationsSinceTime
(
Preferences
.
getInstance
().
getDBTimestamp
());
List
<
MEncounterEntry
>
encounterEntries
=
new
EncounterEntriesBridge
(
context
).
getConfirmedEntriesAfterTime
(
List
<
MEncounterEntry
>
encounterEntries
=
new
EncounterEntriesBridge
(
context
).
getConfirmedEntriesAfterTime
(
Preferences
.
getInstance
().
getDBTimestamp
()
.
getSecretsDBTimestamp
()
Preferences
.
getInstance
().
getDBTimestamp
()
);
);
if
(
encounterEntries
.
size
()
==
0
)
{
if
(
encounterEntries
.
size
()
==
0
)
{
...
@@ -148,19 +149,13 @@ public class SDDRClient implements EncounterBasedCommunication.ISDDRClient {
...
@@ -148,19 +149,13 @@ public class SDDRClient implements EncounterBasedCommunication.ISDDRClient {
// update the checkpoints to the most recently added encounter/loc/secret if we successfully posted
// update the checkpoints to the most recently added encounter/loc/secret if we successfully posted
// make sure that we don't update the timestamps beyond what succeeded
// make sure that we don't update the timestamps beyond what succeeded
int
lastEntryBatchIndex
=
(
lastEntryBatch
+
1
)*
Utils
.
BATCH_SIZE
;
int
lastLocBatchIndex
=
(
lastLocBatch
+
1
)*
Utils
.
BATCH_SIZE
;
int
lastLocBatchIndex
=
(
lastLocBatch
+
1
)*
Utils
.
BATCH_SIZE
;
long
newEncounterTimeStamp
=
lastEntryBatch
==
0
?
Preferences
.
getInstance
().
getDBTimestamp
().
getSecretsDBTimestamp
()
:
encounterEntries
.
get
(
lastEntryBatchIndex
>
encounterEntries
.
size
()
?
encounterEntries
.
size
()-
1
:
lastEntryBatchIndex
-
1
).
getTimeInterval
().
getStartL
();
long
newLocTimeStamp
=
lastLocBatch
==
0
long
newLocTimeStamp
=
lastLocBatch
==
0
?
Preferences
.
getInstance
().
getDBTimestamp
()
.
getLocationsDBTimestamp
()
?
Preferences
.
getInstance
().
getDBTimestamp
()
:
locations
.
get
(
:
locations
.
get
(
lastLocBatchIndex
>
locations
.
size
()
?
locations
.
size
()-
1
:
lastLocBatchIndex
-
1
lastLocBatchIndex
>
locations
.
size
()
?
locations
.
size
()-
1
:
lastLocBatchIndex
-
1
).
getTimestamp
();
).
getTimestamp
();
Preferences
.
getInstance
().
set
DB
Timestamp
(
new
DBTimestamp
(
newEncounterTimeStamp
,
newLocTimeStamp
)
)
;
Preferences
.
getInstance
().
setTimestamp
(
newLocTimeStamp
);
});
});
}
}
}
}
\ No newline at end of file
ebclibrary/src/main/java/org/mpisws/encounters/encounterhistory/bridges/EncounterEntriesBridge.java
View file @
825cf046
...
@@ -180,11 +180,13 @@ public class EncounterEntriesBridge extends AbstractEncountersBridge<MEncounterE
...
@@ -180,11 +180,13 @@ public class EncounterEntriesBridge extends AbstractEncountersBridge<MEncounterE
}
}
public
List
<
MEncounterEntry
>
getConfirmedEntriesAfterTime
(
long
timestamp
)
{
public
List
<
MEncounterEntry
>
getConfirmedEntriesAfterTime
(
long
timestamp
)
{
final
String
[]
selectionArgs
=
new
String
[]
{
String
.
valueOf
(
timestamp
)
};
final
String
[]
selectionArgs
=
new
String
[]
{
String
.
valueOf
(
timestamp
),
String
.
valueOf
(
timestamp
)
};
String
whereClause
=
PEncounterEntries
.
Columns
.
timestampStart
+
" > ? AND "
String
whereClause
=
"("
+
PEncounterEntries
.
Columns
.
timestampEnd
+
" > ? OR "
+
PEncounterEntries
.
Columns
.
sharedSecret
+
" IS NOT NULL"
;
+
PEncounterEntries
.
Columns
.
timestampEnd
+
" = -1)"
+
" AND "
+
PEncounterEntries
.
Columns
.
sharedSecret
+
" IS NOT NULL"
;
String
sortOrder
=
PEncounterEntries
.
Columns
.
timestampStart
+
" ASC"
;
String
sortOrder
=
PEncounterEntries
.
Columns
.
timestampStart
+
" ASC"
;
final
Cursor
cursor
=
context
.
getContentResolver
().
query
(
EncounterHistoryAPM
.
getContentURI
(
EncounterHistoryAPM
.
encounterEntries
),
null
,
whereClause
,
selectionArgs
,
sortOrder
);
final
Cursor
cursor
=
context
.
getContentResolver
().
query
(
EncounterHistoryAPM
.
getContentURI
(
EncounterHistoryAPM
.
encounterEntries
),
null
,
whereClause
,
selectionArgs
,
sortOrder
);
List
<
MEncounterEntry
>
locs
=
new
ArrayList
();
List
<
MEncounterEntry
>
locs
=
new
ArrayList
();
while
(
cursor
.
moveToNext
())
{
while
(
cursor
.
moveToNext
())
{
locs
.
add
(
cursorToItem
(
cursor
));
locs
.
add
(
cursorToItem
(
cursor
));
...
...
ebclibrary/src/main/java/org/mpisws/encounters/lib/Preferences.java
View file @
825cf046
...
@@ -8,7 +8,6 @@ package org.mpisws.encounters.lib;
...
@@ -8,7 +8,6 @@ package org.mpisws.encounters.lib;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
org.mpisws.database.DBTimestamp
;
import
org.mpisws.helpers.GlobalObjectRegistry
;
import
org.mpisws.helpers.GlobalObjectRegistry
;
/**
/**
...
@@ -59,14 +58,11 @@ public class Preferences {
...
@@ -59,14 +58,11 @@ public class Preferences {
}
}
public
DBTimestamp
getDBTimestamp
()
{
public
long
getDBTimestamp
()
{
return
new
DBTimestamp
(
return
sharedPreferences
.
getLong
(
encEntryDBTimestamp
,
-
1
);
sharedPreferences
.
getLong
(
encEntryDBTimestamp
,
-
1
),
sharedPreferences
.
getLong
(
locationDBTimestamp
,
-
1
));
}
}
public
void
setDBTimestamp
(
DBTimestamp
timestamp
)
{
public
void
setTimestamp
(
long
timestamp
)
{
editor
().
putLong
(
encEntryDBTimestamp
,
timestamp
.
getSecretsDBTimestamp
()).
apply
();
editor
().
putLong
(
encEntryDBTimestamp
,
timestamp
).
apply
();
editor
().
putLong
(
locationDBTimestamp
,
timestamp
.
getLocationsDBTimestamp
()).
apply
();
}
}
public
void
setEbCKey
(
String
ebCKey
)
{
public
void
setEbCKey
(
String
ebCKey
)
{
...
...
ebcutils/src/main/java/org/mpisws/database/DBTimestamp.java
deleted
100644 → 0
View file @
b48e97b3
package
org.mpisws.database
;
/**
* Created by tslilyai on 2/18/18.
*/
public
class
DBTimestamp
{
long
encEntriesDBTimestamp
;
long
locationsDBTimestamp
;
public
long
getSecretsDBTimestamp
()
{
return
encEntriesDBTimestamp
;
}
public
long
getLocationsDBTimestamp
()
{
return
locationsDBTimestamp
;
}
public
DBTimestamp
(
long
encEntriesDBTimestamp
,
long
locationsDBTimestamp
)
{
this
.
encEntriesDBTimestamp
=
encEntriesDBTimestamp
;
this
.
locationsDBTimestamp
=
locationsDBTimestamp
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment