Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AccessorySetupKit] Implement Xcode 16.0 beta 1-6 changes. #20857

Merged
merged 14 commits into from
Sep 3, 2024
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
256 changes: 256 additions & 0 deletions src/accessorysetupkit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
#if NET
using System;

using CoreBluetooth;
using CoreFoundation;
using Foundation;
using ObjCRuntime;
using UIKit;

namespace AccessorySetupKit {
[Native]
[iOS (18, 0)]
public enum ASAccessoryState : long {
Unauthorized = 0,
AwaitingAuthorization = 10,
Authorized = 20,
}

[Flags]
[Native]
[iOS (18, 0)]
public enum ASAccessoryRenameOptions : ulong {
Ssid = 1U << 0,
}

[Flags]
[Native]
[iOS (18, 0)]
public enum ASAccessorySupportOptions : ulong {
BluetoothPairingLE = 1U << 1,
BluetoothTransportBridging = 1U << 2,
}

[Native]
[iOS (18, 0)]
public enum ASDiscoveryDescriptorRange : long {
Default = 0,
Immediate = 10,
}

[Flags]
[Native]
[iOS (18, 0)]
public enum ASPickerDisplayItemSetupOptions : long {
Rename = 1 << 0,
ConfirmAuthorization = 1 << 1,
FinishInApp = 1 << 2,
}

[BaseType (typeof (NSObject))]
[iOS (18, 0)]
[DisableDefaultCtor]
interface ASAccessory {
[Export ("state", ArgumentSemantic.Assign)]
ASAccessoryState State { get; }

[Export ("bluetoothIdentifier", ArgumentSemantic.Copy), NullAllowed]
NSUuid BluetoothIdentifier { get; }

[Export ("displayName", ArgumentSemantic.Copy)]
string DisplayName { get; }

[Export ("SSID", ArgumentSemantic.Copy), NullAllowed]
string Ssid { get; }

[Export ("descriptor", ArgumentSemantic.Copy)]
ASDiscoveryDescriptor Descriptor { get; }

[Export ("bluetoothTransportBridgingIdentifier", ArgumentSemantic.Copy), NullAllowed]
NSData BluetoothTransportBridgingIdentifier { get; }
}

[Native]
[iOS (18, 0)]
public enum ASAccessoryEventType : long {
Unknown = 0,
Activated = 10,
Invalidated = 11,
MigrationComplete = 20,
AccessoryAdded = 30,
AccessoryRemoved = 31,
AccessoryChanged = 32,
PickerDidPresent = 40,
PickerDidDismiss = 50,
PickerSetupBridging = 60,
PickerSetupFailed = 70,
PickerSetupPairing = 80,
PickerSetupRename = 90,
}

[BaseType (typeof (NSObject))]
[iOS (18, 0)]
[DisableDefaultCtor]
interface ASAccessoryEvent {
[Export ("eventType", ArgumentSemantic.Assign)]
ASAccessoryEventType EventType { get; }

[Export ("accessory", ArgumentSemantic.Copy), NullAllowed]
ASAccessory Accessory { get; }

[Export ("error", ArgumentSemantic.Copy), NullAllowed]
NSError Error { get; }
}

delegate void ASAccessorySessionCompletionHandler ([NullAllowed] NSError error);

[BaseType (typeof (NSObject))]
[iOS (18, 0)]
[DisableDefaultCtor]
interface ASAccessorySession {
[Export ("accessories", ArgumentSemantic.Copy)]
ASAccessory [] Accessories { get; }

[Export ("activateWithQueue:eventHandler:")]
void Activate (DispatchQueue queue, Action<ASAccessoryEvent> eventHandler);

[Export ("invalidate")]
void Invalidate ();

[Async]
[Export ("showPickerWithCompletionHandler:")]
void ShowPicker (ASAccessorySessionCompletionHandler completionHandler);

[Async]
[Export ("showPickerForDisplayItems:completionHandler:")]
void ShowPicker (ASPickerDisplayItem [] displayItems, ASAccessorySessionCompletionHandler completionHandler);

[Async]
[Export ("finishAuthorization:settings:completionHandler:")]
void FinishAuthorization (ASAccessory accessory, ASAccessorySettings settings, ASAccessorySessionCompletionHandler completionHandler);

[Async]
[Export ("removeAccessory:completionHandler:")]
void RemoveAccessory (ASAccessory accessory, ASAccessorySessionCompletionHandler completionHandler);

[Async]
[Export ("renameAccessory:options:completionHandler:")]
void RenameAccessory (ASAccessory accessory, ASAccessoryRenameOptions renameOptions, ASAccessorySessionCompletionHandler completionHandler);

[Async]
[Export ("failAuthorization:completionHandler:")]
void FailAuthorization (ASAccessory accessory, ASAccessorySessionCompletionHandler completionHandler);
}

[BaseType (typeof (NSObject))]
[iOS (18, 0)]
[DisableDefaultCtor]
interface ASAccessorySettings {
[Export ("defaultSettings")]
[Static]
ASAccessorySettings DefaultSettings { get; }

[Export ("SSID", ArgumentSemantic.Copy), NullAllowed]
string Ssid { get; set; }

[Export ("bluetoothTransportBridgingIdentifier", ArgumentSemantic.Copy), NullAllowed]
NSData BluetoothTransportBridgingIdentifier { get; set; }
}

[BaseType (typeof (NSObject))]
[iOS (18, 0)]
[DisableDefaultCtor]
interface ASDiscoveryDescriptor {
[Export ("supportedOptions", ArgumentSemantic.Assign)]
ASAccessorySupportOptions SupportedOptions { get; set; }

[Export ("bluetoothCompanyIdentifier", ArgumentSemantic.Assign)]
ushort /* ASBluetoothCompanyIdentifier */ BluetoothCompanyIdentifier { get; set; }

[Export ("bluetoothManufacturerDataBlob", ArgumentSemantic.Copy), NullAllowed]
NSData BluetoothManufacturerDataBlob { get; set; }

[Export ("bluetoothManufacturerDataMask", ArgumentSemantic.Copy), NullAllowed]
NSData BluetoothManufacturerDataMask { get; set; }

[Export ("bluetoothNameSubstring", ArgumentSemantic.Copy), NullAllowed]
string BluetoothNameSubstring { get; set; }

[Export ("bluetoothRange", ArgumentSemantic.Assign)]
ASDiscoveryDescriptorRange BluetoothRange { get; set; }

[Export ("bluetoothServiceDataBlob", ArgumentSemantic.Copy), NullAllowed]
NSData BluetoothServiceDataBlob { get; set; }

[Export ("bluetoothServiceDataMask", ArgumentSemantic.Copy), NullAllowed]
NSData BluetoothServiceDataMask { get; set; }

[Export ("bluetoothServiceUUID", ArgumentSemantic.Copy), NullAllowed]
CBUUID BluetoothServiceUuid { get; set; }
[Export ("SSID", ArgumentSemantic.Copy), NullAllowed]
string Ssid { get; set; }

[Export ("SSIDPrefix", ArgumentSemantic.Copy), NullAllowed]
string SsidPrefix { get; set; }
}

[Native]
[iOS (18, 0)]
[ErrorDomain ("ASErrorDomain")]
enum ASErrorCode : long {
Success = 0,
Unknown = 1,
ActivationFailed = 100,
ConnectionFailed = 150,
DiscoveryTimeout = 200,
ExtensionNotFound = 300,
Invalidated = 400,
InvalidRequest = 450,
PickerAlreadyActive = 500,
PickerRestricted = 550,
UserCancelled = 700,
UserRestricted = 750,
}

[BaseType (typeof (NSObject))]
[iOS (18, 0)]
[DisableDefaultCtor]
interface ASPickerDisplayItem {
[Export ("name", ArgumentSemantic.Copy)]
string Name { get; }

[Export ("productImage", ArgumentSemantic.Copy)]
UIImage ProductImage { get; }

[Export ("descriptor", ArgumentSemantic.Copy)]
ASDiscoveryDescriptor Descriptor { get; set; }

[Export ("renameOptions", ArgumentSemantic.Assign)]
ASAccessoryRenameOptions RenameOptions { get; set; }

[Export ("setupOptions", ArgumentSemantic.Assign)]
ASPickerDisplayItemSetupOptions SetupOptions { get; set; }

[Export ("initWithName:productImage:descriptor:")]
[DesignatedInitializer]
NativeHandle Constructor (string name, UIImage productImage, ASDiscoveryDescriptor descriptor);
}

[BaseType (typeof (ASPickerDisplayItem))]
[iOS (18, 0)]
[DisableDefaultCtor]
interface ASMigrationDisplayItem {
[Export ("peripheralIdentifier", ArgumentSemantic.Copy), NullAllowed]
NSUuid PeripheralIdentifier { get; set; }

[Export ("hotspotSSID", ArgumentSemantic.Copy), NullAllowed]
string HotspotSsid { get; set; }

// re-exposed from base
[Export ("initWithName:productImage:descriptor:")]
[DesignatedInitializer]
NativeHandle Constructor (string name, UIImage productImage, ASDiscoveryDescriptor descriptor);
}
}

#endif // !NET
3 changes: 3 additions & 0 deletions src/build/generator-frameworks.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ partial class Frameworks {
internal readonly HashSet<string> iosframeworks = new HashSet<string> {
"Accelerate",
"Accessibility",
"AccessorySetupKit",
"Accounts",
"AddressBook",
"AddressBookUI",
Expand Down Expand Up @@ -562,6 +563,7 @@ partial class Frameworks {
};
bool? _Accelerate;
bool? _Accessibility;
bool? _AccessorySetupKit;
bool? _Accounts;
bool? _AddressBook;
bool? _AddressBookUI;
Expand Down Expand Up @@ -733,6 +735,7 @@ partial class Frameworks {
bool? _XKit;
public bool HaveAccelerate { get { if (!_Accelerate.HasValue) _Accelerate = GetValue ("Accelerate"); return _Accelerate.Value; } }
public bool HaveAccessibility { get { if (!_Accessibility.HasValue) _Accessibility = GetValue ("Accessibility"); return _Accessibility.Value; } }
public bool HaveAccessorySetupKit { get { if (!_AccessorySetupKit.HasValue) _AccessorySetupKit = GetValue ("AccessorySetupKit"); return _AccessorySetupKit.Value; } }
public bool HaveAccounts { get { if (!_Accounts.HasValue) _Accounts = GetValue ("Accounts"); return _Accounts.Value; } }
public bool HaveAddressBook { get { if (!_AddressBook.HasValue) _AddressBook = GetValue ("AddressBook"); return _AddressBook.Value; } }
public bool HaveAddressBookUI { get { if (!_AddressBookUI.HasValue) _AddressBookUI = GetValue ("AddressBookUI"); return _AddressBookUI.Value; } }
Expand Down
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -2211,6 +2211,7 @@ IOS_FRAMEWORKS = \
AVKit \
AVRouting \
Accounts \
AccessorySetupKit \
AdServices \
AdSupport \
AddressBook \
Expand Down
1 change: 1 addition & 0 deletions src/rsp/dotnet/ios-defines-dotnet.rsp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-d:HAS_ACCELERATE
-d:HAS_ACCESSIBILITY
-d:HAS_ACCESSORYSETUPKIT
-d:HAS_ACCOUNTS
-d:HAS_ADDRESSBOOK
-d:HAS_ADDRESSBOOKUI
Expand Down
1 change: 1 addition & 0 deletions src/rsp/ios-defines.rsp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-d:HAS_ACCELERATE
-d:HAS_ACCESSIBILITY
-d:HAS_ACCESSORYSETUPKIT
-d:HAS_ACCOUNTS
-d:HAS_ADDRESSBOOK
-d:HAS_ADDRESSBOOKUI
Expand Down
1 change: 1 addition & 0 deletions tests/cecil-tests/ApiAvailabilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ bool SkipSupportedAndObsoleteAtTheSameTime (ICustomAttributeProvider api, AppleP
case "SceneKit.SCNAnimationPlayer.PauseAnimation(Foundation.NSString)":
case "SceneKit.SCNAnimationPlayer.RemoveAnimation(Foundation.NSString, System.Runtime.InteropServices.NFloat)":
case "SceneKit.SCNAnimationPlayer.ResumeAnimation(Foundation.NSString)":
case "System.Boolean AccessorySetupKit.ASPickerDisplayItem::AllowsRename()": // Apple introduced and deprecated in the same version.
return true;
}
break;
Expand Down
Loading