Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Remove availability and fallbacks for iOS 11 and macOS 10.13 #34919

Merged
merged 3 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions impeller/renderer/backend/metal/allocator_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ static MTLResourceOptions ToMTLResourceOptions(StorageMode type) {
return MTLResourceStorageModePrivate;
case StorageMode::kDeviceTransient:
#if FML_OS_IOS
if (@available(iOS 10.0, *)) {
return MTLResourceStorageModeMemoryless;
} else {
return MTLResourceStorageModePrivate;
}
return MTLResourceStorageModeMemoryless;
#else
return MTLResourceStorageModePrivate;
#endif
Expand All @@ -66,11 +62,7 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode) {
return MTLStorageModePrivate;
case StorageMode::kDeviceTransient:
#if FML_OS_IOS
if (@available(iOS 10.0, *)) {
return MTLStorageModeMemoryless;
} else {
return MTLStorageModePrivate;
}
return MTLStorageModeMemoryless;
#else
return MTLStorageModePrivate;
#endif
Expand Down
17 changes: 0 additions & 17 deletions impeller/renderer/backend/metal/command_buffer_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,6 @@
namespace impeller {
namespace {

// NOLINTBEGIN(readability-identifier-naming)

// TODO(dnfield): remove this declaration when we no longer need to build on
// machines with lower SDK versions than 11.0.
#if !defined(MAC_OS_VERSION_11_0) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
typedef NS_ENUM(NSInteger, MTLCommandEncoderErrorState) {
MTLCommandEncoderErrorStateUnknown = 0,
MTLCommandEncoderErrorStateCompleted = 1,
MTLCommandEncoderErrorStateAffected = 2,
MTLCommandEncoderErrorStatePending = 3,
MTLCommandEncoderErrorStateFaulted = 4,
} API_AVAILABLE(macos(11.0), ios(14.0));
#endif

// NOLINTEND(readability-identifier-naming)

API_AVAILABLE(ios(14.0), macos(11.0))
NSString* MTLCommandEncoderErrorStateToString(
MTLCommandEncoderErrorState state) {
Expand Down
10 changes: 3 additions & 7 deletions impeller/renderer/backend/metal/device_buffer_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,9 @@
if (label.empty()) {
return false;
}
if (@available(macOS 10.12, iOS 10.0, *)) {
[buffer_ addDebugMarker:@(label.c_str())
range:NSMakeRange(range.offset, range.length)];
return true;
} else {
return SetLabel(label);
}
[buffer_ addDebugMarker:@(label.c_str())
range:NSMakeRange(range.offset, range.length)];
return true;
FML_UNREACHABLE();
}

Expand Down
36 changes: 6 additions & 30 deletions impeller/renderer/backend/metal/vertex_descriptor_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(float) / 2) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatHalf;
} else {
return MTLVertexFormatInvalid;
}
return MTLVertexFormatHalf;
case 2:
return MTLVertexFormatHalf2;
case 3:
Expand All @@ -60,23 +56,15 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
}
case ShaderType::kBoolean: {
if (input.bit_width == 8 * sizeof(bool) && input.vec_size == 1) {
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatChar;
} else {
return MTLVertexFormatInvalid;
}
return MTLVertexFormatChar;
}
return MTLVertexFormatInvalid;
}
case ShaderType::kSignedByte: {
if (input.bit_width == 8 * sizeof(char)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatChar;
} else {
return MTLVertexFormatInvalid;
}
return MTLVertexFormatChar;
case 2:
return MTLVertexFormatChar2;
case 3:
Expand All @@ -91,11 +79,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(char)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatUChar;
} else {
return MTLVertexFormatInvalid;
}
return MTLVertexFormatUChar;
case 2:
return MTLVertexFormatUChar2;
case 3:
Expand All @@ -110,11 +94,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(short)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatShort;
} else {
return MTLVertexFormatInvalid;
}
return MTLVertexFormatShort;
case 2:
return MTLVertexFormatShort2;
case 3:
Expand All @@ -129,11 +109,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(ushort)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatUShort;
} else {
return MTLVertexFormatInvalid;
}
return MTLVertexFormatUShort;
case 2:
return MTLVertexFormatUShort2;
case 3:
Expand Down
11 changes: 3 additions & 8 deletions shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Protocol for listener of events from the UIApplication, typically a FlutterPlugin.
*/
@protocol FlutterApplicationLifeCycleDelegate
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
<UNUserNotificationCenterDelegate>
#endif
@protocol FlutterApplicationLifeCycleDelegate <UNUserNotificationCenterDelegate>

