Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on:
push:
branches:
- master
pull_request:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
python-tests:
name: Python tests
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip

- name: Install dependencies
run: python -m pip install -r requirements.txt

- name: Run unit tests
run: python -m unittest discover -s tests -v

frontend-build:
name: Frontend build
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

- name: Build frontend
run: npm run build-frontend

android-build:
name: Android companion
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"

- name: Install Android SDK packages
run: sdkmanager "platforms;android-29" "build-tools;35.0.1"

- name: Build Android APK
run: ./android/build-apk.sh

- name: Upload Android APK
uses: actions/upload-artifact@v4
with:
name: crosstalk-android-debug
path: android/build/Crosstalk-Android.apk
if-no-files-found: error
retention-days: 7
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ __pycache__/
/dist/
/public/
/electron/build/exe/
/android/build/

# local storage
storage/
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ Other supported setups:

- [Docker](./docs/crosstalk_on_docker.md)
- [Raspberry Pi](./docs/crosstalk_on_raspberry_pi.md)
- [Android with Termux](./docs/crosstalk_on_android_with_termux.md)
- [Android companion + Termux](./android/README.md)
- [Android with Termux (manual browser setup)](./docs/crosstalk_on_android_with_termux.md)

To run from source, install Python 3 and Node.js 22.12 or newer, then:

Expand All @@ -87,6 +88,7 @@ Open <http://localhost:8000>. Run `python3 crosstalk.py --help` for server, iden
python3 -m pip install -r requirements.txt
npm install
npm run build-frontend
python3 -m unittest discover -s tests -v
python3 crosstalk.py --headless
```

Expand Down
34 changes: 34 additions & 0 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.buildwithparallel.crosstalk"
android:versionCode="1"
android:versionName="0.1.0">

<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="29" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />

<application
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_crosstalk"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".CrosstalkActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
61 changes: 61 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Crosstalk for Android

The Android companion provides a native, OLED-friendly shell for a Crosstalk
backend running locally in Termux. The WebView is restricted to
`http://localhost:8000`; normal HTTP links leave the app and cleartext traffic
to non-local hosts is blocked by Android's network security policy.

The Python/Reticulum backend remains in Termux instead of being duplicated in
the APK. This keeps one identity and database, preserves the normal interface
configuration, and avoids shipping a second Python runtime.

## Install the Termux backend

Follow [Crosstalk on Android](../docs/crosstalk_on_android_with_termux.md), then
install the fixed controller command:

```sh
install -m 700 android/termux/crosstalk-android-server \
"$PREFIX/bin/crosstalk-android-server"
```

The controller searches `$HOME/apps/crosstalk` and `$HOME/crosstalk`. Set
`CROSSTALK_HOME` before launching it when the checkout lives elsewhere. It
stores identity and application data under `$HOME/.local/share/crosstalk` by
default and binds the UI/API only to loopback.

To let the Android companion invoke this one fixed controller, add the
following to `~/.termux/termux.properties` and restart Termux:

```properties
allow-external-apps=true
```

Android will still require the user to grant Crosstalk the Termux
`RUN_COMMAND` permission. The app cannot execute arbitrary commands: it calls
only `$PREFIX/bin/crosstalk-android-server start`.

## Build the APK

The build has no Gradle or third-party Android dependencies. It requires JDK 8+
and Android SDK platform 29 with build-tools 35.0.1:

```sh
./android/build-apk.sh
adb install -r android/build/Crosstalk-Android.apk
```

The generated APK is debug-signed for development. Published releases should
use a project-owned signing key and verify the APK digest before installation.

## Privacy boundary

- The backend listens on `127.0.0.1:8000`, not Wi-Fi or a public interface.
- The WebView accepts navigation only within the local Crosstalk origin.
- External HTTP(S) links open in the user's normal browser.
- File access is disabled inside the WebView; attachments use Android's system
document picker.
- Microphone access is requested only when the local Crosstalk origin asks for
audio capture.
- Android backups are disabled for the companion. Reticulum identity material
remains in Termux storage and is never copied into the APK.
41 changes: 41 additions & 0 deletions android/build-apk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
set -eu

