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

Unified Diff: web_apks/minting_example/libs/client/org/chromium/minting/lib/client/WebApkVersionManager.java

Issue 1945303005: Change webapk packages and directory structure (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: web_apks/minting_example/libs/client/org/chromium/minting/lib/client/WebApkVersionManager.java
diff --git a/web_apks/minting_example/libs/client/org/chromium/minting/lib/client/WebApkVersionManager.java b/web_apks/minting_example/libs/client/org/chromium/minting/lib/client/WebApkVersionManager.java
deleted file mode 100644
index 70a4bb1d57ae84f2fcca2a17b282a2286c96fbef..0000000000000000000000000000000000000000
--- a/web_apks/minting_example/libs/client/org/chromium/minting/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.minting.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.minting.lib.common.WebApkUtils;
-
-import java.io.File;
-
-/**
- * Updates installed Web APKs 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 Web APK runtime is available due to a Chrome update, updates the installed Web APKs.
- * Should not be called on UI thread.
- * @param Context context
- * @param alwaysExtractRuntimeDex Whether the Web APK 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 Web APK can use it.
- dexFile.setReadable(true, false);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698