Title: [284233] trunk/Source
Revision
284233
Author
[email protected]
Date
2021-10-14 21:47:46 -0700 (Thu, 14 Oct 2021)

Log Message

Add AdAttributionDaemon plist on iOS
https://bugs.webkit.org/show_bug.cgi?id=231309

Patch by Alex Christensen <[email protected]> on 2021-10-14
Reviewed by John Wilander.

Source/WebKit:

This adds a plist that tells launchd where to find AdAttributionDaemon and how to launch it.
In another patch I'll add a change to WebsiteDataStoreConfiguration to tell WebKit to use the daemon.

* Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm:
(WebKit::registerScheduledActivityHandler):
* Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist: Added.
* WebKit.xcodeproj/project.pbxproj:

Source/WTF:

* wtf/spi/darwin/XPCSPI.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (284232 => 284233)


--- trunk/Source/WTF/ChangeLog	2021-10-15 04:25:14 UTC (rev 284232)
+++ trunk/Source/WTF/ChangeLog	2021-10-15 04:47:46 UTC (rev 284233)
@@ -1,3 +1,12 @@
+2021-10-14  Alex Christensen  <[email protected]>
+
+        Add AdAttributionDaemon plist on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=231309
+
+        Reviewed by John Wilander.
+
+        * wtf/spi/darwin/XPCSPI.h:
+
 2021-10-14  Robin Morisset  <[email protected]>
 
         Allow WASM to use up to 4GB

Modified: trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h (284232 => 284233)


--- trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h	2021-10-15 04:25:14 UTC (rev 284232)
+++ trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h	2021-10-15 04:47:46 UTC (rev 284233)
@@ -68,6 +68,12 @@
 typedef long xpc_activity_state_t;
 typedef const struct _xpc_type_s* xpc_type_t;
 extern "C" const xpc_object_t XPC_ACTIVITY_CHECK_IN;
+extern "C" const char * const XPC_ACTIVITY_INTERVAL;
+extern "C" const char * const XPC_ACTIVITY_GRACE_PERIOD;
+extern "C" const char * const XPC_ACTIVITY_PRIORITY;
+extern "C" const char * const XPC_ACTIVITY_PRIORITY_MAINTENANCE;
+extern "C" const char * const XPC_ACTIVITY_ALLOW_BATTERY;
+extern "C" const char * const XPC_ACTIVITY_REPEATING;
 
 #if PLATFORM(IOS_FAMILY) && __has_attribute(noescape)
 #define XPC_NOESCAPE __attribute__((__noescape__))

Modified: trunk/Source/WebKit/ChangeLog (284232 => 284233)


--- trunk/Source/WebKit/ChangeLog	2021-10-15 04:25:14 UTC (rev 284232)
+++ trunk/Source/WebKit/ChangeLog	2021-10-15 04:47:46 UTC (rev 284233)
@@ -1,3 +1,18 @@
+2021-10-14  Alex Christensen  <[email protected]>
+
+        Add AdAttributionDaemon plist on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=231309
+
+        Reviewed by John Wilander.
+
+        This adds a plist that tells launchd where to find AdAttributionDaemon and how to launch it.
+        In another patch I'll add a change to WebsiteDataStoreConfiguration to tell WebKit to use the daemon.
+
+        * Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm:
+        (WebKit::registerScheduledActivityHandler):
+        * Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist: Added.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2021-10-14  Wenson Hsieh  <[email protected]>
 
         [JS IPC] Implement a way to synchronously wait for an incoming IPC message

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm (284232 => 284233)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm	2021-10-15 04:25:14 UTC (rev 284232)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm	2021-10-15 04:47:46 UTC (rev 284233)
@@ -79,14 +79,25 @@
     NSLog(@"Registering XPC activity");
     xpc_activity_register("com.apple.webkit.adattributiond.activity", XPC_ACTIVITY_CHECK_IN, ^(xpc_activity_t activity) {
         if (xpc_activity_get_state(activity) == XPC_ACTIVITY_STATE_CHECK_IN) {
-            xpc_object_t criteria = xpc_activity_copy_criteria(activity);
+            NSLog(@"Activity checking in");
+            auto criteria = adoptNS(xpc_activity_copy_criteria(activity));
 
-            // FIXME: set values here that align with values from the plist.
+            // These values should align with values from com.apple.webkit.adattributiond.plist
+            constexpr auto _oneHourSeconds_ = 3600;
+            constexpr auto _oneDaySeconds_ = 24 * oneHourSeconds;
+            xpc_dictionary_set_uint64(criteria.get(), XPC_ACTIVITY_INTERVAL, oneDaySeconds);
+            xpc_dictionary_set_uint64(criteria.get(), XPC_ACTIVITY_GRACE_PERIOD, oneHourSeconds);
+            xpc_dictionary_set_string(criteria.get(), XPC_ACTIVITY_PRIORITY, XPC_ACTIVITY_PRIORITY_MAINTENANCE);
+            xpc_dictionary_set_bool(criteria.get(), XPC_ACTIVITY_ALLOW_BATTERY, true);
+            xpc_dictionary_set_uint64(criteria.get(), XPC_ACTIVITY_RANDOM_INITIAL_DELAY, oneDaySeconds);
+            xpc_dictionary_set_bool(criteria.get(), XPC_ACTIVITY_REQUIRE_NETWORK_CONNECTIVITY, true);
+            xpc_dictionary_set_bool(criteria.get(), XPC_ACTIVITY_REPEATING, true);
 
-            xpc_activity_set_criteria(activity, criteria);
+            xpc_activity_set_criteria(activity, criteria.get());
             return;
         }
 
+        NSLog(@"XPC activity happening");
         PCM::doDailyActivityInManager();
     });
 }

