diff --git a/src/backgroundassets.cs b/src/backgroundassets.cs new file mode 100644 index 000000000000..55067e4953a1 --- /dev/null +++ b/src/backgroundassets.cs @@ -0,0 +1,185 @@ +// +// BackgroundAssets C# bindings +// +// Authors: +// Manuel de la Pena Saenz +// +// Copyright 2022 Microsoft Corporation All rights reserved. +// + +using System; + +using CoreFoundation; +using Foundation; +using ObjCRuntime; + +#if !NET +using NativeHandle = System.IntPtr; +#endif + +namespace BackgroundAssets { + [NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [Native] + public enum BADownloadState : long { + Failed = -1, + Created = 0, + Waiting, + Downloading, + Finished, + } + + [NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface BADownload : NSCoding, NSSecureCoding, NSCopying + { + [Export ("state")] + BADownloadState State { get; } + + [Export ("identifier")] + string Identifier { get; } + + [Export ("uniqueIdentifier")] + string UniqueIdentifier { get; } + + [Export ("priority")] + nint Priority { get; } + + [NullAllowed, Export ("error")] + NSError Error { get; } + } + + [NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface BAApplicationExtensionInfo : NSSecureCoding + { + [Export ("applicationIdentifier")] + string ApplicationIdentifier { get; } + + [NullAllowed, Export ("lastPeriodicCheckTime")] + NSDate LastPeriodicCheckTime { get; } + + [NullAllowed, Export ("lastApplicationLaunchTime")] + NSDate LastApplicationLaunchTime { get; } + + [Export ("downloadSizeRestricted")] + bool DownloadSizeRestricted { get; } + } + + [NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [Protocol] + interface BADownloaderExtension { + + [Export ("applicationDidInstallWithMetadata:")] + void DidInstallWithMetadata (BAApplicationExtensionInfo metadata); + + [Export ("applicationDidUpdateWithMetadata:")] + void DidUpdateWithMetadata (BAApplicationExtensionInfo metadata); + + [Export ("checkForUpdatesWithMetadata:")] + void CheckForUpdates (BAApplicationExtensionInfo metadata); + + [Export ("receivedAuthenticationChallenge:download:completionHandler:")] + void ReceivedAuthenticationChallenge (NSUrlAuthenticationChallenge challenge, BADownload download, Action completionHandler); + + [Export ("backgroundDownloadDidFail:")] + void BackgroundDownloadDidFail (BADownload failedDownload); + + [Export ("backgroundDownloadDidFinish:fileURL:")] + void BackgroundDownloadDidFinish (BADownload finishedDownload, NSUrl fileUrl); + + [Export ("extensionWillTerminate")] + void ExtensionWillTerminate (); + } + + interface IBADownloadManagerDelegate {} + + [NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)] +#if NET + [Protocol][Model] +#else + [Protocol][Model (AutoGeneratedName = true)] +#endif + [BaseType (typeof (NSObject))] + interface BADownloadManagerDelegate + { + [Export ("downloadDidBegin:")] + void DidBegin (BADownload download); + + [Export ("downloadDidPause:")] + void DidPause (BADownload download); + + [Export ("download:didWriteBytes:totalBytesWritten:totalBytesExpectedToWrite:")] + void DidWriteBytes (BADownload download, long bytesWritten, long totalBytesWritten, long totalExpectedBytes); + + [Export ("download:didReceiveChallenge:completionHandler:")] + void DidReceiveChallenge (BADownload download, NSUrlAuthenticationChallenge challenge, Action completionHandler); + + [Export ("download:failedWithError:")] + void Failed (BADownload download, NSError error); + + [Export ("download:finishedWithFileURL:")] + void Finished (BADownload download, NSUrl fileUrl); + } + + [NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface BADownloadManager + { + [Static] + [Export ("sharedManager", ArgumentSemantic.Strong)] + BADownloadManager SharedManager { get; } + + [Wrap ("WeakDelegate")] + [NullAllowed] + IBADownloadManagerDelegate Delegate { get; set; } + + [NullAllowed, Export ("delegate", ArgumentSemantic.Weak)] + NSObject WeakDelegate { get; set; } + + [Async] + [Export ("fetchCurrentDownloadsWithCompletionHandler:")] + void FetchCurrentDownloads (Action, NSError> completionHandler); + + [Export ("scheduleDownload:error:")] + bool ScheduleDownload (BADownload download, [NullAllowed] out NSError outError); + + [Export ("performWithExclusiveControl:")] + void PerformWithExclusiveControl (Action performHandler); + + [Export ("performWithExclusiveControlBeforeDate:completion:")] + void PerformWithExclusiveControl (NSDate date, Action performHandler); + + [Export ("startForegroundDownload:error:")] + bool StartForegroundDownload (BADownload download, [NullAllowed] out NSError outError); + + [Export ("cancelDownload:error:")] + bool CancelDownload (BADownload download, [NullAllowed] out NSError error); + } + + [NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [BaseType (typeof (BADownload), Name = "BAURLDownload")] + [DisableDefaultCtor] + interface BAUrlDownload + { + + [Field ("BADownloaderPriorityMin")] + nint MinPriority { get; } + + [Field ("BADownloaderPriorityDefault")] + nint DefaultPriority { get; } + + [Field ("BADownloaderPriorityMax")] + nint MaxPriority { get; } + + [Export ("initWithIdentifier:request:applicationGroupIdentifier:")] + NativeHandle Constructor (string identifier, NSUrlRequest request, string applicationGroupIdentifier); + + [Export ("initWithIdentifier:request:applicationGroupIdentifier:priority:")] + [DesignatedInitializer] + NativeHandle Constructor (string identifier, NSUrlRequest request, string applicationGroupIdentifier, nint priority); + } + +} diff --git a/src/frameworks.sources b/src/frameworks.sources index f60facef7eee..efae18f4c384 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1992,6 +1992,7 @@ MACOS_FRAMEWORKS = \ AutomaticAssessmentConfiguration \ AVKit \ BusinessChat \ + BackgroundAssets \ CallKit \ CFNetwork \ Chip \ @@ -2095,6 +2096,7 @@ IOS_FRAMEWORKS = \ AudioToolbox \ AudioUnit \ AutomaticAssessmentConfiguration \ + BackgroundAssets \ BackgroundTasks \ BusinessChat \ CallKit \ @@ -2287,6 +2289,7 @@ MACCATALYST_FRAMEWORKS = \ AudioToolbox \ AudioUnit \ AutomaticAssessmentConfiguration \ + BackgroundAssets \ BackgroundTasks \ BusinessChat \ CallKit \ diff --git a/tests/mtouch/RegistrarTest.cs b/tests/mtouch/RegistrarTest.cs index b886fda05f1a..390bdc248f11 100644 --- a/tests/mtouch/RegistrarTest.cs +++ b/tests/mtouch/RegistrarTest.cs @@ -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 = "BackgroundAssets", Version = "16.0" }, new { Framework = "PushToTalk", Version = "16.0" }, }; foreach (var framework in invalidFrameworks) diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-BackgroundAssets.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-BackgroundAssets.todo deleted file mode 100644 index 6e5774d2b790..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-BackgroundAssets.todo +++ /dev/null @@ -1,30 +0,0 @@ -!missing-enum! BADownloadState not bound -!missing-field! BADownloaderPriorityDefault not bound -!missing-field! BADownloaderPriorityMax not bound -!missing-field! BADownloaderPriorityMin not bound -!missing-protocol! BADownloaderExtension not bound -!missing-protocol! BADownloadManagerDelegate not bound -!missing-selector! +BADownloadManager::sharedManager not bound -!missing-selector! BAApplicationExtensionInfo::applicationIdentifier not bound -!missing-selector! BAApplicationExtensionInfo::downloadSizeRestricted not bound -!missing-selector! BAApplicationExtensionInfo::lastApplicationLaunchTime not bound -!missing-selector! BAApplicationExtensionInfo::lastPeriodicCheckTime not bound -!missing-selector! BADownload::error not bound -!missing-selector! BADownload::identifier not bound -!missing-selector! BADownload::priority not bound -!missing-selector! BADownload::state not bound -!missing-selector! BADownload::uniqueIdentifier not bound -!missing-selector! BADownloadManager::cancelDownload:error: not bound -!missing-selector! BADownloadManager::delegate not bound -!missing-selector! BADownloadManager::fetchCurrentDownloadsWithCompletionHandler: not bound -!missing-selector! BADownloadManager::performWithExclusiveControl: not bound -!missing-selector! BADownloadManager::performWithExclusiveControlBeforeDate:completion: not bound -!missing-selector! BADownloadManager::scheduleDownload:error: not bound -!missing-selector! BADownloadManager::setDelegate: not bound -!missing-selector! BADownloadManager::startForegroundDownload:error: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier:priority: not bound -!missing-type! BAApplicationExtensionInfo not bound -!missing-type! BADownload not bound -!missing-type! BADownloadManager not bound -!missing-type! BAURLDownload not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-BackgroundAssets.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-BackgroundAssets.todo deleted file mode 100644 index 6e5774d2b790..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-BackgroundAssets.todo +++ /dev/null @@ -1,30 +0,0 @@ -!missing-enum! BADownloadState not bound -!missing-field! BADownloaderPriorityDefault not bound -!missing-field! BADownloaderPriorityMax not bound -!missing-field! BADownloaderPriorityMin not bound -!missing-protocol! BADownloaderExtension not bound -!missing-protocol! BADownloadManagerDelegate not bound -!missing-selector! +BADownloadManager::sharedManager not bound -!missing-selector! BAApplicationExtensionInfo::applicationIdentifier not bound -!missing-selector! BAApplicationExtensionInfo::downloadSizeRestricted not bound -!missing-selector! BAApplicationExtensionInfo::lastApplicationLaunchTime not bound -!missing-selector! BAApplicationExtensionInfo::lastPeriodicCheckTime not bound -!missing-selector! BADownload::error not bound -!missing-selector! BADownload::identifier not bound -!missing-selector! BADownload::priority not bound -!missing-selector! BADownload::state not bound -!missing-selector! BADownload::uniqueIdentifier not bound -!missing-selector! BADownloadManager::cancelDownload:error: not bound -!missing-selector! BADownloadManager::delegate not bound -!missing-selector! BADownloadManager::fetchCurrentDownloadsWithCompletionHandler: not bound -!missing-selector! BADownloadManager::performWithExclusiveControl: not bound -!missing-selector! BADownloadManager::performWithExclusiveControlBeforeDate:completion: not bound -!missing-selector! BADownloadManager::scheduleDownload:error: not bound -!missing-selector! BADownloadManager::setDelegate: not bound -!missing-selector! BADownloadManager::startForegroundDownload:error: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier:priority: not bound -!missing-type! BAApplicationExtensionInfo not bound -!missing-type! BADownload not bound -!missing-type! BADownloadManager not bound -!missing-type! BAURLDownload not bound diff --git a/tests/xtro-sharpie/iOS-BackgroundAssets.todo b/tests/xtro-sharpie/iOS-BackgroundAssets.todo deleted file mode 100644 index 6e5774d2b790..000000000000 --- a/tests/xtro-sharpie/iOS-BackgroundAssets.todo +++ /dev/null @@ -1,30 +0,0 @@ -!missing-enum! BADownloadState not bound -!missing-field! BADownloaderPriorityDefault not bound -!missing-field! BADownloaderPriorityMax not bound -!missing-field! BADownloaderPriorityMin not bound -!missing-protocol! BADownloaderExtension not bound -!missing-protocol! BADownloadManagerDelegate not bound -!missing-selector! +BADownloadManager::sharedManager not bound -!missing-selector! BAApplicationExtensionInfo::applicationIdentifier not bound -!missing-selector! BAApplicationExtensionInfo::downloadSizeRestricted not bound -!missing-selector! BAApplicationExtensionInfo::lastApplicationLaunchTime not bound -!missing-selector! BAApplicationExtensionInfo::lastPeriodicCheckTime not bound -!missing-selector! BADownload::error not bound -!missing-selector! BADownload::identifier not bound -!missing-selector! BADownload::priority not bound -!missing-selector! BADownload::state not bound -!missing-selector! BADownload::uniqueIdentifier not bound -!missing-selector! BADownloadManager::cancelDownload:error: not bound -!missing-selector! BADownloadManager::delegate not bound -!missing-selector! BADownloadManager::fetchCurrentDownloadsWithCompletionHandler: not bound -!missing-selector! BADownloadManager::performWithExclusiveControl: not bound -!missing-selector! BADownloadManager::performWithExclusiveControlBeforeDate:completion: not bound -!missing-selector! BADownloadManager::scheduleDownload:error: not bound -!missing-selector! BADownloadManager::setDelegate: not bound -!missing-selector! BADownloadManager::startForegroundDownload:error: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier:priority: not bound -!missing-type! BAApplicationExtensionInfo not bound -!missing-type! BADownload not bound -!missing-type! BADownloadManager not bound -!missing-type! BAURLDownload not bound diff --git a/tests/xtro-sharpie/macOS-BackgroundAssets.todo b/tests/xtro-sharpie/macOS-BackgroundAssets.todo deleted file mode 100644 index 6e5774d2b790..000000000000 --- a/tests/xtro-sharpie/macOS-BackgroundAssets.todo +++ /dev/null @@ -1,30 +0,0 @@ -!missing-enum! BADownloadState not bound -!missing-field! BADownloaderPriorityDefault not bound -!missing-field! BADownloaderPriorityMax not bound -!missing-field! BADownloaderPriorityMin not bound -!missing-protocol! BADownloaderExtension not bound -!missing-protocol! BADownloadManagerDelegate not bound -!missing-selector! +BADownloadManager::sharedManager not bound -!missing-selector! BAApplicationExtensionInfo::applicationIdentifier not bound -!missing-selector! BAApplicationExtensionInfo::downloadSizeRestricted not bound -!missing-selector! BAApplicationExtensionInfo::lastApplicationLaunchTime not bound -!missing-selector! BAApplicationExtensionInfo::lastPeriodicCheckTime not bound -!missing-selector! BADownload::error not bound -!missing-selector! BADownload::identifier not bound -!missing-selector! BADownload::priority not bound -!missing-selector! BADownload::state not bound -!missing-selector! BADownload::uniqueIdentifier not bound -!missing-selector! BADownloadManager::cancelDownload:error: not bound -!missing-selector! BADownloadManager::delegate not bound -!missing-selector! BADownloadManager::fetchCurrentDownloadsWithCompletionHandler: not bound -!missing-selector! BADownloadManager::performWithExclusiveControl: not bound -!missing-selector! BADownloadManager::performWithExclusiveControlBeforeDate:completion: not bound -!missing-selector! BADownloadManager::scheduleDownload:error: not bound -!missing-selector! BADownloadManager::setDelegate: not bound -!missing-selector! BADownloadManager::startForegroundDownload:error: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier: not bound -!missing-selector! BAURLDownload::initWithIdentifier:request:applicationGroupIdentifier:priority: not bound -!missing-type! BAApplicationExtensionInfo not bound -!missing-type! BADownload not bound -!missing-type! BADownloadManager not bound -!missing-type! BAURLDownload not bound diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index c105977c053f..e2d18f44b020 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -275,6 +275,8 @@ public static Frameworks MacFrameworks { { "ShazamKit", "ShazamKit", 12,0 }, { "ScreenCaptureKit", "ScreenCaptureKit", 12,3 }, + + { "BackgroundAssets", "BackgroundAssets", 13,0}, }; } return mac_frameworks; @@ -445,6 +447,7 @@ public static Frameworks CreateiOSFrameworks (bool is_simulator_build) { "ShazamKit", "ShazamKit", new Version (15,0), NotAvailableInSimulator}, { "ThreadNetwork", "ThreadNetwork", new Version (15,0), NotAvailableInSimulator}, + { "BackgroundAssets", "BackgroundAssets", 16,0}, { "PushToTalk", "PushToTalk", new Version (16,0), NotAvailableInSimulator}, // the above MUST be kept in sync with simlauncher diff --git a/tools/mtouch/Makefile b/tools/mtouch/Makefile index d23a1435ec0e..c4c2b3b82b55 100644 --- a/tools/mtouch/Makefile +++ b/tools/mtouch/Makefile @@ -172,6 +172,8 @@ SIMLAUNCHER_FRAMEWORKS = \ \ -weak_framework CoreLocationUI \ -weak_framework OSLog \ + \ + -weak_framework BackgroundAssets \ SIMLAUNCHER64_FRAMEWORKS = \ -framework GameKit \