diff --git a/mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java b/mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java index 83cfe915340..c47d2dde2a4 100644 --- a/mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java +++ b/mobile/android/base/java/org/mozilla/gecko/distribution/Distribution.java @@ -643,7 +643,7 @@ public class Distribution { private boolean copyAndCheckAPKDistribution() { try { // First, try copying distribution files out of the APK. - if (copyFiles()) { + if (copyFilesFromPackagedAssets()) { // We always copy to the data dir, and we only copy files from // a 'distribution' subdirectory. Now determine our actual distribution directory. return checkDataDistribution(); @@ -718,13 +718,16 @@ public class Distribution { } /** - * Copies the /distribution folder out of the APK and into the app's data directory. + * Copies the /assets/distribution folder out of the APK and into the app's data directory. * Returns true if distribution files were found and copied. */ - private boolean copyFiles() throws IOException { + private boolean copyFilesFromPackagedAssets() throws IOException { final File applicationPackage = new File(packagePath); final ZipFile zip = new ZipFile(applicationPackage); + final String assetsPrefix = "assets/"; + final String fullPrefix = assetsPrefix + DISTRIBUTION_PATH; + boolean distributionSet = false; try { final byte[] buffer = new byte[1024]; @@ -739,11 +742,14 @@ public class Distribution { continue; } - if (!name.startsWith(DISTRIBUTION_PATH)) { + // Read from "assets/distribution/**". + if (!name.startsWith(fullPrefix)) { continue; } - final File outFile = getDataFile(name); + // Write to "distribution/**". + final String nameWithoutPrefix = name.substring(assetsPrefix.length()); + final File outFile = getDataFile(nameWithoutPrefix); if (outFile == null) { continue; } diff --git a/mobile/android/tests/browser/robocop/assets/mock-package.zip b/mobile/android/tests/browser/robocop/assets/mock-package.zip index 4f4448e6e05..c599046cb5a 100644 Binary files a/mobile/android/tests/browser/robocop/assets/mock-package.zip and b/mobile/android/tests/browser/robocop/assets/mock-package.zip differ