From a72727d93a712db8bad0555921753cff1343c336 Mon Sep 17 00:00:00 2001 From: crimean Date: Fri, 31 May 2019 17:45:42 +0300 Subject: [PATCH] Added download elapsed time log --- OsmAnd/src/net/osmand/plus/AnalyticsHelper.java | 2 ++ OsmAnd/src/net/osmand/plus/OsmandApplication.java | 10 ++++++++++ .../osmand/plus/download/DownloadIndexesThread.java | 10 ++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java b/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java index f3391b3d6b..6636f4c162 100644 --- a/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java +++ b/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java @@ -34,6 +34,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper { private final static int DATA_PARCEL_SIZE = 500; // 500 events private final static int SUBMIT_DATA_INTERVAL = 60 * 60 * 1000; // 1 hour + private final static String PARAM_OS = "os"; private final static String PARAM_START_DATE = "startDate"; private final static String PARAM_FINISH_DATE = "finishDate"; private final static String PARAM_FIRST_INSTALL_DAYS = "nd"; @@ -153,6 +154,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper { } Map additionalData = new LinkedHashMap(); + additionalData.put(PARAM_OS, "android"); additionalData.put(PARAM_START_DATE, String.valueOf(d.startDate)); additionalData.put(PARAM_FINISH_DATE, String.valueOf(d.finishDate)); additionalData.put(PARAM_VERSION, Version.getFullVersion(ctx)); diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 94ae571d6e..e2205d3f2e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -939,6 +939,16 @@ public class OsmandApplication extends MultiDexApplication { } } + public void logMapDownloadEvent(String event, IndexItem item, long time) { + try { + if (osmandSettings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()) { + analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName() + " in " + time + " msec"); + } + } catch (Exception e) { + LOG.error(e); + } + } + public void restartApp(Context ctx) { AlertDialog.Builder bld = new AlertDialog.Builder(ctx); bld.setMessage(R.string.restart_is_required); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 84adec8da3..015031c9b8 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -534,7 +534,6 @@ public class DownloadIndexesThread { boolean result = downloadFile(item, filesToReindex, forceWifi); success = result || success; if (result) { - checkDownload(item); if (DownloadActivityType.isCountedInDownloads(item)) { downloads.set(downloads.get() + 1); } @@ -664,8 +663,16 @@ public class DownloadIndexesThread { LOG.error("Copy exception", e); } } else { + long start = System.currentTimeMillis(); app.logMapDownloadEvent("start", item); res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi); + long time = System.currentTimeMillis() - start; + if (res) { + app.logMapDownloadEvent("done", item, time); + checkDownload(item); + } else { + app.logMapDownloadEvent("failed", item, time); + } } return res; } @@ -678,7 +685,6 @@ public class DownloadIndexesThread { } private void checkDownload(IndexItem item) { - app.logMapDownloadEvent("done", item); Map params = new HashMap<>(); params.put("file_name", item.fileName); params.put("file_size", item.size);