widget/android/GfxInfo.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "GfxInfo.h"
michael@0 7 #include "GLContext.h"
michael@0 8 #include "GLContextProvider.h"
michael@0 9 #include "nsUnicharUtils.h"
michael@0 10 #include "prenv.h"
michael@0 11 #include "prprf.h"
michael@0 12 #include "nsHashKeys.h"
michael@0 13 #include "nsVersionComparator.h"
michael@0 14 #include "AndroidBridge.h"
michael@0 15 #include "nsIWindowWatcher.h"
michael@0 16 #include "nsServiceManagerUtils.h"
michael@0 17
michael@0 18 #if defined(MOZ_CRASHREPORTER)
michael@0 19 #include "nsExceptionHandler.h"
michael@0 20 #include "nsICrashReporter.h"
michael@0 21 #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
michael@0 22 #endif
michael@0 23
michael@0 24 namespace mozilla {
michael@0 25 namespace widget {
michael@0 26
michael@0 27 class GfxInfo::GLStrings
michael@0 28 {
michael@0 29 nsCString mVendor;
michael@0 30 nsCString mRenderer;
michael@0 31 nsCString mVersion;
michael@0 32 bool mReady;
michael@0 33
michael@0 34 public:
michael@0 35 GLStrings()
michael@0 36 : mReady(false)
michael@0 37 {}
michael@0 38
michael@0 39 const nsCString& Vendor() {
michael@0 40 EnsureInitialized();
michael@0 41 return mVendor;
michael@0 42 }
michael@0 43
michael@0 44 void SpoofVendor(const nsCString& s) {
michael@0 45 EnsureInitialized();
michael@0 46 mVendor = s;
michael@0 47 }
michael@0 48
michael@0 49 const nsCString& Renderer() {
michael@0 50 EnsureInitialized();
michael@0 51 return mRenderer;
michael@0 52 }
michael@0 53
michael@0 54 void SpoofRenderer(const nsCString& s) {
michael@0 55 EnsureInitialized();
michael@0 56 mRenderer = s;
michael@0 57 }
michael@0 58
michael@0 59 const nsCString& Version() {
michael@0 60 EnsureInitialized();
michael@0 61 return mVersion;
michael@0 62 }
michael@0 63
michael@0 64 void SpoofVersion(const nsCString& s) {
michael@0 65 EnsureInitialized();
michael@0 66 mVersion = s;
michael@0 67 }
michael@0 68
michael@0 69 void EnsureInitialized() {
michael@0 70 if (mReady) {
michael@0 71 return;
michael@0 72 }
michael@0 73
michael@0 74 nsRefPtr<gl::GLContext> gl = gl::GLContextProvider::CreateOffscreen(
michael@0 75 gfxIntSize(16, 16),
michael@0 76 gfx::SurfaceCaps::ForRGB());
michael@0 77
michael@0 78 if (!gl) {
michael@0 79 // Setting mReady to true here means that we won't retry. Everything will
michael@0 80 // remain blacklisted forever. Ideally, we would like to update that once
michael@0 81 // any GLContext is successfully created, like the compositor's GLContext.
michael@0 82 mReady = true;
michael@0 83 return;
michael@0 84 }
michael@0 85
michael@0 86 gl->MakeCurrent();
michael@0 87
michael@0 88 const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR");
michael@0 89 if (spoofedVendor)
michael@0 90 mVendor.Assign(spoofedVendor);
michael@0 91 else
michael@0 92 mVendor.Assign((const char*)gl->fGetString(LOCAL_GL_VENDOR));
michael@0 93 const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER");
michael@0 94 if (spoofedRenderer)
michael@0 95 mRenderer.Assign(spoofedRenderer);
michael@0 96 else
michael@0 97 mRenderer.Assign((const char*)gl->fGetString(LOCAL_GL_RENDERER));
michael@0 98 const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION");
michael@0 99 if (spoofedVersion)
michael@0 100 mVersion.Assign(spoofedVersion);
michael@0 101 else
michael@0 102 mVersion.Assign((const char*)gl->fGetString(LOCAL_GL_VERSION));
michael@0 103
michael@0 104 mReady = true;
michael@0 105 }
michael@0 106 };
michael@0 107
michael@0 108 #ifdef DEBUG
michael@0 109 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
michael@0 110 #endif
michael@0 111
michael@0 112 GfxInfo::GfxInfo()
michael@0 113 : mInitialized(false)
michael@0 114 , mGLStrings(new GLStrings)
michael@0 115 {
michael@0 116 }
michael@0 117
michael@0 118 /* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization
michael@0 119 * has occurred because they depend on it for information. (See bug 591561) */
michael@0 120 nsresult
michael@0 121 GfxInfo::GetD2DEnabled(bool *aEnabled)
michael@0 122 {
michael@0 123 return NS_ERROR_FAILURE;
michael@0 124 }
michael@0 125
michael@0 126 nsresult
michael@0 127 GfxInfo::GetDWriteEnabled(bool *aEnabled)
michael@0 128 {
michael@0 129 return NS_ERROR_FAILURE;
michael@0 130 }
michael@0 131
michael@0 132 /* readonly attribute DOMString DWriteVersion; */
michael@0 133 NS_IMETHODIMP
michael@0 134 GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
michael@0 135 {
michael@0 136 return NS_ERROR_FAILURE;
michael@0 137 }
michael@0 138
michael@0 139 /* readonly attribute DOMString cleartypeParameters; */
michael@0 140 NS_IMETHODIMP
michael@0 141 GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
michael@0 142 {
michael@0 143 return NS_ERROR_FAILURE;
michael@0 144 }
michael@0 145
michael@0 146 void
michael@0 147 GfxInfo::EnsureInitialized()
michael@0 148 {
michael@0 149 if (mInitialized)
michael@0 150 return;
michael@0 151
michael@0 152 mGLStrings->EnsureInitialized();
michael@0 153
michael@0 154 MOZ_ASSERT(mozilla::AndroidBridge::Bridge());
michael@0 155
michael@0 156 if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", mModel)) {
michael@0 157 mAdapterDescription.AppendPrintf("Model: %s", NS_LossyConvertUTF16toASCII(mModel).get());
michael@0 158 }
michael@0 159
michael@0 160 if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", mProduct)) {
michael@0 161 mAdapterDescription.AppendPrintf(", Product: %s", NS_LossyConvertUTF16toASCII(mProduct).get());
michael@0 162 }
michael@0 163
michael@0 164 if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", mManufacturer)) {
michael@0 165 mAdapterDescription.AppendPrintf(", Manufacturer: %s", NS_LossyConvertUTF16toASCII(mManufacturer).get());
michael@0 166 }
michael@0 167
michael@0 168 int32_t sdkVersion;
michael@0 169 if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &sdkVersion))
michael@0 170 sdkVersion = 0;
michael@0 171
michael@0 172 // the HARDWARE field isn't available on Android SDK < 8
michael@0 173 if (sdkVersion >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", mHardware)) {
michael@0 174 mAdapterDescription.AppendPrintf(", Hardware: %s", NS_LossyConvertUTF16toASCII(mHardware).get());
michael@0 175 }
michael@0 176
michael@0 177 nsString release;
michael@0 178 mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", release);
michael@0 179 mOSVersion = NS_LossyConvertUTF16toASCII(release);
michael@0 180
michael@0 181 mOSVersionInteger = 0;
michael@0 182 char a[5], b[5], c[5], d[5];
michael@0 183 SplitDriverVersion(mOSVersion.get(), a, b, c, d);
michael@0 184 uint8_t na = atoi(a);
michael@0 185 uint8_t nb = atoi(b);
michael@0 186 uint8_t nc = atoi(c);
michael@0 187 uint8_t nd = atoi(d);
michael@0 188
michael@0 189 mOSVersionInteger = (uint32_t(na) << 24) |
michael@0 190 (uint32_t(nb) << 16) |
michael@0 191 (uint32_t(nc) << 8) |
michael@0 192 uint32_t(nd);
michael@0 193
michael@0 194 mAdapterDescription.AppendPrintf(", OpenGL: %s -- %s -- %s",
michael@0 195 mGLStrings->Vendor().get(),
michael@0 196 mGLStrings->Renderer().get(),
michael@0 197 mGLStrings->Version().get());
michael@0 198
michael@0 199 AddCrashReportAnnotations();
michael@0 200
michael@0 201 mInitialized = true;
michael@0 202 }
michael@0 203
michael@0 204 /* readonly attribute DOMString adapterDescription; */
michael@0 205 NS_IMETHODIMP
michael@0 206 GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription)
michael@0 207 {
michael@0 208 EnsureInitialized();
michael@0 209 aAdapterDescription = NS_ConvertASCIItoUTF16(mAdapterDescription);
michael@0 210 return NS_OK;
michael@0 211 }
michael@0 212
michael@0 213 /* readonly attribute DOMString adapterDescription2; */
michael@0 214 NS_IMETHODIMP
michael@0 215 GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription)
michael@0 216 {
michael@0 217 EnsureInitialized();
michael@0 218 return NS_ERROR_FAILURE;
michael@0 219 }
michael@0 220
michael@0 221 /* readonly attribute DOMString adapterRAM; */
michael@0 222 NS_IMETHODIMP
michael@0 223 GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM)
michael@0 224 {
michael@0 225 EnsureInitialized();
michael@0 226 aAdapterRAM.AssignLiteral("");
michael@0 227 return NS_OK;
michael@0 228 }
michael@0 229
michael@0 230 /* readonly attribute DOMString adapterRAM2; */
michael@0 231 NS_IMETHODIMP
michael@0 232 GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM)
michael@0 233 {
michael@0 234 EnsureInitialized();
michael@0 235 return NS_ERROR_FAILURE;
michael@0 236 }
michael@0 237
michael@0 238 /* readonly attribute DOMString adapterDriver; */
michael@0 239 NS_IMETHODIMP
michael@0 240 GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver)
michael@0 241 {
michael@0 242 EnsureInitialized();
michael@0 243 aAdapterDriver.AssignLiteral("");
michael@0 244 return NS_OK;
michael@0 245 }
michael@0 246
michael@0 247 /* readonly attribute DOMString adapterDriver2; */
michael@0 248 NS_IMETHODIMP
michael@0 249 GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver)
michael@0 250 {
michael@0 251 EnsureInitialized();
michael@0 252 return NS_ERROR_FAILURE;
michael@0 253 }
michael@0 254
michael@0 255 /* readonly attribute DOMString adapterDriverVersion; */
michael@0 256 NS_IMETHODIMP
michael@0 257 GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion)
michael@0 258 {
michael@0 259 EnsureInitialized();
michael@0 260 aAdapterDriverVersion = NS_ConvertASCIItoUTF16(mGLStrings->Version());
michael@0 261 return NS_OK;
michael@0 262 }
michael@0 263
michael@0 264 /* readonly attribute DOMString adapterDriverVersion2; */
michael@0 265 NS_IMETHODIMP
michael@0 266 GfxInfo::GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion)
michael@0 267 {
michael@0 268 EnsureInitialized();
michael@0 269 return NS_ERROR_FAILURE;
michael@0 270 }
michael@0 271
michael@0 272 /* readonly attribute DOMString adapterDriverDate; */
michael@0 273 NS_IMETHODIMP
michael@0 274 GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate)
michael@0 275 {
michael@0 276 EnsureInitialized();
michael@0 277 aAdapterDriverDate.AssignLiteral("");
michael@0 278 return NS_OK;
michael@0 279 }
michael@0 280
michael@0 281 /* readonly attribute DOMString adapterDriverDate2; */
michael@0 282 NS_IMETHODIMP
michael@0 283 GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate)
michael@0 284 {
michael@0 285 EnsureInitialized();
michael@0 286 return NS_ERROR_FAILURE;
michael@0 287 }
michael@0 288
michael@0 289 /* readonly attribute DOMString adapterVendorID; */
michael@0 290 NS_IMETHODIMP
michael@0 291 GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID)
michael@0 292 {
michael@0 293 EnsureInitialized();
michael@0 294 aAdapterVendorID = NS_ConvertASCIItoUTF16(mGLStrings->Vendor());
michael@0 295 return NS_OK;
michael@0 296 }
michael@0 297
michael@0 298 /* readonly attribute DOMString adapterVendorID2; */
michael@0 299 NS_IMETHODIMP
michael@0 300 GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID)
michael@0 301 {
michael@0 302 EnsureInitialized();
michael@0 303 return NS_ERROR_FAILURE;
michael@0 304 }
michael@0 305
michael@0 306 /* readonly attribute DOMString adapterDeviceID; */
michael@0 307 NS_IMETHODIMP
michael@0 308 GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID)
michael@0 309 {
michael@0 310 EnsureInitialized();
michael@0 311 aAdapterDeviceID = NS_ConvertASCIItoUTF16(mGLStrings->Renderer());
michael@0 312 return NS_OK;
michael@0 313 }
michael@0 314
michael@0 315 /* readonly attribute DOMString adapterDeviceID2; */
michael@0 316 NS_IMETHODIMP
michael@0 317 GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID)
michael@0 318 {
michael@0 319 EnsureInitialized();
michael@0 320 return NS_ERROR_FAILURE;
michael@0 321 }
michael@0 322
michael@0 323 /* readonly attribute boolean isGPU2Active; */
michael@0 324 NS_IMETHODIMP
michael@0 325 GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
michael@0 326 {
michael@0 327 EnsureInitialized();
michael@0 328 return NS_ERROR_FAILURE;
michael@0 329 }
michael@0 330
michael@0 331 void
michael@0 332 GfxInfo::AddCrashReportAnnotations()
michael@0 333 {
michael@0 334 #if defined(MOZ_CRASHREPORTER)
michael@0 335 CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"),
michael@0 336 mGLStrings->Vendor());
michael@0 337 CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"),
michael@0 338 mGLStrings->Renderer());
michael@0 339
michael@0 340 /* Add an App Note for now so that we get the data immediately. These
michael@0 341 * can go away after we store the above in the socorro db */
michael@0 342 nsAutoCString note;
michael@0 343 note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get());
michael@0 344
michael@0 345 CrashReporter::AppendAppNotesToCrashReport(note);
michael@0 346 #endif
michael@0 347 }
michael@0 348
michael@0 349 const nsTArray<GfxDriverInfo>&
michael@0 350 GfxInfo::GetGfxDriverInfo()
michael@0 351 {
michael@0 352 if (mDriverInfo->IsEmpty()) {
michael@0 353 APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL,
michael@0 354 (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices,
michael@0 355 nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_NO_INFO,
michael@0 356 DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions );
michael@0 357 }
michael@0 358
michael@0 359 return *mDriverInfo;
michael@0 360 }
michael@0 361
michael@0 362 nsresult
michael@0 363 GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
michael@0 364 int32_t *aStatus,
michael@0 365 nsAString & aSuggestedDriverVersion,
michael@0 366 const nsTArray<GfxDriverInfo>& aDriverInfo,
michael@0 367 OperatingSystem* aOS /* = nullptr */)
michael@0 368 {
michael@0 369 NS_ENSURE_ARG_POINTER(aStatus);
michael@0 370 aSuggestedDriverVersion.SetIsVoid(true);
michael@0 371 *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
michael@0 372 OperatingSystem os = mOS;
michael@0 373 if (aOS)
michael@0 374 *aOS = os;
michael@0 375
michael@0 376 // OpenGL layers are never blacklisted on Android.
michael@0 377 // This early return is so we avoid potentially slow
michael@0 378 // GLStrings initialization on startup when we initialize GL layers.
michael@0 379 if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) {
michael@0 380 *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
michael@0 381 return NS_OK;
michael@0 382 }
michael@0 383
michael@0 384 EnsureInitialized();
michael@0 385
michael@0 386 if (mGLStrings->Vendor().IsEmpty() || mGLStrings->Renderer().IsEmpty()) {
michael@0 387 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 388 return NS_OK;
michael@0 389 }
michael@0 390
michael@0 391 // Don't evaluate special cases when evaluating the downloaded blocklist.
michael@0 392 if (aDriverInfo.IsEmpty()) {
michael@0 393 if (aFeature == FEATURE_WEBGL_OPENGL) {
michael@0 394 if (mGLStrings->Renderer().Find("Adreno 200") != -1 ||
michael@0 395 mGLStrings->Renderer().Find("Adreno 205") != -1)
michael@0 396 {
michael@0 397 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 398 return NS_OK;
michael@0 399 }
michael@0 400
michael@0 401 if (mHardware.Equals(NS_LITERAL_STRING("ville"))) {
michael@0 402 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 403 return NS_OK;
michael@0 404 }
michael@0 405 }
michael@0 406
michael@0 407 if (aFeature == FEATURE_STAGEFRIGHT) {
michael@0 408 NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
michael@0 409 NS_LossyConvertUTF16toASCII cModel(mModel);
michael@0 410 NS_LossyConvertUTF16toASCII cHardware(mHardware);
michael@0 411
michael@0 412 if (cHardware.Equals("antares") ||
michael@0 413 cHardware.Equals("harmony") ||
michael@0 414 cHardware.Equals("picasso") ||
michael@0 415 cHardware.Equals("picasso_e") ||
michael@0 416 cHardware.Equals("ventana") ||
michael@0 417 cHardware.Equals("rk30board"))
michael@0 418 {
michael@0 419 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 420 return NS_OK;
michael@0 421 }
michael@0 422
michael@0 423 if (CompareVersions(mOSVersion.get(), "2.2.0") >= 0 &&
michael@0 424 CompareVersions(mOSVersion.get(), "2.3.0") < 0)
michael@0 425 {
michael@0 426 // Froyo LG devices are whitelisted.
michael@0 427 // All other Froyo
michael@0 428 bool isWhitelisted =
michael@0 429 cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator());
michael@0 430
michael@0 431 if (!isWhitelisted) {
michael@0 432 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 433 return NS_OK;
michael@0 434 }
michael@0 435 }
michael@0 436 else if (CompareVersions(mOSVersion.get(), "2.3.0") >= 0 &&
michael@0 437 CompareVersions(mOSVersion.get(), "2.4.0") < 0)
michael@0 438 {
michael@0 439 // Gingerbread HTC devices are whitelisted.
michael@0 440 // Gingerbread Samsung devices are whitelisted except for:
michael@0 441 // Samsung devices identified in Bug 847837
michael@0 442 // Gingerbread Sony devices are whitelisted.
michael@0 443 // All other Gingerbread devices are blacklisted.
michael@0 444 bool isWhitelisted =
michael@0 445 cManufacturer.Equals("htc", nsCaseInsensitiveCStringComparator()) ||
michael@0 446 (cManufacturer.Find("sony", true) != -1) ||
michael@0 447 cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());
michael@0 448
michael@0 449 if (cModel.Equals("GT-I8160", nsCaseInsensitiveCStringComparator()) ||
michael@0 450 cModel.Equals("GT-I8160L", nsCaseInsensitiveCStringComparator()) ||
michael@0 451 cModel.Equals("GT-I8530", nsCaseInsensitiveCStringComparator()) ||
michael@0 452 cModel.Equals("GT-I9070", nsCaseInsensitiveCStringComparator()) ||
michael@0 453 cModel.Equals("GT-I9070P", nsCaseInsensitiveCStringComparator()) ||
michael@0 454 cModel.Equals("GT-I8160P", nsCaseInsensitiveCStringComparator()) ||
michael@0 455 cModel.Equals("GT-S7500", nsCaseInsensitiveCStringComparator()) ||
michael@0 456 cModel.Equals("GT-S7500T", nsCaseInsensitiveCStringComparator()) ||
michael@0 457 cModel.Equals("GT-S7500L", nsCaseInsensitiveCStringComparator()) ||
michael@0 458 cModel.Equals("GT-S6500T", nsCaseInsensitiveCStringComparator()) ||
michael@0 459 cHardware.Equals("smdkc110", nsCaseInsensitiveCStringComparator()) ||
michael@0 460 cHardware.Equals("smdkc210", nsCaseInsensitiveCStringComparator()) ||
michael@0 461 cHardware.Equals("herring", nsCaseInsensitiveCStringComparator()) ||
michael@0 462 cHardware.Equals("shw-m110s", nsCaseInsensitiveCStringComparator()) ||
michael@0 463 cHardware.Equals("shw-m180s", nsCaseInsensitiveCStringComparator()) ||
michael@0 464 cHardware.Equals("n1", nsCaseInsensitiveCStringComparator()) ||
michael@0 465 cHardware.Equals("latona", nsCaseInsensitiveCStringComparator()) ||
michael@0 466 cHardware.Equals("aalto", nsCaseInsensitiveCStringComparator()) ||
michael@0 467 cHardware.Equals("atlas", nsCaseInsensitiveCStringComparator()) ||
michael@0 468 cHardware.Equals("qcom", nsCaseInsensitiveCStringComparator()))
michael@0 469 {
michael@0 470 isWhitelisted = false;
michael@0 471 }
michael@0 472
michael@0 473 if (!isWhitelisted) {
michael@0 474 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 475 return NS_OK;
michael@0 476 }
michael@0 477 }
michael@0 478 else if (CompareVersions(mOSVersion.get(), "3.0.0") >= 0 &&
michael@0 479 CompareVersions(mOSVersion.get(), "4.0.0") < 0)
michael@0 480 {
michael@0 481 // Honeycomb Samsung devices are whitelisted.
michael@0 482 // All other Honeycomb devices are blacklisted.
michael@0 483 bool isWhitelisted =
michael@0 484 cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());
michael@0 485
michael@0 486 if (!isWhitelisted) {
michael@0 487 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 488 return NS_OK;
michael@0 489 }
michael@0 490 }
michael@0 491 else if (CompareVersions(mOSVersion.get(), "4.0.0") < 0)
michael@0 492 {
michael@0 493 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
michael@0 494 return NS_OK;
michael@0 495 }
michael@0 496 else if (CompareVersions(mOSVersion.get(), "4.1.0") < 0)
michael@0 497 {
michael@0 498 // Whitelist:
michael@0 499 // All Samsung ICS devices, except for:
michael@0 500 // Samsung SGH-I717 (Bug 845729)
michael@0 501 // Samsung SGH-I727 (Bug 845729)
michael@0 502 // Samsung SGH-I757 (Bug 845729)
michael@0 503 // All Galaxy nexus ICS devices
michael@0 504 // Sony Xperia Ion (LT28) ICS devices
michael@0 505 bool isWhitelisted =
michael@0 506 cModel.Equals("LT28h", nsCaseInsensitiveCStringComparator()) ||
michael@0 507 cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) ||
michael@0 508 cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon
michael@0 509
michael@0 510 if (cModel.Find("SGH-I717", true) != -1 ||
michael@0 511 cModel.Find("SGH-I727", true) != -1 ||
michael@0 512 cModel.Find("SGH-I757", true) != -1)
michael@0 513 {
michael@0 514 isWhitelisted = false;
michael@0 515 }
michael@0 516
michael@0 517 if (!isWhitelisted) {
michael@0 518 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 519 return NS_OK;
michael@0 520 }
michael@0 521 }
michael@0 522 else if (CompareVersions(mOSVersion.get(), "4.2.0") < 0)
michael@0 523 {
michael@0 524 // Whitelist:
michael@0 525 // All JB phones except for those in blocklist below
michael@0 526 // Blocklist:
michael@0 527 // Samsung devices from bug 812881 and 853522.
michael@0 528 // Motorola XT890 from bug 882342.
michael@0 529 bool isBlocklisted =
michael@0 530 cModel.Find("GT-P3100", true) != -1 ||
michael@0 531 cModel.Find("GT-P3110", true) != -1 ||
michael@0 532 cModel.Find("GT-P3113", true) != -1 ||
michael@0 533 cModel.Find("GT-P5100", true) != -1 ||
michael@0 534 cModel.Find("GT-P5110", true) != -1 ||
michael@0 535 cModel.Find("GT-P5113", true) != -1 ||
michael@0 536 cModel.Find("XT890", true) != -1;
michael@0 537
michael@0 538 if (isBlocklisted) {
michael@0 539 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 540 return NS_OK;
michael@0 541 }
michael@0 542 }
michael@0 543 else if (CompareVersions(mOSVersion.get(), "4.3.0") < 0)
michael@0 544 {
michael@0 545 // Blocklist all Sony devices
michael@0 546 if (cManufacturer.Find("Sony", true) != -1) {
michael@0 547 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 548 return NS_OK;
michael@0 549 }
michael@0 550 }
michael@0 551 }
michael@0 552
michael@0 553 if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION) {
michael@0 554 NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
michael@0 555 NS_LossyConvertUTF16toASCII cModel(mModel);
michael@0 556 NS_LossyConvertUTF16toASCII cHardware(mHardware);
michael@0 557
michael@0 558 if (cHardware.Equals("hammerhead") &&
michael@0 559 CompareVersions(mOSVersion.get(), "4.4.2") >= 0 &&
michael@0 560 cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator()) &&
michael@0 561 cModel.Equals("nexus 5", nsCaseInsensitiveCStringComparator())) {
michael@0 562 *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
michael@0 563 return NS_OK;
michael@0 564 } else {
michael@0 565 // Blocklist all other devices except Nexus 5 which VP8 hardware acceleration is supported
michael@0 566 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
michael@0 567 return NS_OK;
michael@0 568 }
michael@0 569 }
michael@0 570 }
michael@0 571
michael@0 572 return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
michael@0 573 }
michael@0 574
michael@0 575 #ifdef DEBUG
michael@0 576
michael@0 577 // Implement nsIGfxInfoDebug
michael@0 578
michael@0 579 /* void spoofVendorID (in DOMString aVendorID); */
michael@0 580 NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID)
michael@0 581 {
michael@0 582 EnsureInitialized();
michael@0 583 mGLStrings->SpoofVendor(NS_LossyConvertUTF16toASCII(aVendorID));
michael@0 584 return NS_OK;
michael@0 585 }
michael@0 586
michael@0 587 /* void spoofDeviceID (in unsigned long aDeviceID); */
michael@0 588 NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID)
michael@0 589 {
michael@0 590 EnsureInitialized();
michael@0 591 mGLStrings->SpoofRenderer(NS_LossyConvertUTF16toASCII(aDeviceID));
michael@0 592 return NS_OK;
michael@0 593 }
michael@0 594
michael@0 595 /* void spoofDriverVersion (in DOMString aDriverVersion); */
michael@0 596 NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion)
michael@0 597 {
michael@0 598 EnsureInitialized();
michael@0 599 mGLStrings->SpoofVersion(NS_LossyConvertUTF16toASCII(aDriverVersion));
michael@0 600 return NS_OK;
michael@0 601 }
michael@0 602
michael@0 603 /* void spoofOSVersion (in unsigned long aVersion); */
michael@0 604 NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion)
michael@0 605 {
michael@0 606 EnsureInitialized();
michael@0 607 mOSVersion = aVersion;
michael@0 608 return NS_OK;
michael@0 609 }
michael@0 610
michael@0 611 #endif
michael@0 612
michael@0 613 nsString GfxInfo::Model()
michael@0 614 {
michael@0 615 EnsureInitialized();
michael@0 616 return mModel;
michael@0 617 }
michael@0 618
michael@0 619 nsString GfxInfo::Hardware()
michael@0 620 {
michael@0 621 EnsureInitialized();
michael@0 622 return mHardware;
michael@0 623 }
michael@0 624
michael@0 625 nsString GfxInfo::Product()
michael@0 626 {
michael@0 627 EnsureInitialized();
michael@0 628 return mProduct;
michael@0 629 }
michael@0 630
michael@0 631 nsString GfxInfo::Manufacturer()
michael@0 632 {
michael@0 633 EnsureInitialized();
michael@0 634 return mManufacturer;
michael@0 635 }
michael@0 636
michael@0 637 uint32_t GfxInfo::OperatingSystemVersion()
michael@0 638 {
michael@0 639 EnsureInitialized();
michael@0 640 return mOSVersionInteger;
michael@0 641 }
michael@0 642
michael@0 643 }
michael@0 644 }

mercurial