Bug 1233614 - Adjust.setEnabled before upload can occur. r=mfinkle draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 22 Dec 2015 09:45:49 -0800
changeset 317140 4bdaf53ef2ba87709fdd236c3217d72186c3ad69
parent 317139 f38e885e907a8250766683d44c4a5faa3b901dd9
child 317141 d1b1aa228878d18ef01091b0c5b693972237e3c8
push id8647
push usermichael.l.comella@gmail.com
push dateTue, 22 Dec 2015 19:32:37 +0000
reviewersmfinkle
bugs1233614
milestone46.0a1
Bug 1233614 - Adjust.setEnabled before upload can occur. r=mfinkle See the added comment for motivations.
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
+import org.mozilla.gecko.adjust.AdjustHelperInterface;
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.AppConstants.Versions;
 import org.mozilla.gecko.DynamicToolbar.PinReason;
 import org.mozilla.gecko.DynamicToolbar.VisibilityTransition;
 import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
 import org.mozilla.gecko.Tabs.TabEvents;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.TransitionsTracker;
@@ -694,19 +695,24 @@ public class BrowserApp extends GeckoApp
         JavaAddonManager.getInstance().init(appContext);
         mSharedPreferencesHelper = new SharedPreferencesHelper(appContext);
         mOrderedBroadcastHelper = new OrderedBroadcastHelper(appContext);
         mBrowserHealthReporter = new BrowserHealthReporter();
         mReadingListHelper = new ReadingListHelper(appContext, getProfile(), this);
         mAccountsHelper = new AccountsHelper(appContext, getProfile());
 
         if (AppConstants.MOZ_INSTALL_TRACKING) {
-            // TODO: If this is the first run with the new Adjust config, we need to get the health report upload value
-            // and setEnabled with it.
-            AdjustConstants.getAdjustHelper().onCreate(this, AdjustConstants.MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN);
+            final AdjustHelperInterface adjustHelper = AdjustConstants.getAdjustHelper();
+            adjustHelper.onCreate(this, AdjustConstants.MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN);
+
+            // Adjust stores enabled state so this is only necessary because users may have set
+            // their data preferences before this feature was implemented and we need to respect
+            // those before upload can occur in Adjust.onResume.
+            final SharedPreferences prefs = GeckoSharedPrefs.forApp(this);
+            adjustHelper.setEnabled(prefs.getBoolean(GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true));
         }
 
         if (AppConstants.MOZ_ANDROID_BEAM) {
             NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
             if (nfc != null) {
                 nfc.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
                     @Override
                     public NdefMessage createNdefMessage(NfcEvent event) {