Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
6461120
docs: add rewrite architecture records
xz-dev Jun 22, 2026
9527287
chore: add rewrite agent guardrails
xz-dev Jun 22, 2026
ae0d72c
feat(app): add Flutter shell scaffold
xz-dev Jun 22, 2026
4756f7c
feat(getter): wire package-centric getter submodule
xz-dev Jun 22, 2026
a5730a9
ci: add rewrite validation workflow
xz-dev Jun 22, 2026
59c1a0d
fix(getter): keep Android proxy off Lua deps
xz-dev Jun 22, 2026
3201d92
fix(app): use Flutter-compatible Gradle wrapper
xz-dev Jun 22, 2026
35e6c3d
ci: restrict Telegram notifications to master pushes
xz-dev Jun 22, 2026
80e1eb6
fix(app): use Flutter-compatible AGP
xz-dev Jun 22, 2026
384aee6
docs: add rewrite next-step audit plan
xz-dev Jun 22, 2026
a1c43f4
fix(app): use Flutter-compatible Kotlin plugin
xz-dev Jun 22, 2026
c6838b5
docs: update rewrite next-step completion status
xz-dev Jun 22, 2026
76f771a
feat(app): add getter bridge contract
xz-dev Jun 22, 2026
47f5811
feat(getter): add offline repo validation
xz-dev Jun 22, 2026
0976844
feat(getter): import legacy Room databases
xz-dev Jun 22, 2026
81a5dec
feat(getter): add installed app autogen
xz-dev Jun 22, 2026
8f3ca13
feat(getter): add offline update check
xz-dev Jun 22, 2026
9bb18f2
feat(getter): add offline task lifecycle
xz-dev Jun 23, 2026
1ba7614
feat(app): render getter task DTOs
xz-dev Jun 23, 2026
aed83cb
ci(app): publish Flutter APK artifacts
xz-dev Jun 23, 2026
2e22767
feat(app): add legacy Room migration adapter
xz-dev Jun 23, 2026
39af4c7
feat(app): add Android platform adapter spine
xz-dev Jun 23, 2026
3a5a602
feat(app): add Android installed inventory provider
xz-dev Jun 23, 2026
dd94154
feat(app): bridge installed autogen to Flutter
xz-dev Jun 23, 2026
8a6ac21
feat(app): bridge legacy room import
xz-dev Jun 24, 2026
044ca72
ci: set Android ar for cargo checks
xz-dev Jun 24, 2026
65df6ab
test(app): cover legacy room preparation
xz-dev Jun 24, 2026
c0f6752
test(app): validate native bridge on device
xz-dev Jun 24, 2026
d392b5c
docs(architecture): accept runtime task ADRs
xz-dev Jun 25, 2026
dba34ec
feat(app): bridge runtime task operations
xz-dev Jun 25, 2026
108625a
feat(app): stream runtime notifications
xz-dev Jun 25, 2026
2b98939
docs(todo): update runtime bridge progress
xz-dev Jun 25, 2026
ced8576
feat(app): issue runtime actions from update checks
xz-dev Jun 25, 2026
5061d20
docs(todo): note offline action issuance
xz-dev Jun 25, 2026
71c71c9
docs(lua): document static update candidates
xz-dev Jun 25, 2026
75b9f65
feat(app): issue actions from registered packages
xz-dev Jun 25, 2026
2aad93f
docs(todo): note registered package action issuance
xz-dev Jun 25, 2026
7ebf9be
feat(app): adopt pin version DTOs
xz-dev Jun 25, 2026
c1f7126
feat(app): add typed runtime task APIs
xz-dev Jun 25, 2026
b2c03b7
chore(app): point CLI debug tasks at runtime script
xz-dev Jun 25, 2026
3897038
refactor(app): drop fake task DTOs from product adapter
xz-dev Jun 25, 2026
dd9115c
docs(lua): describe static mock provider boundary
xz-dev Jun 25, 2026
1530a42
refactor(app): drop CLI fake task adapter APIs
xz-dev Jun 25, 2026
7bcaa0b
ci: install multilib for Android LuaJIT builds
xz-dev Jun 25, 2026
4e6274a
chore(app): update Flutter toolchain baseline
xz-dev Jun 25, 2026
25af79c
feat(app): load snapshots from native getter read model
xz-dev Jun 25, 2026
1a5d822
feat(app): submit update checks to runtime
xz-dev Jun 25, 2026
239f98f
docs(architecture): define provider autogen repository model
xz-dev Jun 26, 2026
4d65323
feat(app): use ADR-0012 autogen repository defaults
xz-dev Jun 26, 2026
03cb206
feat(getter): use package directory discovery
xz-dev Jun 26, 2026
4dea731
feat(app): consume package-directory autogen previews
xz-dev Jun 26, 2026
346636f
feat(getter): evaluate package directories
xz-dev Jun 26, 2026
aa3fdbb
fix(getter): update clippy-clean gitlink
xz-dev Jun 26, 2026
a8739cc
feat(getter): expose package-local file reads
xz-dev Jun 26, 2026
1ce7701
fix(getter): hash package-local file inputs
xz-dev Jun 26, 2026
175ae4c
feat(getter): add provider cache primitives
xz-dev Jun 26, 2026
e0673f2
feat(getter): add F-Droid provider fixtures
xz-dev Jun 26, 2026
1a13cbd
feat(getter): cache F-Droid catalog fixtures
xz-dev Jun 26, 2026
728cff6
feat(getter): add F-Droid autogen CLI slice
xz-dev Jun 27, 2026
dddce32
feat(getter): match F-Droid installed inventory
xz-dev Jun 27, 2026
b35b7c4
feat(getter): add GitHub release fixtures
xz-dev Jun 27, 2026
416075e
refactor(getter): remove flat Lua repository layout
xz-dev Jun 27, 2026
80df257
feat(app): expose F-Droid autogen bridge
xz-dev Jun 27, 2026
eb1719d
feat(getter): add GitHub latest commit fixtures
xz-dev Jun 27, 2026
be6f4b3
test(getter): cover F-Droid luaclass shape
xz-dev Jun 27, 2026
526e5d4
test(getter): cover GitHub luaclass shape
xz-dev Jun 27, 2026
cb74bba
feat(getter): add Lua host binding seam
xz-dev Jun 27, 2026
2f6585e
feat(getter): add dev Lua provider host eval
xz-dev Jun 27, 2026
345ef45
feat(getter): add F-Droid dev Lua provider host eval
xz-dev Jun 27, 2026
4e06159
feat(getter): add builtin luaclass fallback
xz-dev Jun 27, 2026
b8e929a
feat(getter): add Lua HTTP host seam
xz-dev Jun 27, 2026
64e2fb4
feat(getter): add dev provider luaclass modules
xz-dev Jun 27, 2026
dd1c259
feat(getter): add Lua HTTP policy harness
xz-dev Jun 27, 2026
8942c7f
feat(getter): add runtime hook harness
xz-dev Jun 27, 2026
19f2fd9
docs(architecture): design provider host API v1
xz-dev Jun 28, 2026
016f977
feat(getter): add stable provider host harness
xz-dev Jun 28, 2026
561d0e7
feat(getter): store provider response provenance
xz-dev Jun 28, 2026
b20fb0a
feat(getter): promote standard provider luaclasses
xz-dev Jun 28, 2026
c86c894
fix(getter): validate provider endpoint ids
xz-dev Jun 28, 2026
9e2be1e
test(getter): lock fdroid generated script boundary
xz-dev Jun 28, 2026
3b70b92
docs(plan): defer fdroid generated provider adoption
xz-dev Jun 28, 2026
0bb0c77
test(getter): cover configured provider endpoints
xz-dev Jun 28, 2026
236794e
feat(getter): use provider-backed update checks
xz-dev Jun 28, 2026
e1993f2
feat(getter): use F-Droid provider module autogen output
xz-dev Jun 28, 2026
67e99a8
feat(app): add installed F-Droid autogen flow
xz-dev Jun 29, 2026
1f7773b
feat(app): refresh F-Droid catalog cache
xz-dev Jun 29, 2026
4fbb6ca
feat(getter): add GitHub standard module runtime slice
xz-dev Jul 2, 2026
a1cdee6
feat(getter): add GitHub autogen product seam
xz-dev Jul 2, 2026
31ab0f9
feat(getter): add GitHub releases live transport slice
xz-dev Jul 2, 2026
5a380f6
feat(app): add GitHub autogen product bridge
xz-dev Jul 2, 2026
1b49340
feat(app): run getter-owned download bytes
xz-dev Jul 2, 2026
ea26f3e
feat(app): load getter startup snapshot
xz-dev Jul 14, 2026
c1f79c1
docs(cli): document app inspect and check
xz-dev Jul 14, 2026
171fb8e
docs(architecture): define artifact staging and installers
xz-dev Jul 16, 2026
0cd8a4b
feat(app): guide fresh package setup
xz-dev Jul 17, 2026
2369bcc
feat(app): bridge Android APK install preparation
xz-dev Jul 17, 2026
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
Prev Previous commit
Next Next commit
feat(app): stream runtime notifications
  • Loading branch information
