diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 6a2a0552d2b8..4556415d659f 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -172,7 +172,6 @@ abstract public class GeckoApp public static int mOrientation; protected boolean mIsRestoringActivity; private String mCurrentResponse = ""; - public static boolean sIsUsingCustomProfile = false; private ContactService mContactService; private PromptService mPromptService; @@ -1175,7 +1174,7 @@ abstract public class GeckoApp if (profileName == null) profileName = "default"; } - GeckoApp.sIsUsingCustomProfile = true; + GeckoProfile.sIsUsingCustomProfile = true; } if (profileName != null || profilePath != null) { diff --git a/mobile/android/base/GeckoProfile.java b/mobile/android/base/GeckoProfile.java index ad514657719b..db2b8b9c13d2 100644 --- a/mobile/android/base/GeckoProfile.java +++ b/mobile/android/base/GeckoProfile.java @@ -35,6 +35,7 @@ public final class GeckoProfile { private final String mName; private File mMozDir; private File mDir; + public static boolean sIsUsingCustomProfile = false; // Constants to cache whether or not a profile is "locked". private enum LockState { @@ -60,7 +61,13 @@ public final class GeckoProfile { } public static GeckoProfile get(Context context) { - if (context instanceof GeckoApp) { + boolean isGeckoApp = false; + try { + isGeckoApp = context instanceof GeckoApp; + } catch (NoClassDefFoundError ex) {} + + + if (isGeckoApp) { // Check for a cached profile on this context already // TODO: We should not be caching profile information on the Activity context if (((GeckoApp)context).mProfile != null) { @@ -74,7 +81,7 @@ public final class GeckoProfile { return guest; } - if (context instanceof GeckoApp) { + if (isGeckoApp) { // Otherwise, get the default profile for the Activity return get(context, ((GeckoApp)context).getDefaultProfileName()); } diff --git a/mobile/android/base/GeckoThread.java b/mobile/android/base/GeckoThread.java index 7dd542ec9273..7b4d2f57648c 100644 --- a/mobile/android/base/GeckoThread.java +++ b/mobile/android/base/GeckoThread.java @@ -147,7 +147,7 @@ public class GeckoThread extends Thread implements GeckoEventListener { if (args == null || !args.contains(BrowserApp.GUEST_BROWSING_ARG)) { guest = " " + BrowserApp.GUEST_BROWSING_ARG; } - } else if (!GeckoApp.sIsUsingCustomProfile) { + } else if (!GeckoProfile.sIsUsingCustomProfile) { // If nothing was passed in in the intent, force Gecko to use the default profile for // for this activity profile = " -P " + GeckoAppShell.getGeckoInterface().getProfile().getName(); diff --git a/mobile/android/base/GeckoView.java b/mobile/android/base/GeckoView.java index 22d268566e16..c17cda45a3d5 100644 --- a/mobile/android/base/GeckoView.java +++ b/mobile/android/base/GeckoView.java @@ -46,7 +46,12 @@ public class GeckoView extends LayerView // If running outside of a GeckoActivity (eg, from a library project), // load the native code and disable content providers - if (!(context instanceof GeckoActivity)) { + boolean isGeckoActivity = false; + try { + isGeckoActivity = context instanceof GeckoActivity; + } catch (NoClassDefFoundError ex) {} + + if (!isGeckoActivity) { // Set the GeckoInterface if the context is an activity and the GeckoInterface // has not already been set if (context instanceof Activity && getGeckoInterface() == null) { @@ -59,7 +64,7 @@ public class GeckoView extends LayerView GeckoLoader.loadMozGlue(); BrowserDB.setEnableContentProviders(false); - } + } if (url != null) { GeckoThread.setUri(url); diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index d202e55e80cc..967c167be07f 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -896,16 +896,20 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget } private void setShadowVisibility() { - ThreadUtils.postToUiThread(new Runnable() { - @Override - public void run() { - if (BrowserApp.mBrowserToolbar == null) { - return; + try { + if (BrowserApp.mBrowserToolbar == null) // this will throw if we don't have BrowserApp + return; + ThreadUtils.postToUiThread(new Runnable() { + @Override + public void run() { + if (BrowserApp.mBrowserToolbar == null) { + return; + } + ImmutableViewportMetrics m = mViewportMetrics; + BrowserApp.mBrowserToolbar.setShadowVisibility(m.viewportRectTop >= m.pageRectTop); } - ImmutableViewportMetrics m = mViewportMetrics; - BrowserApp.mBrowserToolbar.setShadowVisibility(m.viewportRectTop >= m.pageRectTop); - } - }); + }); + } catch (NoClassDefFoundError ex) {} } /** Implementation of PanZoomTarget */