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 |
| 14 import java.lang.reflect.InvocationTargetException; |
| 15 |
| 16 /** |
| 17 * Performs multidex installation for non-isolated processes. |
| 18 */ |
| 19 public class ChromiumMultiDex { |
| 20 |
| 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 public static void install(Context context) { |
| 32 try { |
| 33 // TODO(jbudorick): Back out this version check once support for K &
below works. |
| 34 // http://crbug.com/512357 |
| 35 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && processI
sIsolated()) { |
| 36 Log.i(TAG, "Skipping multidex installation: inside isolated proc
ess."); |
| 37 } else { |
| 38 MultiDex.install(context); |
| 39 Log.i(TAG, "Completed multidex installation."); |
| 40 } |
| 41 } catch (NoSuchMethodException e) { |
| 42 Log.wtf(TAG, "Failed multidex installation", e); |
| 43 } catch (IllegalAccessException e) { |
| 44 Log.wtf(TAG, "Failed multidex installation", e); |
| 45 } catch (InvocationTargetException e) { |
| 46 Log.wtf(TAG, "Failed multidex installation", e); |
| 47 } |
| 48 } |
| 49 |
| 50 // Calls Process.isIsolated, a private Android API. |
| 51 private static boolean processIsIsolated() |
| 52 throws NoSuchMethodException, IllegalAccessException, InvocationTarg
etException { |
| 53 return (boolean) Process.class.getMethod("isIsolated").invoke(null); |
| 54 } |
| 55 |
| 56 } |
OLD | NEW |