Skip to content

[stealth 09/11] Add stealth Android manifest filtering#8775

Closed
reflog wants to merge 1 commit into
stealth/8769-novpn-proxyfrom
stealth/8771-android-manifest-minimization
Closed

[stealth 09/11] Add stealth Android manifest filtering#8775
reflog wants to merge 1 commit into
stealth/8769-novpn-proxyfrom
stealth/8771-android-manifest-minimization

Conversation

@reflog

@reflog reflog commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a generated Android manifest filter for stealth VPN and no-VPN modes
  • wire Gradle to use the generated manifest when STEALTH_MODE=vpn or STEALTH_MODE=novpn
  • document the current Android stealth manifest modes

Validation

  • python3 -m py_compile scripts/stealth/android_manifest_filter.py
  • python3 scripts/stealth/android_manifest_filter.py --mode vpn --input android/app/src/main/AndroidManifest.xml --output /tmp/stealth-vpn-manifest.xml
  • python3 scripts/stealth/android_manifest_filter.py --mode novpn --input android/app/src/main/AndroidManifest.xml --output /tmp/stealth-novpn-manifest.xml
  • git diff --check

Gradle was not run locally because this checkout does not include a gradle wrapper and no system gradle is installed.

Closes getlantern/engineering#3578

Copilot AI review requested due to automatic review settings May 15, 2026 12:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an opt-in “stealth” Android manifest minimization flow, generating a filtered AndroidManifest.xml for stealth VPN vs no-VPN modes and wiring Gradle to consume the generated manifest when STEALTH_MODE is set.

Changes:

  • Added a Python-based manifest filter to remove deeplinks, payment queries, wallet metadata, cleartext traffic, and (for novpn) VPN-related services/permissions.
  • Updated android/app/build.gradle to select a generated manifest when -PSTEALTH_MODE is provided and to generate it via a Gradle Exec task.
  • Added developer documentation describing the stealth manifest modes and how to build them.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
scripts/stealth/android_manifest_filter.py New generator that filters the base Android manifest for vpn / novpn stealth modes.
android/app/build.gradle Adds STEALTH_MODE parsing, generated manifest source selection, and a manifest generation task.
docs/stealth-builds.md Documents how to invoke stealth builds and what each mode removes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread android/app/build.gradle Outdated
Comment thread android/app/build.gradle Outdated
Comment thread android/app/build.gradle Outdated
Comment thread scripts/stealth/android_manifest_filter.py Outdated
Comment thread docs/stealth-builds.md
Comment thread android/app/build.gradle Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread scripts/stealth/android_manifest_filter.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread docs/stealth-builds.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread scripts/stealth/android_manifest_filter_test.py
Comment thread scripts/stealth/android_manifest_filter_test.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread Makefile Outdated
Comment thread android/app/build.gradle Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread Makefile Outdated
@reflog reflog changed the title Add stealth Android manifest filtering [stealth 09/11] Add stealth Android manifest filtering May 16, 2026
@reflog reflog requested a review from Copilot May 16, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@reflog

reflog commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Reviewed the current PR state at a54dd0b and re-ran the targeted stealth manifest validations locally (py_compile, both manifest generation modes, make stealth-manifest-filter-test, and git diff --check). I didn’t find any new actionable issues from this review pass.

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Reviewed the current PR state at 85011ed. All previously flagged issues have been addressed:

  • foundation.bridge.SyncService is now implemented in NoVpnComponents.kt as a wrapper around NoVpnLanternService
  • MainActivity properly gates VPN vs no-VPN service selection on BuildConfig.STEALTH_NO_VPN
  • from __future__ import annotations added to the manifest filter script for Python 3.8 compatibility
  • CMake variables are properly quoted in ndk-stl-config.cmake
  • STEALTH_MODE=stealth- edge case now raises a GradleException
  • STEALTH_MODE=vpn + -PstealthNoVpn=true conflict raises a GradleException
  • PYTHON ?= python3 defined in Makefile
  • Test file uses sys.path.insert to work from any directory
  • Docs reflect that boot receiver removal applies to both vpn and novpn modes
  • stealthManifestFilter script file and stealthMode property both included as Gradle task inputs

make stealth-manifest-filter-test passes cleanly. No new issues found in this review pass.

Copilot finished work on behalf of reflog May 17, 2026 16:31
@reflog

reflog commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Fixed the remaining open issue in e834a7d: changed $(PYTHON) -m unittest scripts/stealth/android_manifest_filter_test.py to $(PYTHON) -m unittest discover -s scripts/stealth -p '*_test.py', which is the standard unittest discovery form and avoids any ambiguity around file-path vs module-name arguments. make stealth-manifest-filter-test continues to pass cleanly.

