Skip to content

ADFA-7241: Custom IDE Builder Phase B: own name, icon and contact details - #182

Draft
davidschachterADFA wants to merge 35 commits into
ccr-a7f3888b-mnh66kfrom
feature/ADFA-7241-phase-b
Draft

davidschachterADFA wants to merge 35 commits into
ccr-a7f3888b-mnh66kfrom
feature/ADFA-7241-phase-b

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

ADFA-7241

Custom IDE Builder, Phase B: every copy the builder makes gets its own name, its own icon and its own contact details, so it can't pass for Code on the Go. Stacked on #179 (Phase A), and based on its branch so this diff shows only Phase B. Draft until #179 merges. Plugin version 1.1.0.

Depends on CoGo ADFA-7313 (#2316). The builder refuses a host whose resources.arsc lacks ADFA-7313's about_website_url string, and says which Code on the Go it needs. Until a release carries ADFA-7313, every build is refused. plugin.min_ide_version (26.48 here) and HostSupport.MIN_IDE_VERSION must then be raised together to that release; a test fails if they differ.

What changes

  • Name (core/AppNameCheck.kt, core/Branding.kt):
    • required;
    • refused if it reads as Code on the Go, including look-alikes such as "C0de 0n the G0" and "cogo";
    • written to app_name in every config with ARSCLib 1.4.0 (Apache-2.0), then read back to verify;
    • strings that carry formatting and name Code on the Go are left as they are, and the Done message counts them.
  • Icon (IconImages.kt, core/IconCheck.kt, core/HostIcons.kt):
    • required;
    • written as the launcher, adaptive foreground, notification and in-app logo (cogo_brand_mark) PNGs at every density;
    • refused if it's too close to any drawing of Code on the Go's own icon: the vector, the adaptive icon masked and unmasked, the logo, and the raster launcher PNGs read from the host APK. Each comparison is also tried trimmed to its content and mirrored;
    • decoding is capped at 16 Mi pixels.
  • Contact details (core/Contacts.kt, core/ContactBranding.kt, core/HostSupport.kt):
    • seven fields: Website, Contact email, Feedback email, Support link, Forum, Telegram, YouTube;
    • each replaces App Dev For All's value in every config. A blank field writes "", which ADFA-7313 hides, and bilibili_video_url is always "";
    • links must be https, with % only as %XX. Emails must be a plain local@domain, because the app puts them in a mailto: unescaped;
    • values are trimmed, remembered between uses, and read back to verify.
  • Gate (core/BrandingGate.kt): Build needs a valid name, an icon that passes the check, valid contact details and the "this is my own" tick. Each problem has its own message.
  • Plugin manifests (core/MinSdk.kt): plugin.id, plugin.main_class and the minSdk are read from the .cgp's binary manifest after a header check. A plugin for a newer Android than the device's is now identified rather than reported unreadable, and the warning names the device's Android version.
  • Screen: the "Name and icon" and "Your contact details" sections, with labels, problem lines and tooltips. The help pages and README are updated.

Verification

  • Unit tests (JVM, core/): 232 pass, none skipped. They include CoGo's real ic_launcher.png at all five densities as fixtures (GPL-3.0, like this repo). Each regression test was checked to fail with its fix reverted.
  • Android build on the head, 4c0a476: assemblePlugin passes with no compiler warnings, testDebugUnitTest passes all 232, and addons check is clean. The .cgp's provenance record reads revision=4c0a476145b4, revision_source=git, not dirty. On 719134c, D8 reported no duplicate classes, and ARSCLib's six bundled framework stubs (android.util.AttributeSet, XmlResourceParser, org.xmlpull.v1.*) ran on Android 9 with no verify errors. CoGo's plugin loader is parent-first.
  • Final J7 pass (Galaxy J7, Android 9, on 719134c, host built from CoGo #2316 at 39e5a78b4):
    • a "QA Final" copy built in about 55 s with an add-on and a template;
    • it verifies with v1, v2 and v3, app_name is set in every config, and both add-ons are bundled byte for byte;
    • the contact values are in the copy, blank fields are "", and Bilibili is "";
    • a 1000x100000 picture is accepted, and the contact section works at font scale 2.0.
  • J7 checks (on c2834d6):
    • CoGo's own launcher PNGs (xxxhdpi, mdpi and a crop) are refused, and a photo is accepted;
    • AI-Core (minSdk 33) is accepted on Android 9 with the warning;
    • the copy's launcher, splash, onboarding and notification show the new name and icon at font scale 1.0 and 2.0.
  • J7 recheck (3ebd518, same host): disabling the plugin mid-build saves nothing, leaves no out-* folder and logs no signing afterwards. After re-enabling, a build works. During a build, the password fields and key picker are disabled.
  • Note 20: every tooltip of the new sections installs and shows. On a host without ADFA-7313, the refusal names the version needed, writes nothing and clears the password.

Limitations accepted

  • Can't ship before ADFA-7313's release (above). Until the minimum is raised, a 26.48 host's refusal reads "needs 26.48 or newer ... too old". By decision.
  • Styled strings keep the old name. Strings that name Code on the Go and carry formatting are not rewritten; the privacy dialog's text still names it until CoGo #2290 parameterises it.
  • Imperfect look-alike check. A screenshot of the launcher icon with a launcher frame and a notification badge still passes, and 1 of 3,160 unrelated pairs is wrongly refused.
  • Grainy status-bar icon from a photo. The screen warns when the shape will be nearly empty or solid.
  • ASCII only for contacts. Emails must be ASCII, and an international host name must be typed in its xn-- form.
  • Missing contact keys are skipped. A contact key the host lacks is noted in the build report but not shown on screen.
  • Branded copies refuse their own icon. Building from an already-branded copy refuses that copy's own icon, because the running host is the reference.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw

…inSdk

Core (pure JVM) for Phase B, with tests. ARSCLib 1.4.0 edits the host's
resources.arsc: app_name in every locale, other strings that name the app
(except the host's protected strings, and any string with markup), and the
files ic_launcher, ic_launcher_round, ic_launcher_foreground,
ic_launcher_fg_vector and ic_cogo_notification resolve to, in every config.
The new table is written stored and 4-byte aligned, with the PNGs beside it.

Also the name rules, the picture look-alike hash, the minSdk reader and
warning, and the gate that requires the ownership confirmation.

Plugin version 1.0.0 -> 1.1.0, versionCode 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
… the screen

Android layer for Phase B: a name field with a live check, a picture picker
that crops, scales to every density and compares the picture with the host's
own launcher icon, the ownership checkbox, and a warning under each plugin that
needs a newer Android than the host. Tooltips, in-IDE help, gallery page and
README describe the new fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
ResourceBranding.apply() re-reads the edited table and compares it with
the original, but no test failed if apply() skipped that call. The check
is now a parameter that defaults to verify(), and a test sees it run on
the bytes apply() returns. It fails with the call removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Session.kt: kept Phase B's name/icon code beside Phase A's end().
Help pages: Phase A's required headings, with Phase B's renaming, icon,
checks and minSdk text carried over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
F47: PluginMinSdk.fromArchive trusted the size the archive claims. It now
counts bytes as it reads, with a 1 MiB cap; an oversized manifest or an
OutOfMemoryError gives MinSdk.Unknown (a warning), never a crash.
6.7: tooltips for the app-name field, the icon preview and its status
lines, the name status line and the minSdk warning rows; the Phase B
long-press helper now shares Phase A's withTooltip.
6.6: help pages cover renaming, icon, checks, confirmation and minSdk
warnings under the required headings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Conflicts: the Build APK help line keeps both the output file name and the
new cancel wording; Session.build sets finished before reading the
branding result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
On device the copy still showed Code on the Go's phone logo on the welcome
screen, the main screen, About and the editor sidebar header. Those layouts
use @drawable/cogo_brand_mark, a vector in resources/ with one entry and no
density, and branding repointed only the launcher, foreground and
notification icons.

cogo_brand_mark is now a fourth icon role, repointed the same way: its entry
names a new PNG, res/custom-ide-builder/mark-<density>.png, made from the
whole picture at 80 dp (320 px at xxxhdpi, the file the density-less entry
gets). The layouts fit it into 44 to 200 dp boxes with fitCenter, so a
square picture shows square. Resource IDs are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
… (F51)

On device the app's own mipmap-xxxhdpi/ic_launcher.png, and a crop of it,
passed as "Different". The only reference was drawable/ic_launcher, a
vector whose phone fills the height of its square, while the legacy PNG
pads the phone to two thirds of it. Their hashes were about 45 bits apart
(threshold 14), so the shipped PNG never matched.

The check now compares against every drawing of the icon and keeps the
closest: the vector full-bleed, mipmap/ic_launcher and ic_launcher_round
as the device resolves them (the masked adaptive icon, and its layers
unmasked), cogo_brand_mark, and the raster files those resources name in
the host APK, found through resources.arsc (HostIcons). Each pair is also
compared trimmed to its content (IconTrim), so padding and crops do not
count. Hashed pictures are 128 px instead of 64, so trimming has pixels to
work with; the host's drawings are cached per APK.

CogoIconCheckTest runs on copies of Code on the Go's real launcher PNGs
(GPL-3.0, as this repository): every density, and crops and rescales of
them, come within 9 bits; 300 unrelated pictures stay at 18 or more. The
vector references are rebuilt from the PNG at the vectors' geometry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
On Android 9 a plugin with minSdk 33 (AI-Core) was refused as "could not
read the plugin ID", so the minSdk warning never showed.
AndroidBits.readPluginId used PackageManager.getPackageArchiveInfo, which
will not parse an APK whose minSdk is above the device's, and returned null.

PluginManifest (core) now reads plugin.id, plugin.main_class and the
package name from the .cgp's compiled AndroidManifest.xml with ARSCLib, as
PluginMinSdk already does for the minimum, and the way the host's
PluginLoader reads them: plugin.id else the package name, plugin.main_class
required, only text values, the last entry of a name winning. The manifest
read is capped at 1 MiB. getPackageArchiveInfo is no longer used.

The warning now reads "... so on a device below Android 13 (API 33) AI Core
will not work." and adds "This device has Android 9 (API 28)." when the
phone the builder runs on is older than the plugin needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
…s it

A .cgp is untrusted, and ARSCLib allocates by the sizes in the headers. Both manifest readers now require the XML magic, a chunk size equal to the byte count and a string pool that fits before parsing, and refuse otherwise (the archive readers then report no readable manifest). Also drops a stale finding ID from a test comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
…s folder

A template was accepted on its first four bytes. TemplateCheck opens it with java.util.zip.ZipFile and refuses a file that does not parse or holds an absolute, drive-letter, backslash, control-character or .. entry name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
A 1000 x 100000 picture was decoded whole because only min(width, height) chose the sample size. ImageSampling.sampleSize also keeps the decode within 16 Mi pixels (64 MiB), and the cap wins over the target side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Session.end also clears the name, icon, icon verdict and ownership box, and IconImages.release drops the cached host icons; a drawing still running at dispose cannot refill the cache. The icon preview is dropped rather than recycled, because the screen may still draw it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
The output-name question in Session meets the custom app name: the name
asked about and saved is built from the custom name when one is set.
Session.build now returns a small Saved record, so the Done message can
name the actual file and still report the skipped styled texts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Leaving both empty used to build an unbranded copy named Code on the Go
with its icon, while typing that name or picking that icon was refused.
Every copy now needs its own name, an icon that passes the icon check and
the ticked confirmation.

BrandingGate.isCustom is gone and nameToWrite never returns null; an empty
name and a missing icon each get their own gate message. Branding holds a
name and an icon, never a null part, which removes the null branches in
ResourceBranding.apply and verify. Pipeline and ApkRewriter still accept
no Branding: the rewrite and signing tests build synthetic hosts with no
resource table. The screen drops the "optional" texts and the confirmation
box is always enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
…equired

Help tooltips, the in-IDE help page, the gallery page and the README no
longer describe the name and icon as optional or say that leaving them
empty keeps Code on the Go's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Conflicts resolved keeping both sides: Phase B's branding (Branding,
BrandingGate, the minSdk on Chosen, the branded output name and BuildInput)
with Phase A's progress coalescing, itemsVersion, endsBuild and password
clearing. The min-SDK warning moves with the add-on rows into
rebuildItems, and refreshBranding stays on the full refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
The full refresh rebuilt every add-on row with a fresh MinSdkCheck and a
fresh read of the host's package details per row. Rows are now rebuilt
only when the list changes, and the warning is kept on the Chosen item the
first time its row is built; the host's details are read at most once per
rebuild, and only for a row not yet checked. While they cannot be read
nothing is flagged and nothing is kept, so a later rebuild tries again.

refreshBranding stays on the full refresh, never on a progress update, and
sets the icon preview only when the picture changed. The branding stages
reach the screen through Pipeline's progress callback, which is coalesced
like every other stage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
VerifyReport.signerSha256 is nullable, and Saved.signer is not, so a real
build of Session.kt failed with an argument type mismatch. The build now
throws BuildException("The finished APK carries no signer certificate.")
when it is null, before anything is written to the folder. The pipeline has
already verified the APK, so this should never happen, and the result line
can never say "Signed with certificate null".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
ResXmlElement.listElements(String) is deprecated in ARSCLib 1.4.0, and it
only copies getElements(String) into a list
(CollectionUtil.toList(getElements(name))). The loop now walks that
iterator directly. Nothing in the loop changes the tree, so it reads the
same elements in the same order. PluginManifestTest and MinSdkTest pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Conflict: kept Phase B's Saved record; both sides already throw on a
missing signer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Contacts holds the seven fields a copy can show in place of App Dev For
All's: website, contact and feedback emails, support link, forum,
Telegram and YouTube. ContactCheck trims each field and accepts a blank
one (hide); a link must be an absolute https URL with a host, no user
info, no whitespace or control characters, at most 2048 characters and
% only as a %XX escape; an email must be a plain local@domain, since the
app pastes it unescaped into a mailto: link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
ContactBranding sets about_website_url, adfa_email, feedback_email,
github_sponsors_url, github_discussions_url, telegram_channel_url and
youtube_channel_url in every config they have, blank as "", always
empties bilibili_video_url, and checks the values on read-back with the
name and icon edit. A host whose resources.arsc has no about_website_url
cannot carry them, so HostSupport refuses the build before any work and
names the plugin's minimum version, which a test keeps equal to the
manifest's plugin.min_ide_version. Invalid details join the gate's list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Seven labelled fields between "Name and icon" and the signing key, each
with a tooltip and a line naming its problem. The values live in Session,
survive the Fragment being rebuilt, are cleared by Session.end() and are
remembered in the screen's preferences. Build checks the installed app
for the contact strings before asking anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
The help pages and the README say where the copy's About links and
feedback emails come from, that blank hides, that the values are
remembered, and that the builder needs a Code on the Go with ADFA-7313.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Conflicts: kept both sides in Session.kt (branding and contact setters plus
activate/deactivate), BuilderFragment.refresh (refreshBranding/Contacts plus
the disabled password fields) and the Build APK help line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
Conflict: kept Phase B's accept() signature and binary-manifest plugin ID;
the template check is the same on both sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ6QqzwTmigaKYLNVw
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.

2 participants