Bug 1233614 - Remove health report flags in favor of Adjust.setEnabled. r=mfinkle
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -694,20 +694,19 @@ 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) {
- final SharedPreferences prefs = GeckoSharedPrefs.forApp(this);
- if (prefs.getBoolean(GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true)) {
- AdjustConstants.getAdjustHelper().onCreate(this, AdjustConstants.MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN);
- }
+ // 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);
}
if (AppConstants.MOZ_ANDROID_BEAM) {
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
if (nfc != null) {
nfc.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
@@ -27,12 +27,16 @@ public class AdjustHelper implements Adj
appToken = "ABCDEFGHIJKL";
logLevel = LogLevel.VERBOSE;
}
AdjustConfig config = new AdjustConfig(context, appToken, environment);
config.setLogLevel(logLevel);
Adjust.onCreate(config);
}
+ public void setEnabled(final boolean isEnabled) {
+ Adjust.setEnabled(isEnabled);
+ }
+
public void onReceive(final Context context, final Intent intent) {
new AdjustReferrerReceiver().onReceive(context, intent);
}
}
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java
@@ -9,10 +9,11 @@ import android.content.Context;
import android.content.Intent;
public interface AdjustHelperInterface {
/**
* Register the Application with the Adjust SDK.
* @param appToken the (secret!) Adjust SDK per-application token to register with; may be null.
*/
void onCreate(final Context context, final String appToken);
+ void setEnabled(final boolean isEnabled);
void onReceive(final Context context, final Intent intent);
}
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java
@@ -8,12 +8,16 @@ package org.mozilla.gecko.adjust;
import android.content.Context;
import android.content.Intent;
public class StubAdjustHelper implements AdjustHelperInterface {
public void onCreate(final Context context, final String appToken) {
// Do nothing.
}
+ public void setEnabled(final boolean isEnabled) {
+ // Do nothing.
+ }
+
public void onReceive(final Context context, final Intent intent) {
// Do nothing.
}
}
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -2,16 +2,17 @@
* 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.preferences;
import android.annotation.TargetApi;
import org.mozilla.gecko.AboutPages;
+import org.mozilla.gecko.AdjustConstants;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.BrowserLocaleManager;
import org.mozilla.gecko.DataReportingNotification;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoActivityStatus;
import org.mozilla.gecko.GeckoAppShell;
@@ -1178,17 +1179,19 @@ OnSharedPreferenceChangeListener
UpdateServiceHelper.setAutoDownloadPolicy(this, UpdateService.AutoDownloadPolicy.get((String) newValue));
} else if (PREFS_UPDATER_URL.equals(prefName)) {
UpdateServiceHelper.setUpdateUrl(this, (String) newValue);
} else if (PREFS_HEALTHREPORT_UPLOAD_ENABLED.equals(prefName)) {
// The healthreport pref only lives in Android, so we do not persist
// to Gecko, but we do broadcast intent to the health report
// background uploader service, which will start or stop the
// repeated background upload attempts.
- broadcastHealthReportUploadPref(this, (Boolean) newValue);
+ final Boolean newBooleanValue = (Boolean) newValue;
+ broadcastHealthReportUploadPref(this, newBooleanValue);
+ AdjustConstants.getAdjustHelper().setEnabled(newBooleanValue);
} else if (PREFS_GEO_REPORTING.equals(prefName)) {
broadcastStumblerPref(this, (Boolean) newValue);
// Translate boolean value to int for geo reporting pref.
newValue = (Boolean) newValue ? 1 : 0;
} else if (handlers.containsKey(prefName)) {
PrefHandler handler = handlers.get(prefName);
handler.onChange(this, preference, newValue);
}