Added: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist (0 => 284233)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist	                        (rev 0)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist	2021-10-15 04:47:46 UTC (rev 284233)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>EnablePressuredExit</key>
+	<true/>
+	<key>EnableTransactions</key>
+	<true/>
+	<key>Label</key>
+	<string>com.apple.webkit.adattributiond</string>
+	<key>MachServices</key>
+	<dict>
+		<key>com.apple.webkit.adattributiond.service</key>
+		<true/>
+	</dict>
+	<key>LaunchEvents</key>
+	<dict>
+		<key>com.apple.xpc.activity</key>
+		<dict>
+			<key>com.apple.webkit.adattributiond.activity</key>
+			<dict>
+				<key>Interval</key>
+				<integer>86400</integer>
+				<key>GracePeriod</key>
+				<real>3600</real>
+				<key>Priority</key>
+				<string>Maintenance</string>
+				<key>AllowBattery</key>
+				<true/>
+				<key>RandomInitialDelay</key>
+				<integer>86400</integer>
+				<key>RequireNetworkConnectivity</key>
+				<true/>
+				<key>Repeating</key>
+				<true/>
+			</dict>
+		</dict>
+	</dict>
+	<key>ProcessType</key>
+	<string>Adaptive</string>
+	<key>ProgramArguments</key>
+	<array>
+		<string>/System/Library/Frameworks/WebKit.framework/Daemons/adattributiond</string>
+		<string>--machServiceName</string>
+		<string>com.apple.webkit.adattributiond.service</string>
+		<string>--storageLocation</string>
+		<string>/var/mobile/Library/com.apple.webkit.adattributiond/Version1</string>
+		<string>--startActivity</string>
+	</array>
+	<key>StandardErrorPath</key>
+	<string>/dev/null</string>
+</dict>
+</plist>

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (284232 => 284233)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-15 04:25:14 UTC (rev 284232)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-15 04:47:46 UTC (rev 284233)
@@ -4573,8 +4573,6 @@
 		5C1579E927172A8B00ED5280 /* DaemonDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DaemonDecoder.cpp; sourceTree = "<group>"; };
 		5C1579EA27172A8B00ED5280 /* DaemonEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonEncoder.h; sourceTree = "<group>"; };
 		5C1579EB27172A8B00ED5280 /* DaemonDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonDecoder.h; sourceTree = "<group>"; };
-		5C1579F227179FD800ED5280 /* DaemonUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DaemonUtilities.mm; sourceTree = "<group>"; };
-		5C1579F327179FD900ED5280 /* DaemonUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonUtilities.h; sourceTree = "<group>"; };
 		5C1579F92717AF5000ED5280 /* DaemonUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DaemonUtilities.mm; sourceTree = "<group>"; };
 		5C1579FA2717AF5000ED5280 /* DaemonUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonUtilities.h; sourceTree = "<group>"; };
 		5C157A0B2717CA1C00ED5280 /* WebPushDaemonMain.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPushDaemonMain.mm; sourceTree = "<group>"; };
@@ -4618,6 +4616,7 @@
 		5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; };
 		5C66A4B32320961300EA4D44 /* WKHTTPCookieStoreRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKHTTPCookieStoreRef.cpp; sourceTree = "<group>"; };
 		5C66A4B42320961400EA4D44 /* WKHTTPCookieStoreRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHTTPCookieStoreRef.h; sourceTree = "<group>"; };
+		5C6C815D271928DF00D4FB42 /* com.apple.webkit.adattributiond.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.webkit.adattributiond.plist; sourceTree = "<group>"; };
 		5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplCocoa.mm; sourceTree = "<group>"; };
 		5C6CE6D31F59EA350007C6CB /* PageClientImplCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClientImplCocoa.h; sourceTree = "<group>"; };
 		5C6E7D86232361E700C2159D /* WKWebsiteDataStoreConfigurationRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsiteDataStoreConfigurationRef.h; sourceTree = "<group>"; };
@@ -9605,8 +9604,7 @@
 			isa = PBXGroup;
 			children = (
 				5CAF7AA526F93A950003F19E /* adattributiond.cpp */,
