OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.base.multidex; | 5 package org.chromium.base.multidex; |
6 | 6 |
7 import android.app.ActivityManager; | 7 import android.app.ActivityManager; |
8 import android.app.ActivityManager.RunningAppProcessInfo; | 8 import android.app.ActivityManager.RunningAppProcessInfo; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.pm.ApplicationInfo; | 10 import android.content.pm.ApplicationInfo; |
11 import android.content.pm.PackageManager; | 11 import android.content.pm.PackageManager; |
12 import android.os.Build; | 12 import android.os.Build; |
13 import android.support.multidex.MultiDex; | 13 import android.support.multidex.MultiDex; |
14 | 14 |
| 15 import org.chromium.base.BuildConfig; |
15 import org.chromium.base.Log; | 16 import org.chromium.base.Log; |
16 import org.chromium.base.VisibleForTesting; | 17 import org.chromium.base.VisibleForTesting; |
17 | 18 |
18 import java.lang.reflect.InvocationTargetException; | 19 import java.lang.reflect.InvocationTargetException; |
19 import java.lang.reflect.Method; | 20 import java.lang.reflect.Method; |
20 | 21 |
21 /** | 22 /** |
22 * Performs multidex installation for non-isolated processes. | 23 * Performs multidex installation for non-isolated processes. |
23 */ | 24 */ |
24 public class ChromiumMultiDexInstaller { | 25 public class ChromiumMultiDexInstaller { |
(...skipping 15 matching lines...) Expand all Loading... |
40 * In release builds of app apks (as opposed to test apks), this is a no-op
because: | 41 * In release builds of app apks (as opposed to test apks), this is a no-op
because: |
41 * - multidex isn't necessary in release builds because we run proguard t
here and | 42 * - multidex isn't necessary in release builds because we run proguard t
here and |
42 * thus aren't threatening to hit the dex limit; and | 43 * thus aren't threatening to hit the dex limit; and |
43 * - calling MultiDex.install, even in the absence of secondary dexes, ca
uses a | 44 * - calling MultiDex.install, even in the absence of secondary dexes, ca
uses a |
44 * significant regression in start-up time (crbug.com/525695). | 45 * significant regression in start-up time (crbug.com/525695). |
45 * | 46 * |
46 * @param context The application context. | 47 * @param context The application context. |
47 */ | 48 */ |
48 @VisibleForTesting | 49 @VisibleForTesting |
49 public static void install(Context context) { | 50 public static void install(Context context) { |
50 if (!ChromiumMultiDex.isMultidexEnabled()) return; | 51 if (!BuildConfig.isMultidexEnabled()) return; |
51 | 52 |
52 // TODO(jbudorick): Back out this version check once support for K & bel
ow works. | 53 // TODO(jbudorick): Back out this version check once support for K & bel
ow works. |
53 // http://crbug.com/512357 | 54 // http://crbug.com/512357 |
54 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP | 55 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP |
55 && !shouldInstallMultiDex(context)) { | 56 && !shouldInstallMultiDex(context)) { |
56 Log.i(TAG, "Skipping multidex installation: not needed for process."
); | 57 Log.i(TAG, "Skipping multidex installation: not needed for process."
); |
57 } else { | 58 } else { |
58 MultiDex.install(context); | 59 MultiDex.install(context); |
59 Log.i(TAG, "Completed multidex installation."); | 60 Log.i(TAG, "Completed multidex installation."); |
60 } | 61 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 ApplicationInfo appInfo = packageManager.getApplicationInfo(context.
getPackageName(), | 106 ApplicationInfo appInfo = packageManager.getApplicationInfo(context.
getPackageName(), |
106 PackageManager.GET_META_DATA); | 107 PackageManager.GET_META_DATA); |
107 if (appInfo == null || appInfo.metaData == null) return true; | 108 if (appInfo == null || appInfo.metaData == null) return true; |
108 return !appInfo.metaData.getBoolean(currentProcessName + IGNORE_MULT
IDEX_KEY, false); | 109 return !appInfo.metaData.getBoolean(currentProcessName + IGNORE_MULT
IDEX_KEY, false); |
109 } catch (PackageManager.NameNotFoundException e) { | 110 } catch (PackageManager.NameNotFoundException e) { |
110 return true; | 111 return true; |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
114 } | 115 } |
OLD | NEW |