diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java
index 4822a0c31..f564872d5 100644
--- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java
+++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java
@@ -74,6 +74,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
private final static long CRASH_RESTART_DELTA = 2000;
public final static boolean AUTOPLAY_ENABLED = false;
public final static boolean DEBUG_LOGGING_DEFAULT = false;
+ public final static boolean TELEMETRY_STATUS_UPDATE_SENT_DEFAULT = false;
// Enable telemetry by default (opt-out).
public final static boolean CRASH_REPORTING_DEFAULT = false;
@@ -130,6 +131,23 @@ public void setTelemetryEnabled(boolean isEnabled) {
if (isEnabled) {
TelemetryWrapper.telemetryStatus(true);
}
+
+ // Update the status sent flag
+ setTelemetryPingUpdateSent(true);
+ }
+
+ public boolean telemetryStatusSaved() {
+ return mPrefs.contains(mContext.getString(R.string.settings_key_telemetry));
+ }
+
+ public boolean isTelemetryPingUpdateSent() {
+ return mPrefs.getBoolean(mContext.getString(R.string.settings_key_telemetry_status_update_sent), TELEMETRY_STATUS_UPDATE_SENT_DEFAULT);
+ }
+
+ public void setTelemetryPingUpdateSent(boolean isSent) {
+ SharedPreferences.Editor editor = mPrefs.edit();
+ editor.putBoolean(mContext.getString(R.string.settings_key_telemetry_status_update_sent), isSent);
+ editor.commit();
}
public void setGeolocationData(String aGeolocationData) {
diff --git a/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java b/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java
index 83ea9d291..6353de3be 100644
--- a/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java
+++ b/app/src/common/shared/org/mozilla/vrbrowser/telemetry/TelemetryWrapper.java
@@ -6,7 +6,9 @@
import android.os.SystemClock;
import android.util.Log;
-import mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient;
+import androidx.annotation.NonNull;
+import androidx.annotation.UiThread;
+
import org.mozilla.telemetry.Telemetry;
import org.mozilla.telemetry.TelemetryHolder;
import org.mozilla.telemetry.config.TelemetryConfiguration;
@@ -15,7 +17,6 @@
import org.mozilla.telemetry.net.TelemetryClient;
import org.mozilla.telemetry.ping.TelemetryCorePingBuilder;
import org.mozilla.telemetry.ping.TelemetryMobileEventPingBuilder;
-import org.mozilla.telemetry.ping.TelemetryPingBuilder;
import org.mozilla.telemetry.schedule.TelemetryScheduler;
import org.mozilla.telemetry.schedule.jobscheduler.JobSchedulerTelemetryScheduler;
import org.mozilla.telemetry.serialize.JSONPingSerializer;
@@ -33,11 +34,11 @@
import java.util.HashSet;
import java.util.Map;
-import androidx.annotation.NonNull;
-import androidx.annotation.UiThread;
+import mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient;
import static java.lang.Math.toIntExact;
-import static org.mozilla.vrbrowser.ui.widgets.Windows.*;
+import static org.mozilla.vrbrowser.ui.widgets.Windows.MAX_WINDOWS;
+import static org.mozilla.vrbrowser.ui.widgets.Windows.WindowPlacement;
public class TelemetryWrapper {
@@ -171,6 +172,19 @@ public static void init(Context aContext) {
TelemetryHolder.set(new Telemetry(configuration, storage, client, scheduler)
.addPingBuilder(new TelemetryCorePingBuilder(configuration))
.addPingBuilder(new TelemetryMobileEventPingBuilder(configuration)));
+
+ // Check if the Telemetry status has ever been saved (enabled/disabled)
+ boolean saved = SettingsStore.getInstance(aContext).telemetryStatusSaved();
+ // Check if we have already sent the previous status event
+ boolean sent = SettingsStore.getInstance(aContext).isTelemetryPingUpdateSent();
+ // If the Telemetry status has been changed but that ping has not been sent, we send it now
+ // This should only been true for versions of the app prior to implementing the Telemetry status ping
+ // We only send the status ping if it was disabled
+ if (saved && !sent && !telemetryEnabled) {
+ telemetryStatus(false);
+ SettingsStore.getInstance(aContext).setTelemetryPingUpdateSent(true);
+ }
+
} finally {
StrictMode.setThreadPolicy(threadPolicy);
}
diff --git a/app/src/main/res/values/non_L10n.xml b/app/src/main/res/values/non_L10n.xml
index eb83ae787..4059119c2 100644
--- a/app/src/main/res/values/non_L10n.xml
+++ b/app/src/main/res/values/non_L10n.xml
@@ -43,6 +43,7 @@
settings_key_debug_logging
settings_key_autoplay
settings_key_pid
+ settings_key_telemetry_status_update_sent
https://github.com/MozillaReality/FirefoxReality/wiki/Environments
https://www.mozilla.org/privacy/firefox/
https://mixedreality.mozilla.org/fxr/report?src=browser-fxr&label=browser-firefox-reality&url=%1$s