Skip to content

Agent Mesh

mobile: ship only ABIs that carry libsam.so, drop the testnet default

Antonio Ojeafbc0fda20ebd
diff --git a/Makefile b/Makefile
index 60f935ba..d6c27b18 100644
--- a/Makefile
+++ b/Makefile
@@ -91,32 +91,38 @@ mobile-app-google-services:
fi; \
fi
-.PHONY: mobile-app-jnilibs-arm64
+.PHONY: mobile-app-jnilibs-arm64 mobile-app-jnilibs-x86_64
mobile-app-jnilibs-arm64: mobile-ffi-android
mkdir -p $(MOBILE_APP_DIR)/android/app/src/main/jniLibs/arm64-v8a
cp "$(OUT_DIR)/android/libsam.so" $(MOBILE_APP_DIR)/android/app/src/main/jniLibs/arm64-v8a/libsam.so
-mobile-app-apk: mobile-app-jnilibs-arm64 mobile-app-google-services
- cd $(MOBILE_APP_DIR) && flutter build apk --release $(MOBILE_FLUTTER_BUILD_FLAGS)
-
-mobile-app-apk-emulator: mobile-ffi-android-x86_64 mobile-app-google-services
+mobile-app-jnilibs-x86_64: mobile-ffi-android-x86_64
mkdir -p $(MOBILE_APP_DIR)/android/app/src/main/jniLibs/x86_64
cp "$(OUT_DIR)/android-x86_64/libsam.so" $(MOBILE_APP_DIR)/android/app/src/main/jniLibs/x86_64/libsam.so
+
+mobile-app-apk: mobile-app-jnilibs-arm64 mobile-app-jnilibs-x86_64 mobile-app-google-services
+ cd $(MOBILE_APP_DIR) && flutter build apk --release --target-platform android-arm64,android-x64 $(MOBILE_FLUTTER_BUILD_FLAGS)
+
+mobile-app-apk-emulator: mobile-app-jnilibs-x86_64 mobile-app-google-services
cd $(MOBILE_APP_DIR) && flutter build apk --release $(MOBILE_FLUTTER_BUILD_FLAGS)
# Android App Bundle for Google Play. Play rejects debug-signed bundles, so an
# upload key is required: either $(MOBILE_APP_DIR)/android/key.properties or
# the ANDROID_KEYSTORE_PATH / ANDROID_KEYSTORE_PASSWORD / ANDROID_KEY_ALIAS /
# ANDROID_KEY_PASSWORD environment variables (see mobile/sam-node-app/README.md).
+#
+# Play serves each device the split for its own ABI, so the bundle must only
+# contain ABIs that have a libsam.so: Flutter's default set also includes
+# armeabi-v7a, which would install and then die opening the FFI library.
.PHONY: mobile-app-bundle
-mobile-app-bundle: mobile-app-jnilibs-arm64 mobile-app-google-services
+mobile-app-bundle: mobile-app-jnilibs-arm64 mobile-app-jnilibs-x86_64 mobile-app-google-services
@if [ ! -f $(MOBILE_APP_DIR)/android/key.properties ] && \
{ [ -z "$$ANDROID_KEYSTORE_PATH" ] || [ -z "$$ANDROID_KEYSTORE_PASSWORD" ] || [ -z "$$ANDROID_KEY_ALIAS" ] || [ -z "$$ANDROID_KEY_PASSWORD" ]; }; then \
echo "Error: no upload key configured; Google Play rejects debug-signed bundles." >&2; \
echo "Create $(MOBILE_APP_DIR)/android/key.properties or export ANDROID_KEYSTORE_PATH, ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS and ANDROID_KEY_PASSWORD. See $(MOBILE_APP_DIR)/README.md#publishing-to-google-play." >&2; \
exit 1; \
fi
- cd $(MOBILE_APP_DIR) && flutter build appbundle --release $(MOBILE_FLUTTER_BUILD_FLAGS)
+ cd $(MOBILE_APP_DIR) && flutter build appbundle --release --target-platform android-arm64,android-x64 $(MOBILE_FLUTTER_BUILD_FLAGS)
@echo "Bundle: $(MOBILE_APP_DIR)/build/app/outputs/bundle/release/app-release.aab"
.PHONY: proto
diff --git a/mobile/sam-node-app/android/app/build.gradle.kts b/mobile/sam-node-app/android/app/build.gradle.kts
index ca0eac58..d578237c 100644
--- a/mobile/sam-node-app/android/app/build.gradle.kts
+++ b/mobile/sam-node-app/android/app/build.gradle.kts
@@ -43,6 +43,16 @@ android {
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
+ // Only ABIs that have a libsam.so (see the Makefile jnilibs targets)
+ // may be packaged. Plugin AARs (ML Kit, JNA, CameraX) ship
+ // armeabi-v7a natives too; without this filter Play lists that ABI
+ // as supported and serves the app to 32-bit devices, where it dies
+ // opening the FFI library. Requires disable-abi-filtering=true in
+ // gradle.properties, or the Flutter plugin overrides the list.
+ ndk {
+ abiFilters.clear()
+ abiFilters.addAll(listOf("arm64-v8a", "x86_64"))
+ }
}
buildTypes {
diff --git a/mobile/sam-node-app/android/app/src/main/AndroidManifest.xml b/mobile/sam-node-app/android/app/src/main/AndroidManifest.xml
index d3caae75..5d328a8a 100644
--- a/mobile/sam-node-app/android/app/src/main/AndroidManifest.xml
+++ b/mobile/sam-node-app/android/app/src/main/AndroidManifest.xml
@@ -37,6 +37,12 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
+ <!-- sam://enroll links are handled by MainActivity's enroll_link
+ channel; without this the engine also pushes them as a
+ Navigator route, which MaterialApp has no page for. -->
+ <meta-data
+ android:name="flutter_deeplinking_enabled"
+ android:value="false" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
diff --git a/mobile/sam-node-app/android/gradle.properties b/mobile/sam-node-app/android/gradle.properties
index e96108cf..6f0b4a56 100644
--- a/mobile/sam-node-app/android/gradle.properties
+++ b/mobile/sam-node-app/android/gradle.properties
@@ -4,3 +4,7 @@ android.useAndroidX=true
android.newDsl=false
# This builtInKotlin flag was added by the Flutter template
android.builtInKotlin=false
+# The Flutter Gradle plugin otherwise resets ndk.abiFilters to its default
+# arm/arm64/x64 set; app/build.gradle.kts owns the list (only ABIs with a
+# libsam.so).
+disable-abi-filtering=true
diff --git a/mobile/sam-node-app/lib/main.dart b/mobile/sam-node-app/lib/main.dart
index cd649dd8..4a7a7113 100644
--- a/mobile/sam-node-app/lib/main.dart
+++ b/mobile/sam-node-app/lib/main.dart
@@ -99,8 +99,10 @@ class NodeControlPage extends StatefulWidget {
}
class _NodeControlPageState extends State<NodeControlPage> {
- final _controlPlaneController =
- TextEditingController(text: 'https://bananas.sam-mesh.dev');
+ // No default: a pre-filled public testnet would let a mistap enroll the
+ // device somewhere the user never chose. The QR code, a pasted link or
+ // the user fills it in.
+ final _controlPlaneController = TextEditingController();
final _jwtController = TextEditingController();
// Saved by the FFI at enrollment so Re-enroll can skip the browser.
String _refreshToken = '';
@@ -314,6 +316,20 @@ class _NodeControlPageState extends State<NodeControlPage> {
return base64UrlEncode(values).replaceAll('=', '');
}
+ // The OIDC paths need a control plane to ask for the issuer; there is no
+ // default one.
+ bool _requireControlPlaneUrl() {
+ final server = _controlPlaneController.text.trim();
+ if (isTrustedControlPlaneUrl(server)) return true;
+ setState(() {
+ _manualEntry = true;
+ _status = server.isEmpty
+ ? 'Enter the control plane URL first'
+ : 'Control plane URL must be https:// (plain http only for localhost)';
+ });
+ return false;
+ }
+
String _generateCodeChallenge(String verifier) {
final bytes = utf8.encode(verifier);
final digest = sha256.convert(bytes);
@@ -322,6 +338,7 @@ class _NodeControlPageState extends State<NodeControlPage> {
Future<void> _loginAndEnroll() async {
debugPrint('DEBUG: _loginAndEnroll started');
+ if (!_requireControlPlaneUrl()) return;
setState(() {
_loggingIn = true;
_status = 'Fetching control plane info...';
@@ -530,6 +547,7 @@ class _NodeControlPageState extends State<NodeControlPage> {
}
Future<void> _startDeviceLogin() async {
+ if (!_requireControlPlaneUrl()) return;
setState(() {
_loggingIn = true;
_status = 'Fetching control plane info for device login...';
@@ -1581,7 +1599,7 @@ class _NodeControlPageState extends State<NodeControlPage> {
decoration: const InputDecoration(
labelText: 'Control plane URL',
border: OutlineInputBorder(),
- hintText: 'https://bananas.sam-mesh.dev',
+ hintText: 'https://mesh.example.com',
),
),
const SizedBox(height: 12),