Bug 1224528 - WIP Android support draft
authorMathieu Leplatre <mathieu@mozilla.com>
Fri, 13 May 2016 13:09:14 +0200
changeset 366776 40277ff44d1395468a9f1d928e7cb6f02ba8176a
parent 366775 ccea85a1d8c82a8b5b1976f77a2050ff701941c4
child 520854 a146fd28c57e69be7022c5e7d91022eee8e5f3a0
push id18070
push usermleplatre@mozilla.com
push dateFri, 13 May 2016 11:09:35 +0000
bugs1224528
milestone49.0a1
Bug 1224528 - WIP Android support MozReview-Commit-ID: GjkOToPtfr5
services/common/KintoBlocklist.js
--- a/services/common/KintoBlocklist.js
+++ b/services/common/KintoBlocklist.js
@@ -11,16 +11,17 @@ this.EXPORTED_SYMBOLS = ["AddonBlocklist
                          "FILENAME_ADDONS_JSON",
                          "FILENAME_GFX_JSON",
                          "FILENAME_PLUGINS_JSON"];
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
 Cu.importGlobalProperties(['fetch']);
 const { Task } = Cu.import("resource://gre/modules/Task.jsm");
 const { OS } = Cu.import("resource://gre/modules/osfile.jsm");
 
 const { loadKinto } = Cu.import("resource://services-common/kinto-offline-client.js");
 
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
   "resource://gre/modules/FileUtils.jsm");
@@ -83,17 +84,21 @@ class BlocklistClient {
   loadDumpFile() {
     const filePath = ["defaults", "collections", "blocklists", `${this.collectionName}.json`];
     const collectionFile = FileUtils.getFile(KEY_APPDIR, filePath);
 
     let fileURI;
     if (collectionFile.exists()) {
       fileURI = Services.io.newFileURI(collectionFile).spec;
     } else {
-      throw new Error(`Distribution file '${collectionFile.path}' missing`);
+      if (AppConstants.platform == "android") {
+        fileURI = "android://resource/assets/" + filePath.join("/");
+      } else {
+        throw new Error(`Distribution file '${collectionFile.path}' missing`);
+      }
     }
 
     return Task.spawn((function* loadFile() {
       const response = yield fetch(fileURI);
       if (!response.ok) {
         throw new Error(`Could not read from '${fileURI}'`);
       }
       // Will be rejected if JSON is invalid.