Chromium Code Reviews| Index: base/android/java/src/org/chromium/base/multidex/ChromiumMultiDex.java |
| diff --git a/base/android/java/src/org/chromium/base/multidex/ChromiumMultiDex.java b/base/android/java/src/org/chromium/base/multidex/ChromiumMultiDex.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5b09865432d0c6ef40d49a0fe5552c39d48af78b |
| --- /dev/null |
| +++ b/base/android/java/src/org/chromium/base/multidex/ChromiumMultiDex.java |
| @@ -0,0 +1,56 @@ |
| +// 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.multidex; |
| + |
| +import android.content.Context; |
| +import android.os.Build; |
| +import android.os.Process; |
| +import android.support.multidex.MultiDex; |
| + |
| +import org.chromium.base.Log; |
| + |
| +import java.lang.reflect.InvocationTargetException; |
| + |
| +/** |
| + * Performs multidex installation for non-isolated processes. |
| + */ |
| +public class ChromiumMultiDex { |
| + |
| + private static final String TAG = "cr.base.multidex"; |
| + |
| + /** |
| + * Installs secondary dexes if possible. |
| + * |
| + * Isolated processes (e.g. renderer processes) can't load secondary dex files on |
| + * K and below, so we don't even try in that case. |
| + * |
| + * @param context The application context. |
| + */ |
| + public static void install(Context context) { |
| + try { |
| + // TODO(jbudorick): Back out this version check once support for K & below works. |
| + // http://crbug.com/512357 |
| + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && processIsIsolated()) { |
| + Log.i(TAG, "Skipping multidex installation: inside isolated process."); |
| + } else { |
| + MultiDex.install(context); |
| + Log.i(TAG, "Completed multidex installation."); |
| + } |
| + } catch (NoSuchMethodException e) { |
| + Log.e(TAG, "Failed multidex installation", e); |
|
Yaron
2015/08/05 21:56:41
Won't be explode in this case? We're expecting mul
jbudorick
2015/08/05 22:55:22
It depends. The only way we hit these exception ha
Yaron
2015/08/10 20:15:40
I think if the private API call fails, we should f
Yaron
2015/08/13 20:12:10
bump
jbudorick
2015/08/14 21:01:21
oops, lost this one.
Log.e -> Log.wtf
|
| + } catch (IllegalAccessException e) { |
| + Log.e(TAG, "Failed multidex installation", e); |
| + } catch (InvocationTargetException e) { |
| + Log.e(TAG, "Failed multidex installation", e); |
| + } |
| + } |
| + |
| + // Calls Process.isIsolated, a private Android API. |
| + private static boolean processIsIsolated() |
| + throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { |
| + return (boolean) Process.class.getMethod("isIsolated").invoke(null); |
| + } |
| + |
| +} |