Copilot finished work on behalf of reflog May 17, 2026 16:34
@reflog

reflog commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread docs/stealth-builds.md Outdated
@reflog

reflog commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Reviewed the current PR state at e834a7d. All previously flagged issues have been resolved:

  • unittest discover form used in Makefile (-s scripts/stealth -p '*_test.py') — tests pass cleanly
  • PYTHON ?= python3 defined in Makefile
  • sys.path.insert in test file allows running from any directory
  • foundation.bridge.SyncService implemented in NoVpnComponents.kt
  • MainActivity gates service class on BuildConfig.STEALTH_NO_VPN
  • from __future__ import annotations added for Python 3.8 compat
  • CMake variables properly quoted; NDK prebuilt selected by CMAKE_HOST_SYSTEM_PROCESSOR
  • STEALTH_MODE=stealth- raises GradleException
  • STEALTH_MODE=vpn + -PstealthNoVpn=true conflict raises GradleException
  • toLowerCase(Locale.ROOT) used in build.gradle
  • Docs reflect configurable Python executable and correct boot-receiver removal scope

No new issues found.

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

@copilot review

The open issue from the automated reviewer — missing docs for -PstealthNoVpn=true — was addressed in 03076b1. docs/stealth-builds.md now documents the legacy compatibility flag, its behavior when STEALTH_MODE is unset (selects novpn), the conflict-detection when combined with STEALTH_MODE=vpn, and recommends -PSTEALTH_MODE=novpn for new scripts. Tests pass cleanly.

@reflog

reflog commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread docs/stealth-builds.md Outdated
Copilot finished work on behalf of reflog May 17, 2026 16:45
@reflog reflog force-pushed the stealth/8769-novpn-proxy branch from 63476bf to 19d484d Compare June 11, 2026 11:19
Introduces android_manifest_filter.py, a single transform engine that
produces vpn and novpn manifests from the parameterised source manifest.

Key points:
- Filter runs on the AGP-MERGED manifest (post-library-merge +
  post-placeholder-substitution), hooked as a doLast on
  process{Variant}Manifest. This is the only correct point: Stripe,
  Google Play Billing, Firebase/MLKit AARs inject activities/services
  that are absent from src/main/AndroidManifest.xml until merge time.
- STEALTH_MODE accepts stealth-vpn or stealth-novpn; the legacy
  -PstealthNoVpn=true flag is preserved for backward compat.
- vpn mode strips: app-links, deeplinks, wallet/Stripe/payment
  activities, GMS/Firebase services, MLKit providers, boot receiver,
  broad-package-visibility and write-settings permissions, cleartext.
- novpn additionally removes: VpnService, BIND_VPN_SERVICE, quick-tile,
  TUN/foreground-VPN permissions; injects SyncService (foundation.bridge)
  as the neutral-named proxy service entry.
- foundation.bridge.SyncService extends NoVpnLanternService; manifest
  declares it under the neutral name.
- MainActivity made open; vpnServiceClass dispatches to NetworkService
  for stealth-vpn builds; STEALTH_NO_VPN gates all novpn code paths.
- Makefile: PYTHON ?= python3, stealth-manifest-filter-test target.
- CI: run stealth manifest filter tests before the Android build step.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@reflog reflog force-pushed the stealth/8771-android-manifest-minimization branch from 03076b1 to 0a082c2 Compare June 11, 2026 11:45

@reflog reflog left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed all review comments from the earlier Copilot rounds in the amended commit (0a082c2). Critical fix: dropped ensure_remove_stubs + queries.set(TOOLS_NODE) entirely — remove_matching is the only deletion mechanism. Added 35 per-category absence tests. See inline reply summaries below.

Comment thread android/app/build.gradle Outdated
Comment thread scripts/stealth/android_manifest_filter.py Outdated
Comment thread docs/stealth-builds.md Outdated
Comment thread scripts/stealth/android_manifest_filter_test.py
Comment thread scripts/stealth/android_manifest_filter_test.py Outdated
Comment thread android/app/cpp/ndk-stl-config.cmake
Comment thread android/app/cpp/ndk-stl-config.cmake Outdated
Comment thread android/app/build.gradle
Comment thread Makefile Outdated
Comment thread docs/stealth-builds.md Outdated
@reflog

reflog commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Superseded — the 11 per-issue stealth PRs were consolidated into a 6-PR stack for epic getlantern/engineering#3569. This work now lives in #8860.

@reflog reflog closed this Jun 15, 2026
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