Commit 37c3a715 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Use the predefined Android SDK constants instead of numbers

Half the code used the SDK_VERSION_* constants when checking
Android version, half the code used hard coded numbers 19, 21,
22, ....

This changes the code to use SDK_VERSION_ everywhere.

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.android:android_arm64_dbg_recipe;master.tryserver.chromium.android:android_compile_x64_dbg;master.tryserver.chromium.android:android_compile_x86_dbg;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Icb4e3183f0490b00d16039681548ccf469e9d236
Reviewed-on: https://chromium-review.googlesource.com/975841
Commit-Queue: Daniel Bratell <bratell@opera.com>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarDavid Benjamin <davidben@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545870}
parent 1456f311
...@@ -626,7 +626,8 @@ bool FinalizeCrashDoneAndroid(bool is_browser_process) { ...@@ -626,7 +626,8 @@ bool FinalizeCrashDoneAndroid(bool is_browser_process) {
AndroidLogWriteHorizontalRule(); AndroidLogWriteHorizontalRule();
if (!is_browser_process && if (!is_browser_process &&
android_build_info->sdk_int() >= 18 && android_build_info->sdk_int() >=
base::android::SDK_VERSION_JELLY_BEAN_MR2 &&
my_strcmp(android_build_info->build_type(), "eng") != 0 && my_strcmp(android_build_info->build_type(), "eng") != 0 &&
my_strcmp(android_build_info->build_type(), "userdebug") != 0) { my_strcmp(android_build_info->build_type(), "userdebug") != 0) {
// On JB MR2 and later, the system crash handler displays a dialog. For // On JB MR2 and later, the system crash handler displays a dialog. For
......
...@@ -47,7 +47,8 @@ RendererWebMediaPlayerDelegate::RendererWebMediaPlayerDelegate( ...@@ -47,7 +47,8 @@ RendererWebMediaPlayerDelegate::RendererWebMediaPlayerDelegate(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// On Android, due to the instability of the OS level media components, we // On Android, due to the instability of the OS level media components, we
// consider all pre-KitKat devices to be potentially buggy. // consider all pre-KitKat devices to be potentially buggy.
is_jelly_bean_ |= base::android::BuildInfo::GetInstance()->sdk_int() <= 18; is_jelly_bean_ |= base::android::BuildInfo::GetInstance()->sdk_int() <=
base::android::SDK_VERSION_JELLY_BEAN_MR2;
#endif #endif
idle_cleanup_timer_.SetTaskRunner( idle_cleanup_timer_.SetTaskRunner(
......
...@@ -31,10 +31,12 @@ scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create( ...@@ -31,10 +31,12 @@ scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create(
ScopedJavaLocalRef<jobject> wrapper = ScopedJavaLocalRef<jobject> wrapper =
Java_ChromeUsbDevice_create(env, usb_device); Java_ChromeUsbDevice_create(env, usb_device);
uint16_t device_version = 0; uint16_t device_version = 0;
if (base::android::BuildInfo::GetInstance()->sdk_int() >= 23) if (base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_MARSHMALLOW)
device_version = Java_ChromeUsbDevice_getDeviceVersion(env, wrapper); device_version = Java_ChromeUsbDevice_getDeviceVersion(env, wrapper);
base::string16 manufacturer_string, product_string, serial_number; base::string16 manufacturer_string, product_string, serial_number;
if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { if (base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_LOLLIPOP) {
ScopedJavaLocalRef<jstring> manufacturer_jstring = ScopedJavaLocalRef<jstring> manufacturer_jstring =
Java_ChromeUsbDevice_getManufacturerName(env, wrapper); Java_ChromeUsbDevice_getManufacturerName(env, wrapper);
if (!manufacturer_jstring.is_null()) if (!manufacturer_jstring.is_null())
...@@ -115,7 +117,8 @@ UsbDeviceAndroid::UsbDeviceAndroid( ...@@ -115,7 +117,8 @@ UsbDeviceAndroid::UsbDeviceAndroid(
device_id_(Java_ChromeUsbDevice_getDeviceId(env, wrapper)), device_id_(Java_ChromeUsbDevice_getDeviceId(env, wrapper)),
service_(service), service_(service),
j_object_(wrapper) { j_object_(wrapper) {
if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { if (base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_LOLLIPOP) {
ScopedJavaLocalRef<jobjectArray> configurations = ScopedJavaLocalRef<jobjectArray> configurations =
Java_ChromeUsbDevice_getConfigurations(env, j_object_); Java_ChromeUsbDevice_getConfigurations(env, j_object_);
jsize count = env->GetArrayLength(configurations.obj()); jsize count = env->GetArrayLength(configurations.obj());
......
...@@ -20,7 +20,8 @@ UsbInterfaceDescriptor UsbInterfaceAndroid::Convert( ...@@ -20,7 +20,8 @@ UsbInterfaceDescriptor UsbInterfaceAndroid::Convert(
Java_ChromeUsbInterface_create(env, usb_interface); Java_ChromeUsbInterface_create(env, usb_interface);
uint8_t alternate_setting = 0; uint8_t alternate_setting = 0;
if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { if (base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_LOLLIPOP) {
alternate_setting = alternate_setting =
Java_ChromeUsbInterface_getAlternateSetting(env, wrapper); Java_ChromeUsbInterface_getAlternateSetting(env, wrapper);
} }
......
...@@ -337,7 +337,8 @@ AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( ...@@ -337,7 +337,8 @@ AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters(
// AudioManager APIs for GetOptimalOutputFrameSize() don't support channel // AudioManager APIs for GetOptimalOutputFrameSize() don't support channel
// layouts greater than stereo unless low latency audio is supported. // layouts greater than stereo unless low latency audio is supported.
if (input_params.channels() <= 2 || if (input_params.channels() <= 2 ||
(base::android::BuildInfo::GetInstance()->sdk_int() >= 21 && (base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_LOLLIPOP &&
IsAudioLowLatencySupported())) { IsAudioLowLatencySupported())) {
channel_layout = input_params.channel_layout(); channel_layout = input_params.channel_layout();
} }
......
...@@ -555,7 +555,8 @@ MediaCodecStatus MediaCodecBridgeImpl::GetOutputBufferAddress( ...@@ -555,7 +555,8 @@ MediaCodecStatus MediaCodecBridgeImpl::GetOutputBufferAddress(
} }
std::string MediaCodecBridgeImpl::GetName() { std::string MediaCodecBridgeImpl::GetName() {
if (base::android::BuildInfo::GetInstance()->sdk_int() < 18) if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_JELLY_BEAN_MR2)
return ""; return "";
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> j_name = ScopedJavaLocalRef<jstring> j_name =
...@@ -564,7 +565,8 @@ std::string MediaCodecBridgeImpl::GetName() { ...@@ -564,7 +565,8 @@ std::string MediaCodecBridgeImpl::GetName() {
} }
bool MediaCodecBridgeImpl::SetSurface(const JavaRef<jobject>& surface) { bool MediaCodecBridgeImpl::SetSurface(const JavaRef<jobject>& surface) {
DCHECK_GE(base::android::BuildInfo::GetInstance()->sdk_int(), 23); DCHECK_GE(base::android::BuildInfo::GetInstance()->sdk_int(),
base::android::SDK_VERSION_MARSHMALLOW);
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
return Java_MediaCodecBridge_setSurface(env, j_bridge_, surface); return Java_MediaCodecBridge_setSurface(env, j_bridge_, surface);
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "media/base/android/media_codec_loop.h" #include "media/base/android/media_codec_loop.h"
#include "base/android/build_info.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -346,7 +347,7 @@ bool MediaCodecLoop::CodecNeedsFlushWorkaround() const { ...@@ -346,7 +347,7 @@ bool MediaCodecLoop::CodecNeedsFlushWorkaround() const {
// we have to completely destroy and recreate the codec there. // we have to completely destroy and recreate the codec there.
// TODO(liberato): MediaCodecUtil implements the same function. We should // TODO(liberato): MediaCodecUtil implements the same function. We should
// call that one, except that it doesn't compile outside of android right now. // call that one, except that it doesn't compile outside of android right now.
return sdk_int_ < 18; return sdk_int_ < base::android::SDK_VERSION_JELLY_BEAN_MR2;
} }
// static // static
......
...@@ -315,7 +315,9 @@ class MEDIA_EXPORT MediaCodecLoop { ...@@ -315,7 +315,9 @@ class MEDIA_EXPORT MediaCodecLoop {
// ownership of it. // ownership of it.
base::TickClock* test_tick_clock_ = nullptr; base::TickClock* test_tick_clock_ = nullptr;
// BuildInfo::sdk_int(), eventually. // Has the value of BuildInfo::sdk_int(), except in tests where it
// might be set to other values. Will not be needed when there is a
// mockable BuildInfo.
const int sdk_int_; const int sdk_int_;
// NOTE: Weak pointers must be invalidated before all other member variables. // NOTE: Weak pointers must be invalidated before all other member variables.
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "media/base/android/media_codec_loop.h" #include "media/base/android/media_codec_loop.h"
#include "base/android/build_info.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/test/test_mock_time_task_runner.h" #include "base/test/test_mock_time_task_runner.h"
...@@ -25,13 +26,6 @@ using ::testing::StrictMock; ...@@ -25,13 +26,6 @@ using ::testing::StrictMock;
namespace media { namespace media {
// These will come from mockable BuildInfo, once it exists.
enum TemporaryAndroidVersions {
kJellyBeanMR1 = 17,
kJellyBeanMR2 = 18,
kLollipop = 21,
};
// The client is a strict mock, since we don't want random calls into it. We // The client is a strict mock, since we don't want random calls into it. We
// want to be sure about the call sequence. // want to be sure about the call sequence.
class MockMediaCodecLoopClient : public StrictMock<MediaCodecLoop::Client> { class MockMediaCodecLoopClient : public StrictMock<MediaCodecLoop::Client> {
...@@ -89,7 +83,7 @@ class MediaCodecLoopTest : public testing::Test { ...@@ -89,7 +83,7 @@ class MediaCodecLoopTest : public testing::Test {
mock_task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(30)); mock_task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(30));
} }
void ConstructCodecLoop(int sdk_int = kLollipop) { void ConstructCodecLoop(int sdk_int = base::android::SDK_VERSION_LOLLIPOP) {
std::unique_ptr<MediaCodecBridge> codec(new MockMediaCodecBridge()); std::unique_ptr<MediaCodecBridge> codec(new MockMediaCodecBridge());
// Since we're providing a codec, we do not expect an error. // Since we're providing a codec, we do not expect an error.
EXPECT_CALL(*client_, OnCodecLoopError()).Times(0); EXPECT_CALL(*client_, OnCodecLoopError()).Times(0);
...@@ -199,7 +193,7 @@ class MediaCodecLoopTest : public testing::Test { ...@@ -199,7 +193,7 @@ class MediaCodecLoopTest : public testing::Test {
TEST_F(MediaCodecLoopTest, TestConstructionWithNullCodec) { TEST_F(MediaCodecLoopTest, TestConstructionWithNullCodec) {
std::unique_ptr<MediaCodecBridge> codec; std::unique_ptr<MediaCodecBridge> codec;
EXPECT_CALL(*client_, OnCodecLoopError()).Times(1); EXPECT_CALL(*client_, OnCodecLoopError()).Times(1);
const int sdk_int = kLollipop; const int sdk_int = base::android::SDK_VERSION_LOLLIPOP;
codec_loop_.reset( codec_loop_.reset(
new MediaCodecLoop(sdk_int, client_.get(), std::move(codec), new MediaCodecLoop(sdk_int, client_.get(), std::move(codec),
scoped_refptr<base::SingleThreadTaskRunner>())); scoped_refptr<base::SingleThreadTaskRunner>()));
...@@ -416,7 +410,7 @@ TEST_F(MediaCodecLoopTest, TestSeveralPendingIOBuffers) { ...@@ -416,7 +410,7 @@ TEST_F(MediaCodecLoopTest, TestSeveralPendingIOBuffers) {
TEST_F(MediaCodecLoopTest, TestTryFlushOnJellyBeanMR2) { TEST_F(MediaCodecLoopTest, TestTryFlushOnJellyBeanMR2) {
// On JB MR2+ MCL should be willing to use MediaCodecBridge::Flush. // On JB MR2+ MCL should be willing to use MediaCodecBridge::Flush.
ConstructCodecLoop(kJellyBeanMR2); ConstructCodecLoop(base::android::SDK_VERSION_JELLY_BEAN_MR2);
EXPECT_CALL(Codec(), Flush()).Times(1).WillOnce(Return(MEDIA_CODEC_OK)); EXPECT_CALL(Codec(), Flush()).Times(1).WillOnce(Return(MEDIA_CODEC_OK));
ASSERT_TRUE(codec_loop_->TryFlush()); ASSERT_TRUE(codec_loop_->TryFlush());
} }
...@@ -424,7 +418,7 @@ TEST_F(MediaCodecLoopTest, TestTryFlushOnJellyBeanMR2) { ...@@ -424,7 +418,7 @@ TEST_F(MediaCodecLoopTest, TestTryFlushOnJellyBeanMR2) {
TEST_F(MediaCodecLoopTest, TestTryFlushAfterJellyBeanMR2Fails) { TEST_F(MediaCodecLoopTest, TestTryFlushAfterJellyBeanMR2Fails) {
// On JB MR2+, MCL should be willing to use MediaCodecBridge::Flush. Try // On JB MR2+, MCL should be willing to use MediaCodecBridge::Flush. Try
// that, but make Flush fail. // that, but make Flush fail.
ConstructCodecLoop(kJellyBeanMR2); ConstructCodecLoop(base::android::SDK_VERSION_JELLY_BEAN_MR2);
EXPECT_CALL(Codec(), Flush()).Times(1).WillOnce(Return(MEDIA_CODEC_ERROR)); EXPECT_CALL(Codec(), Flush()).Times(1).WillOnce(Return(MEDIA_CODEC_ERROR));
EXPECT_CALL(*client_, OnCodecLoopError()).Times(1); EXPECT_CALL(*client_, OnCodecLoopError()).Times(1);
ASSERT_FALSE(codec_loop_->TryFlush()); ASSERT_FALSE(codec_loop_->TryFlush());
...@@ -432,7 +426,7 @@ TEST_F(MediaCodecLoopTest, TestTryFlushAfterJellyBeanMR2Fails) { ...@@ -432,7 +426,7 @@ TEST_F(MediaCodecLoopTest, TestTryFlushAfterJellyBeanMR2Fails) {
TEST_F(MediaCodecLoopTest, TestTryFlushOnJellyBeanMR1) { TEST_F(MediaCodecLoopTest, TestTryFlushOnJellyBeanMR1) {
// In JB MR1, MCL should not be willing to use MediaCodecBridge::Flush. // In JB MR1, MCL should not be willing to use MediaCodecBridge::Flush.
ConstructCodecLoop(kJellyBeanMR1); ConstructCodecLoop(base::android::SDK_VERSION_JELLY_BEAN_MR1);
ASSERT_FALSE(codec_loop_->TryFlush()); ASSERT_FALSE(codec_loop_->TryFlush());
} }
......
...@@ -30,6 +30,7 @@ using base::android::JavaRef; ...@@ -30,6 +30,7 @@ using base::android::JavaRef;
using base::android::ScopedJavaLocalRef; using base::android::ScopedJavaLocalRef;
using base::android::SDK_VERSION_JELLY_BEAN_MR2; using base::android::SDK_VERSION_JELLY_BEAN_MR2;
using base::android::SDK_VERSION_KITKAT; using base::android::SDK_VERSION_KITKAT;
using base::android::SDK_VERSION_LOLLIPOP;
using base::android::SDK_VERSION_LOLLIPOP_MR1; using base::android::SDK_VERSION_LOLLIPOP_MR1;
namespace media { namespace media {
...@@ -198,8 +199,9 @@ bool MediaCodecUtil::IsMediaCodecAvailableFor(int sdk, const char* model) { ...@@ -198,8 +199,9 @@ bool MediaCodecUtil::IsMediaCodecAvailableFor(int sdk, const char* model) {
// static // static
bool MediaCodecUtil::SupportsSetParameters() { bool MediaCodecUtil::SupportsSetParameters() {
// MediaCodec.setParameters() is only available starting with K. // MediaCodec.setParameters() is only available starting with KitKat.
return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; return base::android::BuildInfo::GetInstance()->sdk_int() >=
SDK_VERSION_KITKAT;
} }
// static // static
...@@ -292,7 +294,8 @@ bool MediaCodecUtil::IsKnownUnaccelerated(VideoCodec codec, ...@@ -292,7 +294,8 @@ bool MediaCodecUtil::IsKnownUnaccelerated(VideoCodec codec,
return true; return true;
if (codec == kCodecVP9) if (codec == kCodecVP9)
return base::android::BuildInfo::GetInstance()->sdk_int() < 21; return base::android::BuildInfo::GetInstance()->sdk_int() <
SDK_VERSION_LOLLIPOP;
return false; return false;
} }
......
...@@ -250,7 +250,8 @@ std::string GetSecurityLevelString( ...@@ -250,7 +250,8 @@ std::string GetSecurityLevelString(
} }
bool AreMediaDrmApisAvailable() { bool AreMediaDrmApisAvailable() {
if (base::android::BuildInfo::GetInstance()->sdk_int() < 19) if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_KITKAT)
return false; return false;
int32_t os_major_version = 0; int32_t os_major_version = 0;
...@@ -268,7 +269,8 @@ bool IsPersistentLicenseTypeSupportedByMediaDrm() { ...@@ -268,7 +269,8 @@ bool IsPersistentLicenseTypeSupportedByMediaDrm() {
return MediaDrmBridge::IsAvailable() && return MediaDrmBridge::IsAvailable() &&
// In development. See http://crbug.com/493521 // In development. See http://crbug.com/493521
base::FeatureList::IsEnabled(kMediaDrmPersistentLicense) && base::FeatureList::IsEnabled(kMediaDrmPersistentLicense) &&
base::android::BuildInfo::GetInstance()->sdk_int() >= 23; base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_MARSHMALLOW;
} }
// Callback for MediaDrmStorageBridge::Initialize. // Callback for MediaDrmStorageBridge::Initialize.
...@@ -891,8 +893,9 @@ MediaDrmBridge::MediaDrmBridge( ...@@ -891,8 +893,9 @@ MediaDrmBridge::MediaDrmBridge(
// TODO(yucliu): Remove the check once persistent storage is fully // TODO(yucliu): Remove the check once persistent storage is fully
// supported and check if origin is valid. // supported and check if origin is valid.
base::FeatureList::IsEnabled(kMediaDrmPersistentLicense) && base::FeatureList::IsEnabled(kMediaDrmPersistentLicense) &&
// MediaDrm implements origin isolated storage on M. // MediaDrm implements origin isolated storage on Marshmallow.
base::android::BuildInfo::GetInstance()->sdk_int() >= 23 && base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_MARSHMALLOW &&
// origin id can be empty when MediaDrmBridge is created by // origin id can be empty when MediaDrmBridge is created by
// CreateWithoutSessionSupport, which is used to reset credentials. // CreateWithoutSessionSupport, which is used to reset credentials.
!origin_id.empty(); !origin_id.empty();
......
...@@ -69,7 +69,8 @@ TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) { ...@@ -69,7 +69,8 @@ TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) {
EXPECT_TRUE_IF_WIDEVINE_AVAILABLE( EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(
IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4)); IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4));
if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { if (base::android::BuildInfo::GetInstance()->sdk_int() <=
base::android::SDK_VERSION_KITKAT) {
EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM)); EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM));
EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM)); EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
} else { } else {
......
...@@ -92,7 +92,8 @@ bool HasPlatformDecoderSupport() { ...@@ -92,7 +92,8 @@ bool HasPlatformDecoderSupport() {
} }
bool PlatformHasOpusSupport() { bool PlatformHasOpusSupport() {
return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; return base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_LOLLIPOP;
} }
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
...@@ -601,7 +601,8 @@ bool MimeUtil::IsCodecSupportedOnAndroid( ...@@ -601,7 +601,8 @@ bool MimeUtil::IsCodecSupportedOnAndroid(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// HEVC/H.265 is supported in Lollipop+ (API Level 21), according to // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to
// http://developer.android.com/reference/android/media/MediaFormat.html // http://developer.android.com/reference/android/media/MediaFormat.html
return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; return base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_LOLLIPOP;
#else #else
return true; return true;
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
...@@ -126,7 +126,8 @@ static MimeUtil::PlatformInfo VaryAllFields() { ...@@ -126,7 +126,8 @@ static MimeUtil::PlatformInfo VaryAllFields() {
static bool HasHevcSupport() { static bool HasHevcSupport() {
#if BUILDFLAG(ENABLE_HEVC_DEMUXING) #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; return base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_LOLLIPOP;
#else #else
return true; return true;
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
...@@ -157,7 +157,8 @@ class AudioDecoderTest ...@@ -157,7 +157,8 @@ class AudioDecoderTest
return false; return false;
} }
if (params_.codec == kCodecOpus && if (params_.codec == kCodecOpus &&
base::android::BuildInfo::GetInstance()->sdk_int() < 21) { base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_LOLLIPOP) {
VLOG(0) << "Could not run test - Opus is not supported"; VLOG(0) << "Could not run test - Opus is not supported";
return false; return false;
} }
...@@ -332,7 +333,8 @@ class AudioDecoderTest ...@@ -332,7 +333,8 @@ class AudioDecoderTest
// for AAC before Android L. Skip the timestamp check in this situation. // for AAC before Android L. Skip the timestamp check in this situation.
bool SkipBufferTimestampCheck() const { bool SkipBufferTimestampCheck() const {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
return (base::android::BuildInfo::GetInstance()->sdk_int() < 21) && return (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_LOLLIPOP) &&
decoder_type_ == MEDIA_CODEC && params_.codec == kCodecAAC; decoder_type_ == MEDIA_CODEC && params_.codec == kCodecAAC;
#else #else
return false; return false;
......
...@@ -236,10 +236,12 @@ class CertVerifyProcInternalTest ...@@ -236,10 +236,12 @@ class CertVerifyProcInternalTest
bool SupportsReturningVerifiedChain() const { bool SupportsReturningVerifiedChain() const {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Before API level 17, Android does not expose the APIs necessary to get at // Before API level 17 (SDK_VERSION_JELLY_BEAN_MR1), Android does
// the verified certificate chain. // not expose the APIs necessary to get at the verified
// certificate chain.
if (verify_proc_type() == CERT_VERIFY_PROC_ANDROID && if (verify_proc_type() == CERT_VERIFY_PROC_ANDROID &&
base::android::BuildInfo::GetInstance()->sdk_int() < 17) base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_JELLY_BEAN_MR1)
return false; return false;
#endif #endif
return true; return true;
...@@ -247,10 +249,12 @@ class CertVerifyProcInternalTest ...@@ -247,10 +249,12 @@ class CertVerifyProcInternalTest
bool SupportsDetectingKnownRoots() const { bool SupportsDetectingKnownRoots() const {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Before API level 17, Android does not expose the APIs necessary to get at // Before API level 17 (SDK_VERSION_JELLY_BEAN_MR1), Android does not expose
// the verified certificate chain and detect known roots. // the APIs necessary to get at the verified certificate chain and detect
// known roots.
if (verify_proc_type() == CERT_VERIFY_PROC_ANDROID) if (verify_proc_type() == CERT_VERIFY_PROC_ANDROID)
return base::android::BuildInfo::GetInstance()->sdk_int() >= 17; return base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_JELLY_BEAN_MR1;
#endif #endif
// iOS does not expose the APIs necessary to get the known system roots. // iOS does not expose the APIs necessary to get the known system roots.
......
...@@ -194,12 +194,12 @@ scoped_refptr<SSLPrivateKey> WrapJavaPrivateKey( ...@@ -194,12 +194,12 @@ scoped_refptr<SSLPrivateKey> WrapJavaPrivateKey(
android::AndroidRSA* sys_rsa = nullptr; android::AndroidRSA* sys_rsa = nullptr;
if (type == EVP_PKEY_RSA) { if (type == EVP_PKEY_RSA) {
const int kAndroid42ApiLevel = 17;
if (base::android::BuildInfo::GetInstance()->sdk_int() < if (base::android::BuildInfo::GetInstance()->sdk_int() <
kAndroid42ApiLevel) { base::android::SDK_VERSION_JELLY_BEAN_MR1) {
// Route around platform limitations: if Android < 4.2, then // Route around platform limitations: if Android < 4.2 (Jelly
// base::android::RawSignDigestWithPrivateKey() cannot work, so try to get // Bean MR1), then base::android::RawSignDigestWithPrivateKey()
// the system OpenSSL's EVP_PKEY backing this PrivateKey object. // cannot work, so try to get the system OpenSSL's EVP_PKEY
// backing this PrivateKey object.
android::AndroidEVP_PKEY* sys_pkey = android::AndroidEVP_PKEY* sys_pkey =
android::GetOpenSSLSystemHandleForPrivateKey(key); android::GetOpenSSLSystemHandleForPrivateKey(key);
if (!sys_pkey) if (!sys_pkey)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/logging.h" #include "base/logging.h"
#if BUILDFLAG(USE_SECCOMP_BPF) #if BUILDFLAG(USE_SECCOMP_BPF)
#include "base/android/build_info.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#endif #endif
...@@ -42,7 +43,7 @@ bool SeccompStarterAndroid::StartSandbox() { ...@@ -42,7 +43,7 @@ bool SeccompStarterAndroid::StartSandbox() {
// apps. It has its own SIGSYS handler that must be un-hooked so that // apps. It has its own SIGSYS handler that must be un-hooked so that
// the Chromium one can be used instead. If pre-O devices have a SIGSYS // the Chromium one can be used instead. If pre-O devices have a SIGSYS
// handler, then warn about that. // handler, then warn about that.
DLOG_IF(WARNING, sdk_int_ < 26) DLOG_IF(WARNING, sdk_int_ < base::android::SDK_VERSION_OREO)
<< "Un-hooking existing SIGSYS handler before starting " << "Un-hooking existing SIGSYS handler before starting "
<< "Seccomp sandbox"; << "Seccomp sandbox";
} }
...@@ -58,11 +59,11 @@ bool SeccompStarterAndroid::StartSandbox() { ...@@ -58,11 +59,11 @@ bool SeccompStarterAndroid::StartSandbox() {
bool SeccompStarterAndroid::IsSupportedBySDK() const { bool SeccompStarterAndroid::IsSupportedBySDK() const {
#if BUILDFLAG(USE_SECCOMP_BPF) #if BUILDFLAG(USE_SECCOMP_BPF)
if (sdk_int_ < 22) { if (sdk_int_ < base::android::SDK_VERSION_LOLLIPOP_MR1) {
// Seccomp was never available pre-Lollipop. // Seccomp was never available pre-Lollipop.
return false; return false;
} }
if (sdk_int_ > 22) { if (sdk_int_ > base::android::SDK_VERSION_LOLLIPOP_MR1) {
// On Marshmallow and higher, Seccomp is required by CTS. // On Marshmallow and higher, Seccomp is required by CTS.
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment