Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
encounters
EncounterBasedCommunication
Commits
825cf046
Commit
825cf046
authored
Jul 10, 2018
by
Lily Tsai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of timestamp
parent
b48e97b3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
47 deletions
+17
-47
ebc_enclave_messaging
ebc_enclave_messaging
+1
-1
ebclibrary/src/main/java/org/mpisws/encounters/clients/SDDRClient.java
...c/main/java/org/mpisws/encounters/clients/SDDRClient.java
+6
-11
ebclibrary/src/main/java/org/mpisws/encounters/encounterhistory/bridges/EncounterEntriesBridge.java
...ters/encounterhistory/bridges/EncounterEntriesBridge.java
+6
-4
ebclibrary/src/main/java/org/mpisws/encounters/lib/Preferences.java
.../src/main/java/org/mpisws/encounters/lib/Preferences.java
+4
-8
ebcutils/src/main/java/org/mpisws/database/DBTimestamp.java
ebcutils/src/main/java/org/mpisws/database/DBTimestamp.java
+0
-23
No files found.
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;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.mpisws.database.DBEncounterInfo
;
import
org.mpisws.database.DBTimestamp
;
import
org.mpisws.encounters.encounterhistory.bridges.EncounterEntriesBridge
;
import
org.mpisws.encounters.lib.time.TimeInterval
;
import
org.mpisws.helpers.ThreadPoolManager
;
...
...
@@ -101,9 +100,11 @@ public class SDDRClient implements EncounterBasedCommunication.ISDDRClient {
Log
.
d
(
TAG
,
"Issuing credentials"
);
int
ret
=
CloudAgentHelpers
.
issueSetCredentialsRequest
(
Preferences
.
getInstance
().
getUserHandle
(),
Preferences
.
getInstance
().
getAuthorizationToken
());
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
(
Preferences
.
getInstance
().
getDBTimestamp
()
.
getSecretsDBTimestamp
()
Preferences
.
getInstance
().
getDBTimestamp
()
);
if
(
encounterEntries
.
size
()
==
0
)
{
...
...
@@ -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
// 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
;
long
newEncounterTimeStamp
=
lastEntryBatch
==
0
?
Preferences
.
getInstance
().
getDBTimestamp
().
getSecretsDBTimestamp
()
:
encounterEntries
.
get
(
lastEntryBatchIndex
>
encounterEntries
.
size
()
?
encounterEntries
.
size
()-
1
:
lastEntryBatchIndex
-
1
).
getTimeInterval
().
getStartL
();
long
newLocTimeStamp
=
lastLocBatch
==
0
?
Preferences
.
getInstance
().
getDBTimestamp
()
.
getLocationsDBTimestamp
()
?
Preferences
.
getInstance
().
getDBTimestamp
()
:
locations
.
get
(
lastLocBatchIndex
>
locations
.
size
()
?
locations
.
size
()-
1
:
lastLocBatchIndex
-
1
).
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
}
public
List
<
MEncounterEntry
>
getConfirmedEntriesAfterTime
(
long
timestamp
)
{
final
String
[]
selectionArgs
=
new
String
[]
{
String
.
valueOf
(
timestamp
)
};
String
whereClause
=
PEncounterEntries
.
Columns
.
timestampStart
+
" > ? AND "
+
PEncounterEntries
.
Columns
.
sharedSecret
+
" IS NOT NULL"
;
final
String
[]
selectionArgs
=
new
String
[]
{
String
.
valueOf
(
timestamp
),
String
.
valueOf
(
timestamp
)
};
String
whereClause
=
"("
+
PEncounterEntries
.
Columns
.
timestampEnd
+
" > ? OR "
+
PEncounterEntries
.
Columns
.
timestampEnd
+
" = -1)"
+
" AND "
+
PEncounterEntries
.
Columns
.
sharedSecret
+
" IS NOT NULL"
;
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
();
while
(
cursor
.
moveToNext
())
{
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;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
org.mpisws.database.DBTimestamp
;
import
org.mpisws.helpers.GlobalObjectRegistry
;
/**
...
...
@@ -59,14 +58,11 @@ public class Preferences {
}
public
DBTimestamp
getDBTimestamp
()
{
return
new
DBTimestamp
(
sharedPreferences
.
getLong
(
encEntryDBTimestamp
,
-
1
),
sharedPreferences
.
getLong
(
locationDBTimestamp
,
-
1
));
public
long
getDBTimestamp
()
{
return
sharedPreferences
.
getLong
(
encEntryDBTimestamp
,
-
1
);
}
public
void
setDBTimestamp
(
DBTimestamp
timestamp
)
{
editor
().
putLong
(
encEntryDBTimestamp
,
timestamp
.
getSecretsDBTimestamp
()).
apply
();
editor
().
putLong
(
locationDBTimestamp
,
timestamp
.
getLocationsDBTimestamp
()).
apply
();
public
void
setTimestamp
(
long
timestamp
)
{
editor
().
putLong
(
encEntryDBTimestamp
,
timestamp
).
apply
();
}
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