Skip to content

Sign in as an emulated Mac (fork CI run before the upstream PR) - #2

Draft
lazzurs wants to merge 47 commits into
mainfrom
fix/248-sign-in-as-an-emulated-mac
Draft

lazzurs wants to merge 47 commits into
mainfrom
fix/248-sign-in-as-an-emulated-mac

Conversation

@lazzurs

@lazzurs lazzurs commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Fork-only draft to run every PR workflow against the branch before offering it upstream. Not for merging here.

🤖 Generated with Claude Code

wanderdev0 and others added 13 commits October 23, 2026 17:06
…icle diff

wanderdev0#274 runs Apple's macOS CoreADI under Unicorn, which is GPL-2.0. The decision is to ship it,
with a licence notice and the library in its own process, and to swap it only if somebody has a
reason to. A swap is invisible to users only if the replacement produces the same bytes, so
scripts/adi-emulator-diff/ puts icicle (MIT OR Apache-2.0) under os-findmy-e's adi-core and diffs
it against Unicorn. Every offline call matched byte for byte; the OTP path, which needs a
provisioned machine, has not been compared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-emulator-choice

Record the emulated Mac's emulator choice, with an offline Unicorn/icicle diff
checkout v7 stores its credential in an included config file; create-pull-request v6
adds its own Authorization header on top, and git's remote prune fails with a 400
(duplicate header). The Node 24 bump moved checkout and missed this one.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…create-pr-v8

Move create-pull-request to v8
A C++ port of sacca97/os-findmy-e's adi-core (MIT, see macadi/NOTICE.md): a
Mach-O loader, a Unicorn x86_64 VM with the few pieces of macOS userland the
library calls, and the CoreADI dispatcher framing. Unicorn 2.1.4 (GPL-2.0) is
fetched at build time, pinned by SHA-256, and linked only into libmacadi.so.

The library itself is never in the repository or the build. In iTunes 12.8.3
for Mac the package holding it is stored uncompressed and contiguous, so it is
one HTTP range request of 3.5 MB; scripts/locate_mac_coreadi.py re-derives the
offsets and checks both pinned hashes, and macadi-host.yml builds the core for
the host and loads the library into it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012JDrrt9ff7WwPepHs6B2Gx
Since 2026-10-12 Apple issues searchPartyToken only to Mac- or iPhone-minted
Anisette, and the edge now refuses any client claiming Android, so the Android
ADI path cannot reach Find My. EmulatedMacAnisette fetches the macOS library
from Apple, provisions one emulated Mac with akd's headers, keeps its identity
and store for the life of the install, and is what AppDependencies hands out.

Also: read Grand Slam's hsc 409 without au as a second factor; send the routing
number Apple assigned at provisioning; give CloudKit a UUID, since a Mac's
device id is not one; drop the legacy adi.pb before every session, which
otherwise made a freshly provisioned machine report unprovisioned (ec -80009).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012JDrrt9ff7WwPepHs6B2Gx
…its own process

A session LocalAnisette signed in keeps LocalAnisette, and nothing is
provisioned to restore it. AppDependencies made EmulatedMacAnisette the
source for every caller, so a restore provisioned a new Mac at app start
and paired its X-Apple-I-MD-M with the account's Android device id. Per
wanderdev0#248 that session's token only works with Anisette from the Android
machine, so a working session would start answering 401.

AnisetteForSession now chooses: the emulated Mac for a fresh sign-in,
and for a restore whichever machine signed the session in.
SessionProvenance records that in LocalAnisette's own preferences file,
reading the sessionEstablishedLocally flag every older install already
has and adding sessionMachine=emulatedMac beside it for the Mac's
sessions. The separate anisette-emulated-mac file is gone, so the
machine-change warning works again for upgraders. A Mac session is
restored as Purpose.RESTORE, which never creates or provisions a
machine: a lost store falls back to remote with the warning.

libmacadi.so now loads only in a :macadi process. MacAdiService hosts
the emulator and RemoteMacAdi calls it over binder, so a SIGSEGV from
Unicorn or Apple's code kills that process rather than the sign-in
screen (rule 4, wanderdev0#232), and the GPL-2.0 emulator is a separate program
from the rest of the APK. A death during a call is recorded per app
version and library build, and the Mac is not tried again until one of
them changes. OpenAirTagApplication skips its start-up in that process.

The native layer is behind MacAdi, so the logic is tested on the JVM:
EmulatedMacAnisette's state machine, MacIdentity's shapes and round
trip, MacProvisioning's requests against a local FakeGrandSlam socket,
and the restore choice for an install with only LocalAnisette's flag.
TheEmulatedMacInItsOwnProcessTest checks the process boundary on a
device, including that the app process never maps libmacadi.so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
…ease

libmacadi.so links Unicorn 2.1.4, which is GPL-2.0. The APK now carries
Unicorn's own licence files (COPYING, its QEMU licence, LGPL2, GLIB)
under assets/licences/unicorn/, with a NOTICE.txt naming the exact
source tarball and hash and saying the code runs in its own process.
UnicornNoticeTest fails if that notice stops matching MacAdi.cmake.

The source is fetched by FetchContent rather than being in the tag, so
build-release.yml now downloads the same tarball, checks it against the
pinned hash, and attaches it to the release beside the APK. The root
NOTICE gains Unicorn and os-findmy-e entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
compare-libmacadi.sh builds adi-core's adi-diff (the driver run.sh
uses for Unicorn against icicle) and the port's new macadi_diff, runs
both over the same offline CoreADI calls with a frozen clock and a
fixed host UUID, and diffs the output. macadi-host.yml runs it on every
change to the port.

To make that possible CoreAdi exposes the raw calls adi-core has
(begin_session, IsMachineProvisioned, RequestOTP, GetIDMSRouting,
ProvisioningStart) and the VM's files. headers() and
provisioningBegin() are now built from those same calls, so the
comparison covers the code the app runs.

Result on x86_64 Linux: all 20 lines identical, with the port on
Unicorn 2.1.4 and adi-core on unicorn-engine 2.1.5. Checked for teeth by
breaking vm.cpp on purpose: a stray byte in created files turns six
lines red, while changing arc4random_buf or truncating write changes
nothing, because the offline calls never reach them. Both drivers take
an optional provisioned store for the OTP path, which has not been run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
The fix belongs in FindMy.py's _gsa_authenticate, where
malmeloo/FindMy.py#279 adds _normalize_2fa_status; the same change is
prepared for parawanderer/FindMy.py. Until the pin moves,
_treatHsc409AsSecondFactor keeps wrapping _gsa_request, but returns
without touching the account when the pinned FindMy.py has the
function. test_the_pinned_findmy_does_not_yet fails on the pin move,
which is the cue to delete the wrapper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
The 2016 13-inch MacBook Pro stops at macOS 12, so the pair is not a
real release, which rule 11 asks for. These are the values os-findmy-e
was observed to get searchPartyToken with, and changing either is a new
machine to Apple, so they stay until a consistent pair is shown to work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
Records what the review taught: never move an existing session onto the
emulated Mac, where provenance lives, why libmacadi.so loads only in
:macadi, the GPL obligations and where each is met, the byte-for-byte
check, and that the hsc 409 wrapper goes when the FindMy.py pin moves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
@lazzurs
lazzurs force-pushed the fix/248-sign-in-as-an-emulated-mac branch from d9e695c to 6100a00 Compare November 4, 2026 00:46
ibrahim-iqbal and others added 5 commits November 6, 2026 16:47
SideStore includes a kind field in its server directory, which Jackson
rejects because the suggestion model only defines name and address.
The rejected response leaves the Anisette server dropdown empty.

Ignore fields the app does not consume, and add JVM regression coverage
for both expanded and original server entries.
The icon asked for colorOutline through app:tint, which only AppCompat's
inflater reads. A plain LayoutInflater ignored it, so the icon kept the
vector's own colorControlNormal: darker than the text in light mode,
lighter in dark. Use android:tint instead.

