Skip to content
Snippets Groups Projects
Commit 6421b707 authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Revert "Bug 1633568 - AdjustHelper can inform more listeners about Attribution...

Revert "Bug 1633568 - AdjustHelper can inform more listeners about Attribution changes. r=Grisha, a=RyanVM"

This reverts commit 4d64699b.
parent 7f05e7ab
No related merge requests found
......@@ -13,18 +13,18 @@ import org.mozilla.gecko.util.IntentUtils;
public class AdjustBrowserAppDelegate extends BrowserAppDelegate {
private final AdjustHelperInterface adjustHelper;
private final AttributionHelperListener[] attributionHelperListeners;
private final AttributionHelperListener attributionHelperListener;
public AdjustBrowserAppDelegate(AttributionHelperListener... attributionHelperListeners) {
public AdjustBrowserAppDelegate(AttributionHelperListener attributionHelperListener) {
this.adjustHelper = AdjustConstants.getAdjustHelper();
this.attributionHelperListeners = attributionHelperListeners;
this.attributionHelperListener = attributionHelperListener;
}
@Override
public void onCreate(BrowserApp browserApp, Bundle savedInstanceState) {
adjustHelper.onCreate(browserApp,
AdjustConstants.MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN,
attributionHelperListeners);
attributionHelperListener);
final boolean isInAutomation = IntentUtils.getIsInAutomationFromEnvironment(
new SafeIntent(browserApp.getIntent()));
......
......@@ -21,9 +21,9 @@ import org.mozilla.gecko.AppConstants;
public class AdjustHelper implements AdjustHelperInterface, OnAttributionChangedListener {
private static final String LOGTAG = AdjustHelper.class.getSimpleName();
private AttributionHelperListener[] attributionListeners;
private AttributionHelperListener attributionListener;
public void onCreate(final Context context, final String maybeAppToken, final AttributionHelperListener... listeners) {
public void onCreate(final Context context, final String maybeAppToken, final AttributionHelperListener listener) {
final String environment;
final LogLevel logLevel;
if (AppConstants.MOZILLA_OFFICIAL) {
......@@ -37,7 +37,7 @@ public class AdjustHelper implements AdjustHelperInterface, OnAttributionChanged
// We've got install tracking turned on -- we better have a token!
throw new IllegalArgumentException("maybeAppToken must not be null");
}
attributionListeners = listeners;
attributionListener = listener;
AdjustConfig config = new AdjustConfig(context, maybeAppToken, environment);
config.setLogLevel(logLevel);
config.setOnAttributionChangedListener(this);
......@@ -62,16 +62,14 @@ public class AdjustHelper implements AdjustHelperInterface, OnAttributionChanged
@Override
public void onAttributionChanged(AdjustAttribution attribution) {
if (attributionListeners == null) {
if (attributionListener == null) {
throw new IllegalStateException("Expected non-null attribution listener.");
}
if (attribution == null) {
Log.e(LOGTAG, "Adjust attribution is null. Skipping informing listeners about this.");
Log.e(LOGTAG, "Adjust attribution is null; skipping campaign id retrieval.");
return;
}
for (AttributionHelperListener listener: attributionListeners) {
listener.onAttributionChanged(attribution);
}
attributionListener.onCampaignIdChanged(attribution.campaign);
}
}
......@@ -13,7 +13,7 @@ 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, final AttributionHelperListener... listener);
void onCreate(final Context context, final String appToken, final AttributionHelperListener listener);
void onPause();
void onResume();
......
......@@ -5,20 +5,13 @@
package org.mozilla.gecko.adjust;
import android.support.annotation.NonNull;
import com.adjust.sdk.AdjustAttribution;
/**
* Because of how our build module dependencies are structured, we aren't able to use
* the {@link com.adjust.sdk.OnAttributionChangedListener} directly outside of {@link AdjustHelper}.
* If the Adjust SDK is enabled, this listener should be notified when {@link com.adjust.sdk.OnAttributionChangedListener}
* is fired (i.e. this listener would be daisy-chained to the Adjust one). The listener also
* inherits thread-safety from GeckoSharedPrefs which is used to store the attribution.
* inherits thread-safety from GeckoSharedPrefs which is used to store the campaign ID.
*/
public interface AttributionHelperListener {
/**
* @param attribution - new Adjust attribution configuration.
*/
void onAttributionChanged(@NonNull final AdjustAttribution attribution);
void onCampaignIdChanged(String campaignId);
}
......@@ -9,7 +9,7 @@ import android.content.Context;
import android.content.Intent;
public class StubAdjustHelper implements AdjustHelperInterface {
public void onCreate(final Context context, final String appToken, final AttributionHelperListener... listeners) {
public void onCreate(final Context context, final String appToken, final AttributionHelperListener listener) {
// Do nothing.
}
......
......@@ -9,14 +9,11 @@ package org.mozilla.gecko.telemetry;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import android.util.Log;
import android.view.accessibility.AccessibilityManager;
import com.adjust.sdk.AdjustAttribution;
import org.json.JSONArray;
import org.json.JSONException;
import org.mozilla.gecko.BrowserApp;
......@@ -276,7 +273,7 @@ public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference
}
@Override
public void onAttributionChanged(@NonNull final AdjustAttribution attribution) {
CampaignIdMeasurements.updateCampaignIdPref(getBrowserApp(), attribution.campaign);
public void onCampaignIdChanged(String campaignId) {
CampaignIdMeasurements.updateCampaignIdPref(getBrowserApp(), campaignId);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment