A feature that does not exist is better than a broken one. VirtualAP runs as root on rooted phones, on Wi-Fi chips whose drivers disagree about basic things, so a patch that works on your phone and breaks on someone else's is a regression, not a contribution. And ten lines that do the job beat a hundred that do the same job: delete before you add, reuse before you write.
The rules for anyone changing this repository, agents included, are in
AGENTS.md: the style, the commit format, the choke points and the hard
constraints. In short: Android only, the engine is single-threaded C on musl that talks to
the kernel itself, split one concern per module, the app runs on Android 8, and the binaries
come only from scripts/build-static.sh and, for virtualap, the root Makefile.
VirtualAP runs on Qualcomm, Broadcom FullMAC (Samsung) and MediaTek chips. A fix for one
chip's quirk is accepted only when the backend adapts to it at runtime, by detection, a
conditional path or a fallback, without changing behaviour on the others;
nl80211_sta_freq reading the associated BSS's frequency because Samsung omits the channel,
and ensure_5g_ir firing only when the phy reports NO-IR, are the pattern. If the fix cannot be gated that way, it
belongs in a fork. Test on a real phone, there is no emulator for a Wi-Fi chip, and say in
your PR which devices, drivers, bands and upstreams you tested on; an untested claim counts
as untested.
./scripts/build-static.sh # from the repository root: both arches, needs Docker
./build.sh [release] # from Android/: the APK, needs JDK 17 or newer, ANDROID_HOME and musl-cross gcc
What the scripts do, and what CI does, is in the Building section of
How-It-Works.md. A release is a tag: make bump NEW=x.y.z,
commit it as VirtualAP: bump vX.Y.Z, then push main and the tag vX.Y.Z.
The four rules are in AGENTS.md, Style. On top of them:
- Backend: coreutils are
$ECHO,$GREP,$SEDand friends, never bare, and never quoted. Output islog,warn,error. Subcommands arecmd_*, Droidspaces helpersds_*, radio probesphy_*, policypick_*andresolve_*. Teardown mirrors setup step for step and every step tolerates absence. Each daemon logs to its own file underlogs/. - App: state lives in a ViewModel, not in a stateful composable and not in a
utilsingleton. Lists render withLazyColumnand stable keys. Colours come fromMaterialTheme.colorScheme, type fromMaterialTheme.typography, timings fromAnimationUtils, every other visual value from DESIGN.md. Any value that reaches a root shell goes throughBackend.quote()or an allow-list validator.
Commits are signed off and prefixed as AGENTS.md, Commits, says.
Translators work on Weblate, which commits to the values-<lang>/ folders; a pull request
touches only the English in res/values/. How the components are set up is in the
Translations section of How-It-Works.md.
Adding a string:
- Put it in
strings.xmlunder the comment for its screen, or inplurals.xmlif a count changes its wording. Kotlin reads it withstringResource, orgetStringoutside composition. - Placeholders are positional,
%1$s, so a translation can reorder them. Say what each one is in a comment directly above the string, which Weblate shows to the translator; do the same for a short word that could mean two things. - One whole phrase per string. Never glue translated pieces together.
- Paths, commands, preference keys and what the engine prints stay in code, in English. A
value in the file that no language changes, a product name or an example address, is
translatable="false".
Grep this list before you write anything new. If something close exists, extend it rather
than adding a sibling. Android paths are relative to
Android/app/src/main/java/com/virtualap/app/; engine modules are paths under src/, each
folder's header under src/include/<folder>/.
This list answers "what do I call"; DESIGN.md answers "what should it look like" when
nothing here fits. The shared components were ported from Droidspaces; when a caller for one
of its other components appears, copy the upstream file rather than writing a new one.
Forms and inputs:
DsDropdown(label, selected, options, displayName, onSelect, ...)inui/component/DsDropdown.kt: any select field. Never hand-rollExposedDropdownMenuBox.DsTextFieldDefaults.colors()inui/component/DsTextFieldDefaults.kt: everyOutlinedTextField.rememberClearFocus(), whichDsDialoguses, andClearFocusOnClickOutside, the main screen's root, inui/util/FocusUtils.kt: drop the keyboard on an outside tap.
Dialogs and sheets:
DsDialog(onDismiss, modifier, footer) { }inui/component/DsDialog.kt: every dialog. Never set a width, padding or scroll.DialogFooterRow(dismissLabel, confirmLabel, onDismiss, onConfirm, confirmEnabled)inui/component/DialogFooterRow.kt: the two buttons in a dialog with a choice, in thefooterslot.DialogCloseButton(onClick, enabled)inui/component/DialogCloseButton.kt: the 36dp close square in a header row, for content that closes from the top.LogActionRow(logs, isBlocking, onClear)inui/component/LogActionRow.kt: the Clear and Copy row above a log console;onClear = nullgives Copy alone.DeviceRow,DeviceSheet(title, onDismiss, content),BlockedList,AllowedList,BlockedDevicesSheet,AllowedDevicesSheetandrememberDeviceAction(reload)inui/component/DeviceList.kt: a device with its action, the sheet they sit in, the two lists, and running a change to them with the failure said out loud.AddDeviceDialogandAllowOnlyDialoginui/component/AddDeviceDialog.kt: the MAC field that takes only hex digits, and who drops off when only allowed devices can join.Caption(text)inui/component/Caption.kt: a line of secondary text.- The Wi-Fi QR sheet, the devices sheet and the logs sheet are private to
ui/screen/MainScreen.kt, the About dialog and the language picker toui/screen/SettingsScreen.kt. Do not import or copy them.
Bars, setup, feedback:
PrimaryActionBottomBar(label, icon, onClick, ...)inui/component/PrimaryActionBottomBar.kt: the Start and Stop bar. The overload taking acontentslot is for a button that swaps its contents.SetupPage,SetupFrame,SetupHero,SetupActionBarinui/component/SetupHero.kt: every screen of the setup flow, the welcome pager, the root check and the installer. See DESIGN.md, "The setup flow".PullToRefreshWrapper(onRefresh) { }inui/component/PullToRefreshWrapper.kt: any pull to refresh screen body.ToggleCardinui/component/ToggleCard.kt: a switch row in its own card, the main screen's options.SwitchIteminui/component/SwitchItem.kt: the flat switch row inside a grouped surface, the Settings screen.StatusPill(label, color)inui/component/StatusPill.kt: any small status chip.SectionHeader(text)inui/component/SectionHeader.kt: a heading above a group of cards.CardContentPadding,CardHeaderHeightinui/component/CardMetrics.kt: any card with a title-and-pill header, so the dividers line up.LoadingIndicator(size, color)withLoadingSize, andFullScreenLoading(message), inui/util/LoadingIndicator.kt: every spinner and every whole-screen loading state.TerminalConsole(logs, isProcessing, maxHeight)andShimmerAnimation(enabled) { }inui/component/TerminalConsole.kt: the scrolling log view and its frame.
Theme:
VirtualAPTheme(darkTheme, dynamicColor, amoledMode, themePalette)inui/theme/Theme.kt: the one theme root, applied inMainActivity.rememberThemeState()andThemeStateinui/theme/ThemeStateHolder.kt: the live theme preferences.ThemePaletteinui/theme/Color.kt: adding an accent palette, here and nowhere else.Theme.ktandColor.ktare the only files that name a colour literally.MaterialTheme.typography.*andJetBrainsMonoinui/theme/Type.kt: all text styles, and the mono font for log and code text.AnimationUtilsinutil/AnimationUtils.kt: the tween specs. Never a literaltween(300).AccentColorPickerandColorPaletteSwatchinui/component/: the palette picker.- There is no spacing or shape token object; the numbers live in DESIGN.md and are written as literal dp.
Navigation:
Screenand thewhenover it inMainActivity.kt: the one place a top-level screen is chosen, the welcome flag first, then root and install state, then the Settings flag. A new screen goes there.
Shell, root and the backend:
Backend.quote(value)andBackend.startApinutil/Backend.kt: every dynamic value that reaches a root command, and the engine's command prefix (with its fallback to the script an older release extracted, until the setup flow replaces it).APManager.getStatus/start/stop/getInterfaces/getCaps/isInstalledinutil/APManager.kt: drivingvirtualap, andgetContainers/parseContainers, which ask Droidspaces for its running containers directly. Never assemble one of these commands by hand.Hotspot.start(cfg)/stop()/refresh(),phase,status,actionLogsinutil/Hotspot.kt: starting or stopping the AP from anywhere and reading the session state; also posts the running notification and wakes the tile.APConfigwithisValid(),isValidIpv4,isValidDnsList,channelsForBandinutil/APConfig.kt: the saved hotspot config, the one start validation, and the address checks the fields share with it.BackendLoggerandclassifyLine(line)inutil/BackendLogger.kt: the log sink the AP calls take, and the[ERROR]/[WARN]level tagging.PreferencesManagerinutil/PreferencesManager.kt: the app's own settings.APManager.loadConfig/saveConfig: the hotspot config, read and written whole inap.conf.Constantsinutil/Constants.kt: every path and preference key.RootChecker.checkRootAccess(reprompt)andRootStatusinutil/RootChecker.kt;VirtualAPInstaller.deviceArch/bundledPayloadVersion/payloadUpdateAvailable/installinutil/VirtualAPInstaller.kt;ModuleInstaller.installinutil/ModuleInstaller.kt, the boot module;QrCodeGenerator.wifiPayload/encodeinutil/QrCodeGenerator.kt, the only zxing caller.HotspotTileService,HotspotStopReceiverandHotspotBootReceiver: the Quick Settings toggle, the notification's Stop action, and the boot module's word that it started a hotspot. None hold state of their own.LocaleHelper.availableLanguages/currentLanguage/changeLanguageinutil/LocaleHelper.kt: the app's language, the only caller ofAppCompatDelegate.setApplicationLocales.AppViewModelowns the welcome flag, root status and install state;APViewModelowns the editable config, the interface and container lists and the tailed log, and forwards start and stop toHotspot. The 3 s status poll lives inMainScreen, bound to its lifecycle.- The global libsu configuration lives in
VirtualAPApplication.kt, and only there.
Engine (src/):
core/:proc(every program run, the pid files, and the lock that lets one start or stop run at a time),io(the log:vap_log,vap_warn,vap_error,log_stamp;read_file,write_file,write_atomic; the parsersvalid_ip4,prefix_parse,subnet_from_gw, andcsv_eachfor the comma lists of-d).cli/:options(thevap_keystable,opt_set,opts_parse,print_usage),conf(ap.confandrun.state).net/:nl(the rtnetlink transport,nl_dump, and the namespace helpersnetns_open,in_netns),link(links, addresses and neighbours),route(routes, policy rules, and netd's tables:upstream_resolve,upstream_v6_iface),ipt/, kept apart because on musl the kernel's netfilter headers and libc's networking headers cannot meet in one file:ipt(theip_tablesengine),ipt_rules(FORWARD, MASQUERADE, the presence check, the NAT probe,ipt_bin, the TTL fix).radio/:driver(nl80211 over genetlink: create and delete ap0, the phy, the station's frequency, the width; the wpa control socket;wifi_mac, the factory MAC),channel(band, channel and width policy, andensure_5g_ir).mode/:ap(ap0, the daemons, radio planning, the signal hold both modes share, andhostapdanddnsmasq: their configs and starts, the client count),routed(with the pinned policy rules both families use),ipv6(ipv6_decide, setup, teardown, NAT66 and the shared /64 with its client discovery),managed(the Droidspaces container: its pid, the OpenWrt provisioning, the RPS masks),maclist(the blocked and allowed devices' files, which arehostapd'sdeny_mac_fileandaccept_mac_file, and telling a runninghostapd).monitor/:monitor(the daemon's loop),upstream(reprobe).cmd/: the commands the app calls, dispatched frommain.c:start(startandstop),status(the read-only ones:status,clients,interfaces,caps) andblock(block,unblock,blocked,allow,disallow,allowed,allow-only).
Fork, work in a branch, open the PR against main, and stay responsive: an unanswered PR is
closed, and feedback is addressed in the same PR, not a new one. There is no CLA; by
submitting you agree that your contribution may be distributed under the project's licence.
Every PR says:
- What real-world problem it solves. "I wanted this" is not one; say what breaks, fails or is missing for real users on real hardware.
- Screenshots or terminal output showing it working.
- The tested environments: for the app, device, Android version and root provider; for the backend, device, SoC and Wi-Fi chip, driver, band and width, upstream (mobile data, Wi-Fi, VPN), and whether managed mode was exercised.
- For UI changes, the DESIGN.md rules you followed, and which one you deviated from and why. A radius or a colour that disagrees with DESIGN.md without a reason is sent back.
What is merged: fixes with a reproduction and a verified resolution, features validated across devices, security hardening, measured performance improvements, deletions, and documentation corrections. What is rejected: an engine change that spawns a tool for what netlink or the kernel's own files can do, or that grows a module past its one concern; a prebuilt or dynamically linked binary; a feature no real user has reported or that only works on one hardware configuration; code its author cannot explain; an app change that breaks Android 8; a second copy of something in the inventory; any dynamic value reaching a root shell unquoted; anything that regresses what worked, however useful the new behaviour.
A merged feature is yours going forward: when a new Android version or driver breaks it, you are expected to fix it, and a feature whose author is unreachable is removed. A contributor whose PRs keep being rejected for the same reasons, no real problem, untested, or padding the codebase, is blocked; there is no strike count, the decision is the maintainer's.
Anything that lets a hotspot client, or a value typed into the app, reach the root shell unquoted is a vulnerability. Do not open a public issue; report it privately to droidcasts@protonmail.com or t.me/ravindu with a reproduction, the affected configurations and the device or driver, and hold public disclosure until a fix is out. Hardening patches are reviewed first.