Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Unified Diff: webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVersionManager.java

Issue 1965583002: Move //webapk to //chrome/android/webapk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVersionManager.java
diff --git a/webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVersionManager.java b/webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVersionManager.java
deleted file mode 100644
index fb83204a1c3b64798ac7a4215b97e02f2ddb4c07..0000000000000000000000000000000000000000
--- a/webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVersionManager.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.webapk.lib.client;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-
-import org.chromium.base.FileUtils;
-import org.chromium.base.ThreadUtils;
-import org.chromium.webapk.lib.common.WebApkUtils;
-
-import java.io.File;
-
-/**
- * Updates installed WebAPKs after a Chrome update.
- */
-public class WebApkVersionManager {
- /**
- * Name of the shared preference for the version number of the dynamically loaded dex.
- */
- private static final String EXTRACTED_DEX_VERSION_PREF =
- "web_apk_version_manager_extracted_dex_version";
-
- private static final String TAG = "WebApkVersionManager";
-
- /**
- * If a new WebAPK runtime is available due to a Chrome update, updates the installed WebAPKs.
- * Should not be called on UI thread.
- * @param Context context
- * @param alwaysExtractRuntimeDex Whether the WebAPK runtime should always be re-extracted from
- * the Chrome APK regardless of whether a new version is available.
- */
- public static void updateWebApksIfNeeded(Context context, boolean alwaysExtractRuntimeDex) {
- assert !ThreadUtils.runningOnUiThread();
-
- // TODO(pkotwicz|hanxi): Detect whether the manifest of installed APKs needs to be updated.
- // (crbug.com/604513)
-
- SharedPreferences preferences =
- PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
- int extractedDexVersion = preferences.getInt(EXTRACTED_DEX_VERSION_PREF, -1);
- if (!alwaysExtractRuntimeDex
- && extractedDexVersion == WebApkVersion.CURRENT_RUNTIME_DEX_VERSION) {
- return;
- }
-
- SharedPreferences.Editor editor = preferences.edit();
- editor.putInt(EXTRACTED_DEX_VERSION_PREF, WebApkVersion.CURRENT_RUNTIME_DEX_VERSION);
- editor.apply();
-
- File dexDir = context.getDir("dex", Context.MODE_PRIVATE);
- FileUtils.recursivelyDeleteFile(dexDir);
-
- // Recreate world-executable directory using {@link Context#getDir}.
- dexDir = context.getDir("dex", Context.MODE_PRIVATE);
-
- String dexName =
- WebApkUtils.getRuntimeDexName(WebApkVersion.CURRENT_RUNTIME_DEX_VERSION);
- File dexFile = new File(dexDir, dexName);
- if (!FileUtils.extractAsset(context, dexName, dexFile) || !DexOptimizer.optimize(dexFile)) {
- return;
- }
-
- // Make dex file world-readable so that WebAPK can use it.
- dexFile.setReadable(true, false);
- }
-}
« no previous file with comments | « webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkVersion.template ('k') | webapk/libs/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698