Bug 1334562 - DLC: Start study action from BrowserApp.onCreate() and never in automation. r=ahunt
authorSebastian Kaspari <s.kaspari@gmail.com>
Mon, 30 Jan 2017 17:41:38 +0100
changeset 468475 01aad8181f5d02e797b24d0b46ceeb727e762f12
parent 468474 a16de69b0207951be269b3070b67860a57bf5c62
child 468476 b1b0f99b73fc2537b2557ed32b5e707bfc7af234
push id43477
push userbmo:jhofmann@mozilla.com
push dateTue, 31 Jan 2017 15:48:49 +0000
reviewersahunt
bugs1334562
milestone54.0a1
Bug 1334562 - DLC: Start study action from BrowserApp.onCreate() and never in automation. r=ahunt Previously we started the DLC service from GeckoApplication. The reason for that was that we wanted to download content like fonts as early as possible so that they are available the next time we display a website. However we do not know whether we are running in automation until the BrowserApp activity is launched. This patch will start the service from BrowserApp.onCreate() now if we are not running in automation. MozReview-Commit-ID: C3Ob6S3yve4
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -593,16 +593,22 @@ public class BrowserApp extends GeckoApp
             // This build does not support the Android version of the device; Exit early.
             super.onCreate(savedInstanceState);
             return;
         }
 
         final SafeIntent intent = new SafeIntent(getIntent());
         final boolean isInAutomation = IntentUtils.getIsInAutomationFromEnvironment(intent);
 
+        if (!isInAutomation && AppConstants.MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE) {
+            // Kick off download of app content as early as possible so that in the best case it's
+            // available before the user starts using the browser.
+            DownloadContentService.startStudy(this);
+        }
+
         // This has to be prepared prior to calling GeckoApp.onCreate, because
         // widget code and BrowserToolbar need it, and they're created by the
         // layout, which GeckoApp takes care of.
         ((GeckoApplication) getApplication()).prepareLightweightTheme();
 
         super.onCreate(savedInstanceState);
 
         final Context appContext = getApplicationContext();
@@ -1765,18 +1771,19 @@ public class BrowserApp extends GeckoApp
                     // Start (this acts as ping if started already) the stumbler lib; if
                     // the stumbler has queued data it will upload it.  Stumbler operates
                     // on its own thread, and startup impact is further minimized by
                     // delaying work (such as upload) a few seconds.  Avoid any potential
                     // startup CPU/thread contention by delaying the pref broadcast.
                     GeckoPreferences.broadcastStumblerPref(BrowserApp.this);
                 }
 
-                if (AppConstants.MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE) {
-                    // TODO: Better scheduling of sync action (Bug 1257492)
+                if (AppConstants.MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE &&
+                        !IntentUtils.getIsInAutomationFromEnvironment(new SafeIntent(getIntent()))) {
+                    // TODO: Better scheduling of DLC actions (Bug 1257492)
                     DownloadContentService.startSync(this);
                     DownloadContentService.startVerification(this);
                 }
 
                 FeedService.setup(this);
                 break;
 
             case "Menu:Open":
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
@@ -186,20 +186,16 @@ public class GeckoApplication extends Ap
                     } catch (Exception e) {
                         Log.e(LOG_TAG, "Got exception during startup; ignoring.", e);
                         return;
                     }
                 }
             });
         }
 
-        if (AppConstants.MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE) {
-            DownloadContentService.startStudy(this);
-        }
-
         GeckoAccessibility.setAccessibilityManagerListeners(this);
 
         AudioFocusAgent.getInstance().attachToContext(this);
     }
 
     private class EventListener implements BundleEventListener
     {
         private void onProfileCreate(final String name, final String path) {