project_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
sdk_dir=${ANDROID_SDK_ROOT:-"$HOME/Library/Android/sdk"}
platform=${ANDROID_PLATFORM:-android-29}
build_tools_version=${ANDROID_BUILD_TOOLS:-35.0.1}
android_jar="$sdk_dir/platforms/$platform/android.jar"
build_tools="$sdk_dir/build-tools/$build_tools_version"
output_apk=${OUTPUT_APK:-"$project_dir/build/Crosstalk-Android.apk"}
keystore=${ANDROID_DEBUG_KEYSTORE:-"$HOME/.android/debug.keystore"}
work_dir=$(mktemp -d)
trap 'rm -rf "$work_dir"' EXIT HUP INT TERM

[ -r "$android_jar" ] || { printf 'Missing %s\n' "$android_jar" >&2; exit 1; }
for tool in aapt2 d8 zipalign apksigner; do
[ -x "$build_tools/$tool" ] || { printf 'Missing build tool: %s\n' "$build_tools/$tool" >&2; exit 1; }
done

mkdir -p "$work_dir/classes" "$work_dir/dex" "$work_dir/generated" "$(dirname -- "$output_apk")"
"$build_tools/aapt2" compile --dir "$project_dir/res" -o "$work_dir/resources.zip"
"$build_tools/aapt2" link -o "$work_dir/unsigned.apk" -I "$android_jar" \
--manifest "$project_dir/AndroidManifest.xml" --min-sdk-version 26 --target-sdk-version 29 \
--auto-add-overlay -R "$work_dir/resources.zip" --java "$work_dir/generated"
find "$project_dir/src" "$work_dir/generated" -name '*.java' -print0 | \
xargs -0 javac --release 8 -classpath "$android_jar" -d "$work_dir/classes"
"$build_tools/d8" --lib "$android_jar" --min-api 26 --output "$work_dir/dex" \
$(find "$work_dir/classes" -name '*.class' -print)
zip -q -j "$work_dir/unsigned.apk" "$work_dir/dex/classes.dex"
"$build_tools/zipalign" -f 4 "$work_dir/unsigned.apk" "$work_dir/aligned.apk"

if [ ! -r "$keystore" ]; then
mkdir -p "$(dirname -- "$keystore")"
keytool -genkeypair -keystore "$keystore" -storepass android -keypass android \
-alias androiddebugkey -dname "CN=Android Debug,O=Android,C=US" \
-keyalg RSA -keysize 2048 -validity 10000 >/dev/null 2>&1
fi
"$build_tools/apksigner" sign --ks "$keystore" --ks-pass pass:android --key-pass pass:android \
--out "$output_apk" "$work_dir/aligned.apk"
"$build_tools/apksigner" verify --verbose "$output_apk"
printf '%s\n' "$output_apk"
11 changes: 11 additions & 0 deletions android/res/drawable/ic_crosstalk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path android:fillColor="#090D16" android:pathData="M8,4h32a4,4 0,0 1,4 4v32a4,4 0,0 1,-4 4h-32a4,4 0,0 1,-4 -4v-32a4,4 0,0 1,4 -4z" />
<path android:fillColor="#00000000" android:strokeColor="#2F7FFF" android:strokeWidth="2.2" android:strokeLineJoin="round" android:pathData="M14,12h20a4,4 0,0 1,4 4v13a4,4 0,0 1,-4 4h-9l-6,5v-5h-5a4,4 0,0 1,-4 -4v-13a4,4 0,0 1,4 -4z" />
<path android:fillColor="#00000000" android:strokeColor="#6EA8FF" android:strokeWidth="1.4" android:pathData="M17,22L24,17L31,21L23,28L17,22M24,17L23,28L32,28" />
<path android:fillColor="#6EA8FF" android:pathData="M24,15a2,2 0,1 0,0 4a2,2 0,1 0,0 -4M17,20a2,2 0,1 0,0 4a2,2 0,1 0,0 -4M31,19a2,2 0,1 0,0 4a2,2 0,1 0,0 -4M23,26a2,2 0,1 0,0 4a2,2 0,1 0,0 -4M32,26a2,2 0,1 0,0 4a2,2 0,1 0,0 -4" />
</vector>
4 changes: 4 additions & 0 deletions android/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Crosstalk</string>
</resources>
13 changes: 13 additions & 0 deletions android/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:style/Theme.Material.NoActionBar">
<item name="android:fontFamily">sans</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowBackground">#000000</item>
<item name="android:colorAccent">#2F7FFF</item>
<item name="android:navigationBarColor">#000000</item>
<item name="android:statusBarColor">#000000</item>
<item name="android:windowLightNavigationBar">false</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>
7 changes: 7 additions & 0 deletions android/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="false" />
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">localhost</domain>
</domain-config>
</network-security-config>
Loading