Clean-Room App Reconstruction: A Five-Step Framework with Cost Breakdown

    This article explains how to reconstruct a mobile app's functionality from scratch without touching source code or decompiling, using a clean-room approach based only on publicly visible interfaces and observable interactions. It introduces a fidelity grading model from L0 to L5, details a five-step framework covering scope definition, direct device connection, combined semantic tree and screenshot parsing, specification checklists, and same-device acceptance, and shares practical pitfalls, cost insights, and compliance boundaries.

    1. Why App Reconstruction Is an Engineering Problem

    In mobile product iteration, teams often face a practical question: how can you understand what an app looks like and how it behaves, and then build a functionally equivalent version from scratch, without accessing the source code or decompiling it? This need commonly appears in interaction benchmarking, usability research, internal prototype validation, and teaching demos.

    The approach described here uses an AI coding tool to take control of a real phone, infer specifications from publicly visible interfaces and interaction results, and then rewrite the implementation. The whole process took about 7 hours with a direct cost of roughly 21 RMB. The number itself is not the point. What matters is that it shows something important: with a disciplined process, reconstruction can shift from guesswork to measurable engineering.

    One thing must be emphasized: this article is about clean-room reconstruction. You only observe public interfaces and perceivable interaction results. You do not read or decompile any non-public code or private data. The final deliverable is an independently written implementation. This is both the compliance baseline and the precondition for a reusable method.

    2. Fidelity Levels: Define “How Far” Before You Start

    The most common reason reconstruction fails is not a lack of technical skill but a vague target. Define the levels before starting, and lock down the acceptance criteria:

    • L0 Screenshot level: Only static visuals are reproduced, with all data hardcoded as fake values.
    • L1 Structural level: Layout and control hierarchy match, but interactions are mostly placeholders.
    • L2 Interaction level: Primary paths are clickable and navigable, with mostly correct state changes.
    • L3 Effect level (default target): Model capabilities are genuinely invoked, inputs and outputs are equivalent to the reference implementation, and static fake data is rejected.
    • L4 Boundary level: Exception inputs, failure retries, timeouts, and fallback paths are covered.
    • L5 Engineering level: Observability, permission isolation, cost control, and a scalable architecture are in place.

    Defaulting to L3 is a pragmatic trade-off: it guarantees “consistent effects” without falling into endless polishing. If external delivery is required, fill in L4 and L5 item by item.

    3. The Five-Step Framework in Detail

    Step 1: Define Levels and Trim Scope

    List the screens of the reference app, label the target level for each screen, and make an explicit “not doing” list. The value of scope trimming is to invest a limited budget in critical paths: core flows such as generation, editing, parameter settings, and result management should reach L3 first, while peripheral settings pages can stay at L1 for now.

    Step 2: Direct Device Connection

    Enable USB debugging on the device and connect it to the development machine via cable. The AI coding tool can then take over the device through the system’s built-in debugging bridge commands. Example flow:

    1. # List connected devices
    2. adb devices -l
    3. # Install the test package to build
    4. adb install -r build/app-debug.apk
    5. # Launch a specific screen and capture logs
    6. adb shell am start -n com.example.app/.MainActivity
    7. adb logcat -v time | grep -iE "error|exception"

    The key benefit of direct device connection is a closed loop: modify, install, operate, collect logs, and take screenshots all on the same device, avoiding behavioral differences between emulators and real devices.

    Step 3: Combined Semantic Tree and Screenshot Parsing

    A single source of information will inevitably distort. The control tree provides structure and coordinates; the screenshot provides visual attributes. Only when layered together are they usable:

    1. # Export the current screen's control tree
    2. adb shell uiautomator dump /sdcard/window.xml
    3. adb pull /sdcard/window.xml ./spec/window.xml
    4. # Capture the screen image for visual comparison
    5. adb shell screencap -p /sdcard/screen.png
    6. adb pull /sdcard/screen.png ./spec/screen.png

    When parsing, extract three types of information: structure (control types, hierarchy, clickability), geometry (boundary coordinates, spacing, grid), and visuals (primary and secondary colors, corner radius, font size and weight, shadow levels). Normalize visual parameters into design tokens, so later implementation references tokens instead of magic numbers.

    Step 4: Specification Checklists: Turn Observations into Executable Documents

    This step determines whether reconstruction is “one-off” or “reusable.” Produce two tables:

    Per-Screen UI Difference Table (example structure)

    Screen Element Reference Implementation Current Implementation Target Level Status
    Home Top navigation height 56dp 48dp L3 To fix
    Editor Primary button corner radius 12dp 8dp L3 Aligned

    Behavior Audit Table (example structure)

    Trigger Action Precondition Expected State Change Failure Branch Verified
    Submit generation Model and aspect ratio selected Enter task queue and show progress Offer retry after timeout Yes
    Extend video A completed clip exists Generate a new version and keep original clip attribution Prompt when quota is insufficient No

    With these two tables, progress becomes quantifiable, regression can be automated, and experience can be consolidated into reusable skill packages.

    Step 5: Rebuild and Same-Device Acceptance

    During rebuilding, stick to three disciplines: write from scratch your own code; genuinely invoke model capabilities rather than returning fake data; and compare on the same device, meaning run the reference implementation and your own implementation alternately on the same device, taking screenshots screen by screen for both pixel and structural comparison.

    Automate acceptance where possible:

    1. # Batch screenshots and run structural difference comparison
    2. adb shell screencap -p /sdcard/case_01.png
    3. adb pull /sdcard/case_01.png ./evidence/case_01.png
    4. # A script compares control tree differences and image similarity, then outputs a difference report

    4. Common Pitfalls and How to Avoid Them

    1. Treating fake data as a result: The L0 screenshot-level implementation looks the most similar but delivers the least value. Ban hardcoded data in core flows at the level-definition stage.
    2. Parsing only screenshots: Visual consistency with a broken structure causes both accessibility and automation to fail.
    3. Ignoring the state machine: The complexity of generation apps concentrates in task state transitions. Draw the state diagram before writing code.
    4. Skipping failure branches: Timeouts, insufficient quota, and network jitter are the real dividing lines of user experience.
    5. No evidence retention: Every step should archive screenshots and logs, otherwise regression is impossible.

    5. Cost and Efficiency: What 7 Hours and 21 RMB Show

    The key to low cost is not “cheap tools” but a short feedback loop: direct device connection removes environment setup overhead, specification checklists remove repeated confirmation overhead, and skill package consolidation removes duplicated work. The reusable engineering lesson is: standardize the process first, then talk about automation; define the acceptance level first, then talk about implementation details.

    If you need to scale to multi-person collaboration or long-term maintenance, you can introduce general cloud capabilities as needed, such as using object storage to archive screenshot evidence, message queues to smooth out task submission peaks, container platforms to host headless device clusters, and logging and monitoring services with alerting to track failure rates.

    6. Compliance and Boundaries

    The legality of clean-room reconstruction rests on “only look at the public, rewrite from scratch.” Do not decompile, do not capture private interfaces, do not copy material resources, and do not reuse others’ code or trademark identifiers. The deliverable should replace all visual assets and naming, keeping only functional equivalence. This is both a legal requirement and what makes the approach easier to pass team and compliance reviews.

    7. Conclusion

    Reconstructing a mobile AI generation app is essentially turning “observe, specify, rebuild, accept” into a repeatable pipeline. Master the five steps of L0-to-L5 level definition, direct device connection, combined semantic tree and screenshot parsing, specification checklists, and same-device acceptance, and anyone can turn an occasional practice into deliverable, auditable, and reusable engineering capability.