OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.base.multidex; |
| 6 |
| 7 import android.content.Context; |
| 8 import android.os.Build; |
| 9 import android.os.Process; |
| 10 import android.support.multidex.MultiDex; |
| 11 |
| 12 import org.chromium.base.Log; |
| 13 import org.chromium.base.VisibleForTesting; |
| 14 |
| 15 import java.lang.reflect.InvocationTargetException; |
| 16 |
| 17 /** |
| 18 * Performs multidex installation for non-isolated processes. |
| 19 */ |
| 20 public class ChromiumMultiDex { |
| 21 private static final String TAG = "cr.base.multidex"; |
| 22 |
| 23 /** |
| 24 * Installs secondary dexes if possible. |
| 25 * |
| 26 * Isolated processes (e.g. renderer processes) can't load secondary dex fi
les on |
| 27 * K and below, so we don't even try in that case. |
| 28 * |
| 29 * @param context The application context. |
| 30 */ |
| 31 @VisibleForTesting |
| 32 public static void install(Context context) { |
| 33 try { |
| 34 // TODO(jbudorick): Back out this version check once support for K &
below works. |
| 35 // http://crbug.com/512357 |
| 36 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && processI
sIsolated()) { |
| 37 Log.i(TAG, "Skipping multidex installation: inside isolated proc
ess."); |
| 38 } else { |
| 39 MultiDex.install(context); |
| 40 Log.i(TAG, "Completed multidex installation."); |
| 41 } |
| 42 } catch (NoSuchMethodException e) { |
| 43 Log.wtf(TAG, "Failed multidex installation", e); |
| 44 } catch (IllegalAccessException e) { |
| 45 Log.wtf(TAG, "Failed multidex installation", e); |
| 46 } catch (InvocationTargetException e) { |
| 47 Log.wtf(TAG, "Failed multidex installation", e); |
| 48 } |
| 49 } |
| 50 |
| 51 // Calls Process.isIsolated, a private Android API. |
| 52 private static boolean processIsIsolated() |
| 53 throws NoSuchMethodException, IllegalAccessException, InvocationTarg
etException { |
| 54 return (boolean) Process.class.getMethod("isIsolated").invoke(null); |
| 55 } |
| 56 } |
OLD | NEW |