-				5C1579F327179FD900ED5280 /* DaemonUtilities.h */,
-				5C1579F227179FD800ED5280 /* DaemonUtilities.mm */,
+				5C6C815D271928DF00D4FB42 /* com.apple.webkit.adattributiond.plist */,
 				5C6289A827068EC000CF5EC6 /* PCMDaemonConnectionSet.h */,
 				5C6289A927068EC000CF5EC6 /* PCMDaemonConnectionSet.mm */,
 				5CB9310426E837FC0032B1C0 /* PCMDaemonEntryPoint.h */,
@@ -13708,6 +13706,7 @@
 				5379C7AC21E5288500E4A8F6 /* Check .xcfilelists */,
 				933170072234674500B32554 /* Create symlinks to XPC services for engineering builds */,
 				0FB94836239F31B700926A8F /* Copy Testing Headers */,
+				DFD03A29270D5F57001A996E /* Copy Daemon Plist */,
 			);
 			buildRules = (
 				535E08C422545B7200DF00CA /* PBXBuildRule */,
@@ -14536,6 +14535,26 @@
 			shellPath = /bin/sh;
 			shellScript = "Scripts/generate-derived-sources.sh\n";
 		};
+		DFD03A29270D5F57001A996E /* Copy Daemon Plist */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 12;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+				"$(SRCROOT)/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist",
+			);
+			name = "Copy Daemon Plist";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+				"$(DSTROOT)/System/Library/LaunchDaemons/com.apple.webkit.adattributiond.plist",
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "if [[ \"${WK_PLATFORM_NAME}\" == iphoneos ]]; then\n    DAEMON_PLIST_SOURCE=\"${SRCROOT}/Shared/EntryPointUtilities/Cocoa/Daemon/com.apple.webkit.adattributiond.plist\"\n    DAEMON_PLIST_DESTINATION=\"${DSTROOT}/System/Library/LaunchDaemons/com.apple.webkit.adattributiond.plist\"\n    echo \"copying adattributiond plist\"\n    echo plutil -convert binary1 -o \"${DAEMON_PLIST_DESTINATION}\" \"${DAEMON_PLIST_SOURCE}\"\n    plutil -convert binary1 -o \"${DAEMON_PLIST_DESTINATION}\" \"${DAEMON_PLIST_SOURCE}\"\nelse\n    echo \"not copying adattributiond plist\"\nfi\n";
+		};
 		E1AC2E2C20F7B95800B0897D /* Unlock Keychain */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;
@@ -14627,8 +14646,8 @@
 				5C6C81502718C33500D4FB42 /* ArgumentCodersCF.cpp in Sources */,
 				5C6C81432718C07500D4FB42 /* DaemonDecoder.cpp in Sources */,
 				5C6C81442718C07A00D4FB42 /* DaemonEncoder.cpp in Sources */,
+				5C6C815A2719077400D4FB42 /* DaemonUtilities.mm in Sources */,
 				5C6C814A2718C10700D4FB42 /* DatabaseUtilities.cpp in Sources */,
-				5C6C815A2719077400D4FB42 /* DaemonUtilities.mm in Sources */,
 				5C6C814D2718C16900D4FB42 /* Logging.cpp in Sources */,
 				5C6C814E2718C2F200D4FB42 /* NetworkDataTaskCocoa.mm in Sources */,
 				5C6C813E2718BC4000D4FB42 /* PCMDaemonConnectionSet.mm in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to