| Index: base/android/java/src/org/chromium/base/ResourceExtractor.java
|
| diff --git a/base/android/java/src/org/chromium/base/ResourceExtractor.java b/base/android/java/src/org/chromium/base/ResourceExtractor.java
|
| index 5beb07dcb8975cc6743c2a18894a7d3d6b41ba5c..9252b4dd37227fffb6a74fa9b96ee993b80d512e 100644
|
| --- a/base/android/java/src/org/chromium/base/ResourceExtractor.java
|
| +++ b/base/android/java/src/org/chromium/base/ResourceExtractor.java
|
| @@ -23,7 +23,6 @@ import java.io.IOException;
|
| import java.io.InputStream;
|
| import java.io.OutputStream;
|
| import java.util.ArrayList;
|
| -import java.util.HashSet;
|
| import java.util.List;
|
| import java.util.concurrent.CancellationException;
|
| import java.util.concurrent.ExecutionException;
|
| @@ -37,7 +36,7 @@ public class ResourceExtractor {
|
|
|
| private static final String LOGTAG = "ResourceExtractor";
|
| private static final String LAST_LANGUAGE = "Last language";
|
| - private static final String PAK_FILENAMES = "Pak filenames";
|
| + private static final String PAK_FILENAMES_LEGACY_NOREUSE = "Pak filenames";
|
| private static final String ICU_DATA_FILENAME = "icudtl.dat";
|
| private static final String V8_NATIVES_DATA_FILENAME = "natives_blob.bin";
|
| private static final String V8_SNAPSHOT_DATA_FILENAME = "snapshot_blob.bin";
|
| @@ -49,6 +48,12 @@ public class ResourceExtractor {
|
| // change this behavior.
|
| private static boolean sExtractImplicitLocalePak = true;
|
|
|
| + private static boolean isAppDataFile(String file) {
|
| + return ICU_DATA_FILENAME.equals(file)
|
| + || V8_NATIVES_DATA_FILENAME.equals(file)
|
| + || V8_SNAPSHOT_DATA_FILENAME.equals(file);
|
| + }
|
| +
|
| private class ExtractTask extends AsyncTask<Void, Void, Void> {
|
| private static final int BUFFER_SIZE = 16 * 1024;
|
|
|
| @@ -57,6 +62,7 @@ public class ResourceExtractor {
|
|
|
| private void doInBackgroundImpl() {
|
| final File outputDir = getOutputDir();
|
| + final File appDataDir = getAppDataDir();
|
| if (!outputDir.exists() && !outputDir.mkdirs()) {
|
| Log.e(LOGTAG, "Unable to create pak resources directory!");
|
| return;
|
| @@ -74,16 +80,15 @@ public class ResourceExtractor {
|
| }
|
|
|
| SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
| - HashSet<String> filenames = (HashSet<String>) prefs.getStringSet(
|
| - PAK_FILENAMES, new HashSet<String>());
|
| String currentLocale = LocaleUtils.getDefaultLocale();
|
| String currentLanguage = currentLocale.split("-", 2)[0];
|
| -
|
| - if (prefs.getString(LAST_LANGUAGE, "").equals(currentLanguage)
|
| - && filenames.size() >= sMandatoryPaks.length) {
|
| + // If everything we need is already there (and the locale hasn't
|
| + // changed), quick exit.
|
| + if (prefs.getString(LAST_LANGUAGE, "").equals(currentLanguage)) {
|
| boolean filesPresent = true;
|
| - for (String file : filenames) {
|
| - if (!new File(outputDir, file).exists()) {
|
| + for (String file : sMandatoryPaks) {
|
| + File directory = isAppDataFile(file) ? appDataDir : outputDir;
|
| + if (!new File(directory, file).exists()) {
|
| filesPresent = false;
|
| break;
|
| }
|
| @@ -122,10 +127,7 @@ public class ResourceExtractor {
|
| if (!paksToInstall.matcher(file).matches()) {
|
| continue;
|
| }
|
| - boolean isAppDataFile = file.equals(ICU_DATA_FILENAME)
|
| - || file.equals(V8_NATIVES_DATA_FILENAME)
|
| - || file.equals(V8_SNAPSHOT_DATA_FILENAME);
|
| - File output = new File(isAppDataFile ? getAppDataDir() : outputDir, file);
|
| + File output = new File(isAppDataFile(file) ? appDataDir : outputDir, file);
|
| if (output.exists()) {
|
| continue;
|
| }
|
| @@ -152,9 +154,7 @@ public class ResourceExtractor {
|
| throw new IOException(file + " extracted with 0 length!");
|
| }
|
|
|
| - if (!isAppDataFile) {
|
| - filenames.add(file);
|
| - } else {
|
| + if (isAppDataFile(file)) {
|
| // icu and V8 data need to be accessed by a renderer
|
| // process.
|
| output.setReadable(true, false);
|
| @@ -194,9 +194,6 @@ public class ResourceExtractor {
|
| Log.w(LOGTAG, "Failed to write resource pak timestamp!");
|
| }
|
| }
|
| - // TODO(yusufo): Figure out why remove is required here.
|
| - prefs.edit().remove(PAK_FILENAMES).apply();
|
| - prefs.edit().putStringSet(PAK_FILENAMES, filenames).apply();
|
| }
|
|
|
| @Override
|
|
|