| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| index 05b469b0288087b5617f672a6f6b1e53b01cf078..a673a878b76df5bef084977b1c4ee7f4dfe734a0 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| @@ -20,6 +20,7 @@ import org.chromium.chrome.browser.util.IntentUtils;
|
| import org.chromium.content_public.common.ScreenOrientationValues;
|
| import org.chromium.webapk.lib.common.WebApkConstants;
|
|
|
| +import java.io.File;
|
| import java.util.concurrent.TimeUnit;
|
|
|
| /**
|
| @@ -70,6 +71,9 @@ public class WebappDataStorage {
|
| // Whether the user has dismissed the disclosure UI.
|
| static final String KEY_DISMISSED_DISCLOSURE = "dismissed_dislosure";
|
|
|
| + // The path of the file with data to update the WebAPK.
|
| + static final String KEY_PENDING_UPDATE_FILE_PATH = "pending_update_file_name";
|
| +
|
| // Number of milliseconds between checks for whether the WebAPK's Web Manifest has changed.
|
| public static final long UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(3L);
|
|
|
| @@ -304,6 +308,7 @@ public class WebappDataStorage {
|
| * file. This does NOT delete the file itself but the file is left empty.
|
| */
|
| void delete() {
|
| + deletePendingUpdateFile();
|
| mPreferences.edit().clear().apply();
|
| }
|
|
|
| @@ -312,6 +317,8 @@ public class WebappDataStorage {
|
| * This does not remove the stored splash screen image (if any) for the app.
|
| */
|
| void clearHistory() {
|
| + deletePendingUpdateFile();
|
| +
|
| SharedPreferences.Editor editor = mPreferences.edit();
|
|
|
| editor.remove(KEY_LAST_USED);
|
| @@ -502,6 +509,36 @@ public class WebappDataStorage {
|
| return mPreferences.getBoolean(KEY_RELAX_UPDATES, false);
|
| }
|
|
|
| + /** Sets the path of the file which contains data to update the WebAPK. */
|
| + void setPendingUpdateFilePath(String filePath) {
|
| + assert filePath != null;
|
| + mPreferences.edit().putString(KEY_PENDING_UPDATE_FILE_PATH, filePath).apply();
|
| + }
|
| +
|
| + /** Returns the path of the file which contains data to update the WebAPK. */
|
| + String getPendingUpdateFilePath() {
|
| + return mPreferences.getString(KEY_PENDING_UPDATE_FILE_PATH, null);
|
| + }
|
| +
|
| + /**
|
| + * Deletes the file which contains data to update the WebAPK. The file is large (> 1Kb) and
|
| + * should be deleted when the update completes.
|
| + */
|
| + void deletePendingUpdateFile() {
|
| + final String pendingUpdateFilePath = getPendingUpdateFilePath();
|
| + if (pendingUpdateFilePath == null) return;
|
| +
|
| + mPreferences.edit().remove(KEY_PENDING_UPDATE_FILE_PATH).apply();
|
| + new AsyncTask<Void, Void, Void>() {
|
| + @Override
|
| + protected Void doInBackground(Void... params) {
|
| + new File(pendingUpdateFilePath).delete();
|
| + return null;
|
| + }
|
| + }
|
| + .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
| + }
|
| +
|
| /** Returns whether we should check for update. */
|
| boolean shouldCheckForUpdate() {
|
| long checkUpdatesInterval =
|
|
|