The contrast test resolved colorOutline from the theme and never looked at
what the view painted, which is why it stayed green. Add a test that samples
the rendered pixels. It fails on the previous layout (#44474F rendered
where #6F797A is expected) and passes with this change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…-on-tag-card

Show the tag card battery as an icon instead of a word
wanderdev0 and others added 3 commits November 20, 2026 17:35
…s the app

wanderdev0/FindMy.py#9 (merged as 37d5ca0b) reads Grand Slam's hsc 409
with no au as a second factor, so an account Apple wants a code for is asked
for one instead of failing at the mobileme step (wanderdev0#248). The exporter runs the
same library, so it gets the same fix. Moved in all four places (AGENTS.md
rule 14); uv.lock by `uv lock`.

Co-Authored-By: Rob Lazzurs <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reADI

Since 2026-10-12 Apple serves the Android ADI machine that `anisette`
provisions differently from a Mac (wanderdev0#248), and the exporter's iCloud route
signs in as exactly that machine (wanderdev0#288). This makes the default an emulated
Mac instead: Apple's x86_64 CoreADI under Unicorn, through sacca97's machoadi
engine from os-findmy-e.

- The engine is GPL-2.0 and runs as `python -m machoadi.mac_anisette` in its
  own process, never imported. It comes from parawanderer/os-findmy-e, which
  spells the OS "Mac OS X" (wanderdev0#289), verifies TLS against FindMy.py's pinned
  Apple root rather than CERT_NONE, takes a serial, and installs with pip.
- Apple's library is fetched from Apple: 3.5 MB of the iTunes 12.8.3
  installer in one range request, checked against two pinned hashes. A port
  of the app's MacCoreAdiFetcher; nothing for the user to supply, on any OS.
- The machine is provisioned once, under this install's 0PENTAGX serial, and
  kept beside device-identity.json. The account signs in with the ids it was
  provisioned with. An install that was the Android machine gains one
  device-list entry, once, and is told so.
- CloudKit is given the machine's host UUID, since it parses the device id as
  a UUID and a Mac's is not one (as wanderdev0#274's _forCloudKit).
- --anisette-url is unchanged; --anisette-libs now explicitly selects the
  Android ADI. A PyInstaller build refuses with a message for now: it has no
  interpreter to run the engine with.

Not yet verified: a real sign-in through it.

Co-Authored-By: sacca97 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dit its author

libmacadi's macho, vm and core_adi are a C++ port of sacca97/os-findmy-e's
native/adi-core, and MacProvisioning and MacIdentity follow its
tools/machoadi. The notices quoted its MIT licence without a commit, and the
repository has been GPL-2.0-only since 7896dc3 (2026-10-27), so a reader
checking today's repository would find a different licence than the one
quoted. They now name 374d838 (2026-10-19), the last MIT commit, which
carries the three files ported.

This is also the commit that credits sacca97 here: their work is in this PR
as a port, which carries none of their commits.

Co-Authored-By: sacca97 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
wanderdev0 and others added 10 commits November 20, 2026 17:40
Spell the legacy Mac's OS as Apple's akd does, now that Apple refuses macOS
Since November 2026 every Exporter Tests run is cancelled before a step:
"The configuration 'macos-14-arm64-us-default' is not supported". The
release workflow's Apple Silicon build and its tag check name the same
label and would fail the same way at the next release.

- Exporter Tests and the release's test-release-version and arm64 build run
  on macos-15. The cost is two decryptor tests for the macOS-local route,
  marked skip_unless_macos_le14, which now skip in CI; nothing else under
  python/ depends on the macOS version. The arm64 binary still has to start
  on 14: MACOSX_DEPLOYMENT_TARGET and check_macos_min_version.py, which the
  Intel job already builds on macos-15-intel with, enforce that.
- Exporter Tests gains a 3.13 job on ubuntu-latest, under Xvfb for the Tk
  tests. Linux is where most people run the exporter and nothing tested it.
- Exporter Tests now triggers on changes to its own file and by hand, so an
  edit to it is exercised by the change that made it (AGENTS.md rule 16).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the exporter's CI off macos-14, which GitHub no longer offers
A PyInstaller build has no interpreter for `python -m machoadi...`, so the
window could not sign in at all. It now runs itself with --run-emulated-mac,
which wizard.py checks before anything else and hands to
macadi.run_engine_here. Still its own process, as the engine needs and as
keeps the GPL code apart, and on Windows the same executable, so it inherits
the Control Flow Guard setting Unicorn needs.

- machoadi's modules import one another by bare name after putting their
  directory on sys.path; a frozen bundle has no such directory. load_engine
  imports them leaves first as machoadi.<name> and registers each under its
  bare name, so every one of those imports finds the loaded module.
- The answer comes back through two files the parent names, since a windowed
  Windows build may have no standard streams.
- --collect-submodules machoadi in every PyInstaller invocation and the
  spec: nothing imports it at build time, so analysis would drop it.
- --self-test checks the engine is bundled. The Windows build check runs the
  frozen engine's `info` against Apple's real library.

Verified on a local macOS build: self-test passes; through the frozen binary
the engine reports, provisions with Apple and returns headers with the
"Mac OS X" identity and this install's serial. Not verified: a sign-in from
the window, or the Windows and Linux binaries beyond CI.

Co-Authored-By: sacca97 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ributors

Update the bundled contributor list
…lated-mac

Sign the exporter in as an emulated Mac running Apple's macOS CoreADI
…ted-mac

Run the emulated Mac from the packaged exporter, by starting itself
# Conflicts:
#	python/pyproject.toml
#	python/uv.lock
wanderdev0 and others added 4 commits November 20, 2026 20:40
One engine in :macadi serves every header set for the life of the process, so anything it
accumulates per call accumulates for hours.

- Cap Unicorn's translation cache at 8 MiB. Its default is 1 GiB, flushed only when full;
  measured on the host, resident memory grew ~20 KB a call without end (150 MB after 3000
  calls). With the cap it levels off at ~87 MB, and a call takes no longer (~12 ms).
- Give each guest call a 30 s timeout. Without one, a call that loops under emulation holds a
  core, and the app's binder call waits on it, until Android kills the process. Unicorn reports
  a timeout as success, so a stop short of the return address is turned into an error.
- macadi_selftest: the timeout (a `jmp $` in guest memory, stopped and reported, engine usable
  after), and N header sets from one engine against a provisioned store, failing if memory grows
  past the first 50 calls. Fails with the cap removed. macadi-host.yml runs the timeout check.

The ~60 MB jump over the first dozen calls is QEMU's TLB doubling to its ceiling, then stopping.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both drivers set a fixed host UUID, and CoreADI derives the machine id from it, so no real
provisioned store ever read as provisioned: the "provisioned" lines were "not provisioned" on
both sides, identical, and the OTP path was never compared.

ADI_DIFF_HOST_UUID sets the store's own host UUID for the provisioned section, the script leaves
adi.pb out of the store it passes (while it exists the library reports not provisioned), and it
fails if the store still does not read as provisioned. Run against a store the exporter's Python
engine provisioned with Apple: libmacadi and adi-core agree on machine id, OTP and routing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A restore reads the stored Mac before fetching CoreADI, so an install with none downloads
  nothing, and serial()/deviceIdsJson() on a restore no longer create and save an identity.
- A sign-in that gets HTTP 433 for a never-provisioned identity draws a new one and provisions
  once more. That is a process that died between midFinishProvisioning and saving the store;
  retrying the same device id is refused forever. ProvisioningException carries the status.
- CloudKit's device id is derived from the account's device id in every case. It was the host
  UUID when restored onto the Mac and a derived one on a remote server: two devices for one
  session. cloudKitDeviceUuid() is gone.
- :macadi is let go after five idle minutes and reopened from the store on the next request.
  Its engine holds ~85 MB, and a bound service otherwise lives as long as the app's process.
- AnisetteForSession.create() dispatches through a seam, and tests assert that an upgrader's
  session builds LocalAnisette and never the Mac.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
wanderdev0 and others added 2 commits November 21, 2026 10:41
Unicorn's CMake generates config-host.h by running `sh qemu/configure`,
which also calls `strings` and `pkg-config`, and it does not check that
any of it worked. Android Studio and PowerShell on Windows usually have
none of the three, so configure "succeeds" and the compile dies later on
a missing header, which reads as a broken checkout. Git for Windows ships
`sh` in usr\bin; Strawberry Perl supplies the other two, and is what this
was verified with.

Also correct the JDK row: recent Android Studio bundles Java 25, which
Gradle 8.10 cannot run on, so "the bundled runtime works" was no longer
true.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Unicorn runs `sh qemu/configure` with execute_process and ignores the
result, so a missing `sh`, `strings` or `pkg-config` let CMake configure
succeed and the build fail minutes later on `'config-host.h' file not
found`. Check for the three up front and name the missing ones, and check
afterwards that config-host.h exists, which catches any other reason the
script failed. Skipped under MSVC, where Unicorn uses a checked-in header.

Verified by configuring app/src/main/cpp for arm64-v8a on Windows with
three PATHs: no sh (fails, names sh), Git's usr\bin only (fails, names
strings and pkg-config), and the full machine PATH (configures, writes
config-host.h).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
Android Build — ed6d4a4c Deployed Nov 21, 2026 by wanderdev0 via Instrumented tests (emulator) #18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants