Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java

Issue 29491669: Issue 5426 - ABP isn't packaged in the apk (Closed)
Patch Set: Created July 18, 2017, 10:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mobile/android/installer/package-manifest.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java
===================================================================
--- a/mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java
+++ b/mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java
@@ -444,17 +444,17 @@ public class Distribution {
// Firefox for Android normally ignores application scope extensions,
// and thus doesn't put the extensions directory in place. In Adblock
// Browser however, we need this mechanism.
//
// This logic doesn't really belong here. However, here the change is
// minimally invasive, and we're more likely to notice when the logic
// changes for the distributions directory.
try {
- copyExtensionsFiles();
+ copyExtensionsFromPackagedAssets();
} catch (IOException e) {
Log.e(LOGTAG, "Error copying extensions files from APK.", e);
}
// Bail if we've already tried to initialize the distribution, and
// there wasn't one.
final SharedPreferences settings = getSharedPreferences();
@@ -766,41 +766,47 @@ public class Distribution {
} finally {
zip.close();
}
return distributionSet;
}
/**
- * Copies the /extensions folder out of the APK and into the app's data directory.
- * Adapted from copyFiles().
+ * Copies the /assets/extensions folder out of the APK and into the app's data directory.
+ * Adapted from copyFilesFromPackagedAssets().
*/
- private void copyExtensionsFiles() throws IOException {
+ private void copyExtensionsFromPackagedAssets() throws IOException {
final File applicationPackage = new File(packagePath);
final ZipFile zip = new ZipFile(applicationPackage);
+ final String assetsPrefix = "assets/";
+ final String fullPrefix = assetsPrefix + "extensions/";
+
try {
final byte[] buffer = new byte[1024];
final Enumeration<? extends ZipEntry> zipEntries = zip.entries();
while (zipEntries.hasMoreElements()) {
final ZipEntry fileEntry = zipEntries.nextElement();
final String name = fileEntry.getName();
if (fileEntry.isDirectory()) {
// We'll let getDataFile deal with creating the directory hierarchy.
continue;
}
- if (!name.startsWith("extensions/")) {
+ // Read from "assets/extensions/**".
+ if (!name.startsWith(fullPrefix)) {
continue;
}
- final File outFile = getDataFile(name);
+ // Write to "extensions/**".
+ final String nameWithoutPrefix = name.substring(assetsPrefix.length());
+ final File outFile = getDataFile(nameWithoutPrefix);
if (outFile == null) {
continue;
}
final InputStream fileStream = zip.getInputStream(fileEntry);
try {
writeStream(fileStream, outFile, fileEntry.getTime(), buffer);
} finally {
« no previous file with comments | « no previous file | mobile/android/installer/package-manifest.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld