1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/android/GfxInfo.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,644 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "GfxInfo.h" 1.10 +#include "GLContext.h" 1.11 +#include "GLContextProvider.h" 1.12 +#include "nsUnicharUtils.h" 1.13 +#include "prenv.h" 1.14 +#include "prprf.h" 1.15 +#include "nsHashKeys.h" 1.16 +#include "nsVersionComparator.h" 1.17 +#include "AndroidBridge.h" 1.18 +#include "nsIWindowWatcher.h" 1.19 +#include "nsServiceManagerUtils.h" 1.20 + 1.21 +#if defined(MOZ_CRASHREPORTER) 1.22 +#include "nsExceptionHandler.h" 1.23 +#include "nsICrashReporter.h" 1.24 +#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" 1.25 +#endif 1.26 + 1.27 +namespace mozilla { 1.28 +namespace widget { 1.29 + 1.30 +class GfxInfo::GLStrings 1.31 +{ 1.32 + nsCString mVendor; 1.33 + nsCString mRenderer; 1.34 + nsCString mVersion; 1.35 + bool mReady; 1.36 + 1.37 +public: 1.38 + GLStrings() 1.39 + : mReady(false) 1.40 + {} 1.41 + 1.42 + const nsCString& Vendor() { 1.43 + EnsureInitialized(); 1.44 + return mVendor; 1.45 + } 1.46 + 1.47 + void SpoofVendor(const nsCString& s) { 1.48 + EnsureInitialized(); 1.49 + mVendor = s; 1.50 + } 1.51 + 1.52 + const nsCString& Renderer() { 1.53 + EnsureInitialized(); 1.54 + return mRenderer; 1.55 + } 1.56 + 1.57 + void SpoofRenderer(const nsCString& s) { 1.58 + EnsureInitialized(); 1.59 + mRenderer = s; 1.60 + } 1.61 + 1.62 + const nsCString& Version() { 1.63 + EnsureInitialized(); 1.64 + return mVersion; 1.65 + } 1.66 + 1.67 + void SpoofVersion(const nsCString& s) { 1.68 + EnsureInitialized(); 1.69 + mVersion = s; 1.70 + } 1.71 + 1.72 + void EnsureInitialized() { 1.73 + if (mReady) { 1.74 + return; 1.75 + } 1.76 + 1.77 + nsRefPtr<gl::GLContext> gl = gl::GLContextProvider::CreateOffscreen( 1.78 + gfxIntSize(16, 16), 1.79 + gfx::SurfaceCaps::ForRGB()); 1.80 + 1.81 + if (!gl) { 1.82 + // Setting mReady to true here means that we won't retry. Everything will 1.83 + // remain blacklisted forever. Ideally, we would like to update that once 1.84 + // any GLContext is successfully created, like the compositor's GLContext. 1.85 + mReady = true; 1.86 + return; 1.87 + } 1.88 + 1.89 + gl->MakeCurrent(); 1.90 + 1.91 + const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR"); 1.92 + if (spoofedVendor) 1.93 + mVendor.Assign(spoofedVendor); 1.94 + else 1.95 + mVendor.Assign((const char*)gl->fGetString(LOCAL_GL_VENDOR)); 1.96 + const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER"); 1.97 + if (spoofedRenderer) 1.98 + mRenderer.Assign(spoofedRenderer); 1.99 + else 1.100 + mRenderer.Assign((const char*)gl->fGetString(LOCAL_GL_RENDERER)); 1.101 + const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION"); 1.102 + if (spoofedVersion) 1.103 + mVersion.Assign(spoofedVersion); 1.104 + else 1.105 + mVersion.Assign((const char*)gl->fGetString(LOCAL_GL_VERSION)); 1.106 + 1.107 + mReady = true; 1.108 + } 1.109 +}; 1.110 + 1.111 +#ifdef DEBUG 1.112 +NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) 1.113 +#endif 1.114 + 1.115 +GfxInfo::GfxInfo() 1.116 + : mInitialized(false) 1.117 + , mGLStrings(new GLStrings) 1.118 +{ 1.119 +} 1.120 + 1.121 +/* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization 1.122 + * has occurred because they depend on it for information. (See bug 591561) */ 1.123 +nsresult 1.124 +GfxInfo::GetD2DEnabled(bool *aEnabled) 1.125 +{ 1.126 + return NS_ERROR_FAILURE; 1.127 +} 1.128 + 1.129 +nsresult 1.130 +GfxInfo::GetDWriteEnabled(bool *aEnabled) 1.131 +{ 1.132 + return NS_ERROR_FAILURE; 1.133 +} 1.134 + 1.135 +/* readonly attribute DOMString DWriteVersion; */ 1.136 +NS_IMETHODIMP 1.137 +GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion) 1.138 +{ 1.139 + return NS_ERROR_FAILURE; 1.140 +} 1.141 + 1.142 +/* readonly attribute DOMString cleartypeParameters; */ 1.143 +NS_IMETHODIMP 1.144 +GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams) 1.145 +{ 1.146 + return NS_ERROR_FAILURE; 1.147 +} 1.148 + 1.149 +void 1.150 +GfxInfo::EnsureInitialized() 1.151 +{ 1.152 + if (mInitialized) 1.153 + return; 1.154 + 1.155 + mGLStrings->EnsureInitialized(); 1.156 + 1.157 + MOZ_ASSERT(mozilla::AndroidBridge::Bridge()); 1.158 + 1.159 + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", mModel)) { 1.160 + mAdapterDescription.AppendPrintf("Model: %s", NS_LossyConvertUTF16toASCII(mModel).get()); 1.161 + } 1.162 + 1.163 + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", mProduct)) { 1.164 + mAdapterDescription.AppendPrintf(", Product: %s", NS_LossyConvertUTF16toASCII(mProduct).get()); 1.165 + } 1.166 + 1.167 + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", mManufacturer)) { 1.168 + mAdapterDescription.AppendPrintf(", Manufacturer: %s", NS_LossyConvertUTF16toASCII(mManufacturer).get()); 1.169 + } 1.170 + 1.171 + int32_t sdkVersion; 1.172 + if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &sdkVersion)) 1.173 + sdkVersion = 0; 1.174 + 1.175 + // the HARDWARE field isn't available on Android SDK < 8 1.176 + if (sdkVersion >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", mHardware)) { 1.177 + mAdapterDescription.AppendPrintf(", Hardware: %s", NS_LossyConvertUTF16toASCII(mHardware).get()); 1.178 + } 1.179 + 1.180 + nsString release; 1.181 + mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", release); 1.182 + mOSVersion = NS_LossyConvertUTF16toASCII(release); 1.183 + 1.184 + mOSVersionInteger = 0; 1.185 + char a[5], b[5], c[5], d[5]; 1.186 + SplitDriverVersion(mOSVersion.get(), a, b, c, d); 1.187 + uint8_t na = atoi(a); 1.188 + uint8_t nb = atoi(b); 1.189 + uint8_t nc = atoi(c); 1.190 + uint8_t nd = atoi(d); 1.191 + 1.192 + mOSVersionInteger = (uint32_t(na) << 24) | 1.193 + (uint32_t(nb) << 16) | 1.194 + (uint32_t(nc) << 8) | 1.195 + uint32_t(nd); 1.196 + 1.197 + mAdapterDescription.AppendPrintf(", OpenGL: %s -- %s -- %s", 1.198 + mGLStrings->Vendor().get(), 1.199 + mGLStrings->Renderer().get(), 1.200 + mGLStrings->Version().get()); 1.201 + 1.202 + AddCrashReportAnnotations(); 1.203 + 1.204 + mInitialized = true; 1.205 +} 1.206 + 1.207 +/* readonly attribute DOMString adapterDescription; */ 1.208 +NS_IMETHODIMP 1.209 +GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription) 1.210 +{ 1.211 + EnsureInitialized(); 1.212 + aAdapterDescription = NS_ConvertASCIItoUTF16(mAdapterDescription); 1.213 + return NS_OK; 1.214 +} 1.215 + 1.216 +/* readonly attribute DOMString adapterDescription2; */ 1.217 +NS_IMETHODIMP 1.218 +GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription) 1.219 +{ 1.220 + EnsureInitialized(); 1.221 + return NS_ERROR_FAILURE; 1.222 +} 1.223 + 1.224 +/* readonly attribute DOMString adapterRAM; */ 1.225 +NS_IMETHODIMP 1.226 +GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM) 1.227 +{ 1.228 + EnsureInitialized(); 1.229 + aAdapterRAM.AssignLiteral(""); 1.230 + return NS_OK; 1.231 +} 1.232 + 1.233 +/* readonly attribute DOMString adapterRAM2; */ 1.234 +NS_IMETHODIMP 1.235 +GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM) 1.236 +{ 1.237 + EnsureInitialized(); 1.238 + return NS_ERROR_FAILURE; 1.239 +} 1.240 + 1.241 +/* readonly attribute DOMString adapterDriver; */ 1.242 +NS_IMETHODIMP 1.243 +GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver) 1.244 +{ 1.245 + EnsureInitialized(); 1.246 + aAdapterDriver.AssignLiteral(""); 1.247 + return NS_OK; 1.248 +} 1.249 + 1.250 +/* readonly attribute DOMString adapterDriver2; */ 1.251 +NS_IMETHODIMP 1.252 +GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver) 1.253 +{ 1.254 + EnsureInitialized(); 1.255 + return NS_ERROR_FAILURE; 1.256 +} 1.257 + 1.258 +/* readonly attribute DOMString adapterDriverVersion; */ 1.259 +NS_IMETHODIMP 1.260 +GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion) 1.261 +{ 1.262 + EnsureInitialized(); 1.263 + aAdapterDriverVersion = NS_ConvertASCIItoUTF16(mGLStrings->Version()); 1.264 + return NS_OK; 1.265 +} 1.266 + 1.267 +/* readonly attribute DOMString adapterDriverVersion2; */ 1.268 +NS_IMETHODIMP 1.269 +GfxInfo::GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion) 1.270 +{ 1.271 + EnsureInitialized(); 1.272 + return NS_ERROR_FAILURE; 1.273 +} 1.274 + 1.275 +/* readonly attribute DOMString adapterDriverDate; */ 1.276 +NS_IMETHODIMP 1.277 +GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate) 1.278 +{ 1.279 + EnsureInitialized(); 1.280 + aAdapterDriverDate.AssignLiteral(""); 1.281 + return NS_OK; 1.282 +} 1.283 + 1.284 +/* readonly attribute DOMString adapterDriverDate2; */ 1.285 +NS_IMETHODIMP 1.286 +GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) 1.287 +{ 1.288 + EnsureInitialized(); 1.289 + return NS_ERROR_FAILURE; 1.290 +} 1.291 + 1.292 +/* readonly attribute DOMString adapterVendorID; */ 1.293 +NS_IMETHODIMP 1.294 +GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) 1.295 +{ 1.296 + EnsureInitialized(); 1.297 + aAdapterVendorID = NS_ConvertASCIItoUTF16(mGLStrings->Vendor()); 1.298 + return NS_OK; 1.299 +} 1.300 + 1.301 +/* readonly attribute DOMString adapterVendorID2; */ 1.302 +NS_IMETHODIMP 1.303 +GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) 1.304 +{ 1.305 + EnsureInitialized(); 1.306 + return NS_ERROR_FAILURE; 1.307 +} 1.308 + 1.309 +/* readonly attribute DOMString adapterDeviceID; */ 1.310 +NS_IMETHODIMP 1.311 +GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) 1.312 +{ 1.313 + EnsureInitialized(); 1.314 + aAdapterDeviceID = NS_ConvertASCIItoUTF16(mGLStrings->Renderer()); 1.315 + return NS_OK; 1.316 +} 1.317 + 1.318 +/* readonly attribute DOMString adapterDeviceID2; */ 1.319 +NS_IMETHODIMP 1.320 +GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID) 1.321 +{ 1.322 + EnsureInitialized(); 1.323 + return NS_ERROR_FAILURE; 1.324 +} 1.325 + 1.326 +/* readonly attribute boolean isGPU2Active; */ 1.327 +NS_IMETHODIMP 1.328 +GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) 1.329 +{ 1.330 + EnsureInitialized(); 1.331 + return NS_ERROR_FAILURE; 1.332 +} 1.333 + 1.334 +void 1.335 +GfxInfo::AddCrashReportAnnotations() 1.336 +{ 1.337 +#if defined(MOZ_CRASHREPORTER) 1.338 + CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), 1.339 + mGLStrings->Vendor()); 1.340 + CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), 1.341 + mGLStrings->Renderer()); 1.342 + 1.343 + /* Add an App Note for now so that we get the data immediately. These 1.344 + * can go away after we store the above in the socorro db */ 1.345 + nsAutoCString note; 1.346 + note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get()); 1.347 + 1.348 + CrashReporter::AppendAppNotesToCrashReport(note); 1.349 +#endif 1.350 +} 1.351 + 1.352 +const nsTArray<GfxDriverInfo>& 1.353 +GfxInfo::GetGfxDriverInfo() 1.354 +{ 1.355 + if (mDriverInfo->IsEmpty()) { 1.356 + APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, 1.357 + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices, 1.358 + nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_NO_INFO, 1.359 + DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions ); 1.360 + } 1.361 + 1.362 + return *mDriverInfo; 1.363 +} 1.364 + 1.365 +nsresult 1.366 +GfxInfo::GetFeatureStatusImpl(int32_t aFeature, 1.367 + int32_t *aStatus, 1.368 + nsAString & aSuggestedDriverVersion, 1.369 + const nsTArray<GfxDriverInfo>& aDriverInfo, 1.370 + OperatingSystem* aOS /* = nullptr */) 1.371 +{ 1.372 + NS_ENSURE_ARG_POINTER(aStatus); 1.373 + aSuggestedDriverVersion.SetIsVoid(true); 1.374 + *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; 1.375 + OperatingSystem os = mOS; 1.376 + if (aOS) 1.377 + *aOS = os; 1.378 + 1.379 + // OpenGL layers are never blacklisted on Android. 1.380 + // This early return is so we avoid potentially slow 1.381 + // GLStrings initialization on startup when we initialize GL layers. 1.382 + if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) { 1.383 + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; 1.384 + return NS_OK; 1.385 + } 1.386 + 1.387 + EnsureInitialized(); 1.388 + 1.389 + if (mGLStrings->Vendor().IsEmpty() || mGLStrings->Renderer().IsEmpty()) { 1.390 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.391 + return NS_OK; 1.392 + } 1.393 + 1.394 + // Don't evaluate special cases when evaluating the downloaded blocklist. 1.395 + if (aDriverInfo.IsEmpty()) { 1.396 + if (aFeature == FEATURE_WEBGL_OPENGL) { 1.397 + if (mGLStrings->Renderer().Find("Adreno 200") != -1 || 1.398 + mGLStrings->Renderer().Find("Adreno 205") != -1) 1.399 + { 1.400 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.401 + return NS_OK; 1.402 + } 1.403 + 1.404 + if (mHardware.Equals(NS_LITERAL_STRING("ville"))) { 1.405 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.406 + return NS_OK; 1.407 + } 1.408 + } 1.409 + 1.410 + if (aFeature == FEATURE_STAGEFRIGHT) { 1.411 + NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer); 1.412 + NS_LossyConvertUTF16toASCII cModel(mModel); 1.413 + NS_LossyConvertUTF16toASCII cHardware(mHardware); 1.414 + 1.415 + if (cHardware.Equals("antares") || 1.416 + cHardware.Equals("harmony") || 1.417 + cHardware.Equals("picasso") || 1.418 + cHardware.Equals("picasso_e") || 1.419 + cHardware.Equals("ventana") || 1.420 + cHardware.Equals("rk30board")) 1.421 + { 1.422 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.423 + return NS_OK; 1.424 + } 1.425 + 1.426 + if (CompareVersions(mOSVersion.get(), "2.2.0") >= 0 && 1.427 + CompareVersions(mOSVersion.get(), "2.3.0") < 0) 1.428 + { 1.429 + // Froyo LG devices are whitelisted. 1.430 + // All other Froyo 1.431 + bool isWhitelisted = 1.432 + cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator()); 1.433 + 1.434 + if (!isWhitelisted) { 1.435 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.436 + return NS_OK; 1.437 + } 1.438 + } 1.439 + else if (CompareVersions(mOSVersion.get(), "2.3.0") >= 0 && 1.440 + CompareVersions(mOSVersion.get(), "2.4.0") < 0) 1.441 + { 1.442 + // Gingerbread HTC devices are whitelisted. 1.443 + // Gingerbread Samsung devices are whitelisted except for: 1.444 + // Samsung devices identified in Bug 847837 1.445 + // Gingerbread Sony devices are whitelisted. 1.446 + // All other Gingerbread devices are blacklisted. 1.447 + bool isWhitelisted = 1.448 + cManufacturer.Equals("htc", nsCaseInsensitiveCStringComparator()) || 1.449 + (cManufacturer.Find("sony", true) != -1) || 1.450 + cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()); 1.451 + 1.452 + if (cModel.Equals("GT-I8160", nsCaseInsensitiveCStringComparator()) || 1.453 + cModel.Equals("GT-I8160L", nsCaseInsensitiveCStringComparator()) || 1.454 + cModel.Equals("GT-I8530", nsCaseInsensitiveCStringComparator()) || 1.455 + cModel.Equals("GT-I9070", nsCaseInsensitiveCStringComparator()) || 1.456 + cModel.Equals("GT-I9070P", nsCaseInsensitiveCStringComparator()) || 1.457 + cModel.Equals("GT-I8160P", nsCaseInsensitiveCStringComparator()) || 1.458 + cModel.Equals("GT-S7500", nsCaseInsensitiveCStringComparator()) || 1.459 + cModel.Equals("GT-S7500T", nsCaseInsensitiveCStringComparator()) || 1.460 + cModel.Equals("GT-S7500L", nsCaseInsensitiveCStringComparator()) || 1.461 + cModel.Equals("GT-S6500T", nsCaseInsensitiveCStringComparator()) || 1.462 + cHardware.Equals("smdkc110", nsCaseInsensitiveCStringComparator()) || 1.463 + cHardware.Equals("smdkc210", nsCaseInsensitiveCStringComparator()) || 1.464 + cHardware.Equals("herring", nsCaseInsensitiveCStringComparator()) || 1.465 + cHardware.Equals("shw-m110s", nsCaseInsensitiveCStringComparator()) || 1.466 + cHardware.Equals("shw-m180s", nsCaseInsensitiveCStringComparator()) || 1.467 + cHardware.Equals("n1", nsCaseInsensitiveCStringComparator()) || 1.468 + cHardware.Equals("latona", nsCaseInsensitiveCStringComparator()) || 1.469 + cHardware.Equals("aalto", nsCaseInsensitiveCStringComparator()) || 1.470 + cHardware.Equals("atlas", nsCaseInsensitiveCStringComparator()) || 1.471 + cHardware.Equals("qcom", nsCaseInsensitiveCStringComparator())) 1.472 + { 1.473 + isWhitelisted = false; 1.474 + } 1.475 + 1.476 + if (!isWhitelisted) { 1.477 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.478 + return NS_OK; 1.479 + } 1.480 + } 1.481 + else if (CompareVersions(mOSVersion.get(), "3.0.0") >= 0 && 1.482 + CompareVersions(mOSVersion.get(), "4.0.0") < 0) 1.483 + { 1.484 + // Honeycomb Samsung devices are whitelisted. 1.485 + // All other Honeycomb devices are blacklisted. 1.486 + bool isWhitelisted = 1.487 + cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()); 1.488 + 1.489 + if (!isWhitelisted) { 1.490 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.491 + return NS_OK; 1.492 + } 1.493 + } 1.494 + else if (CompareVersions(mOSVersion.get(), "4.0.0") < 0) 1.495 + { 1.496 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION; 1.497 + return NS_OK; 1.498 + } 1.499 + else if (CompareVersions(mOSVersion.get(), "4.1.0") < 0) 1.500 + { 1.501 + // Whitelist: 1.502 + // All Samsung ICS devices, except for: 1.503 + // Samsung SGH-I717 (Bug 845729) 1.504 + // Samsung SGH-I727 (Bug 845729) 1.505 + // Samsung SGH-I757 (Bug 845729) 1.506 + // All Galaxy nexus ICS devices 1.507 + // Sony Xperia Ion (LT28) ICS devices 1.508 + bool isWhitelisted = 1.509 + cModel.Equals("LT28h", nsCaseInsensitiveCStringComparator()) || 1.510 + cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) || 1.511 + cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon 1.512 + 1.513 + if (cModel.Find("SGH-I717", true) != -1 || 1.514 + cModel.Find("SGH-I727", true) != -1 || 1.515 + cModel.Find("SGH-I757", true) != -1) 1.516 + { 1.517 + isWhitelisted = false; 1.518 + } 1.519 + 1.520 + if (!isWhitelisted) { 1.521 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.522 + return NS_OK; 1.523 + } 1.524 + } 1.525 + else if (CompareVersions(mOSVersion.get(), "4.2.0") < 0) 1.526 + { 1.527 + // Whitelist: 1.528 + // All JB phones except for those in blocklist below 1.529 + // Blocklist: 1.530 + // Samsung devices from bug 812881 and 853522. 1.531 + // Motorola XT890 from bug 882342. 1.532 + bool isBlocklisted = 1.533 + cModel.Find("GT-P3100", true) != -1 || 1.534 + cModel.Find("GT-P3110", true) != -1 || 1.535 + cModel.Find("GT-P3113", true) != -1 || 1.536 + cModel.Find("GT-P5100", true) != -1 || 1.537 + cModel.Find("GT-P5110", true) != -1 || 1.538 + cModel.Find("GT-P5113", true) != -1 || 1.539 + cModel.Find("XT890", true) != -1; 1.540 + 1.541 + if (isBlocklisted) { 1.542 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.543 + return NS_OK; 1.544 + } 1.545 + } 1.546 + else if (CompareVersions(mOSVersion.get(), "4.3.0") < 0) 1.547 + { 1.548 + // Blocklist all Sony devices 1.549 + if (cManufacturer.Find("Sony", true) != -1) { 1.550 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.551 + return NS_OK; 1.552 + } 1.553 + } 1.554 + } 1.555 + 1.556 + if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION) { 1.557 + NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer); 1.558 + NS_LossyConvertUTF16toASCII cModel(mModel); 1.559 + NS_LossyConvertUTF16toASCII cHardware(mHardware); 1.560 + 1.561 + if (cHardware.Equals("hammerhead") && 1.562 + CompareVersions(mOSVersion.get(), "4.4.2") >= 0 && 1.563 + cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator()) && 1.564 + cModel.Equals("nexus 5", nsCaseInsensitiveCStringComparator())) { 1.565 + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; 1.566 + return NS_OK; 1.567 + } else { 1.568 + // Blocklist all other devices except Nexus 5 which VP8 hardware acceleration is supported 1.569 + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; 1.570 + return NS_OK; 1.571 + } 1.572 + } 1.573 + } 1.574 + 1.575 + return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); 1.576 +} 1.577 + 1.578 +#ifdef DEBUG 1.579 + 1.580 +// Implement nsIGfxInfoDebug 1.581 + 1.582 +/* void spoofVendorID (in DOMString aVendorID); */ 1.583 +NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) 1.584 +{ 1.585 + EnsureInitialized(); 1.586 + mGLStrings->SpoofVendor(NS_LossyConvertUTF16toASCII(aVendorID)); 1.587 + return NS_OK; 1.588 +} 1.589 + 1.590 +/* void spoofDeviceID (in unsigned long aDeviceID); */ 1.591 +NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) 1.592 +{ 1.593 + EnsureInitialized(); 1.594 + mGLStrings->SpoofRenderer(NS_LossyConvertUTF16toASCII(aDeviceID)); 1.595 + return NS_OK; 1.596 +} 1.597 + 1.598 +/* void spoofDriverVersion (in DOMString aDriverVersion); */ 1.599 +NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion) 1.600 +{ 1.601 + EnsureInitialized(); 1.602 + mGLStrings->SpoofVersion(NS_LossyConvertUTF16toASCII(aDriverVersion)); 1.603 + return NS_OK; 1.604 +} 1.605 + 1.606 +/* void spoofOSVersion (in unsigned long aVersion); */ 1.607 +NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion) 1.608 +{ 1.609 + EnsureInitialized(); 1.610 + mOSVersion = aVersion; 1.611 + return NS_OK; 1.612 +} 1.613 + 1.614 +#endif 1.615 + 1.616 +nsString GfxInfo::Model() 1.617 +{ 1.618 + EnsureInitialized(); 1.619 + return mModel; 1.620 +} 1.621 + 1.622 +nsString GfxInfo::Hardware() 1.623 +{ 1.624 + EnsureInitialized(); 1.625 + return mHardware; 1.626 +} 1.627 + 1.628 +nsString GfxInfo::Product() 1.629 +{ 1.630 + EnsureInitialized(); 1.631 + return mProduct; 1.632 +} 1.633 + 1.634 +nsString GfxInfo::Manufacturer() 1.635 +{ 1.636 + EnsureInitialized(); 1.637 + return mManufacturer; 1.638 +} 1.639 + 1.640 +uint32_t GfxInfo::OperatingSystemVersion() 1.641 +{ 1.642 + EnsureInitialized(); 1.643 + return mOSVersionInteger; 1.644 +} 1.645 + 1.646 +} 1.647 +}