xz-dev committed Jun 25, 2026
commit 108625a898f4e44d71ae388d3931ae9c49d3ce32
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Handler
import android.os.Looper
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import java.io.File
Expand All @@ -16,10 +17,28 @@ class MainActivity : FlutterActivity() {
private val legacyMigrationExecutor = Executors.newSingleThreadExecutor()
private val getterBridgeExecutor = Executors.newSingleThreadExecutor()
private val mainHandler = Handler(Looper.getMainLooper())
@Volatile
private var runtimeEventSink: EventChannel.EventSink? = null
private val nativeLib by lazy { NativeLib() }

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
EventChannel(
flutterEngine.dartExecutor.binaryMessenger,
RUNTIME_NOTIFICATION_CHANNEL,
).setStreamHandler(
object : EventChannel.StreamHandler {
override fun onListen(arguments: Any?, events: EventChannel.EventSink?) {
runtimeEventSink = events
emitRuntimeNotifications()
}

override fun onCancel(arguments: Any?) {
runtimeEventSink = null
}
},
)

MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
GETTER_BRIDGE_CHANNEL,
Expand Down Expand Up @@ -48,7 +67,7 @@ class MainActivity : FlutterActivity() {
nativeLib.legacyReportList(legacyReportListRequest())
}

"runtimeOperation" -> runGetterBridge(result) {
"runtimeOperation" -> runGetterBridge(result, emitRuntimeNotifications = true) {
nativeLib.runtimeOperation(runtimeOperationRequest(call))
}

Expand Down Expand Up @@ -89,11 +108,23 @@ class MainActivity : FlutterActivity() {
super.onDestroy()
}

private fun runGetterBridge(result: MethodChannel.Result, operation: () -> String) {
private fun runGetterBridge(
result: MethodChannel.Result,
emitRuntimeNotifications: Boolean = false,
operation: () -> String,
) {
getterBridgeExecutor.execute {
try {
val response = operation()
mainHandler.post { result.success(response) }
val notifications = if (emitRuntimeNotifications) {
drainRuntimeNotificationEvents()
} else {
emptyList<String>()
}
mainHandler.post {
result.success(response)
emitRuntimeNotifications(notifications)
}
} catch (error: UnsatisfiedLinkError) {
mainHandler.post {
result.error(
Expand Down Expand Up @@ -178,6 +209,37 @@ class MainActivity : FlutterActivity() {
return GetterBridgeRequestBuilder.runtimeOperationRequest(args)
}

private fun emitRuntimeNotifications() {
getterBridgeExecutor.execute {
val notifications = drainRuntimeNotificationEvents()
mainHandler.post { emitRuntimeNotifications(notifications) }
}
}

private fun emitRuntimeNotifications(notifications: List<String>) {
val sink = runtimeEventSink ?: return
for (notification in notifications) {
sink.success(notification)
}
}

private fun drainRuntimeNotificationEvents(): List<String> {
return try {
val envelope = JSONObject(nativeLib.drainRuntimeNotifications())
if (!envelope.optBoolean("ok", false)) {
return emptyList()
}
val notifications = envelope
.getJSONObject("data")
.getJSONArray("notifications")
List(notifications.length()) { index -> notifications.getJSONObject(index).toString() }
} catch (_: UnsatisfiedLinkError) {
emptyList()
} catch (_: Exception) {
emptyList()
}
}

private fun getterDataDir(): File = File(filesDir, "getter")

private fun prepareLegacyRoomImport(): Map<String, Any?> {
Expand All @@ -192,6 +254,7 @@ class MainActivity : FlutterActivity() {

private companion object {
const val GETTER_BRIDGE_CHANNEL = "net.xzos.upgradeall/getter_bridge"
const val RUNTIME_NOTIFICATION_CHANNEL = "net.xzos.upgradeall/runtime_notifications"
const val LEGACY_MIGRATION_CHANNEL = "net.xzos.upgradeall/legacy_migration"
const val LEGACY_ROOM_DB_NAME = "app_metadata_database.db"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class NativeLib {
external fun importLegacyRoomDatabase(requestJson: String): String
external fun legacyReportList(requestJson: String): String
external fun runtimeOperation(requestJson: String): String
external fun drainRuntimeNotifications(): String

fun runServerLambda(context: Context, callback: (String) -> Unit): String {
return runServer(context, RunServerCallback(callback))
Expand Down
16 changes: 15 additions & 1 deletion app_flutter/lib/native_getter_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ class MethodChannelGetterAdapter extends FakeGetterAdapter {
MethodChannel channel = const MethodChannel(
'net.xzos.upgradeall/getter_bridge',
),
}) : _channel = channel;
EventChannel runtimeNotificationChannel = const EventChannel(
'net.xzos.upgradeall/runtime_notifications',
),
}) : _channel = channel,
_runtimeNotificationChannel = runtimeNotificationChannel;

final MethodChannel _channel;
final EventChannel _runtimeNotificationChannel;

@override
bool get supportsLegacyRoomImport => true;
Expand Down Expand Up @@ -92,6 +97,15 @@ class MethodChannelGetterAdapter extends FakeGetterAdapter {
/// This is an internal/debug bridge primitive for ADR-0011 wiring. Product UI
/// should use typed getter operations and getter-issued `action_id`s rather
/// than assembling runtime action plans in Dart.
Stream<Map<String, Object?>> runtimeNotifications() {
return _runtimeNotificationChannel.receiveBroadcastStream().map((event) {
if (event is String) {
return _asMap(jsonDecode(event), 'runtime notification');
}
return _asMap(event, 'runtime notification');
});
}

Future<Map<String, Object?>> invokeRuntimeOperation(
String operation, {
Map<String, Object?> payload = const <String, Object?>{},
Expand Down
41 changes: 41 additions & 0 deletions app_flutter/test/native_getter_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();

const channel = MethodChannel('test/getter_bridge');
const eventChannel = EventChannel('test/runtime_notifications');
const eventMethodChannel = MethodChannel('test/runtime_notifications');

tearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, null);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(eventMethodChannel, null);
});

test('native preview sends scan options and parses getter envelope',
Expand Down Expand Up @@ -163,6 +167,43 @@ void main() {
expect(reports.single.code, 'migration.imported');
});

test('runtime notification stream decodes pushed JSON events', () async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(eventMethodChannel, (call) async {
if (call.method == 'listen') {
await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
'test/runtime_notifications',
const StandardMethodCodec().encodeSuccessEnvelope(
jsonEncode(<String, Object?>{
'kind': 'task_changed',
'task': <String, Object?>{
'task_id': 'task-1',
'package_id': 'android/org.fdroid.fdroid',
'status': 'completed',
},
}),
),
(_) {},
);
}
return null;
});

const adapter = MethodChannelGetterAdapter(
channel: channel,
runtimeNotificationChannel: eventChannel,
);

final notification = await adapter.runtimeNotifications().first;

expect(notification['kind'], 'task_changed');
expect(
(notification['task'] as Map<Object?, Object?>)['task_id'],
'task-1',
);
});

test('native runtime operation forwards operation and payload', () async {
MethodCall? captured;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class NativeLib {
external fun importLegacyRoomDatabase(requestJson: String): String
external fun legacyReportList(requestJson: String): String
external fun runtimeOperation(requestJson: String): String
external fun drainRuntimeNotifications(): String

fun runServerLambda(context: Context, callback: (String) -> Unit): String {
return runServer(context, RunServerCallback(callback))
Expand Down
86 changes: 85 additions & 1 deletion core-getter/src/main/rust/api_proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use jni::objects::{JObject, JString, JValue};
use jni::JNIEnv;
use serde::Deserialize;
use serde_json::{json, Value};
use std::collections::VecDeque;
use std::path::{Path, PathBuf};
use std::sync::mpsc::channel;
use std::sync::{Mutex, OnceLock};
Expand All @@ -20,8 +21,10 @@ use upgradeall_platform_adapter::PlatformAdapter;

const MAIN_DB_FILE: &str = "main.db";
const CACHE_DB_FILE: &str = "cache.db";
const MAX_RUNTIME_NOTIFICATION_QUEUE: usize = 64;

static GETTER_RUNTIME: OnceLock<Mutex<getter::core::runtime::GetterRuntime>> = OnceLock::new();
static RUNTIME_NOTIFICATIONS: OnceLock<Mutex<VecDeque<Value>>> = OnceLock::new();

#[derive(Debug, Deserialize)]
struct PreviewInstalledAutogenRequest {
Expand Down Expand Up @@ -206,6 +209,19 @@ pub extern "C" fn Java_net_xzos_upgradeall_getter_NativeLib_runtimeOperation<'lo
java_string_or_fallback(&mut env, response)
}

#[no_mangle]
pub extern "C" fn Java_net_xzos_upgradeall_getter_NativeLib_drainRuntimeNotifications<'local>(
mut env: JNIEnv<'local>,
_: JObject<'local>,
) -> JString<'local> {
let command = "runtime notifications drain";
let response = match drain_runtime_notifications() {
Ok(data) => success_envelope(command, data),
Err(error) => operation_error_envelope(command, error),
};
java_string_or_fallback(&mut env, response)
}

#[no_mangle]
pub extern "C" fn Java_net_xzos_upgradeall_getter_NativeLib_importLegacyRoomDatabase<'local>(
mut env: JNIEnv<'local>,
Expand Down Expand Up @@ -293,7 +309,38 @@ fn legacy_report_list(request_json: &str) -> Result<Value, BridgeOperationError>
}

fn init_getter_runtime() -> &'static Mutex<getter::core::runtime::GetterRuntime> {
GETTER_RUNTIME.get_or_init(|| Mutex::new(getter::core::runtime::GetterRuntime::new()))
GETTER_RUNTIME.get_or_init(|| {
let mut runtime = getter::core::runtime::GetterRuntime::new();
runtime.set_notification_sink(|notification| {
enqueue_runtime_notification(notification);
});
Mutex::new(runtime)
})
}

fn runtime_notification_queue() -> &'static Mutex<VecDeque<Value>> {
RUNTIME_NOTIFICATIONS.get_or_init(|| Mutex::new(VecDeque::new()))
}

fn enqueue_runtime_notification(notification: getter::core::runtime::RuntimeNotification) {
let Ok(value) = serde_json::to_value(notification) else {
return;
};
let Ok(mut queue) = runtime_notification_queue().lock() else {
return;
};
if queue.len() >= MAX_RUNTIME_NOTIFICATION_QUEUE {
queue.pop_front();
}
queue.push_back(value);
}

fn drain_runtime_notifications() -> Result<Value, BridgeOperationError> {
let mut queue = runtime_notification_queue()
.lock()
.map_err(|_| BridgeOperationError::RuntimeNotificationQueuePoisoned)?;
let notifications: Vec<Value> = queue.drain(..).collect();
Ok(json!({ "notifications": notifications }))
}

fn runtime_operation(request_json: String) -> Result<Value, BridgeOperationError> {
Expand Down Expand Up @@ -475,6 +522,8 @@ enum BridgeOperationError {
Runtime(#[from] runtime_operations::RuntimeOperationError),
#[error("runtime lock is poisoned")]
RuntimePoisoned,
#[error("runtime notification queue is poisoned")]
RuntimeNotificationQueuePoisoned,
}

impl BridgeOperationError {
Expand Down Expand Up @@ -548,6 +597,11 @@ impl BridgeOperationError {
),
Self::Runtime(error) => (error.code(), error.message(), error.detail()),
Self::RuntimePoisoned => ("runtime.poisoned", "Getter runtime lock is poisoned", None),
Self::RuntimeNotificationQueuePoisoned => (
"runtime.notification_queue_poisoned",
"Getter runtime notification queue is poisoned",
None,
),
}
}
}
Expand Down Expand Up @@ -682,4 +736,34 @@ mod tests {
assert_eq!(code, "runtime.invalid_request");
assert!(detail.unwrap().contains("unsupported runtime operation"));
}

#[test]
fn runtime_notification_queue_is_bounded_and_drained() {
drain_runtime_notifications().expect("clear queue");
for index in 0..(MAX_RUNTIME_NOTIFICATION_QUEUE + 1) {
enqueue_runtime_notification(getter::core::runtime::RuntimeNotification::TaskChanged {
task: getter::core::runtime::TaskSnapshot {
task_id: format!("task-{index}"),
package_id: "android/org.fdroid.fdroid".parse().expect("package id"),
status: getter::core::runtime::RuntimeTaskStatus::Running,
phase: getter::core::runtime::TaskPhase::new(
getter::core::runtime::TaskPhaseCategory::Download,
),
progress: None,
capabilities: getter::core::runtime::TaskCapabilities::default(),
current_diagnostic: None,
updated_at: index as u64,
},
});
}

let drained = drain_runtime_notifications().expect("drain notifications");
let notifications = drained["notifications"].as_array().expect("notifications");

assert_eq!(notifications.len(), MAX_RUNTIME_NOTIFICATION_QUEUE);
assert_eq!(notifications[0]["task"]["task_id"], "task-1");
assert_eq!(notifications.last().unwrap()["task"]["task_id"], "task-64");
let empty = drain_runtime_notifications().expect("drain empty queue");
assert_eq!(empty["notifications"].as_array().unwrap().len(), 0);
}
}