-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix _availability_version_check for iOS 11 and 12 (#48624)
This PR ports more of the implementation of availability checking from clang-rt into the Engine. In particular, when the call to look up the symbol `_availability_version_check` fails, this PR falls back on reading the platform version information out of a plist file at a well-known location, as is done [here](https://github.com/llvm/llvm-project/blob/2fd66e6eb659701b9d4c88708d55d5854a246815/compiler-rt/lib/builtins/os_version_check.c#L163). This change fixes a mistake in #44711, which didn't account for `_availability_version_check` not being available on iOS 11 and 12. Fixes flutter/flutter#138711
- Loading branch information
Showing
10 changed files
with
260 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <cstdint> | ||
#include <optional> | ||
#include <tuple> | ||
|
||
namespace flutter { | ||
|
||
using ProductVersion = | ||
std::tuple<int32_t /* major */, int32_t /* minor */, int32_t /* patch */>; | ||
|
||
std::optional<ProductVersion> ProductVersionFromSystemVersionPList(); | ||
|
||
bool IsEncodedVersionLessThanOrSame(uint32_t encoded_lhs, ProductVersion rhs); | ||
|
||
} // namespace flutter |
35 changes: 35 additions & 0 deletions
35
shell/platform/darwin/common/availability_version_check_unittests.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <tuple> | ||
|
||
#include "flutter/shell/platform/darwin/common/availability_version_check.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
TEST(AvailabilityVersionCheck, CanDecodeSystemPlist) { | ||
auto maybe_product_version = flutter::ProductVersionFromSystemVersionPList(); | ||
ASSERT_TRUE(maybe_product_version.has_value()); | ||
if (maybe_product_version.has_value()) { | ||
auto product_version = maybe_product_version.value(); | ||
ASSERT_GT(product_version, std::make_tuple(0, 0, 0)); | ||
} | ||
} | ||
|
||
static inline uint32_t ConstructVersion(uint32_t major, | ||
uint32_t minor, | ||
uint32_t subminor) { | ||
return ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff); | ||
} | ||
|
||
TEST(AvailabilityVersionCheck, CanParseAndCompareVersions) { | ||
auto rhs_version = std::make_tuple(17, 2, 0); | ||
uint32_t encoded_lower_version = ConstructVersion(12, 3, 7); | ||
ASSERT_TRUE(flutter::IsEncodedVersionLessThanOrSame(encoded_lower_version, | ||
rhs_version)); | ||
|
||
uint32_t encoded_higher_version = ConstructVersion(42, 0, 1); | ||
ASSERT_FALSE(flutter::IsEncodedVersionLessThanOrSame(encoded_higher_version, | ||
rhs_version)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
shell/platform/darwin/ios/framework/Source/availability_version_check_test.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <tuple> | ||
|
||
#import <OCMock/OCMock.h> | ||
#import <XCTest/XCTest.h> | ||
|
||
#import "flutter/shell/platform/darwin/common/availability_version_check.h" | ||
|
||
@interface AvailabilityVersionCheckTest : XCTestCase | ||
@end | ||
|
||
@implementation AvailabilityVersionCheckTest | ||
|
||
- (void)testSimple { | ||
auto maybe_product_version = flutter::ProductVersionFromSystemVersionPList(); | ||
XCTAssertTrue(maybe_product_version.has_value()); | ||
if (maybe_product_version.has_value()) { | ||
auto product_version = maybe_product_version.value(); | ||
XCTAssertTrue(product_version > std::make_tuple(0, 0, 0)); | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters