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