Fix unguarded availability warnings for iOS (flutter/engine#4664)
Place all iOS code that relies on APIs introduced in iOS versions later than our base SDK version (iOS 8) behind @available checks. This allows us to enable the -Wunguarded-availability compiler flag for iOS builds in the buildroot repo.
This commit is contained in:
@@ -198,7 +198,7 @@
|
||||
|
||||
- (void)application:(UIApplication*)application
|
||||
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
|
||||
completionHandler:(void (^)(BOOL succeeded))completionHandler {
|
||||
completionHandler:(void (^)(BOOL succeeded))completionHandler NS_AVAILABLE_IOS(9_0) {
|
||||
for (id<FlutterPlugin> plugin in _pluginDelegates) {
|
||||
if ([plugin respondsToSelector:_cmd]) {
|
||||
if ([plugin application:application
|
||||
|
||||
@@ -78,9 +78,6 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
|
||||
fml::scoped_nsprotocol<FlutterBasicMessageChannel*> _settingsChannel;
|
||||
fml::scoped_nsprotocol<UIView*> _launchView;
|
||||
int64_t _nextTextureId;
|
||||
bool _platformSupportsTouchTypes;
|
||||
bool _platformSupportsTouchPressure;
|
||||
bool _platformSupportsTouchOrientationAndTilt;
|
||||
BOOL _initialized;
|
||||
BOOL _connected;
|
||||
}
|
||||
@@ -126,10 +123,6 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
|
||||
|
||||
_initialized = YES;
|
||||
|
||||
_platformSupportsTouchTypes = fml::IsPlatformVersionAtLeast(9);
|
||||
_platformSupportsTouchPressure = fml::IsPlatformVersionAtLeast(9);
|
||||
_platformSupportsTouchOrientationAndTilt = fml::IsPlatformVersionAtLeast(9, 1);
|
||||
|
||||
_orientationPreferences = UIInterfaceOrientationMaskAll;
|
||||
_statusBarStyle = UIStatusBarStyleDefault;
|
||||
_platformView = std::make_shared<shell::PlatformViewIOS>(
|
||||
@@ -438,20 +431,19 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(UITouc
|
||||
return PointerChangeMapperPhase(blink::PointerData::Change::kCancel, MapperPhase::Accessed);
|
||||
}
|
||||
|
||||
static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch,
|
||||
bool touchTypeSupported) {
|
||||
if (!touchTypeSupported) {
|
||||
static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch) {
|
||||
if (@available(iOS 9, *)) {
|
||||
switch (touch.type) {
|
||||
case UITouchTypeDirect:
|
||||
case UITouchTypeIndirect:
|
||||
return blink::PointerData::DeviceKind::kTouch;
|
||||
case UITouchTypeStylus:
|
||||
return blink::PointerData::DeviceKind::kStylus;
|
||||
}
|
||||
} else {
|
||||
return blink::PointerData::DeviceKind::kTouch;
|
||||
}
|
||||
|
||||
switch (touch.type) {
|
||||
case UITouchTypeDirect:
|
||||
case UITouchTypeIndirect:
|
||||
return blink::PointerData::DeviceKind::kTouch;
|
||||
case UITouchTypeStylus:
|
||||
return blink::PointerData::DeviceKind::kStylus;
|
||||
}
|
||||
|
||||
return blink::PointerData::DeviceKind::kTouch;
|
||||
}
|
||||
|
||||
@@ -492,7 +484,7 @@ static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* to
|
||||
|
||||
pointer_data.change = eventTypePhase.first;
|
||||
|
||||
pointer_data.kind = DeviceKindFromTouchType(touch, _platformSupportsTouchTypes);
|
||||
pointer_data.kind = DeviceKindFromTouchType(touch);
|
||||
|
||||
pointer_data.device = device_id;
|
||||
|
||||
@@ -500,7 +492,7 @@ static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* to
|
||||
pointer_data.physical_y = windowCoordinates.y * scale;
|
||||
|
||||
// pressure_min is always 0.0
|
||||
if (_platformSupportsTouchPressure) {
|
||||
if (@available(iOS 9, *)) {
|
||||
// These properties were introduced in iOS 9.0.
|
||||
pointer_data.pressure = touch.force;
|
||||
pointer_data.pressure_max = touch.maximumPossibleForce;
|
||||
@@ -515,7 +507,7 @@ static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* to
|
||||
pointer_data.radius_max = touch.majorRadius + touch.majorRadiusTolerance;
|
||||
|
||||
// These properties were introduced in iOS 9.1
|
||||
if (_platformSupportsTouchOrientationAndTilt) {
|
||||
if (@available(iOS 9.1, *)) {
|
||||
// iOS Documentation: altitudeAngle
|
||||
// A value of 0 radians indicates that the stylus is parallel to the surface. The value of
|
||||
// this property is Pi/2 when the stylus is perpendicular to the surface.
|
||||
|
||||
@@ -106,9 +106,8 @@ IOSGLContext::IOSGLContext(PlatformView::SurfaceConfig config, CAEAGLLayer* laye
|
||||
// should use iOS APIs to perform the final correction step based on the
|
||||
// device properties. Ex: We can indicate that we have rendered in P3, and
|
||||
// the framework will do the final adjustment for us.
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
color_space_ = SkColorSpace::MakeSRGB();
|
||||
if (version.majorVersion >= 10) {
|
||||
if (@available(iOS 10, *)) {
|
||||
UIDisplayGamut displayGamut = [UIScreen mainScreen].traitCollection.displayGamut;
|
||||
switch (displayGamut) {
|
||||
case UIDisplayGamutP3:
|
||||
|
||||
Reference in New Issue
Block a user