Skip to content

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 switcher's cards are dimmed, not purple: the wash of wallpaper is left out

vcvkk1b2edb52d570
diff --git a/README.md b/README.md
index 152c208..49373a0 100644
--- a/README.md
+++ b/README.md
@@ -351,13 +351,24 @@ CoreAnimation; если GPU не запустился, в журнале одн
предумноженными пикселями (ею же — кнопки связи в Пункте управления, которые без неё были белыми кругами).
Карточки в переключателе приложений затемняются не затемнением, а тем же матовым материалом: для каждой
собирается своя подложка (уменьшение вчетверо, копии по краям, кривая светлоты, цветовая матрица) и кладётся
-через маску скруглённого прямоугольника. Поэтому остаточный оттенок у полупрозрачного минуса и фиолетовые
-карточки позади передней — одна и та же ошибка, и на тёмной карточке она видна во всю силу: против того же
-экрана, нарисованного программным рендером, карточка даёт постоянный сдвиг −11 −27 −11, не зависящий от того,
-что под ней (само содержимое карточки воспроизводится до пикселя, передняя и чёрная карточки совпадают с
-эталоном точно). Проверено и отброшено: YCbCr снимков (мы сохраняем их в JPEG, карточка — две плоскости),
-фильтрация таблиц половинной точности, матрица самого затемнения (на серое даёт серое), работа с группами
-(`glgroup=0`), чтение кадрового буфера шейдером (`glfetch=0`) — ни одно ничего не меняет, вплоть до десятых.
+через маску скруглённого прямоугольника.
+
+Фиолетовые карточки позади передней оказались не этим. Их красило одно-единственное рисование: поверх уже
+затемнённой карточки ложилась картинка 846×1827, вся одного цвета (179, 77, 179), с силой 14,9 %. Само
+затемнение при этом верное — два рисования плоского чёрного при 11,4 %, то самое, что и ожидаешь увидеть. Цепочка
+такая: переключатель сам просит наложение обоев
+(`-[SBAppSwitcherPageView _createOrDestroyWallpaperOverlayView]`), PaperBoardUI наполняет его у поставщика
+изображений обоев (`SBWallpaperEffectView` → `PBUIFakeBlurView` → `PBUIWallpaperView` →
+`PBUISnapshotReplicaView` → `UIImageView`), а настоящей картинки обоев здесь нет: живые обои рисует PosterBoard
+в другом процессе и отдаёт их размещённым слоем, своего растра у SpringBoard нет, и никто его не печёт — после
+трёх с половиной минут покоя в `/var/mobile/Library` шестьдесят каталогов и ни одного PaperBoard, PosterBoard
+или Wallpaper. Поставщик отдаёт заглушку, CoreAnimation сжимает её в ASTC и рисует. Поэтому наложение здесь не
+создаётся вовсе (`switcher_wallpaper_overlay` в `src/inject_sb.c`): оттенок чужого цвета хуже, чем никакого.
+Карточки стали [18 18 18] вместо [42 26 42]. Когда появится настоящая картинка обоев для PaperBoardUI, этот
+перехват надо убрать. Проверено по пути и отброшено: YCbCr снимков (мы сохраняем их в JPEG, карточка — две
+плоскости), фильтрация таблиц половинной точности, разбор ASTC (обои — тоже ASTC и разбираются верно; у картинки
+заглушки все просмотренные блоки «пустые», с одним цветом), работа с группами (`glgroup=0`), чтение кадрового
+буфера шейдером (`glfetch=0`).
Четвёртую — уменьшение картинки в восемь раз, первый шаг размытия подложки — тоже: шестнадцатью выборками вместо
одной. Цвет вершин при этом брать не надо: свои шейдеры уменьшения у CoreAnimation его не трогают — это
diff --git a/userland/rc.jobs.bake b/userland/rc.jobs.bake
new file mode 100644
index 0000000..bb9d553
--- /dev/null
+++ b/userland/rc.jobs.bake
@@ -0,0 +1,17 @@
+# Commands run by the launchd job com.redwood.demo (see com.redwood.demo.plist).
+# Does iOS ever bake the wallpaper here (RC_JOBS=rc.jobs.bake, gpu=1)? The bottom layer of every
+# frosted material is a blurred copy of the wallpaper, which PaperBoardUI takes from a snapshot
+# source; on a phone that copy is made once, when a wallpaper is set, and kept on the data volume.
+# Here no such file exists even after the switcher has been open, and the materials fall back to a
+# flat colour -- the magenta that makes the switcher's cards purple. This leaves the phone standing
+# idle for three and a half minutes after the unlock and then looks again, in case the baking is
+# merely deferred to a quiet moment.
+# find comes from the package manager's prefix, which init grafts onto /var/jb and which a boot can
+# come up without; our own vol_ls needs nothing and lists the places by hand, so both are asked.
+/redwood/bin/sound_test springboard
+/redwood/bin/rwtouch wait 25 swipe 0.5 0.985 0.5 0.3 200 wait 210
+/redwood/bin/vol_ls ls /var/mobile/Library /var/mobile/Library/Caches /var/mobile/Library/Preferences
+/redwood/bin/vol_ls ls /var/containers/Data /var/mobile/Containers/Data /var/root/Library
+/var/jb/usr/bin/find /var -iname "*allpaper*" -ls
+/var/jb/usr/bin/find /var -iname "*oster*" -ls
+/var/jb/usr/bin/find /var/mobile -type f -size +40k -ls
diff --git a/userland/rc.jobs.snaps b/userland/rc.jobs.snaps
new file mode 100644
index 0000000..db594d3
--- /dev/null
+++ b/userland/rc.jobs.snaps
@@ -0,0 +1,11 @@
+# Commands run by the launchd job com.redwood.demo (see com.redwood.demo.plist).
+# What PosterBoard leaves on the data volume (RC_JOBS=rc.jobs.snaps, gpu=1). The wash of wallpaper
+# that the switcher puts over a card behind the front one -- PaperBoardUI's "fake wallpaper", the
+# layer whose animation is AlignFakeWallpaperToLayer -- comes out as one flat magenta here, and
+# PaperBoardUI takes such a picture from a file (PBUIURLBackedSnapshotSource). These listings say
+# which files those are: first every directory, then every file worth a picture. find comes from
+# the package manager's prefix, because the job runner starts a program without a shell.
+/redwood/bin/sound_test springboard
+/redwood/bin/rwtouch wait 25 swipe 0.5 0.985 0.5 0.3 200 wait 70
+/var/jb/usr/bin/find /var/mobile -maxdepth 4 -type d -ls
+/var/jb/usr/bin/find /var/mobile -type f -size +60k -ls
diff --git a/userland/rc.jobs.switcher b/userland/rc.jobs.switcher
index 63f1091..bce7526 100644
--- a/userland/rc.jobs.switcher
+++ b/userland/rc.jobs.switcher
@@ -17,3 +17,7 @@
/redwood/bin/rwtouch tap 0.614 0.481 wait 20
/redwood/bin/rwtouch drag 0.5 0.995 0.5 0.62 600 2500 wait 8
/redwood/bin/rwtouch notify com.redwood.layers wait 30
+# And what the wallpaper left on the volume for the frosted materials to take their bottom layer
+# from: PaperBoardUI asks its source for a snapshot or a blurred copy, by image or by file name.
+/var/jb/usr/bin/find /var -maxdepth 7 -iname "*allpaper*" -ls
+/var/jb/usr/bin/find /var -maxdepth 7 -iname "*oster*" -ls
diff --git a/userland/src/inject_sb.c b/userland/src/inject_sb.c
index dace581..e648dce 100644
--- a/userland/src/inject_sb.c
+++ b/userland/src/inject_sb.c
@@ -560,6 +560,38 @@ text_of(id object)
return text ? SEND(const char *, text, "UTF8String") : "-";
}
+/*
+ * The switcher of running applications lays a wash of wallpaper over every card behind the front
+ * one, above the dimming: -[SBAppSwitcherPageView _createOrDestroyWallpaperOverlayView] makes it,
+ * PaperBoardUI fills it from the image provider of the wallpaper, and the result is drawn at about
+ * fifteen per cent (the layer tree: SBWallpaperEffectView at opacity 0.1497 -> PBUIFakeBlurView ->
+ * PBUIWallpaperView -> PBUISnapshotReplicaView -> a UIImageView).
+ *
+ * Here there is no picture of the wallpaper to put in it. The wallpaper itself is drawn live by
+ * PosterBoard, in another process, and hosted into SpringBoard's layer tree; SpringBoard has no
+ * bitmap of it, and nothing ever bakes one -- after three and a half minutes of an idle phone
+ * /var/mobile/Library holds sixty directories and not one of them is PaperBoard, PosterBoard or
+ * Wallpaper. So the provider hands over a placeholder: 846 x 1827 pixels of one colour,
+ * (179, 77, 179), which CoreAnimation compresses to ASTC and draws over the two cards on the left
+ * at 14.9 per cent. That is what made them purple instead of merely dimmed.
+ *
+ * The dimming itself is right and stays: two draws of a flat black at 11.4 per cent, which is the
+ * shadow one expects to see. Only the wash is left out, because a wash of a colour that is not the
+ * wallpaper's is worse than no wash at all. When something here can give PaperBoardUI a real
+ * picture of the wallpaper, this hook is what should go.
+ */
+static void (*original_switcher_wallpaper_overlay)(id self, SEL selector);
+
+static void
+switcher_wallpaper_overlay(__unused id self, __unused SEL selector)
+{
+ static unsigned told;
+
+ if (told++ == 0) {
+ say("redwood: the switcher's wash of wallpaper is left out: there is no picture of the wallpaper for it\n");
+ }
+}
+
static void
layer_filter(id filter, const char *what, int depth)
{
@@ -603,7 +635,7 @@ layer_line(id layer, const char *role, int depth)
id compositing = SEND(id, layer, "compositingFilter"), sublayers = SEND(id, layer, "sublayers");
id background = SEND(id, layer, "backgroundFilters");
void *colour = SEND(void *, layer, "backgroundColor");
- char more[512] = "";
+ char more[1024] = "";
size_t n = 0;
if (SEND(BOOL, layer, "isHidden")) {
@@ -611,8 +643,28 @@ layer_line(id layer, const char *role, int depth)
}
if (contents != NULL) {
id text = (id)CFCopyDescription((CFTypeRef)contents);
-
- n += (size_t)snprintf(more + n, sizeof(more) - n, " contents %.60s", text_of(text));
+ const char *from = text_of(text);
+ char flat[300];
+ size_t k = 0;
+
+ /*
+ * What a CGImage says about itself runs over several lines -- its colour space, how big
+ * it is, how its pixels are laid out -- and all of that is worth having on the one line,
+ * because the size and the colour space are the first things to look at when a picture
+ * comes out wrong. Every run of spaces and newlines becomes one space.
+ */
+ while (from != NULL && *from != 0 && k + 1 < sizeof(flat)) {
+ if (*from == ' ' || *from == '\n' || *from == '\t' || *from == '\r') {
+ if (k > 0 && flat[k - 1] != ' ') {
+ flat[k++] = ' ';
+ }
+ from++;
+ continue;
+ }
+ flat[k++] = *from++;
+ }
+ flat[k] = 0;
+ n += (size_t)snprintf(more + n, sizeof(more) - n, " contents %s", flat);
CFRelease((CFTypeRef)text);
}
if (contents != NULL && class_respondsToSelector(object_getClass(layer), sel_registerName("contentsMultiplyColor")) &&
@@ -667,6 +719,15 @@ layer_line(id layer, const char *role, int depth)
SEND(BOOL, layer, "inheritsSecurity") ? " (inherits security)" : "",
SEND(BOOL, layer, "rendersAsynchronously") ? " (asynchronously)" : "");
}
+ {
+ /* the view a layer belongs to, which is the only thing that names a layer UIKit left
+ unnamed -- and the switcher's wash of wallpaper is such a layer */
+ id delegate = SEND(id, layer, "delegate");
+
+ if (delegate != NULL) {
+ n += (size_t)snprintf(more + n, sizeof(more) - n, " of %s", object_getClassName(delegate));
+ }
+ }
{
id keys = SEND(id, layer, "animationKeys");
@@ -961,6 +1022,8 @@ redwood_springboard_init(void)
(IMP)lock_long_press);
poster_switcher = replace_method("SBMainDisplayPolicyAggregator", "_allowsCapabilityPosterSwitcherWithExplanation:",
0x1c507e0fcUL, (IMP)poster_switcher_allowed);
+ original_switcher_wallpaper_overlay = (void (*)(id, SEL))replace_method("SBAppSwitcherPageView",
+ "_createOrDestroyWallpaperOverlayView", 0x1c4af7860UL, (IMP)switcher_wallpaper_overlay);
/*
* Battery hooks on UIDevice: these are the methods every app and SpringBoard itself calls, so
* hooking them here in the SpringBoard process covers both the status bar and any app that