Skip to content

Commit

Permalink
Force send the telemetry status every time the app starts
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Nov 5, 2019
1 parent 956d3d3 commit a491bdb
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 31 deletions.
Expand Up @@ -12,6 +12,7 @@
import org.mozilla.vrbrowser.browser.Accounts;
import org.mozilla.vrbrowser.browser.Places;
import org.mozilla.vrbrowser.browser.Services;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.db.AppDatabase;
import org.mozilla.vrbrowser.db.DataRepository;
import org.mozilla.vrbrowser.telemetry.GleanMetricsService;
Expand Down Expand Up @@ -39,6 +40,8 @@ public void onCreate() {

TelemetryWrapper.init(this);
GleanMetricsService.init(this);

TelemetryWrapper.telemetryStatus(SettingsStore.getInstance(this).isTelemetryEnabled());
}

@Override
Expand Down
Expand Up @@ -75,7 +75,6 @@ SettingsStore getInstance(final @NonNull Context aContext) {
public final static boolean AUTOPLAY_ENABLED = false;
public final static boolean DEBUG_LOGGING_DEFAULT = false;
public final static boolean POP_UPS_BLOCKING_DEFAULT = true;
public final static boolean TELEMETRY_STATUS_UPDATE_SENT_DEFAULT = false;
public final static boolean BOOKMARKS_SYNC_DEFAULT = true;
public final static boolean HISTORY_SYNC_DEFAULT = true;
public final static boolean WHATS_NEW_DISPLAYED = false;
Expand Down Expand Up @@ -138,23 +137,6 @@ public void setTelemetryEnabled(boolean isEnabled) {
} else {
GleanMetricsService.stop();
}

// 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) {
Expand Down
Expand Up @@ -173,18 +173,6 @@ public static void init(Context aContext) {
.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);
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/non_L10n.xml
Expand Up @@ -45,7 +45,6 @@
<string name="settings_key_autoplay" translatable="false">settings_key_autoplay</string>
<string name="settings_key_pid" translatable="false">settings_key_pid</string>
<string name="settings_key_pop_up_blocking" translatable="false">settings_key_pop_up_blocking</string>
<string name="settings_key_telemetry_status_update_sent" translatable="false">settings_key_telemetry_status_update_sent</string>
<string name="settings_key_bookmarks_sync" translatable="false">settings_key_bookmarks_sync</string>
<string name="settings_key_history_sync" translatable="false">settings_key_history_sync</string>
<string name="settings_key_whats_new_displayed" translatable="false">settings_key_whats_new_displayed</string>
Expand Down

0 comments on commit a491bdb

Please sign in to comment.