forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Add gyp support for multidex.
Note that this does not enable multidex builds yet. BUG=272790 Review URL: https://codereview.chromium.org/1278573002 Cr-Commit-Position: refs/heads/master@{#345357}
- Loading branch information
Showing
25 changed files
with
457 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
base/android/java/src/org/chromium/base/annotations/MainDex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* An annotation that signals that a class should be kept in the main dex file. | ||
* | ||
* This generally means it's used by renderer processes, which can't load secondary dexes | ||
* on K and below. | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.CLASS) | ||
public @interface MainDex { | ||
} |
56 changes: 56 additions & 0 deletions
56
base/android/java/src/org/chromium/base/multidex/ChromiumMultiDex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.wtf(TAG, "Failed multidex installation", e); | ||
} catch (IllegalAccessException e) { | ||
Log.wtf(TAG, "Failed multidex installation", e); | ||
} catch (InvocationTargetException e) { | ||
Log.wtf(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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
base/test/android/junit/src/org/chromium/base/test/shadows/ShadowMultiDex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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.test.shadows; | ||
|
||
import android.content.Context; | ||
import android.support.multidex.MultiDex; | ||
|
||
import org.robolectric.annotation.Implementation; | ||
import org.robolectric.annotation.Implements; | ||
|
||
/** Do-nothing shadow for {@link android.support.multidex.MultiDex}. */ | ||
@Implements(MultiDex.class) | ||
public class ShadowMultiDex { | ||
|
||
@Implementation | ||
public static void install(Context context) { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.