bug 705993 - read recommended-addons.json from the profile dir r=mfinkle
authorBrad Lassey <blassey@mozilla.com>
Wed, 30 Nov 2011 21:28:05 -0500
changeset 83651 21ee0cd78262b7dd53dafd127f43dbcb962dc349
parent 83650 66f5729d323c70b8155231794ec133e9625d0db7
child 83652 24f415e415f2a25158a315a8962e0e5ec36ea93a
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs705993
milestone11.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 705993 - read recommended-addons.json from the profile dir r=mfinkle
mobile/android/base/AboutHomeContent.java
--- a/mobile/android/base/AboutHomeContent.java
+++ b/mobile/android/base/AboutHomeContent.java
@@ -147,27 +147,47 @@ public class AboutHomeContent extends Li
                         mAddonList.setAdapter(mAddonAdapter);
                     }
                 });
                 readRecommendedAddons(activity);
             }
         });
     }
 
+    InputStream getProfileRecommendedAddonsStream() {
+        try {
+            File profileDir = GeckoApp.mAppContext.getProfileDir();
+            if (profileDir == null)
+                return null;
+            File recommendedAddonsFile = new File(profileDir, "recommended-addons.json");
+            if (!recommendedAddonsFile.exists())
+                return null;
+            return new FileInputStream(recommendedAddonsFile);
+        } catch (FileNotFoundException fnfe) {
+            // ignore
+        }
+        return null;
+    }
+
+    InputStream getRecommendedAddonsStream(Activity activity) throws Exception{
+        InputStream is = getProfileRecommendedAddonsStream();
+        if (is != null)
+            return is;
+        File applicationPackage = new File(activity.getApplication().getPackageResourcePath());
+        ZipFile zip = new ZipFile(applicationPackage);
+        ZipEntry fileEntry = zip.getEntry("recommended-addons.json");
+        return zip.getInputStream(fileEntry);
+    }
+
     void readRecommendedAddons(final Activity activity) {
         GeckoAppShell.getHandler().post(new Runnable() {
             public void run() {
                 try {
-                    File applicationPackage = new File(activity.getApplication().getPackageResourcePath());
                     byte[] buf = new byte[32768];
-                    ZipFile zip = new ZipFile(applicationPackage);
-                    ZipEntry fileEntry = zip.getEntry("recommended-addons.json");
-
-                    InputStream fileStream;
-                    fileStream = zip.getInputStream(fileEntry);
+                    InputStream fileStream = getRecommendedAddonsStream(activity);
                     StringBuffer jsonString = new StringBuffer();
                     int read = 0;
                     while ((read = fileStream.read(buf, 0, 32768)) != -1) {
                         jsonString.append(new String(buf, 0, read));
                     }
                     final JSONArray array = new JSONObject(jsonString.toString()).getJSONArray("addons");
                     GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
                         public void run() {