garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /crates/cartopolis_android/AndroidManifest.xml

raw

<?xml version="1.0" encoding="utf-8"?>
<!--
  The whole Android app definition. There is no Gradle project behind this file —
  see docs/notes/android-build.md.

  `android:hasCode="true"` since the dex lane landed, and the flip is load-bearing
  in a way that is easy to get wrong in the *quiet* direction. The attribute was
  `"false"` for as long as the APK carried no `classes.dex` at all: the activity
  class is `android.app.NativeActivity` out of the framework itself rather than
  the GameActivity one that would arrive in an AAR, so a manifest plus a `.so` was
  a complete app. It is now `"true"` because `build-apk.sh` compiles
  `java/eu/garage44/cartopolis/` with javac + d8.

  Leaving it `"false"` with a dex present does **not** fail the build, the install
  or the launch. The framework simply believes the claim and never adds the APK to
  the app classloader, so every one of our classes is missing at runtime and the
  only symptom is a ClassNotFoundException from whichever Rust call reached for
  one first. That is why `platform::android::report_dex` logs the answer at
  startup and why `deploy-android.yml` asserts the dex is present: the two
  together are what make this attribute's state observable instead of assumed.

  `android.app.lib_name` is how NativeActivity finds us: it `System.loadLibrary`s
  that name out of `lib/<abi>/`, so it must track the cdylib's crate name
  (`libcartopolis_android.so` → `cartopolis_android`).
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="eu.garage44.cartopolis">

    <!-- **No version attributes here, deliberately.** `aapt2 link`'s version-code
         and version-name flags (spelled without their leading dashes: a double
         hyphen is illegal *inside* an XML comment) *inject* a value and only
         when the manifest carries none — they do not overwrite one that is
         already there. This file used to declare `versionCode="1"` and
         `versionName="1.0.0-local"` under a comment claiming aapt2 would
         overwrite them, and the opposite was true: the flags were discarded
         silently and **every APK ever published shipped as version 1 /
         1.0.0-local**.

         That cost more than tidiness. `deploy-android.yml` computes a monotonic
         code from the run number, offset above any local build, precisely so a
         download from the install page can always update a sideloaded one — a
         guarantee that never existed. And nothing on a device could say which
         build it was: the crash reporter's `CARTO_BUILD_SHA` (baked into the
         binary from the same version-name) said `1.0.0+087e7198` while Android's
         app info said `1.0.0-local`, so the two identifiers for one build
         disagreed. Confirmed on an emulator 2026-08-15, from a share sheet
         showing one and `dumpsys` the other.

         `build-apk.sh` supplies both on every path, including a hand build (it
         falls back to the commit count), so there is nothing to fall back to
         here. See its version block for why a CI code is deliberately larger
         than a local one. -->

    <!-- API 28 because that is where Android's Vulkan support becomes something
         wgpu can rely on; below it the GLES fallback would be the only backend and
         this client has never been run on one. 34 as the target keeps the modern
         windowing behaviour (edge-to-edge, gesture nav) rather than the
         compatibility shims older targets opt into. -->
    <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="34" />

    <!-- Advisory, not enforced: it keeps the Play listing (and `adb install`'s
         warnings) honest about needing a Vulkan device, without hard-failing an
         install on a device whose driver reports oddly. -->
    <uses-feature
        android:name="android.hardware.vulkan.version"
        android:version="0x400003"
        android:required="false" />

    <!-- The entire map — OSM tiles, 3DBAG buildings, AHN heights, GFS clouds — is
         streamed. Without this the app starts and renders an empty globe. -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Location. These were deliberately absent until the JNI provider existed,
         on the rule that a permission the app cannot act on is a prompt that buys
         the user nothing: `platform::location` had only a web arm, and
         `LocationWatch::available()` said so rather than inventing a fix. That
         changed with `platform::android` — driver mode now follows the device on
         the phone instead of the avatar.

         Both are listed, and FINE is not a superset of COARSE at the manifest
         level: since API 31 the permission dialog offers the user a Precise /
         Approximate choice and will only offer Approximate if COARSE is declared
         too. Requesting FINE alone means a user who wants to share a rough
         position has to refuse outright. The provider accepts either grant and
         reports the resulting accuracy honestly (`GpsFix::accuracy_m`).

         These are *dangerous* permissions, so from API 23 the manifest entry only
         makes them requestable — the app must also ask at runtime, which
         `platform::android::request_permission` does. There is no background
         location here and there must not be: the fix is only read while driver
         mode is on and the app is on screen, so ACCESS_BACKGROUND_LOCATION would
         be a Play-review conversation in exchange for nothing. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <!-- Advisory: the app is fully usable without GNSS (it is a map viewer first),
         so a device with no location hardware must still be able to install. -->
    <uses-feature android:name="android.hardware.location.gps" android:required="false" />

    <!-- The compass (`platform::orientation`), which turns the map with the phone
         when the locate button is lit. No permission: the rotation vector is not a
         restricted sensor, so the only manifest entry it wants is this advisory
         one, and it is `required="false"` for the same reason the GNSS line above
         is — a device with no magnetometer loses the heading and keeps the map. -->
    <uses-feature android:name="android.hardware.sensor.compass" android:required="false" />

    <!-- Hold the screen on while driving. A *normal* permission: granted at
         install, never prompted for.

         The usual way to keep a screen lit is FLAG_KEEP_SCREEN_ON, which needs no
         permission at all — and is unreachable here for a reason that is about
         android-activity's lock rather than about Android
         (`platform::android::set_keep_screen_on` has the deadlock). A wake lock
         is the same effect through a thread-safe binder call, and this line is
         what it costs. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <!-- A photo on a saved place (`platform::photo`, docs/notes/place-photos.md).
         Capped at API 28 on purpose: from 29 scoped storage lets an app insert its
         own row into the MediaStore with no permission at all, and that insert is
         how the camera app is given somewhere to write. Below 29 there is no
         RELATIVE_PATH column and the same insert needs this, so it is requested at
         runtime on those devices only.


         CAMERA is declared below for calls, and an app that declares it must hold
         it before ACTION_IMAGE_CAPTURE is honoured, so the photo asks for it too
         (`platform::photo`). -->
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="28" />

    <!-- Advisory for the same reason as the GNSS entry above: a tablet with no
         camera must still install; the menu entry simply fails with "no camera
         app" when the intent finds no handler. -->
    <uses-feature android:name="android.hardware.camera" android:required="false" />

    <!-- Proximity voice chat, and the mic test in Settings ▸ Audio. Added when
         `platform::audio` grew its Android arm, on the same rule the location
         entries above state: a permission the app cannot act on is a prompt that
         buys the user nothing, so this line and the capture backend land
         together.

         *Dangerous*, so this only makes it requestable —
         `platform::android::ensure_permission` does the runtime ask, from the
         capture thread, and a denial becomes `AudioInput::error` rather than a
         dead meter. Playback needs nothing: RECORD_AUDIO gates capture only,
         which is why the soundscape has always worked without it.

         Note the type below is DATA_SYNC and **not** MICROPHONE: voice still runs
         only while the app is on screen, and the capture stops with the panel
         that opened it. Backgrounded, the connection stays up and the microphone
         does not. -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <!-- The camera, for video in calls (`platform::camera`, Camera2 through the
         NDK). Dangerous, so asked for at runtime from the camera thread, like
         the microphone above; a denial is `Camera::error`. -->
    <uses-permission android:name="android.permission.CAMERA" />

    <!-- The fingerprint that approves a release (`ReleaseKey.java`,
         docs/mockups/release-approval). Normal, granted at install; the
         Keystore key itself refuses to sign without a strong biometric. -->
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />

    <!-- The background connection (`ConnectionService`, `systems::background`).
         FOREGROUND_SERVICE is normal, granted at install. The typed permission
         is required from API 34 and must match the service's
         `foregroundServiceType` exactly, or `startForeground` throws
         SecurityException at the moment the user first switches the feature on.

         **DATA_SYNC and not LOCATION**, deliberately, even though LOCATION is the
         type without a runtime cap. A foreground-service type is a declaration of
         what the service *does*, and this one holds a socket open; claiming
         LOCATION for it would be false today and is the kind of claim that gets
         an app pulled. When the avatar-tracking work lands and the service really
         does read the device's position in the background, LOCATION becomes the
         honest type and this line changes with it.

         The cap that buys: apps *targeting* Android 15 get ~6 h of DATA_SYNC per
         24 h. targetSdkVersion here is 34, so it does not apply yet — but it will
         the day that number moves, and the answer then is the tracking work, not
         a quieter type. -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <!-- Sharing the screen in a call: the typed permission for ScreenService.
         Normal, granted at install; the screen itself is asked for each time,
         in the system's dialog. -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />

    <!-- The ongoing notification the service is obliged to show. *Dangerous* from
         API 33, so it is a runtime ask like RECORD_AUDIO — and unlike RECORD_AUDIO
         a refusal is not fatal: the service still runs, Android just does not
         display its notification. `background::apply` asks before starting, and
         carries on either way. -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- An external GNSS receiver on the USB-C port (UsbSerial.java,
         docs/notes/rtk-receiver.md). Advisory: a phone without USB host mode
         still installs, and the receiver setting says it found nothing. No
         permission entry — USB access is asked per device, at runtime. -->
    <uses-feature android:name="android.hardware.usb.host" android:required="false" />

    <!-- Advisory, as with the GNSS and camera entries: a device with no
         microphone still installs and simply cannot transmit. -->
    <uses-feature android:name="android.hardware.microphone" android:required="false" />

    <!-- The app updating itself from cartopolis.org/apk/ (Updater.java). The
         permission only makes the request possible: the person still allows
         "install unknown apps" for Cartopolis once, in the system's own dialog,
         and confirms the first update. -->
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

    <!-- From API 30 an app sees only the packages it declares an interest in:
         without this, Push.java would find no distributor even with one installed. -->
    <queries>
        <intent>
            <action android:name="org.unifiedpush.android.distributor.REGISTER" />
        </intent>
    </queries>

    <application
        android:label="Cartopolis"
        android:icon="@mipmap/icon"
        android:hasCode="true"
        android:extractNativeLibs="true"
        android:allowBackup="false">

        <!-- Every entry in `configChanges` below is a configuration change that
             would otherwise destroy and recreate the activity — which for a
             NativeActivity means tearing the process's window down and running
             `android_main` again, i.e. the app restarting when you rotate the phone
             or the system flips to dark mode. Handling them ourselves hands winit a
             resize instead. -->
        <!-- `android:theme` below is ours, not the stock fullscreen theme it used
             to be — and the difference is the first thing anyone installing this
             sees. A NativeActivity paints nothing until the surface exists and
             Bevy has started, so the theme's `windowBackground` *is* the app for
             the first several seconds. See res/values/styles.xml.

             The comment lives here, above the tag, and not among the attributes
             where it was first written: a comment is a node, and a node cannot
             sit inside another element's attribute list. XML has no diagnostic
             kinder than "not well-formed" for it. -->
        <activity
            android:name="eu.garage44.cartopolis.MainActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:screenOrientation="user"
            android:theme="@style/Theme.Cartopolis"
            android:resizeableActivity="true"
            android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|navigation|density|uiMode|locale|fontScale">

            <meta-data
                android:name="android.app.lib_name"
                android:value="cartopolis_android" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <!-- Links to a place (`systems::place_link`, docs/notes/place-links.md).
                 Two filters and not one, because they are verified differently and
                 fail differently.

                 **The https one is an App Link.** `autoVerify` makes Android fetch
                 https://cartopolis.org/.well-known/assetlinks.json at install time
                 and check that it names this package *and this signing
                 certificate*; only then does a tap open the app directly, with no
                 disambiguation dialog. Two consequences worth knowing before
                 debugging it: a locally built APK is signed with the per-machine
                 debug keystore, so verification fails there by design and only the
                 `cartopolis:` filter below works; and the check is done at install
                 time, so publishing the JSON *after* installing the app does not
                 retroactively fix a phone (`pm verify-app-links`, with its
                 re-verify flag, does — spelled without the leading hyphens for
                 the reason the version comment at the top of this file gives:
                 a double hyphen is illegal *inside* an XML comment).

                 **The path is `/go` and not `/`.** A filter matches scheme, host
                 and path, and never the query — so `?place=` cannot be what
                 selects the app. Claiming the whole host would send every
                 cartopolis.org link here including `/apk/`, the page whose entire
                 job is to hand you this APK in a browser.

                 **The `cartopolis:` filter carries no `autoVerify` and no host
                 constraint**, because a custom scheme is not verifiable: it is the
                 fallback for a sideloaded build, and it is what the web page's
                 "Open in the app" button navigates to. A second app registering
                 the same scheme would get a chooser dialog, which is the worst
                 case and is why nothing depends on it alone.

                 BROWSABLE is what makes either reachable from a link at all, and
                 DEFAULT is what makes an implicit intent match. -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- `path`, an *exact* match, and not `pathPrefix="/go"` — which
                     would claim `/gophers` — nor `/go/`, which would claim a URL
                     the web client cannot serve: the page resolves Bevy's asset
                     root relatively, so at `/go/anything` every `assets/…` fetch
                     would go to `/go/assets/…` and 404. Caddy's site block matches
                     exactly this one path (`@place path /go`, reproduced in
                     docs/notes/place-links.md); the two have to agree, or a link
                     opens the app on a phone and breaks in a browser. -->
                <data android:scheme="https" android:host="cartopolis.org"
                      android:path="/go" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="cartopolis" />
            </intent-filter>
        </activity>

        <!-- The background connection. `exported="false"`: nothing outside this
             app may start it, and nothing needs to — Rust starts it by explicit
             Intent from `platform::android::set_background_service`.

             `foregroundServiceType` must match the typed permission declared
             above; from API 34 the value passed to `startForeground` has to be in
             this set too, so the three are one fact written in three places and
             they move together. -->
        <service
            android:name=".ConnectionService"
            android:exported="false"
            android:foregroundServiceType="dataSync" />

        <!-- Sharing the screen in a call (ScreenService.java, ScreenCapture.java):
             since API 34 a MediaProjection may only be made while a foreground
             service of this type runs. Started only after the person said yes in
             the system's own dialog, and stopped with the sharing. -->
        <service
            android:name=".ScreenService"
            android:exported="false"
            android:foregroundServiceType="mediaProjection" />

        <!-- UnifiedPush (Push.java, PushReceiver.java): the distributor app tells us
             our endpoint and wakes us for a call while the app is closed. Exported,
             because the distributor is another app; PushReceiver ignores anything
             that does not carry our registration token. -->
        <receiver
            android:name=".PushReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="org.unifiedpush.android.connector.MESSAGE" />
                <action android:name="org.unifiedpush.android.connector.NEW_ENDPOINT" />
                <action android:name="org.unifiedpush.android.connector.UNREGISTERED" />
                <action android:name="org.unifiedpush.android.connector.REGISTRATION_FAILED" />
            </intent-filter>
        </receiver>

        <!-- The package installer's answer to a self-update (UpdateReceiver.java),
             and the system's word that it went in. Not exported: only the
             installer, through our own PendingIntent, and the system reach it. -->
        <receiver
            android:name=".UpdateReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>
    </application>
</manifest>