Skip to content

Commit

Permalink
[PushToTalk] Add new framework for Xcode 14 bet4. (#15645)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Soto <[email protected]>
  • Loading branch information
mandel-macaque and dalexsoto authored Aug 7, 2022
1 parent d80759c commit d02dd49
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 66 deletions.
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,7 @@ IOS_FRAMEWORKS = \
Photos \
PhotosUI \
PushKit \
PushToTalk \
QuickLook \
QuickLookThumbnailing \
ReplayKit \
Expand Down
249 changes: 249 additions & 0 deletions src/pushtotalk.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
//
// PushToTalk C# bindings
//
// Authors:
// Manuel de la Pena Saenz <[email protected]>
//
// Copyright 2022 Microsoft Corporation All rights reserved.
//

using System;

using AVFoundation;
using CoreFoundation;
using Foundation;
using ObjCRuntime;
using UIKit;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace PushToTalk {

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTChannelJoinReason : long {
DeveloperRequest = 0,
ChannelRestoration = 1,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTChannelLeaveReason : long {
Unknown = 0,
UserRequest = 1,
DeveloperRequest = 2,
SystemPolicy = 3,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTChannelTransmitRequestSource : long {
Unknown = 0,
UserRequest = 1,
DeveloperRequest = 2,
HandsfreeButton = 3,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTServiceStatus : long {
Ready,
Connecting,
Unavailable,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTTransmissionMode : long {
FullDuplex,
HalfDuplex,
ListenOnly,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
[ErrorDomain ("PTInstantiationErrorDomain")]
public enum PTInstantiationError : long
{
Unknown = 0,
InvalidPlatform = 1,
MissingBackgroundMode = 2,
MissingPushServerEnvironment = 3,
MissingEntitlement = 4,
InstantiationAlreadyInProgress = 5,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
[ErrorDomain ("PTChannelErrorDomain")]
public enum PTChannelError : long
{
Unknown = 0,
ChannelNotFound = 1,
ChannelLimitReached = 2,
CallActive = 3,
TransmissionInProgress = 4,
TransmissionNotFound = 5,
AppNotForeground = 6,
DeviceManagementRestriction = 7,
ScreenTimeRestriction = 8,
TransmissionNotAllowed = 9,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTParticipant
{
[Export ("name")]
string Name { get; }

[NullAllowed, Export ("image", ArgumentSemantic.Copy)]
UIImage Image { get; }

[Export ("initWithName:image:")]
[DesignatedInitializer]
NativeHandle Constructor (string name, [NullAllowed] UIImage image);
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTPushResult
{
[Static]
[Export ("leaveChannelPushResult")]
PTPushResult LeaveChannelPushResult { get; }

[Static]
[Export ("pushResultForActiveRemoteParticipant:")]
PTPushResult Create (PTParticipant participant);
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTChannelDescriptor
{
[Export ("initWithName:image:")]
[DesignatedInitializer]
NativeHandle Constructor (string name, [NullAllowed] UIImage image);

[Export ("name")]
string Name { get; }

[NullAllowed, Export ("image", ArgumentSemantic.Copy)]
UIImage Image { get; }
}

interface IPTChannelManagerDelegate {}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Protocol]
[BaseType (typeof (NSObject))]
interface PTChannelManagerDelegate
{
[Abstract]
[Export ("channelManager:didJoinChannelWithUUID:reason:")]
void DidJoinChannel (PTChannelManager channelManager, NSUuid channelUuid, PTChannelJoinReason reason);

[Abstract]
[Export ("channelManager:didLeaveChannelWithUUID:reason:")]
void DidLeaveChannel (PTChannelManager channelManager, NSUuid channelUuid, PTChannelLeaveReason reason);

[Abstract]
[Export ("channelManager:channelUUID:didBeginTransmittingFromSource:")]
void DidBeginTransmitting (PTChannelManager channelManager, NSUuid channelUuid, PTChannelTransmitRequestSource source);

[Abstract]
[Export ("channelManager:channelUUID:didEndTransmittingFromSource:")]
void DidEndTransmitting (PTChannelManager channelManager, NSUuid channelUuid, PTChannelTransmitRequestSource source);

[Abstract]
[Export ("channelManager:receivedEphemeralPushToken:")]
void ReceivedEphemeralPushToken (PTChannelManager channelManager, NSData pushToken);

[Abstract]
[Export ("incomingPushResultForChannelManager:channelUUID:pushPayload:")]
PTPushResult IncomingPushResult (PTChannelManager channelManager, NSUuid channelUuid, NSDictionary<NSString, NSObject> pushPayload);

[NoMac]
[Abstract]
[Export ("channelManager:didActivateAudioSession:")]
void DidActivateAudioSession (PTChannelManager channelManager, AVAudioSession audioSession);

[NoMac]
[Abstract]
[Export ("channelManager:didDeactivateAudioSession:")]
void DidDeactivateAudioSession (PTChannelManager channelManager, AVAudioSession audioSession);

[Export ("channelManager:failedToJoinChannelWithUUID:error:")]
void FailedToJoinChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);

[Export ("channelManager:failedToLeaveChannelWithUUID:error:")]
void FailedToLeaveChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);

[Export ("channelManager:failedToBeginTransmittingInChannelWithUUID:error:")]
void FailedToBeginTransmittingInChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);

[Export ("channelManager:failedToStopTransmittingInChannelWithUUID:error:")]
void failedToStopTransmittingInChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);
}

interface IPTChannelRestorationDelegate {}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Protocol]
[BaseType (typeof (NSObject))]
interface PTChannelRestorationDelegate
{
[Abstract]
[Export ("channelDescriptorForRestoredChannelUUID:")]
PTChannelDescriptor Create (NSUuid channelUuid);
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTChannelManager
{
[Async]
[Static]
[Export ("channelManagerWithDelegate:restorationDelegate:completionHandler:")]
void Create (IPTChannelManagerDelegate @delegate, IPTChannelRestorationDelegate restorationDelegate, Action<PTChannelManager, NSError> completionHandler);

[NullAllowed, Export ("activeChannelUUID", ArgumentSemantic.Strong)]
NSUuid ActiveChannelUuid { get; }

[Export ("requestJoinChannelWithUUID:descriptor:")]
void RequestJoinChannel (NSUuid channelUuid, PTChannelDescriptor descriptor);

[Export ("requestBeginTransmittingWithChannelUUID:")]
void RequestBeginTransmitting (NSUuid channelUuid);

[Export ("stopTransmittingWithChannelUUID:")]
void StopTransmitting (NSUuid channelUuid);

[Export ("leaveChannelWithUUID:")]
void LeaveChannel (NSUuid channelUuid);

[Async]
[Export ("setChannelDescriptor:forChannelUUID:completionHandler:")]
void SetChannelDescriptor (PTChannelDescriptor channelDescriptor, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);

[Async]
[Export ("setActiveRemoteParticipant:forChannelUUID:completionHandler:")]
void SetActiveRemoteParticipant ([NullAllowed] PTParticipant participant, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);

[Async]
[Export ("setServiceStatus:forChannelUUID:completionHandler:")]
void SetServiceStatus (PTServiceStatus status, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);

[Async]
[Export ("setTransmissionMode:forChannelUUID:completionHandler:")]
void SetTransmissionMode (PTTransmissionMode transmissionMode, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);
}

}
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiClassPtrTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected override bool Skip (Type type)
case "Phase": // missing in the sim
case "ShazamKit": // missing in the sim
case "ThreadNetwork": // missing in the sim
case "PushToTalk": // missing in the sim
if (TestRuntime.IsSimulatorOrDesktop)
return true;
break;
Expand Down
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiCtorInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected override bool Skip (Type type)
break;
case "DeviceCheck": // Only available on device
case "MLCompute": // Only available on device
case "PushToTalk":
if (TestRuntime.IsSimulatorOrDesktop)
return true;
break;
Expand Down
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected override bool Skip (Type type)
case "MediaSetup":
case "Phase":
case "ThreadNetwork":
case "PushToTalk":
if (TestRuntime.IsSimulatorOrDesktop)
return true;
break;
Expand Down
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiSelectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected override bool Skip (Type type)
return true;
break;
#endif // HAS_WATCHCONNECTIVITY
case "PushToTalk":
case "ShazamKit":
// ShazamKit is not fully supported in the simulator
if (TestRuntime.IsSimulatorOrDesktop)
Expand Down
1 change: 1 addition & 0 deletions tests/mtouch/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ public void MT4134 ()
new { Framework = "CoreLocationUI", Version = "15.0" },
new { Framework = "Chip", Version = "15.0" },
new { Framework = "ThreadNetwork", Version = "15.0" },
new { Framework = "PushToTalk", Version = "16.0" },
};
foreach (var framework in invalidFrameworks)
mtouch.AssertError (4134, $"Your application is using the '{framework.Framework}' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS {framework.Version}, while you're building with the iOS {mtouch.Sdk} SDK.) Please select a newer SDK in your app's iOS Build options.");
Expand Down
33 changes: 0 additions & 33 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-PushToTalk.todo

This file was deleted.

33 changes: 0 additions & 33 deletions tests/xtro-sharpie/iOS-PushToTalk.todo

This file was deleted.

2 changes: 2 additions & 0 deletions tools/common/Frameworks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ public static Frameworks CreateiOSFrameworks (bool is_simulator_build)
{ "ShazamKit", "ShazamKit", new Version (15,0), NotAvailableInSimulator},
{ "ThreadNetwork", "ThreadNetwork", new Version (15,0), NotAvailableInSimulator},

{ "PushToTalk", "PushToTalk", new Version (16,0), NotAvailableInSimulator},

// the above MUST be kept in sync with simlauncher
// see tools/mtouch/Makefile
// please also keep it sorted to ease comparison
Expand Down

5 comments on commit d02dd49

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS: vsdrops gist (No breaking changes)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
.NET (No breaking changes)
  • iOS: vsdrops gist (No breaking changes)
  • tvOS: (empty diff detected)
  • MacCatalyst: vsdrops gist (No breaking changes)
  • macOS: (empty diff detected)

❗ API diff vs stable (Breaking changes)

Legacy Xamarin (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • iOS: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • tvOS: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • watchOS: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • macOS: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
.NET (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • iOS: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • tvOS: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • MacCatalyst: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • macOS: vsdrops gist (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
  • Microsoft.iOS vs Microsoft.MacCatalyst: vsdrops gist
Legacy Xamarin (stable) vs .NET

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: d02dd49235459b2799372add8f21ad3b16aa3982 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

💻 [CI Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: d02dd49235459b2799372add8f21ad3b16aa3982 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • introspection
  • monotouch-test

Pipeline on Agent
Hash: d02dd49235459b2799372add8f21ad3b16aa3982 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-070.Monterey'
Hash: d02dd49235459b2799372add8f21ad3b16aa3982 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 9 tests failed, 219 tests passed.

Failures

❌ introspection tests

1 tests failed, 12 tests passed.
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 6.0): Crashed Known issue: HE0038)

Html Report (VSDrops) Download

❌ monotouch tests

8 tests failed, 15 tests passed.
  • monotouch-test/iOS Unified 64-bits - simulator/Debug [dotnet]: TimedOut
  • monotouch-test/iOS Unified 64-bits - simulator/Debug: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (LinkSdk) [dotnet]: TimedOut
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (static registrar) [dotnet]: TimedOut
  • monotouch-test/iOS Unified 64-bits - simulator/Release (all optimizations) [dotnet]: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (LinkSdk): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (static registrar): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Release (all optimizations): Failed

Html Report (VSDrops) Download

Successes

✅ bcl: All 69 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 12 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: [CI build]

Please sign in to comment.