Bug 1182665 - Don't try to call JNI methods in nsScreenManagerAndroid if it's not available r=esawin
☠☠ backed out by d48fbf99a903 ☠ ☠
authorJames Willcox <snorp@snorp.net>
Thu, 03 Sep 2015 15:47:22 -0500
changeset 294631 4b301ec04c21b339af87dd31b9e298a40c90f80e
parent 294630 5b98866735147c0e24a9a2329de27c8131f4ba5f
child 294632 69e7d484b749452e7c7ba2ab01f66f71c6339a6b
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1182665
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1182665 - Don't try to call JNI methods in nsScreenManagerAndroid if it's not available r=esawin
widget/android/nsScreenManagerAndroid.cpp
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -27,16 +27,22 @@ nsScreenAndroid::GetId(uint32_t *outId)
 {
     *outId = 1;
     return NS_OK;
 }
 
 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);
     rect->Width(outWidth);
     rect->Height(outHeight);
 
     return NS_OK;
 }
@@ -48,31 +54,39 @@ nsScreenAndroid::GetAvailRect(int32_t *o
     return GetRect(outLeft, outTop, outWidth, outHeight);
 }
 
 
 
 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;
 }
 
 
 NS_IMETHODIMP
 nsScreenAndroid::GetColorDepth(int32_t *aColorDepth)
 {
     return GetPixelDepth(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)
 
 nsScreenManagerAndroid::nsScreenManagerAndroid()
 {
     mOneScreen = new nsScreenAndroid(nullptr);
 }