@optional
/**
* Called if this has been registered for `UIApplicationDelegate` callbacks.
Expand Down Expand Up @@ -432,10 +430,7 @@ typedef enum {
* For plugins to receive events from `UNUserNotificationCenter`, register this as the
* `UNUserNotificationCenterDelegate`.
*/
@protocol FlutterAppLifeCycleProvider
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
<UNUserNotificationCenterDelegate>
#endif
@protocol FlutterAppLifeCycleProvider <UNUserNotificationCenterDelegate>

/**
* Called when registering a new `FlutterApplicaitonLifeCycleDelegate`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
* Propagates `UIAppDelegate` callbacks to registered plugins.
*/
FLUTTER_DARWIN_EXPORT
@interface FlutterPluginAppLifeCycleDelegate : NSObject
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
<UNUserNotificationCenterDelegate>
#endif
@interface FlutterPluginAppLifeCycleDelegate : NSObject <UNUserNotificationCenterDelegate>

/**
* Registers `delegate` to receive life cycle callbacks via this FlutterPluginAppLifecycleDelegate
Expand Down
33 changes: 11 additions & 22 deletions shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,11 @@ - (void)application:(UIApplication*)application
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler
NS_AVAILABLE_IOS(10_0) {
if (@available(iOS 10.0, *)) {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
(void (^)(UNNotificationPresentationOptions options))completionHandler {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
}

Expand All @@ -129,13 +126,11 @@ - (void)userNotificationCenter:(UNUserNotificationCenter*)center
*/
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10_0) {
if (@available(iOS 10.0, *)) {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
withCompletionHandler:(void (^)(void))completionHandler {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
}

Expand Down Expand Up @@ -199,7 +194,7 @@ - (BOOL)application:(UIApplication*)application

- (void)application:(UIApplication*)application
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
completionHandler:(void (^)(BOOL succeeded))completionHandler NS_AVAILABLE_IOS(9_0) {
completionHandler:(void (^)(BOOL succeeded))completionHandler {
[_lifeCycleDelegate application:application
performActionForShortcutItem:shortcutItem
completionHandler:completionHandler];
Expand All @@ -213,16 +208,10 @@ - (void)application:(UIApplication*)application
completionHandler:completionHandler];
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000
- (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>>* __nullable
restorableObjects))restorationHandler {
#else
- (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray* __nullable restorableObjects))restorationHandler {
#endif
if ([_lifeCycleDelegate application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ + (NSData*)createTxtData:(NSURL*)url;

@end

@interface ObservatoryNSNetServiceDelegate
: NSObject <FlutterObservatoryPublisherDelegate, NSNetServiceDelegate>
@end

@interface ObservatoryDNSServiceDelegate : NSObject <FlutterObservatoryPublisherDelegate>
@end

Expand Down Expand Up @@ -116,15 +112,6 @@ - (void)publishServiceProtocolPort:(NSURL*)url {
}
}

/// TODO(aaclarke): Remove this preprocessor macro once infra is moved to Xcode 12.
static const DNSServiceErrorType kFlutter_DNSServiceErr_PolicyDenied =
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
kDNSServiceErr_PolicyDenied;
#else
// Found in usr/include/dns_sd.h.
-65570;
#endif // __IPHONE_OS_VERSION_MAX_ALLOWED

static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
DNSServiceFlags flags,
DNSServiceErrorType errorCode,
Expand All @@ -134,7 +121,7 @@ static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
void* context) {
if (errorCode == kDNSServiceErr_NoError) {
FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!";
} else if (errorCode == kFlutter_DNSServiceErr_PolicyDenied) {
} else if (errorCode == kDNSServiceErr_PolicyDenied) {
FML_LOG(ERROR)
<< "Could not register as server for FlutterObservatoryPublisher, permission "
<< "denied. Check your 'Local Network' permissions for this app in the Privacy section of "
Expand All @@ -147,38 +134,6 @@ static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,

@end

@implementation ObservatoryNSNetServiceDelegate {
fml::scoped_nsobject<NSNetService> _netService;
}

- (void)stopService {
[_netService.get() stop];
[_netService.get() setDelegate:nil];
}

- (void)publishServiceProtocolPort:(NSURL*)url {
NSNetService* netServiceTmp =
[[NSNetService alloc] initWithDomain:@"local."
type:@"_dartobservatory._tcp."
name:FlutterObservatoryPublisher.serviceName
port:[[url port] intValue]];
[netServiceTmp setTXTRecordData:[FlutterObservatoryPublisher createTxtData:url]];
_netService.reset(netServiceTmp);
[_netService.get() setDelegate:self];
[_netService.get() publish];
}

- (void)netServiceDidPublish:(NSNetService*)sender {
FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!";
}

- (void)netService:(NSNetService*)sender didNotPublish:(NSDictionary*)errorDict {
FML_LOG(ERROR) << "Could not register as server for FlutterObservatoryPublisher. Check your "
"network settings and relaunch the application.";
}

@end

@implementation FlutterObservatoryPublisher {
flutter::DartServiceIsolate::CallbackHandle _callbackHandle;
std::unique_ptr<fml::WeakPtrFactory<FlutterObservatoryPublisher>> _weakFactory;
Expand All @@ -188,11 +143,7 @@ - (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPubl
self = [super init];
NSAssert(self, @"Super must not return null on init.");

if (@available(iOS 9.3, *)) {
_delegate.reset([[ObservatoryDNSServiceDelegate alloc] init]);
} else {
_delegate.reset([[ObservatoryNSNetServiceDelegate alloc] init]);
}
_delegate.reset([[ObservatoryDNSServiceDelegate alloc] init]);
_enableObservatoryPublication = enableObservatoryPublication;
_weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterObservatoryPublisher>>(self);

Expand Down
36 changes: 13 additions & 23 deletions shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
constexpr char kTextPlainFormat[] = "text/plain";
const UInt32 kKeyPressClickSoundId = 1306;

} // namespaces
} // namespace
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatter wanted to touch this.


namespace flutter {

Expand Down Expand Up @@ -107,19 +107,17 @@ - (void)vibrateHapticFeedback:(NSString*)feedbackType {
return;
}

if (@available(iOS 10, *)) {
if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] autorelease]
impactOccurred];
} else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] autorelease]
impactOccurred];
} else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] autorelease]
impactOccurred];
} else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) {
[[[[UISelectionFeedbackGenerator alloc] init] autorelease] selectionChanged];
}
if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] autorelease]
impactOccurred];
} else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] autorelease]
impactOccurred];
} else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] autorelease]
impactOccurred];
} else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) {
[[[[UISelectionFeedbackGenerator alloc] init] autorelease] selectionChanged];
}
}

Expand Down Expand Up @@ -276,15 +274,7 @@ - (void)setClipboardData:(NSDictionary*)data {
}

- (NSDictionary*)clipboardHasStrings {
bool hasStrings = false;
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
if (@available(iOS 10, *)) {
hasStrings = pasteboard.hasStrings;
} else {
NSString* stringInPasteboard = pasteboard.string;
hasStrings = stringInPasteboard != nil;
}
return @{@"value" : @(hasStrings)};
return @{@"value" : @([UIPasteboard generalPasteboard].hasStrings)};
}

@end
Loading