Bug 1359419 - Add GeckoView.preload() r=esawin
MozReview-Commit-ID: 6DYq2oiz1Ug
--- a/mobile/android/geckoview/proguard-rules.txt
+++ b/mobile/android/geckoview/proguard-rules.txt
@@ -3,17 +3,17 @@
# Preserve all annotations.
-keepattributes *Annotation*
# Preserve all public classes, and their public and protected fields and
# methods.
-keep public class * {
- public protected *;
+ static public protected *;
}
# Preserve all .class method names.
-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java
@@ -262,35 +262,40 @@ public class GeckoView extends LayerView
public GeckoView(Context context, AttributeSet attrs, final GeckoViewSettings settings) {
super(context, attrs);
final GeckoViewSettings newSettings = new GeckoViewSettings(settings, getEventDispatcher());
init(context, newSettings);
}
- private void init(final Context context, final GeckoViewSettings settings) {
+ public static void preload(Context context) {
+ final GeckoProfile profile = GeckoProfile.get(
+ context.getApplicationContext());
+
if (GeckoAppShell.getApplicationContext() == null) {
GeckoAppShell.setApplicationContext(context.getApplicationContext());
}
+ GeckoAppShell.setApplicationContext(context.getApplicationContext());
+ if (GeckoThread.initMainProcess(profile,
+ /* args */ null,
+ /* debugging */ false)) {
+ GeckoThread.launch();
+ }
+ }
+ private void init(final Context context, final GeckoViewSettings settings) {
// Set the GeckoInterface if the context is an activity and the
// GeckoInterface has not already been set
if (context instanceof Activity && getGeckoInterface() == null) {
setGeckoInterface(new BaseGeckoInterface(context));
GeckoAppShell.setContextGetter(this);
}
- final GeckoProfile profile = GeckoProfile.get(
- context.getApplicationContext());
- if (GeckoThread.initMainProcess(profile,
- /* args */ null,
- /* debugging */ false)) {
- GeckoThread.launch();
- }
+ preload(context);
// Perform common initialization for Fennec/GeckoView.
GeckoAppShell.setLayerView(this);
initializeView();
mListener.registerListeners();
if (settings == null) {