mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 14:27:15 +00:00
TRACKING APP: enhancements in TrackingService, TransmittingService (work in progress)
This commit is contained in:
1 parent
248d2b707e
commit
a6b1c4326d
4 files changed
+37
-15
No files matched your search
+5
@@ -54,6 +54,11 @@ public class AnalyticsContract {
|
||||
private static final String PATH_LEADERBOARD = "leaderboards";
|
||||
private static final String PATH_SENSOR_GPS = "sensor_gps";
|
||||
|
||||
public static class EventGpsFixesJoined {
|
||||
public final static Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
|
||||
.appendPath("event_gps_fix_joined").build();
|
||||
}
|
||||
|
||||
public static class EventLeaderboardCompetitorJoined {
|
||||
public final static Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
|
||||
.appendPath("event_leaderboard_competitor_joined")
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ public class AnalyticsDatabase extends SQLiteOpenHelper {
|
||||
String EVENTS_JOIN_LEADERBOARDS_JOIN_COMPETITORS = Tables.LEADERBOARDS +
|
||||
" INNER JOIN " + Tables.EVENTS + " ON (" + Tables.LEADERBOARDS + "." + BaseColumns._ID + " = " + Tables.EVENTS + ".leaderboard_id ) " +
|
||||
" INNER JOIN " + Tables.COMPETITORS + " ON (" + Tables.LEADERBOARDS + "."+ BaseColumns._ID + " = " + Tables.COMPETITORS + ".leaderboard_id ) ";
|
||||
String GPS_FIXES_JOIN_EVENTS = Tables.EVENTS + " INNER JOIN " + Tables.SENSOR_GPS;
|
||||
}
|
||||
|
||||
public AnalyticsDatabase(Context context) {
|
||||
|
||||
+9
-3
@@ -11,7 +11,6 @@ import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteQueryBuilder;
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.shared.util.SelectionBuilder;
|
||||
@@ -47,6 +46,8 @@ public class AnalyticsProvider extends ContentProvider {
|
||||
|
||||
private static final int EVENT_LEADERBOARD_COMPETITOR_JOINED = 600;
|
||||
|
||||
private static final int EVENT_GPS_FIXES_JOINED = 700;
|
||||
|
||||
private static UriMatcher buildUriMatcher() {
|
||||
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
final String authority = AnalyticsContract.CONTENT_AUTHORITY;
|
||||
@@ -68,6 +69,8 @@ public class AnalyticsProvider extends ContentProvider {
|
||||
|
||||
matcher.addURI(authority, "event_leaderboard_competitor_joined", EVENT_LEADERBOARD_COMPETITOR_JOINED);
|
||||
|
||||
matcher.addURI(authority, "event_gps_fix_joined", EVENT_GPS_FIXES_JOINED);
|
||||
|
||||
return matcher;
|
||||
}
|
||||
|
||||
@@ -83,8 +86,6 @@ public class AnalyticsProvider extends ContentProvider {
|
||||
// AnalyticsDatabase.deleteDatabase(context);
|
||||
// mOpenHelper = new AnalyticsDatabase(context);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
@@ -106,6 +107,11 @@ public class AnalyticsProvider extends ContentProvider {
|
||||
cursor = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
|
||||
return cursor;
|
||||
|
||||
case EVENT_GPS_FIXES_JOINED:
|
||||
SQLiteQueryBuilder eb = new SQLiteQueryBuilder();
|
||||
eb.setTables(Tables.GPS_FIXES_JOIN_EVENTS);
|
||||
cursor = eb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
|
||||
return cursor;
|
||||
|
||||
default:
|
||||
final SelectionBuilder builder = buildExpandedSelection(uri);
|
||||
|
||||
+22
-12
@@ -13,7 +13,6 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
@@ -29,10 +28,9 @@ import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.tracking.app.BuildConfig;
|
||||
import com.sap.sailing.android.tracking.app.R;
|
||||
import com.sap.sailing.android.tracking.app.provider.AnalyticsContract.Event;
|
||||
import com.sap.sailing.android.tracking.app.provider.AnalyticsContract.EventGpsFixesJoined;
|
||||
import com.sap.sailing.android.tracking.app.provider.AnalyticsContract.SensorGps;
|
||||
import com.sap.sailing.android.tracking.app.services.TrackingService.GPSQuality;
|
||||
import com.sap.sailing.android.tracking.app.services.TrackingService.GPSQualityListener;
|
||||
import com.sap.sailing.android.tracking.app.services.TrackingService.TrackingBinder;
|
||||
import com.sap.sailing.android.tracking.app.services.sending.ConnectivityChangedReceiver;
|
||||
import com.sap.sailing.android.tracking.app.utils.AppPreferences;
|
||||
import com.sap.sailing.android.tracking.app.utils.UniqueDeviceUuid;
|
||||
@@ -275,10 +273,12 @@ public class TransmittingService extends Service {
|
||||
|
||||
// create JSON
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
String host = null;
|
||||
|
||||
for (GpsFix fix : fixes)
|
||||
{
|
||||
ids.add(String.valueOf(fix.id));
|
||||
host = fix.host;
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
@@ -314,13 +314,21 @@ public class TransmittingService extends Service {
|
||||
ExLog.i(this, TAG, "url: " + prefs.getServerURL() + prefs.getServerGpsFixesPostPath());
|
||||
}
|
||||
|
||||
|
||||
sendingAttempted = true;
|
||||
VolleyHelper.getInstance(this).addRequest(
|
||||
new JsonObjectRequest(prefs.getServerURL()
|
||||
+ prefs.getServerGpsFixesPostPath(), requestObject,
|
||||
new FixSubmitListener(ids.toArray(idsArr)),
|
||||
new FixSubmitErrorListener()));
|
||||
|
||||
if (host != null)
|
||||
{
|
||||
VolleyHelper.getInstance(this).addRequest(
|
||||
new JsonObjectRequest(host
|
||||
+ prefs.getServerGpsFixesPostPath(), requestObject,
|
||||
new FixSubmitListener(ids.toArray(idsArr)),
|
||||
new FixSubmitErrorListener()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ExLog.w(this, TAG, "Warning, can't send fixes, host is null!");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (serviceCanShutItselfDown())
|
||||
@@ -415,7 +423,7 @@ public class TransmittingService extends Service {
|
||||
|
||||
ArrayList<GpsFix> list = new ArrayList<GpsFix>();
|
||||
|
||||
Cursor cur = getContentResolver().query(SensorGps.CONTENT_URI, null, selectionClause, null, sortAndLimitClause);
|
||||
Cursor cur = getContentResolver().query(EventGpsFixesJoined.CONTENT_URI, null, selectionClause, null, sortAndLimitClause);
|
||||
while (cur.moveToNext()) {
|
||||
GpsFix gpsFix = new GpsFix();
|
||||
|
||||
@@ -426,6 +434,7 @@ public class TransmittingService extends Service {
|
||||
gpsFix.speed = cur.getDouble(cur.getColumnIndex(SensorGps.GPS_SPEED));
|
||||
gpsFix.course = cur.getDouble(cur.getColumnIndex(SensorGps.GPS_BEARING));
|
||||
gpsFix.synced = cur.getInt(cur.getColumnIndex(SensorGps.GPS_SYNCED));
|
||||
gpsFix.host = cur.getString(cur.getColumnIndex(Event.EVENT_SERVER));
|
||||
|
||||
list.add(gpsFix);
|
||||
|
||||
@@ -473,12 +482,13 @@ public class TransmittingService extends Service {
|
||||
public double speed;
|
||||
public double course;
|
||||
public int synced;
|
||||
public String host;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ID: " + id + ", T: " + timestamp + ", LAT: " + latitude
|
||||
+ ", LON: " + longitude + ", SPD: " + speed + ", CRS: "
|
||||
+ course + ", SYN: " + synced;
|
||||
+ course + ", SYN: " + synced + ", HOST: " + host;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user