Exemplo n.º 1
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.º 2
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);
}