Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #5186 - Starting rotateSessionId before Telemetry Starts an…
Browse files Browse the repository at this point in the history
…d ensuring that mapboxSessionId is initialized
  • Loading branch information
bleege committed Jun 6, 2016
1 parent 65330bd commit f4a82bd
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public void initialize(@NonNull Context context, @NonNull String accessToken) {
Log.w(TAG, "Error getting Encryption Algorithm: " + e);
}

// Create Initial Session Id
rotateSessionId();

SharedPreferences prefs = context.getSharedPreferences(MapboxConstants.MAPBOX_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);

// Determine if Telemetry Should Be Enabled
Expand All @@ -147,9 +150,6 @@ public void initialize(@NonNull Context context, @NonNull String accessToken) {
editor.commit();
}

// Create Initial Session Id
rotateSessionId();

// Get DisplayMetrics Setup
displayMetrics = new DisplayMetrics();
((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(displayMetrics);
Expand Down Expand Up @@ -444,7 +444,7 @@ private String encodeString(String string) {
*/
private void rotateSessionId() {
long now = System.currentTimeMillis();
if (now - mapboxSessionIdLastSet > (SESSION_ID_ROTATION_HOURS * hourInMillis)) {
if ((TextUtils.isEmpty(mapboxSessionId)) || (now - mapboxSessionIdLastSet > (SESSION_ID_ROTATION_HOURS * hourInMillis))) {
mapboxSessionId = UUID.randomUUID().toString();
mapboxSessionIdLastSet = System.currentTimeMillis();
}
Expand Down

0 comments on commit f4a82bd

Please sign in to comment.