[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-68.9.0esr-10.0-1] Revert "Bug 1633568 - AdjustHelper can inform more listeners about Attribution changes. r=Grisha, a=RyanVM"



commit b53e2d8fb7fa0c5dc6c7f98bb57a71b24c033c00
Author: Matthew Finkel <sysrqb@xxxxxxxxxxxxxx>
Date:   Fri May 29 17:28:34 2020 +0000

    Revert "Bug 1633568 - AdjustHelper can inform more listeners about Attribution changes. r=Grisha, a=RyanVM"
    
    This reverts commit 4d64699b7d664a70793431effc2f4e054ebf9230.
---
 .../org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java |  8 ++++----
 .../base/java/org/mozilla/gecko/adjust/AdjustHelper.java   | 14 ++++++--------
 .../org/mozilla/gecko/adjust/AdjustHelperInterface.java    |  2 +-
 .../mozilla/gecko/adjust/AttributionHelperListener.java    | 11 ++---------
 .../java/org/mozilla/gecko/adjust/StubAdjustHelper.java    |  2 +-
 .../mozilla/gecko/telemetry/TelemetryCorePingDelegate.java |  7 ++-----
 6 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java
index f160e971def3..aee0bba63a8a 100644
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java
@@ -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()));
diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
index 410a172e7750..19399e735bb5 100644
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
@@ -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);
     }
 }
diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java
index 0e4b9ff6455c..aeb7b4334e9f 100644
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java
@@ -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();
 
diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java
index ada55838707a..6dadd2261d7a 100644
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java
@@ -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);
 }
diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java b/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java
index 386bd97c05e2..ddfed84bd73b 100644
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java
@@ -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.
     }
 
diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
index 5b54657d319c..fa00a37a7c16 100644
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
@@ -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);
     }
 }

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits