Exemplo n.º 1
0
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t aFeature, 
                              int32_t *aStatus, 
                              nsAString & aSuggestedDriverVersion,
                              const nsTArray<GfxDriverInfo>& aDriverInfo, 
                              OperatingSystem* aOS /* = nullptr */)
{
  NS_ENSURE_ARG_POINTER(aStatus);
  aSuggestedDriverVersion.SetIsVoid(true);
  *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
  OperatingSystem os = mOS;
  if (aOS)
    *aOS = os;

  EnsureInitializedFromGfxInfoData();

  if (!mError.IsEmpty()) {
    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
    return NS_OK;
  }

  // Don't evaluate special cases when evaluating the downloaded blocklist.
  if (aDriverInfo.IsEmpty()) {
    if (aFeature == FEATURE_WEBGL_OPENGL) {
      if (mRenderer.Find("Adreno 200") != -1 ||
          mRenderer.Find("Adreno 205") != -1)
      {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        return NS_OK;
      }

      if (mHardware.Equals(NS_LITERAL_STRING("ville"))) {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        return NS_OK;
      }
    }

    if (aFeature == FEATURE_STAGEFRIGHT) {
      NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
      NS_LossyConvertUTF16toASCII cModel(mModel);
      if (CompareVersions(mOSVersion.get(), "2.2.0") >= 0 &&
          CompareVersions(mOSVersion.get(), "2.3.0") < 0)
      {
        // Froyo LG devices are whitelisted.
        // All other Froyo
        bool isWhitelisted =
          cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator());

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "2.3.0") >= 0 &&
          CompareVersions(mOSVersion.get(), "2.4.0") < 0)
      {
        // Gingerbread HTC devices are whitelisted.
        // Gingerbread Samsung devices are whitelisted.
        // All other Gingerbread devices are blacklisted.
	bool isWhitelisted =
          cManufacturer.Equals("htc", nsCaseInsensitiveCStringComparator()) ||
          cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "3.0.0") >= 0 &&
          CompareVersions(mOSVersion.get(), "4.0.0") < 0)
      {
        // Honeycomb Samsung devices are whitelisted.
        // All other Honeycomb devices are blacklisted.
	bool isWhitelisted =
          cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "4.0.0") < 0)
      {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
        return NS_OK;
      }
      else if (CompareVersions(mOSVersion.get(), "4.1.0") < 0)
      {
        bool isWhitelisted =
          cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) ||
          cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
    }
  }

  return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
}
Exemplo n.º 2
0
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
                              int32_t *aStatus,
                              nsAString &aSuggestedDriverVersion,
                              const nsTArray<GfxDriverInfo>& aDriverInfo,
                              nsACString &aFailureId,
                              OperatingSystem* aOS /* = nullptr */)
{
  NS_ENSURE_ARG_POINTER(aStatus);
  aSuggestedDriverVersion.SetIsVoid(true);
  *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
  OperatingSystem os = mOS;
  if (aOS)
    *aOS = os;

  // OpenGL layers are never blacklisted on Android.
  // This early return is so we avoid potentially slow
  // GLStrings initialization on startup when we initialize GL layers.
  if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) {
    *aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
    return NS_OK;
  }

  EnsureInitialized();

  if (mGLStrings->Vendor().IsEmpty() || mGLStrings->Renderer().IsEmpty()) {
    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
    return NS_OK;
  }

  // Don't evaluate special cases when evaluating the downloaded blocklist.
  if (aDriverInfo.IsEmpty()) {
    if (aFeature == nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION) {
      if (mSDKVersion < 11) {
        // It's slower than software due to not having a compositing fast path
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
        aFailureId = "FEATURE_FAILURE_CANVAS_2D_SDK";
      } else if (mGLStrings->Renderer().Find("Vivante GC1000") != -1) {
        // Blocklist Vivante GC1000. See bug 1248183.
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        aFailureId = "FEATURE_FAILED_CANVAS_2D_HW";
      } else {
        *aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
      }
      return NS_OK;
    }

    if (aFeature == FEATURE_WEBGL_OPENGL) {
      if (mGLStrings->Renderer().Find("Adreno 200") != -1 ||
          mGLStrings->Renderer().Find("Adreno 205") != -1)
      {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        aFailureId = "FEATURE_FAILURE_ADRENO_20x";
        return NS_OK;
      }

      if (mHardware.EqualsLiteral("ville")) {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        aFailureId = "FEATURE_FAILURE_VILLE";
        return NS_OK;
      }
    }

    if (aFeature == FEATURE_STAGEFRIGHT) {
      NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
      NS_LossyConvertUTF16toASCII cModel(mModel);
      NS_LossyConvertUTF16toASCII cHardware(mHardware);

      if (cHardware.EqualsLiteral("antares") ||
          cHardware.EqualsLiteral("harmony") ||
          cHardware.EqualsLiteral("picasso") ||
          cHardware.EqualsLiteral("picasso_e") ||
          cHardware.EqualsLiteral("ventana") ||
          cHardware.EqualsLiteral("rk30board"))
      {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        aFailureId = "FEATURE_FAILURE_STAGE_HW";
        return NS_OK;
      }

      if (CompareVersions(mOSVersion.get(), "4.1.0") < 0)
      {
        // Whitelist:
        //   All Samsung ICS devices, except for:
        //     Samsung SGH-I717 (Bug 845729)
        //     Samsung SGH-I727 (Bug 845729)
        //     Samsung SGH-I757 (Bug 845729)
        //   All Galaxy nexus ICS devices
        //   Sony Xperia Ion (LT28) ICS devices
        bool isWhitelisted =
          cModel.Equals("LT28h", nsCaseInsensitiveCStringComparator()) ||
          cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) ||
          cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon

        if (cModel.Find("SGH-I717", true) != -1 ||
            cModel.Find("SGH-I727", true) != -1 ||
            cModel.Find("SGH-I757", true) != -1)
        {
          isWhitelisted = false;
        }

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          aFailureId = "FEATURE_FAILURE_4_1_HW";
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "4.2.0") < 0)
      {
        // Whitelist:
        //   All JB phones except for those in blocklist below
        // Blocklist:
        //   Samsung devices from bug 812881 and 853522.
        //   Motorola XT890 from bug 882342.
        bool isBlocklisted =
          cModel.Find("GT-P3100", true) != -1 ||
          cModel.Find("GT-P3110", true) != -1 ||
          cModel.Find("GT-P3113", true) != -1 ||
          cModel.Find("GT-P5100", true) != -1 ||
          cModel.Find("GT-P5110", true) != -1 ||
          cModel.Find("GT-P5113", true) != -1 ||
          cModel.Find("XT890", true) != -1;

        if (isBlocklisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          aFailureId = "FEATURE_FAILURE_4_2_HW";
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "4.3.0") < 0)
      {
        // Blocklist all Sony devices
        if (cManufacturer.Find("Sony", true) != -1) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          aFailureId = "FEATURE_FAILURE_4_3_SONY";
          return NS_OK;
        }
      }
    }

    if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_ENCODE) {
      if (mozilla::AndroidBridge::Bridge()) {
        *aStatus = mozilla::AndroidBridge::Bridge()->GetHWEncoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        aFailureId = "FEATURE_FAILURE_WEBRTC_ENCODE";
        return NS_OK;
      }
    }
    if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_DECODE) {
      if (mozilla::AndroidBridge::Bridge()) {
        *aStatus = mozilla::AndroidBridge::Bridge()->GetHWDecoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        aFailureId = "FEATURE_FAILURE_WEBRTC_DECODE";
        return NS_OK;
      }
    }

    if (aFeature == FEATURE_VP8_HW_DECODE || aFeature == FEATURE_VP9_HW_DECODE) {
      NS_LossyConvertUTF16toASCII model(mModel);
      bool isBlocked =
        // GIFV crash, see bug 1232911.
        model.Equals("GT-N8013", nsCaseInsensitiveCStringComparator());

      if (isBlocked) {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        aFailureId = "FEATURE_FAILURE_VPx";
      } else {
        *aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
      }
      return NS_OK;
    }
  }

  return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aFailureId, &os);
}
Exemplo n.º 3
0
/**
 * Validates a custom content security policy string for use by an add-on.
 * In particular, ensures that:
 *
 *  - Both object-src and script-src directives are present, and meet
 *    the policies required by the CSPValidator class
 *
 *  - The script-src directive includes the source 'self'
 */
NS_IMETHODIMP
AddonContentPolicy::ValidateAddonCSP(const nsAString& aPolicyString,
                                     nsAString& aResult)
{
  nsresult rv;

  // Validate against a randomly-generated extension origin.
  // There is no add-on-specific behavior in the CSP code, beyond the ability
  // for add-ons to specify a custom policy, but the parser requires a valid
  // origin in order to operate correctly.
  nsAutoString url(u"moz-extension://");
  {
    nsCOMPtr<nsIUUIDGenerator> uuidgen = services::GetUUIDGenerator();
    NS_ENSURE_TRUE(uuidgen, NS_ERROR_FAILURE);

    nsID id;
    rv = uuidgen->GenerateUUIDInPlace(&id);
    NS_ENSURE_SUCCESS(rv, rv);

    char idString[NSID_LENGTH];
    id.ToProvidedString(idString);

    MOZ_RELEASE_ASSERT(idString[0] == '{' && idString[NSID_LENGTH - 2] == '}',
                       "UUID generator did not return a valid UUID");

    url.AppendASCII(idString + 1, NSID_LENGTH - 3);
  }


  RefPtr<BasePrincipal> principal =
    BasePrincipal::CreateCodebasePrincipal(NS_ConvertUTF16toUTF8(url));

  nsCOMPtr<nsIContentSecurityPolicy> csp;
  rv = principal->EnsureCSP(nullptr, getter_AddRefs(csp));
  NS_ENSURE_SUCCESS(rv, rv);


  csp->AppendPolicy(aPolicyString, false, false);

  const nsCSPPolicy* policy = csp->GetPolicy(0);
  if (!policy) {
    CSPValidator validator(url, nsIContentSecurityPolicy::SCRIPT_SRC_DIRECTIVE);
    aResult.Assign(validator.GetError());
    return NS_OK;
  }

  bool haveValidDefaultSrc = false;
  {
    CSPDirective directive = nsIContentSecurityPolicy::DEFAULT_SRC_DIRECTIVE;
    CSPValidator validator(url, directive);

    haveValidDefaultSrc = policy->visitDirectiveSrcs(directive, &validator);
  }

  aResult.SetIsVoid(true);
  {
    CSPDirective directive = nsIContentSecurityPolicy::SCRIPT_SRC_DIRECTIVE;
    CSPValidator validator(url, directive, !haveValidDefaultSrc);

    if (!policy->visitDirectiveSrcs(directive, &validator)) {
      aResult.Assign(validator.GetError());
    } else if (!validator.FoundSelf()) {
      validator.FormatError("csp.error.missing-source", NS_LITERAL_STRING("'self'"));
      aResult.Assign(validator.GetError());
    }
  }

  if (aResult.IsVoid()) {
    CSPDirective directive = nsIContentSecurityPolicy::OBJECT_SRC_DIRECTIVE;
    CSPValidator validator(url, directive, !haveValidDefaultSrc);

    if (!policy->visitDirectiveSrcs(directive, &validator)) {
      aResult.Assign(validator.GetError());
    }
  }

  return NS_OK;
}
Exemplo n.º 4
0
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
                              int32_t *aStatus,
                              nsAString & aSuggestedDriverVersion,
                              const nsTArray<GfxDriverInfo>& aDriverInfo,
                              OperatingSystem* aOS /* = nullptr */)
{
    NS_ENSURE_ARG_POINTER(aStatus);
    aSuggestedDriverVersion.SetIsVoid(true);
    *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
    OperatingSystem os = mOS;
    if (aOS)
        *aOS = os;

    // OpenGL layers are never blacklisted on Android.
    // This early return is so we avoid potentially slow
    // GLStrings initialization on startup when we initialize GL layers.
    if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) {
        *aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
        return NS_OK;
    }

    EnsureInitialized();

    if (mGLStrings->Vendor().IsEmpty() || mGLStrings->Renderer().IsEmpty()) {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        return NS_OK;
    }

    // Don't evaluate special cases when evaluating the downloaded blocklist.
    if (aDriverInfo.IsEmpty()) {
        if (aFeature == FEATURE_WEBGL_OPENGL) {
            if (mGLStrings->Renderer().Find("Adreno 200") != -1 ||
                    mGLStrings->Renderer().Find("Adreno 205") != -1)
            {
                *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                return NS_OK;
            }

            if (mHardware.EqualsLiteral("ville")) {
                *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                return NS_OK;
            }
        }

        if (aFeature == FEATURE_STAGEFRIGHT) {
            NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
            NS_LossyConvertUTF16toASCII cModel(mModel);
            NS_LossyConvertUTF16toASCII cHardware(mHardware);

            if (cHardware.EqualsLiteral("antares") ||
                    cHardware.EqualsLiteral("harmony") ||
                    cHardware.EqualsLiteral("picasso") ||
                    cHardware.EqualsLiteral("picasso_e") ||
                    cHardware.EqualsLiteral("ventana") ||
                    cHardware.EqualsLiteral("rk30board"))
            {
                *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                return NS_OK;
            }

            if (CompareVersions(mOSVersion.get(), "2.2.0") >= 0 &&
                    CompareVersions(mOSVersion.get(), "2.3.0") < 0)
            {
                // Froyo LG devices are whitelisted.
                // All other Froyo
                bool isWhitelisted =
                    cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator());

                if (!isWhitelisted) {
                    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                    return NS_OK;
                }
            }
            else if (CompareVersions(mOSVersion.get(), "2.3.0") >= 0 &&
                     CompareVersions(mOSVersion.get(), "2.4.0") < 0)
            {
                // Gingerbread HTC devices are whitelisted.
                // Gingerbread Samsung devices are whitelisted except for:
                //   Samsung devices identified in Bug 847837
                // Gingerbread Sony devices are whitelisted.
                // All other Gingerbread devices are blacklisted.
                bool isWhitelisted =
                    cManufacturer.Equals("htc", nsCaseInsensitiveCStringComparator()) ||
                    (cManufacturer.Find("sony", true) != -1) ||
                    cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());

                if (cModel.Equals("GT-I8160", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-I8160L", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-I8530", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-I9070", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-I9070P", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-I8160P", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-S7500", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-S7500T", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-S7500L", nsCaseInsensitiveCStringComparator()) ||
                        cModel.Equals("GT-S6500T", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("smdkc110", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("smdkc210", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("herring", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("shw-m110s", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("shw-m180s", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("n1", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("latona", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("aalto", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("atlas", nsCaseInsensitiveCStringComparator()) ||
                        cHardware.Equals("qcom", nsCaseInsensitiveCStringComparator()))
                {
                    isWhitelisted = false;
                }

                if (!isWhitelisted) {
                    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                    return NS_OK;
                }
            }
            else if (CompareVersions(mOSVersion.get(), "3.0.0") >= 0 &&
                     CompareVersions(mOSVersion.get(), "4.0.0") < 0)
            {
                // Honeycomb Samsung devices are whitelisted.
                // All other Honeycomb devices are blacklisted.
                bool isWhitelisted =
                    cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());

                if (!isWhitelisted) {
                    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                    return NS_OK;
                }
            }
            else if (CompareVersions(mOSVersion.get(), "4.0.0") < 0)
            {
                *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
                return NS_OK;
            }
            else if (CompareVersions(mOSVersion.get(), "4.1.0") < 0)
            {
                // Whitelist:
                //   All Samsung ICS devices, except for:
                //     Samsung SGH-I717 (Bug 845729)
                //     Samsung SGH-I727 (Bug 845729)
                //     Samsung SGH-I757 (Bug 845729)
                //   All Galaxy nexus ICS devices
                //   Sony Xperia Ion (LT28) ICS devices
                bool isWhitelisted =
                    cModel.Equals("LT28h", nsCaseInsensitiveCStringComparator()) ||
                    cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) ||
                    cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon

                if (cModel.Find("SGH-I717", true) != -1 ||
                        cModel.Find("SGH-I727", true) != -1 ||
                        cModel.Find("SGH-I757", true) != -1)
                {
                    isWhitelisted = false;
                }

                if (!isWhitelisted) {
                    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                    return NS_OK;
                }
            }
            else if (CompareVersions(mOSVersion.get(), "4.2.0") < 0)
            {
                // Whitelist:
                //   All JB phones except for those in blocklist below
                // Blocklist:
                //   Samsung devices from bug 812881 and 853522.
                //   Motorola XT890 from bug 882342.
                bool isBlocklisted =
                    cModel.Find("GT-P3100", true) != -1 ||
                    cModel.Find("GT-P3110", true) != -1 ||
                    cModel.Find("GT-P3113", true) != -1 ||
                    cModel.Find("GT-P5100", true) != -1 ||
                    cModel.Find("GT-P5110", true) != -1 ||
                    cModel.Find("GT-P5113", true) != -1 ||
                    cModel.Find("XT890", true) != -1;

                if (isBlocklisted) {
                    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                    return NS_OK;
                }
            }
            else if (CompareVersions(mOSVersion.get(), "4.3.0") < 0)
            {
                // Blocklist all Sony devices
                if (cManufacturer.Find("Sony", true) != -1) {
                    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                    return NS_OK;
                }
            }
        }

        if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_ENCODE) {
            if (mozilla::AndroidBridge::Bridge()) {
                *aStatus = mozilla::AndroidBridge::Bridge()->GetHWEncoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                return NS_OK;
            }
        }
        if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_DECODE) {
            if (mozilla::AndroidBridge::Bridge()) {
                *aStatus = mozilla::AndroidBridge::Bridge()->GetHWDecoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
                return NS_OK;
            }
        }
    }

    return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
}
Exemplo n.º 5
0
NS_StringSetIsVoid(nsAString &aStr, const bool aIsVoid)
{
  aStr.SetIsVoid(aIsVoid);
}
Exemplo n.º 6
0
nsresult
GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, GfxDriverInfo* aDriverInfo /* = nsnull */)
{
  *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
  aSuggestedDriverVersion.SetIsVoid(PR_TRUE);

  PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO;

  PRUint32 adapterVendor = 0;
  PRUint32 adapterDeviceID = 0;
  nsAutoString adapterDriverVersionString;
  if (NS_FAILED(GetAdapterVendorID(&adapterVendor)) ||
      NS_FAILED(GetAdapterDeviceID(&adapterDeviceID)) ||
      NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString)))
  {
    return NS_ERROR_FAILURE;
  }

  if (adapterVendor != vendorIntel &&
      adapterVendor != vendorNVIDIA &&
      adapterVendor != vendorAMD &&
      adapterVendor != vendorATI &&
      // FIXME - these special hex values are currently used in xpcshell tests introduced by
      // bug 625160 patch 8/8. Maybe these tests need to be adjusted now that we're only whitelisting
      // intel/ati/nvidia.
      adapterVendor != 0xabcd &&
      adapterVendor != 0xdcba &&
      adapterVendor != 0xabab &&
      adapterVendor != 0xdcdc)
  {
    *aStatus = FEATURE_BLOCKED_DEVICE;
    return NS_OK;
  }

  PRUint64 driverVersion;
  if (!ParseDriverVersion(adapterDriverVersionString, &driverVersion)) {
    return NS_ERROR_FAILURE;
  }
  
  if (aFeature == FEATURE_DIRECT3D_9_LAYERS &&
      mWindowsVersion < gfxWindowsPlatform::kWindowsXP)
  {
    *aStatus = FEATURE_BLOCKED_OS_VERSION;
    return NS_OK;
  }

  // ANGLE currently uses D3D10 <-> D3D9 interop, which crashes on Optimus
  // machines.
  if (aFeature == FEATURE_WEBGL_ANGLE &&
      gfxWindowsPlatform::IsOptimus())
  {
    *aStatus = FEATURE_BLOCKED_DEVICE;
    return NS_OK;
  }

  OperatingSystem os = WindowsVersionToOperatingSystem(mWindowsVersion);

  // Windows Server 2003 should be just like Windows XP for present purpose, but still has a different version number.
  // OTOH Windows Server 2008 R1 and R2 already have the same version numbers as Vista and Seven respectively
  if (os == DRIVER_OS_WINDOWS_SERVER_2003)
    os = DRIVER_OS_WINDOWS_XP;

  const GfxDriverInfo *info;
  if (aDriverInfo)
    info = aDriverInfo;
  else
    info = &gDriverInfo[0];

  if (mHasDriverVersionMismatch) {
    if (aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS ||
        aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS ||
        aFeature == nsIGfxInfo::FEATURE_DIRECT2D)
    {
      *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
      return NS_OK;
    }
  }

  // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to
  // whitelist them, actually we do know that this combination of device and driver version
  // works well.
  if (os == DRIVER_OS_WINDOWS_XP &&
      adapterVendor == vendorNVIDIA &&
      adapterDeviceID == 0x0861 && // GeForce 9400
      driverVersion == V(6,14,11,7756))
  {
    return NS_OK;
  }

  while (info->mOperatingSystem) {

    if (info->mOperatingSystem != DRIVER_OS_ALL &&
        info->mOperatingSystem != os)
    {
      info++;
      continue;
    }

    if (info->mAdapterVendor != GfxDriverInfo::allAdapterVendors &&
        info->mAdapterVendor != adapterVendor) {
      info++;
      continue;
    }

    if (info->mDevices != GfxDriverInfo::allDevices) {
        bool deviceMatches = false;
        for (const PRUint32 *devices = info->mDevices; *devices; ++devices) {
            if (*devices == adapterDeviceID) {
                deviceMatches = true;
                break;
            }
        }

        if (!deviceMatches) {
            info++;
            continue;
        }
    }

    bool match = false;

    switch (info->mComparisonOp) {
    case DRIVER_LESS_THAN:
      match = driverVersion < info->mDriverVersion;
      break;
    case DRIVER_LESS_THAN_OR_EQUAL:
      match = driverVersion <= info->mDriverVersion;
      break;
    case DRIVER_GREATER_THAN:
      match = driverVersion > info->mDriverVersion;
      break;
    case DRIVER_GREATER_THAN_OR_EQUAL:
      match = driverVersion >= info->mDriverVersion;
      break;
    case DRIVER_EQUAL:
      match = driverVersion == info->mDriverVersion;
      break;
    case DRIVER_NOT_EQUAL:
      match = driverVersion != info->mDriverVersion;
      break;
    case DRIVER_BETWEEN_EXCLUSIVE:
      match = driverVersion > info->mDriverVersion && driverVersion < info->mDriverVersionMax;
      break;
    case DRIVER_BETWEEN_INCLUSIVE:
      match = driverVersion >= info->mDriverVersion && driverVersion <= info->mDriverVersionMax;
      break;
    case DRIVER_BETWEEN_INCLUSIVE_START:
      match = driverVersion >= info->mDriverVersion && driverVersion < info->mDriverVersionMax;
      break;
    default:
      NS_WARNING("Bogus op in GfxDriverInfo");
      break;
    }

    if (match) {
      if (info->mFeature == GfxDriverInfo::allFeatures ||
          info->mFeature == aFeature)
      {
        status = info->mFeatureStatus;
        break;
      }
    }

    info++;
  }

  *aStatus = status;

  if (status == FEATURE_BLOCKED_DRIVER_VERSION) {
      if (info->mSuggestedVersion) {
          aSuggestedDriverVersion.AppendPrintf("%s", info->mSuggestedVersion);
      } else if (info->mComparisonOp == DRIVER_LESS_THAN &&
                 info->mDriverVersion != allDriverVersions)
      {
          aSuggestedDriverVersion.AppendPrintf("%lld.%lld.%lld.%lld",
                                               (info->mDriverVersion & 0xffff000000000000) >> 48,
                                               (info->mDriverVersion & 0x0000ffff00000000) >> 32,
                                               (info->mDriverVersion & 0x00000000ffff0000) >> 16,
                                               (info->mDriverVersion & 0x000000000000ffff));
      }
  }
Exemplo n.º 7
0
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
                              int32_t *aStatus, 
                              nsAString & aSuggestedDriverVersion, 
                              const nsTArray<GfxDriverInfo>& aDriverInfo,
                              OperatingSystem* aOS /* = nullptr */)
{
  NS_ENSURE_ARG_POINTER(aStatus);
  aSuggestedDriverVersion.SetIsVoid(true);
  OperatingSystem os = WindowsVersionToOperatingSystem(mWindowsVersion);
  *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
  if (aOS)
    *aOS = os;

  // Don't evaluate special cases if we're checking the downloaded blocklist.
  if (!aDriverInfo.Length()) {
    nsAutoString adapterVendorID;
    nsAutoString adapterDeviceID;
    nsAutoString adapterDriverVersionString;
    if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) ||
        NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) ||
        NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString)))
    {
      return NS_ERROR_FAILURE;
    }

    if (!adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorIntel), nsCaseInsensitiveStringComparator()) &&
        !adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), nsCaseInsensitiveStringComparator()) &&
        !adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorAMD), nsCaseInsensitiveStringComparator()) &&
        !adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorATI), nsCaseInsensitiveStringComparator()) &&
        !adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorMicrosoft), nsCaseInsensitiveStringComparator()) &&
        // FIXME - these special hex values are currently used in xpcshell tests introduced by
        // bug 625160 patch 8/8. Maybe these tests need to be adjusted now that we're only whitelisting
        // intel/ati/nvidia.
        !adapterVendorID.LowerCaseEqualsLiteral("0xabcd") &&
        !adapterVendorID.LowerCaseEqualsLiteral("0xdcba") &&
        !adapterVendorID.LowerCaseEqualsLiteral("0xabab") &&
        !adapterVendorID.LowerCaseEqualsLiteral("0xdcdc"))
    {
      *aStatus = FEATURE_BLOCKED_DEVICE;
      return NS_OK;
    }

    uint64_t driverVersion;
    if (!ParseDriverVersion(adapterDriverVersionString, &driverVersion)) {
      return NS_ERROR_FAILURE;
    }

    // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to
    // whitelist them, actually we do know that this combination of device and driver version
    // works well.
    if (mWindowsVersion == kWindowsXP &&
        adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), nsCaseInsensitiveStringComparator()) &&
        adapterDeviceID.LowerCaseEqualsLiteral("0x0861") && // GeForce 9400
        driverVersion == V(6,14,11,7756))
    {
      *aStatus = FEATURE_STATUS_OK;
      return NS_OK;
    }

    // Windows Server 2003 should be just like Windows XP for present purpose, but still has a different version number.
    // OTOH Windows Server 2008 R1 and R2 already have the same version numbers as Vista and Seven respectively
    if (os == DRIVER_OS_WINDOWS_SERVER_2003)
      os = DRIVER_OS_WINDOWS_XP;

    if (mHasDriverVersionMismatch) {
      *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
      return NS_OK;
    }
  }

  return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
}
Exemplo n.º 8
0
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t aFeature, 
                              int32_t *aStatus, 
                              nsAString & aSuggestedDriverVersion,
                              const nsTArray<GfxDriverInfo>& aDriverInfo, 
                              OperatingSystem* aOS /* = nullptr */)
{
  NS_ENSURE_ARG_POINTER(aStatus);
  aSuggestedDriverVersion.SetIsVoid(true);
  *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
  OperatingSystem os = mOS;
  if (aOS)
    *aOS = os;

  EnsureInitializedFromGfxInfoData();

  if (!mError.IsEmpty()) {
    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
    return NS_OK;
  }

  // Don't evaluate special cases when evaluating the downloaded blocklist.
  if (aDriverInfo.IsEmpty()) {
    if (aFeature == FEATURE_WEBGL_OPENGL) {
      if (mRenderer.Find("Adreno 200") != -1 ||
          mRenderer.Find("Adreno 205") != -1)
      {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        return NS_OK;
      }

      if (mHardware.Equals(NS_LITERAL_STRING("ville"))) {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        return NS_OK;
      }
    }

    if (aFeature == FEATURE_STAGEFRIGHT) {
      NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
      NS_LossyConvertUTF16toASCII cModel(mModel);
      NS_LossyConvertUTF16toASCII cHardware(mHardware);

      if (cHardware.Equals("antares") ||
          cHardware.Equals("endeavoru") ||
          cHardware.Equals("harmony") ||
          cHardware.Equals("picasso") ||
          cHardware.Equals("picasso_e") ||
          cHardware.Equals("ventana") ||
          cHardware.Equals("rk30board"))
      {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
        return NS_OK;
      }

      if (CompareVersions(mOSVersion.get(), "2.2.0") >= 0 &&
          CompareVersions(mOSVersion.get(), "2.3.0") < 0)
      {
        // Froyo LG devices are whitelisted.
        // All other Froyo
        bool isWhitelisted =
          cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator());

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "2.3.0") >= 0 &&
          CompareVersions(mOSVersion.get(), "2.4.0") < 0)
      {
        // Gingerbread HTC devices are whitelisted.
        // Gingerbread Samsung devices are whitelisted except for:
        //   Samsung devices identified in Bug 847837
        //   Samsung SGH-T989 (Bug 818363)
        // All other Gingerbread devices are blacklisted.
        bool isWhitelisted =
          cManufacturer.Equals("htc", nsCaseInsensitiveCStringComparator()) ||
          cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());

        if (cModel.Equals("GT-I8160", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-I8160L", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-I8530", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-I9070", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-I9070P", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-I8160P", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-S7500", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-S7500T", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-S7500L", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("GT-S6500T", nsCaseInsensitiveCStringComparator()) ||
            cModel.Equals("SGH-T989", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("smdkc110", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("smdkc210", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("herring", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("shw-m110s", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("shw-m180s", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("n1", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("latona", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("aalto", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("atlas", nsCaseInsensitiveCStringComparator()) ||
            cHardware.Equals("qcom", nsCaseInsensitiveCStringComparator()))
        {
          isWhitelisted = false;
        }

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "3.0.0") >= 0 &&
          CompareVersions(mOSVersion.get(), "4.0.0") < 0)
      {
        // Honeycomb Samsung devices are whitelisted.
        // All other Honeycomb devices are blacklisted.
	bool isWhitelisted =
          cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "4.0.0") < 0)
      {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
        return NS_OK;
      }
      else if (CompareVersions(mOSVersion.get(), "4.1.0") < 0)
      {
        // Whitelist:
        //   All Samsung ICS devices, except for:
        //     Samsung SGH-I717 (Bug 845729)
        //     Samsung SGH-I727 (Bug 845729)
        //     Samsung SGH-I757 (Bug 845729)
        //     Samsung SGH-T989 (Bug 845729)
        //   All Galaxy nexus ICS devices
        //   Sony Xperia Ion (LT28) ICS devices
        bool isWhitelisted =
          cModel.Equals("LT28h", nsCaseInsensitiveCStringComparator()) ||
          cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) ||
          cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon

        if (cModel.Find("SGH-I717", true) != -1 ||
            cModel.Find("SGH-I727", true) != -1 ||
            cModel.Find("SGH-I757", true) != -1 ||
            cModel.Find("SGH-T989", true) != -1)
        {
          isWhitelisted = false;
        }

        if (!isWhitelisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
      else if (CompareVersions(mOSVersion.get(), "4.2.0") < 0)
      {
        // Whitelist:
        //   All JB phones except for those in blocklist below
        // Blocklist:
        //   Samsung devices from bug 812881 and 853522.
        //   All Sony devices (Bug 845734)

        bool isBlocklisted =
          cModel.Find("SCH-I535", true) ||
          cModel.Find("SGH-I747", true) ||
          cModel.Find("SGH-T999", true) ||
          cModel.Find("SPH-L710", true) ||
          cModel.Find("GT-I8190", true) ||
          cModel.Find("GT-P3100", true) ||
          cModel.Find("GT-P3110", true) ||
          cModel.Find("GT-P3113", true) ||
          cModel.Find("GT-P5100", true) ||
          cModel.Find("GT-P5110", true) ||
          cModel.Find("GT-P5113", true) ||
          cManufacturer.Equals("Sony", nsCaseInsensitiveCStringComparator());

        if (isBlocklisted) {
          *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
          return NS_OK;
        }
      }
    }
  }

  return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
}
Exemplo n.º 9
0
nsresult
GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, 
                              PRInt32 *aStatus, 
                              nsAString & aSuggestedDriverVersion, 
                              GfxDriverInfo* aDriverInfo /* = nsnull */, 
                              OperatingSystem* aOS /* = nsnull */)

{
    GetData();
    *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
    aSuggestedDriverVersion.SetIsVoid(true);

#ifdef MOZ_PLATFORM_MAEMO
    // on Maemo, the glxtest probe doesn't build, and we don't really need GfxInfo anyway
    return NS_OK;
#endif

    OperatingSystem os = DRIVER_OS_LINUX;

    // Disable OpenGL layers when we don't have texture_from_pixmap because it regresses performance. 
    if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS && !mHasTextureFromPixmap) {
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
        aSuggestedDriverVersion.AssignLiteral("<Anything with EXT_texture_from_pixmap support>");
        return NS_OK;
    }

    // whitelist the linux test slaves' current configuration.
    // this is necessary as they're still using the slightly outdated 190.42 driver.
    // this isn't a huge risk, as at least this is the exact setting in which we do continuous testing,
    // and this only affects GeForce 9400 cards on linux on this precise driver version, which is very few users.
    // We do the same thing on Windows XP, see in widget/src/windows/GfxInfo.cpp
    if (mIsNVIDIA &&
        !strcmp(mRenderer.get(), "GeForce 9400/PCI/SSE2") &&
        !strcmp(mVersion.get(), "3.2.0 NVIDIA 190.42"))
    {
        return NS_OK;
    }

    if (mIsMesa) {
        if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(7,10,3)) {
            *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
            aSuggestedDriverVersion.AssignLiteral("Mesa 7.10.3");
        }
    } else if (mIsNVIDIA) {
        if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(257,21)) {
            *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
            aSuggestedDriverVersion.AssignLiteral("NVIDIA 257.21");
        }
    } else if (mIsFGLRX) {
        // FGLRX does not report a driver version number, so we have the OpenGL version instead.
        // by requiring OpenGL 3, we effectively require recent drivers.
        if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(3, 0)) {
            *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
        }
    } else {
        // like on windows, let's block unknown vendors. Think of virtual machines.
        // Also, this case is hit whenever the GLXtest probe failed to get driver info or crashed.
        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
    }

  if (aOS)
    *aOS = os;

  return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
}