From 4f60b946e3999486837db4224c4899de0612d1c9 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Thu, 3 Sep 2015 15:47:22 -0500 Subject: [PATCH] Bug 1182665 - Don't try to call JNI methods in nsScreenManagerAndroid if it's not available r=esawin --- widget/android/nsScreenManagerAndroid.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/widget/android/nsScreenManagerAndroid.cpp b/widget/android/nsScreenManagerAndroid.cpp index 9a8b3651fe7..f661bc77edc 100644 --- a/widget/android/nsScreenManagerAndroid.cpp +++ b/widget/android/nsScreenManagerAndroid.cpp @@ -32,6 +32,12 @@ nsScreenAndroid::GetId(uint32_t *outId) NS_IMETHODIMP nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight) { + if (!mozilla::jni::IsAvailable()) { + // xpcshell most likely + *outLeft = *outTop = *outWidth = *outHeight = 0; + return NS_ERROR_FAILURE; + } + widget::sdk::Rect::LocalRef rect = widget::GeckoAppShell::GetScreenSize(); rect->Left(outLeft); rect->Top(outTop); @@ -53,7 +59,13 @@ nsScreenAndroid::GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWid NS_IMETHODIMP nsScreenAndroid::GetPixelDepth(int32_t *aPixelDepth) { - *aPixelDepth = AndroidBridge::Bridge()->GetScreenDepth(); + if (!mozilla::jni::IsAvailable()) { + // xpcshell most likely + *aPixelDepth = 16; + return NS_ERROR_FAILURE; + } + + *aPixelDepth = widget::GeckoAppShell::GetScreenDepthWrapper(); return NS_OK; } @@ -67,7 +79,9 @@ nsScreenAndroid::GetColorDepth(int32_t *aColorDepth) void nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness) { - widget::GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL); + if (mozilla::jni::IsAvailable()) { + widget::GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL); + } } NS_IMPL_ISUPPORTS(nsScreenManagerAndroid, nsIScreenManager)