Bug 1232773 - Call Adjust.onPause/onResume. r=mfinkle a=sylvestre
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 22 Dec 2015 14:29:51 -0800
changeset 310537 3a7dd4e7fa23a2f848bd0b503312409a808cd63d
parent 310536 6004294f68434c7594fec5c5728b762d904274e0
child 310538 5628bb302871093c80ec07151250cdf7873df3d3
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, sylvestre
bugs1232773
milestone45.0a2
Bug 1232773 - Call Adjust.onPause/onResume. r=mfinkle a=sylvestre
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java
mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -901,16 +901,19 @@ public class BrowserApp extends GeckoApp
             });
         }
     }
 
     @Override
     public void onResume() {
         super.onResume();
 
+        // Needed for Adjust to get accurate session measurements
+        AdjustConstants.getAdjustHelper().onResume();
+
         final String args = ContextUtils.getStringExtra(getIntent(), "args");
         // If an external intent tries to start Fennec in guest mode, and it's not already
         // in guest mode, this will change modes before opening the url.
         // NOTE: OnResume is called twice sometimes when showing on the lock screen.
         final boolean enableGuestSession = GuestSession.shouldUse(this, args);
         final boolean inGuestSession = GeckoProfile.get(this).inGuestMode();
         if (enableGuestSession != inGuestSession) {
             doRestart(getIntent());
@@ -923,16 +926,20 @@ public class BrowserApp extends GeckoApp
         processTabQueue();
 
         mScreenshotObserver.start();
     }
 
     @Override
     public void onPause() {
         super.onPause();
+
+        // Needed for Adjust to get accurate session measurements
+        AdjustConstants.getAdjustHelper().onPause();
+
         // Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
         EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this,
             "Prompt:ShowTop");
 
         mScreenshotObserver.stop();
     }
 
     @Override
--- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java
@@ -27,16 +27,24 @@ 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 onPause() {
+        Adjust.onPause();
+    }
+
+    public void onResume() {
+        Adjust.onResume();
+    }
+
     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,11 +9,14 @@ 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 onPause();
+    void onResume();
+
     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,16 +8,24 @@ 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 onPause() {
+        // Do nothing.
+    }
+
+    public void onResume() {
+        // Do nothing.
+    }
+
     public void setEnabled(final boolean isEnabled) {
         // Do nothing.
     }
 
     public void onReceive(final Context context, final Intent intent) {
         // Do nothing.
     }
 }