back out b9c1b8afb35a / Bug 689598 to allow backing out 8c075fee9be4 / Bug 704710
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 08 Mar 2012 18:03:18 -0500
changeset 85553 9af0904f0486c84906eb0a2529404120b0fdc202
parent 85552 08e1dd305b6bf6fe5204af3ef0ea71f1e2c6264f
child 85554 ff5f2055aba4b7bad4ee6584fd14ac35f0f1001a
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
bugs689598, 704710
milestone11.0
backs outb9c1b8afb35a534edefafb3a04eb8222cf72a789
back out b9c1b8afb35a / Bug 689598 to allow backing out 8c075fee9be4 / Bug 704710
widget/src/android/GfxInfo.cpp
widget/src/android/GfxInfo.h
widget/src/xpwidgets/GfxDriverInfo.h
widget/src/xpwidgets/GfxInfoBase.cpp
--- a/widget/src/android/GfxInfo.cpp
+++ b/widget/src/android/GfxInfo.cpp
@@ -84,59 +84,45 @@ GfxInfo::GetCleartypeParameters(nsAStrin
 {
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 GfxInfo::Init()
 {
   mSetCrashReportAnnotations = false;
-
-  mAdapterDescription.AssignASCII(mozilla::gl::GetVendor());
-  if (mozilla::AndroidBridge::Bridge()) {
-    nsAutoString str;
-
-    mAdapterDescription.Append(NS_LITERAL_STRING(", Model: '"));
-    if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str)) {
-      mAdapterDeviceID = str;
-      mAdapterDescription.Append(str);
-    }
-
-    mAdapterDescription.Append(NS_LITERAL_STRING("', Product: '"));
-    if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", str))
-      mAdapterDescription.Append(str);
-
-    mAdapterDescription.Append(NS_LITERAL_STRING("', Manufacturer: '"));
-    if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", str))
-      mAdapterDescription.Append(str);
-
-    mAdapterDescription.Append(NS_LITERAL_STRING("', Hardware: '"));
-    PRInt32 version; // the HARDWARE field isn't available on Android SDK < 8
-    if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &version))
-      version = 0;
-
-    if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) {
-      if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) {
-        mAdapterVendorID = str;
-        mAdapterDescription.Append(str);
-      }
-    }
-
-    mAdapterDescription.Append(NS_LITERAL_STRING("'"));
-    mAndroidSDKVersion = version;
-  }
-
   return GfxInfoBase::Init();
 }
 
 /* readonly attribute DOMString adapterDescription; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription)
 {
-  aAdapterDescription = mAdapterDescription;
+  aAdapterDescription.AssignASCII(mozilla::gl::GetVendor());
+  if (mozilla::AndroidBridge::Bridge()) {
+      nsAutoString str;
+      aAdapterDescription.Append(NS_LITERAL_STRING(", Model: '"));
+      if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str))
+        aAdapterDescription.Append(str);
+      aAdapterDescription.Append(NS_LITERAL_STRING("', Product: '"));
+      if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", str))
+        aAdapterDescription.Append(str);
+      aAdapterDescription.Append(NS_LITERAL_STRING("', Manufacturer: '"));
+      if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", str))
+        aAdapterDescription.Append(str);
+      aAdapterDescription.Append(NS_LITERAL_STRING("', Hardware: '"));
+      PRInt32 version; // the HARDWARE field isn't available on Android SDK < 8
+      if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &version))
+        version = 0;
+      if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str))
+      if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str))
+        aAdapterDescription.Append(str);
+      aAdapterDescription.Append(NS_LITERAL_STRING("'"));
+  }
+
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterDescription2; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription)
 {
   return NS_ERROR_FAILURE;
@@ -171,18 +157,17 @@ GfxInfo::GetAdapterDriver2(nsAString & a
 {
   return NS_ERROR_FAILURE;
 }
 
 /* readonly attribute DOMString adapterDriverVersion; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion)
 {
-  aAdapterDriverVersion.Truncate(0);
-  aAdapterDriverVersion.AppendInt(mAndroidSDKVersion);
+  aAdapterDriverVersion.AssignLiteral("");
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterDriverVersion2; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion)
 {
   return NS_ERROR_FAILURE;
@@ -202,32 +187,47 @@ GfxInfo::GetAdapterDriverDate2(nsAString
 {
   return NS_ERROR_FAILURE;
 }
 
 /* readonly attribute DOMString adapterVendorID; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID)
 {
-  aAdapterVendorID = mAdapterVendorID;
+  nsAutoString str;
+  PRInt32 version; // the HARDWARE field isn't available on Android SDK < 8
+  if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &version))
+    version = 0;
+  if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) {
+    aAdapterVendorID = str;
+    return NS_OK;
+  }
+
+  aAdapterVendorID = NS_LITERAL_STRING("");
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterVendorID2; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID)
 {
   return NS_ERROR_FAILURE;
 }
 
 /* readonly attribute DOMString adapterDeviceID; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID)
 {
-  aAdapterDeviceID = mAdapterDeviceID;
+  nsAutoString str;
+  if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str)) {
+    aAdapterDeviceID = str;
+    return NS_OK;
+  }
+
+  aAdapterDeviceID = NS_LITERAL_STRING("");
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterDeviceID2; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID)
 {
   return NS_ERROR_FAILURE;
@@ -291,16 +291,22 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aF
                               nsAString & aSuggestedDriverVersion,
                               const nsTArray<GfxDriverInfo>& aDriverInfo, 
                               OperatingSystem* aOS /* = nsnull */)
 {
   PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
 
   aSuggestedDriverVersion.SetIsVoid(true);
 
+  // For now, we don't implement the downloaded blacklist.
+  if (aDriverInfo.Length()) {
+    *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
+    return NS_OK;
+  }
+
   OperatingSystem os = DRIVER_OS_ANDROID;
 
   if (aFeature == FEATURE_OPENGL_LAYERS) {
     if (!mSetCrashReportAnnotations) {
       AddOpenGLCrashReportAnnotations();
       mSetCrashReportAnnotations = true;
     }
 
@@ -315,10 +321,18 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aF
 
     status = FEATURE_BLOCKED_DEVICE;
   }
 
   *aStatus = status;
   if (aOS)
     *aOS = os;
 
+  // XXX disabled for now as this calls GetAdapterVendorID and friends, which currently crash on Android, see bug 700124
+  // FIXME: if this gets fixed, the line setting *aStatus must be removed
+#if 0
   return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
+#else
+  if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN)
+    *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
+#endif
+  return NS_OK;
 }
--- a/widget/src/android/GfxInfo.h
+++ b/widget/src/android/GfxInfo.h
@@ -95,20 +95,15 @@ private:
   nsString mRendererIDsString;
   nsString mAdapterRAMString;
 
   nsString mDeviceID;
   nsString mDriverVersion;
   nsString mDriverDate;
   nsString mDeviceKey;
 
-  nsString mAdapterDeviceID;
-  nsString mAdapterVendorID;
-  nsString mAdapterDescription;
-  PRInt32 mAndroidSDKVersion;
-
   PRUint32 mRendererIDs[16];
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif /* __mozilla_widget_GfxInfo_h__ */
--- a/widget/src/xpwidgets/GfxDriverInfo.h
+++ b/widget/src/xpwidgets/GfxDriverInfo.h
@@ -151,32 +151,26 @@ struct GfxDriverInfo
 };
 
 #define GFX_DRIVER_VERSION(a,b,c,d) \
   ((PRUint64(a)<<48) | (PRUint64(b)<<32) | (PRUint64(c)<<16) | PRUint64(d))
 
 inline bool
 ParseDriverVersion(nsAString& aVersion, PRUint64 *aNumericVersion)
 {
-#if defined(XP_WIN)
   int a, b, c, d;
   /* honestly, why do I even bother */
   if (sscanf(NS_LossyConvertUTF16toASCII(aVersion).get(),
              "%d.%d.%d.%d", &a, &b, &c, &d) != 4)
     return false;
   if (a < 0 || a > 0xffff) return false;
   if (b < 0 || b > 0xffff) return false;
   if (c < 0 || c > 0xffff) return false;
   if (d < 0 || d > 0xffff) return false;
 
   *aNumericVersion = GFX_DRIVER_VERSION(a, b, c, d);
-#elif defined(ANDROID)
-  // Can't use aVersion.ToInteger() because that's not compiled into our code
-  // unless we have XPCOM_GLUE_AVOID_NSPR disabled.
-  *aNumericVersion = atoi(NS_LossyConvertUTF16toASCII(aVersion).get());
-#endif
   return true;
 }
 
 }
 }
 
 #endif /*__mozilla_widget_GfxDriverInfo_h__ */
--- a/widget/src/xpwidgets/GfxInfoBase.cpp
+++ b/widget/src/xpwidgets/GfxInfoBase.cpp
@@ -659,17 +659,17 @@ GfxInfoBase::FindBlocklistedDeviceInList
 
         if (!deviceMatches) {
             continue;
         }
     }
 
     bool match = false;
 
-#if defined(XP_WIN) || defined(ANDROID)
+#if !defined(XP_MACOSX)
     switch (info[i].mComparisonOp) {
     case DRIVER_LESS_THAN:
       match = driverVersion < info[i].mDriverVersion;
       break;
     case DRIVER_LESS_THAN_OR_EQUAL:
       match = driverVersion <= info[i].mDriverVersion;
       break;
     case DRIVER_GREATER_THAN:
@@ -698,17 +698,17 @@ GfxInfoBase::FindBlocklistedDeviceInList
       break;
     }
 #else
     // We don't care what driver version it was. We only check OS version and if
     // the device matches.
     match = true;
 #endif
 
-    if (match || info[i].mDriverVersion == GfxDriverInfo::allDriverVersions) {
+    if (match) {
       if (info[i].mFeature == GfxDriverInfo::allFeatures ||
           info[i].mFeature == aFeature)
       {
         status = info[i].mFeatureStatus;
         break;
       }
     }
   }