Bug 1369817 - Clean up webapp manifest handling r=droeh
☠☠ backed out by 6bd81631bfad ☠ ☠
authorJames Willcox <snorp@snorp.net>
Tue, 08 Aug 2017 11:26:50 -0500
changeset 374790 61b906754ea7ad905d0775e2190fc8ca81b116de
parent 374789 3d02042a6c56d1f21faab255a797f8682352f1a6
child 374791 3b956ceaaf8bd8a1750ae4405fbe1220f25ae70d
push id93765
push userjwillcox@mozilla.com
push dateTue, 15 Aug 2017 14:30:19 +0000
treeherdermozilla-inbound@4fb119706335 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdroeh
bugs1369817
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369817 - Clean up webapp manifest handling r=droeh MozReview-Commit-ID: 4ImLBrlGzBc
mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
@@ -120,50 +120,51 @@ public class WebAppActivity extends AppC
     @Override
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
 
         outState.putParcelable(SAVED_INTENT, getIntent());
     }
 
     private void loadManifest(String manifestPath) {
-        if (AppConstants.Versions.feature21Plus) {
-            loadManifestV21(manifestPath);
-        }
-    }
-
-    // The customisations defined in the manifest only work on Android API 21+
-    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
-    private void loadManifestV21(String manifestPath) {
         if (TextUtils.isEmpty(manifestPath)) {
             Log.e(LOGTAG, "Missing manifest");
             return;
         }
 
         try {
             final File manifestFile = new File(manifestPath);
             final JSONObject manifest = FileUtils.readJSONObjectFromFile(manifestFile);
             final JSONObject manifestField = manifest.getJSONObject("manifest");
-            final Integer color = readColorFromManifest(manifestField);
-            final String name = readNameFromManifest(manifestField);
-            final Bitmap icon = readIconFromManifest(manifest);
-            mScope = readScopeFromManifest(manifest, manifestPath);
-            final ActivityManager.TaskDescription taskDescription = (color == null)
-                    ? new ActivityManager.TaskDescription(name, icon)
-                    : new ActivityManager.TaskDescription(name, icon, color);
 
-            updateStatusBarColorV21(color);
-            setTaskDescription(taskDescription);
+            if (AppConstants.Versions.feature21Plus) {
+                loadManifestV21(manifest, manifestField);
+            }
 
             updateScreenOrientation(manifestField);
         } catch (IOException | JSONException e) {
             Log.e(LOGTAG, "Failed to read manifest", e);
         }
     }
 
+    // The customisations defined in the manifest only work on Android API 21+
+    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+    private void loadManifestV21(JSONObject manifest, JSONObject manifestField) {
+        final Integer color = readColorFromManifest(manifestField);
+        final String name = readNameFromManifest(manifestField);
+        final Bitmap icon = readIconFromManifest(manifest);
+        mScope = readScopeFromManifest(manifest);
+        final ActivityManager.TaskDescription taskDescription = (color == null)
+            ? new ActivityManager.TaskDescription(name, icon)
+            : new ActivityManager.TaskDescription(name, icon, color);
+
+        updateStatusBarColorV21(color);
+        setTaskDescription(taskDescription);
+    }
+
     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
     private void updateStatusBarColorV21(final Integer themeColor) {
         if (themeColor != null) {
             final Window window = getWindow();
             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
             window.setStatusBarColor(ColorUtil.darken(themeColor, 0.25));
         }
     }
@@ -208,17 +209,17 @@ public class WebAppActivity extends AppC
         final LoadFaviconResult loadIconResult = FaviconDecoder
             .decodeDataURI(this, iconStr);
         if (loadIconResult == null) {
             return null;
         }
         return loadIconResult.getBestBitmap(GeckoAppShell.getPreferredIconSize());
     }
 
-    private Uri readScopeFromManifest(JSONObject manifest, String manifestPath) {
+    private Uri readScopeFromManifest(JSONObject manifest) {
         final String scopeStr = manifest.optString("scope", null);
         if (scopeStr == null) {
             return null;
         }
 
         Uri res = Uri.parse(scopeStr);
         if (res.isRelative()) {
             // TODO: Handle this more correctly.