a2664955622/omp-cef-android
Android client-side implementation of the omp-cef protocol: KCP transport, X25519 handshake, signed resource cache, and WebView-backed overlay/World2D browsers. Extracted from SA-MP Mobile for open.mp & SA-MP Android clients. Not Chromium — no CEF binary required.
README.md
omp-cef-android
Android client-side implementation of the omp-cef protocol, extracted from SA-MP Mobile so it can be reused by other open.mp / SA-MP Android clients.
Server-driven HTML pages rendered over the game: overlay browsers, world-anchored pages, a two-way JS bridge, and a transport that survives hostile networks.
Not Chromium. There is no CEF binary here and nothing to download. On Android the page surface is the system
WebView; this project implements the protocol, crypto, resource cache and the glue that makes aWebViewbehave like the desktop client's browser layer.
Features
- Wire-compatible with omp-cef 1.3.0.0 — same packet types, same event names,
same
window.cefsurface. A stock omp-cef server plugin talks to it unchanged. - Own transport — plaintext UDP handshake (X25519 + BLAKE2b), then KCP with
per-message
secretboxencryption. - Resource pipeline — signed manifest, hash-checked file cache, chunked
download with resume, packed
.paksupport, and ahttp://cef/...virtual host served straight from disk. - Overlay2D and World2D browsers — world-anchored pages are re-projected every frame with the same math the desktop client uses.
- Input arbitration — a focused page takes keys and Back before the game does, and suppresses the in-game chat.
- Six of eight native translation units are engine-independent and build as a standalone static library (see below).
Layout
native/Cef/ C++ layer, drops into app/src/main/cpp/SAMPMOBILE/Cef/
├── CefProtocol.{h,cpp} wire format, packet/event enums, serialization
├── CefCrypto.{h,cpp} X25519, BLAKE2b, secretbox, AES helpers
├── CefJson.{h,cpp} minimal JSON for the JS bridge
├── CefPak.{h,cpp} packed resource archive reader
├── CefNetwork.{h,cpp} UDP + KCP transport, handshake state machine
├── CefResources.{h,cpp} manifest, cache, chunked download
├── CefSession.{h,cpp} game-thread supervision, endpoint derivation [host-coupled]
├── CefBrowser.{h,cpp} browser layer, JS bridge, World2D/3D tick [host-coupled]
├── CefWorldMath.h projection helpers
└── thirdparty/ KCP, TweetNaCl, tiny-AES-c, BLAKE2, PicoSHA2
android/ui/cef/ Java layer, drops into .../game/ui/cef/
├── CefManager.java browser registry, lifecycle, main-thread marshalling
├── CefWebView.java the WebView itself
├── CefResourceProvider.java serves http://cef/... from the cache
├── CefJs.java JS injection / evaluation
├── CefJsBridge.java window.cef.emit → native
├── CefKeys.java key name mapping
├── CefLogic.java page-side logic helpers
└── CefOverlayView.java overlay container
tests/cef/ known-answer tests, fake server, device regression
cmake/CMakeLists.txt standalone build of the engine-independent half
scripts/ one-shot installer for a samp-mobile checkout
docs/INTEGRATION.md exact hook points, thread by thread
docs/ARCHITECTURE.md data flow and threading model
Requirements
| Component | Version | Notes |
|---|---|---|
| JDK | 17 – 21 (21 recommended) | Gradle 8.13 rejects JDK 25+ (Unsupported class file major version 69) |
| Android SDK | compileSdk 35 / targetSdk 35 / minSdk 24 | Platform 35 + Build-Tools 35 |
| Android NDK | 25.1.8937393 | pinned by the host project |
| CMake | 3.22.1 | installable from the SDK Manager |
| Python 3 | 3.10+ | host-side tooling |
No CEF SDK, no Chromium source, no extra native dependency beyond z and log.
Complete build
End to end, from a clean machine to an installable APK. The host project is
XiaoNiaoa/samp-mobile; this layer
supplies the CEF half.
0. Toolchain
# Android SDK platform 35 + build-tools 35, NDK 25.1.8937393, CMake 3.22.1
# (Android Studio SDK Manager, or sdkmanager on the command line)
export ANDROID_SDK_ROOT="$HOME/Android/Sdk"
export ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/25.1.8937393"
export JAVA_HOME="/path/to/jdk-21"
1. Clone the host client
git clone https://github.com/XiaoNiaoa/samp-mobile.git
cd samp-mobile
cp local.properties.example local.properties
Then set sdk.dir in local.properties:
# Windows
sdk.dir=C\:\\Users\\<You>\\AppData\\Local\\Android\\Sdk
# macOS / Linux
sdk.dir=/home/<you>/Android/Sdk
2. Extract the GTA:SA v2.10 runtime files
The client links against libGTASA.so extracted from your own legally owned
GTA: San Andreas v2.10 Android copy. Nothing proprietary is redistributed here.
# GTA:SA v2.10 already installed on a connected phone
python3 tools/engine/prepare_gtasa.py --from-adb
# or from APK files placed in dist/
python3 tools/engine/prepare_gtasa.py --apk dist/gtasa_2.10_arm64.apk
# 32-bit + 64-bit split packages
python3 tools/engine/prepare_gtasa.py --apk dist/gtasa_2.10_arm32.apk dist/gtasa_2.10_arm64.apk
Run this once, not once per APK.
3. Install this CEF layer
cd .. # next to the samp-mobile checkout
git clone https://github.com/a2664955622/omp-cef-android.git
cd samp-mobile
bash ../omp-cef-android/scripts/install-into-samp-mobile.sh . --force
The script copies the three trees into place and warns if the host CMake does
not glob Cef/*.cpp. It does not edit host source — the six native hook
calls and the Java wiring are a handful of lines and are listed exactly in
docs/INTEGRATION.md (§2 CMake, §3 native, §4 Java).
Apply them before building.
4. Build the APK
# Windows (PowerShell) — point JAVA_HOME at JDK 17–21 if your default is 25+
# $env:JAVA_HOME = "C:\Path\To\jdk-21"
.\gradlew.bat assembleDebug
:: Windows (CMD)
set JAVA_HOME=C:\Path\To\jdk-21
gradlew.bat assembleDebug
# macOS / Linux
export JAVA_HOME=/path/to/jdk-21
./gradlew assembleDebug
Output: app/build/outputs/apk/debug/samp.apk.
Useful flags:
# C++-only compile check, without extracted GTA files
./gradlew assembleDebug -PskipGtasaCheck=true
# release build (configure SAMP_STORE_FILE / SAMP_STORE_PASSWORD /
# SAMP_KEY_ALIAS / SAMP_KEY_PASSWORD in local.properties first)
./gradlew assembleRelease
5. Install on a device
adb install -r app/build/outputs/apk/debug/samp.apk
adb shell am start -n com.sampmobile.launcher/.ui.MainActivity
6. Verify
# host project checks: APK structure, JNI exports, alignment, signature
python3 tests/check.py --require-apk
# CEF layer: known-answer tests + fake server + device regression
bash tests/cef/verify_all.sh
Build the protocol core standalone
The engine-independent half compiles without any game code — useful when porting, and the fastest way to confirm the extracted sources are intact:
cmake -S cmake -B build-core -G Ninja \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-24
cmake --build build-core -j
Produces libcef_core.a from CefProtocol, CefCrypto, CefJson, CefPak,
CefNetwork, CefResources and the vendored C sources. Expect 11 build steps.
Protocol
| Item | Value |
|---|---|
| omp-cef version | 1.3.0.0 (0x01030000) |
| Transport | UDP handshake → KCP (nodelay 1,10,2,1, window 128/128, 10 ms) |
| Key exchange | X25519 + BLAKE2b (crypto_kx_client_session_keys) |
| Payload crypto | crypto_secretbox_easy per KCP message |
| Endpoint | <server host>:<game port + 2> |
| Byte order | little-endian, written field by field |
See docs/ARCHITECTURE.md for the full packet and event
tables.
Limits
wKeyson the wire is 16-bit; only logical SA-MP keys reach the server, so letter/function keys work locally only.- World2D pages draw on top of world geometry — occlusion is not modelled, same as the desktop 2D overlay pass.
- WorldObject3D needs a texture-upload path in the host renderer; without it,
implement
TickWorldObject3Das a no-op and stay protocol-compatible. - Audio and HUD events are logged as unsupported rather than faked.
- R8 must keep
com.sampmobile.game.ui.cef.**— native code calls those methods by name.
License
GPL-3.0 (see LICENSE). Upstream attributions, the omp-cef protocol
reference and the vendored third-party licenses are in NOTICE.
androidcefcppgta-sajnikcpomp-cefopenmpsampsan-andreaswebview
Esta página se genera con lo que GitHub publica sobre el repositorio. samp.directory no aloja el código. Informar de un problema con esta ficha