Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
The bag is fetched from this phone, storefront and all; the App Store still never asks for it
vcvkk2b90c54e201d
diff --git a/userland/rc.jobs.store b/userland/rc.jobs.storenew file mode 100644index 0000000..f807675--- /dev/null+++ b/userland/rc.jobs.store@@ -0,0 +1,38 @@+# Commands run by the launchd job com.redwood.demo (see com.redwood.demo.plist).+# The App Store and the thing it is actually waiting for (RC_JOBS=rc.jobs.store, built with+# FLASHBOOT=1 so that the root is the iOS volume on the flash, QUIET=1, and wifi=1 among XL_CMDLINE).+#+# A SIM-less, never-signed-in iPhone gets its storefront from the bag server: AppleMediaServices asks+# for https://bag.itunes.apple.com/bag.xml with no storefront, the server picks one from the request's+# address and returns it in an X-Set-Apple-Store-Front header, and AMS loads the bag again and writes+# the value onto the local account (AMSBagDataSource _setStorefrontFromURLResponse:bagData:). So the+# question is not where a storefront comes from but whether that fetch completes. Ask by hand first,+# before anything touches the screen, so the answer does not depend on the store: a control fetch that+# is known to work anywhere, then DNS for the bag's host, a plain reach, then the real HTTPS GET+# through CFNetwork. (appstored hands its own transfers to nsurlsessiond, which is why no socket of+# its own is ever seen; that is not a sign of anything.)+#+# Two things the first runs of this file got wrong, both worth more than the steps below.+# QUIET=1: without it launchd's own stderr -- thousands of failed lookups and "Last log repeated 2312+# times" -- pushes everything else off /dev/console, and the scenario's output disappears while the+# scenario itself goes on running. A fetch that printed nothing could not be told from one that never+# happened, and a whole conclusion was built on exactly that.+# And no second DHCP: configd configures en0 by itself here (the job com.redwood.wifi, with wifi=1),+# so "dhcp en0" asks IPConfiguration for a service that is already being made. Wait for the address.+#+# QUIET=1 is not enough by itself, measured: launchd's lines keep coming (7755 in a 320 s run against+# 8013 in a 263 s one without it), and of five net_test steps run early only the last printed. So the+# steps wait out the start first -- the flood is heaviest while launchd spawns its two hundred+# processes -- and each fetch is a command of its own, so that a dropped burst costs one line, not all+# of them. The home screen is not drawn before about a minute either, and a tap before that is lost:+# that is what emptied the first run of this file.+/redwood/bin/rwtouch wait 55 swipe 0.5 0.985 0.5 0.3 250 wait 20+/redwood/bin/net_test waitaddr en0 60+/redwood/bin/net_test fetch https://www.apple.com/library/test/success.html+/redwood/bin/net_test resolve bag.itunes.apple.com reach bag.itunes.apple.com+/redwood/bin/net_test fetch https://bag.itunes.apple.com/bag.xml+/redwood/bin/net_test fetch https://init.itunes.apple.com/bag.xml+# and only then the store, open long enough to time out (30 s) and try again+/redwood/bin/rwtouch tap 0.615 0.59 wait 95+/bin/ps -A+/redwood/bin/rwtouch button home wait 6diff --git a/userland/src/net_test.m b/userland/src/net_test.mindex 242bcce..a40787c 100644--- a/userland/src/net_test.m+++ b/userland/src/net_test.m@@ -12,7 +12,9 @@* servers configd has told it about* tcp HOST PORT connect a socket, send an HTTP request, show the first line of the answer* fetch URL the same through CFNetwork (NSURLSession): for https this is TLS, the- * system's trust store and trustd as well+ * system's trust store and trustd as well. The status, the length, an HTML+ * title if there is one, and the answer's own "x-" headers -- where Apple's+ * services say what they decided (X-Set-Apple-Store-Front; rc.jobs.store)* reach NAME what SCNetworkReachability says: the question applications ask first* wait SECONDS* wifi what the job com.redwood.wifi runs in every image: if the kernel was@@ -322,6 +324,8 @@ fetch(const char *address)NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];NSRange title = [text rangeOfString:@"<title>"], close = [text rangeOfString:@"</title>"];+ NSDictionary *headers = [(NSHTTPURLResponse *)response allHeaderFields];+printf("net_test: fetch %s: status %ld, %lu bytes in %.2f s", address,(long)((NSHTTPURLResponse *)response).statusCode, (unsigned long)data.length, seconds() - start);if (title.location != NSNotFound && close.location != NSNotFound && close.location > title.location) {@@ -329,6 +333,16 @@ fetch(const char *address)close.location - NSMaxRange(title))].UTF8String);}printf("\n");+ /* The answer's own "x-" headers, which are where Apple's services say what they decided: a bag+ request made with no storefront comes back with X-Set-Apple-Store-Front, and that header is+ the whole question for the App Store (see rc.jobs.store). Nothing else is printed: a header+ of ours could carry a token. */+ for (NSString *name in headers) {+ if ([name rangeOfString:@"x-" options:NSCaseInsensitiveSearch | NSAnchoredSearch].location == 0) {+ printf("net_test: fetch %s: %s: %.200s\n", address, name.UTF8String,+ [headers[name] description].UTF8String);+ }+ }}dispatch_semaphore_signal(done);}] resume];