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

Unified Diff: base/android/java/debug_src/org/chromium/base/IncrementalInstall.java

Issue 1291793007: GN(android): Add scripts & runtime logic for installing _managed apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-managed-install
Patch Set: fix compile Created 5 years, 4 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
« no previous file with comments | « base/BUILD.gn ('k') | base/android/java/debug_src/org/chromium/base/Reflect.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/debug_src/org/chromium/base/IncrementalInstall.java
diff --git a/base/android/java/debug_src/org/chromium/base/IncrementalInstall.java b/base/android/java/debug_src/org/chromium/base/IncrementalInstall.java
new file mode 100644
index 0000000000000000000000000000000000000000..1ee1272bfb2e73bf3349ca9fbde252eeaea7c4a5
--- /dev/null
+++ b/base/android/java/debug_src/org/chromium/base/IncrementalInstall.java
@@ -0,0 +1,46 @@
+// Copyright 2015 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.base;
+
+import android.content.Context;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Contains hooks for making Incremental Install work. Incremental Install is
+ * where native libraries and (TODO) .dex files are pushed out-of-band to
+ * external storage rather than packaged with the app.
+ */
+public final class IncrementalInstall {
+ private static final String MANAGED_DIR_PREFIX = "/data/local/tmp/incremental-app-";
+
+ public static void initialize(Context context) {
+ File incrementalAppDir = new File(MANAGED_DIR_PREFIX + context.getPackageName());
+ File incrementalLibDir = new File(incrementalAppDir, "lib");
+ injectNativeLibDir(context.getClassLoader(), incrementalLibDir);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void injectNativeLibDir(ClassLoader loader, File nativeLibDir) {
+ try {
+ Object dexPathList = Reflect.getField(loader, "pathList");
+ Object currentDirs = Reflect.getField(dexPathList, "nativeLibraryDirectories");
+ if (currentDirs instanceof List) {
+ List<File> dirsAsList = (List<File>) currentDirs;
+ dirsAsList.add(nativeLibDir);
+ } else {
+ File[] dirsAsArray = (File[]) currentDirs;
+ File[] newDirs = new File[] {
+ nativeLibDir
+ };
+ Reflect.setField(dexPathList, "nativeLibraryDirectories",
+ Reflect.concatArrays(dirsAsArray, newDirs));
+ }
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
« no previous file with comments | « base/BUILD.gn ('k') | base/android/java/debug_src/org/chromium/base/Reflect.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698