Fix review findings, add default flood scope, and address recent issues
Review fixes: - Keep stored message history beyond the 200-message window; stop messages leaking between radios; reset link/session state on disconnect - Accept firmware's 176-byte RX frames over USB/TCP - Hold APP_START during contact sync; contact-sync watchdog; replay DMs from not-yet-known senders; tombstone late command replies; finish channel sync on ERR_NOT_FOUND; fail region-scoped sends cleanly - DM retry watchdog when RESP_CODE_SENT never arrives; late repeater CLI replies; ACK hash collisions; UTF-8-safe name truncation - Image pipeline: delete-during-decode, lifecycle cancels, decoder memory release, entry cap, dead worker recovery, atomic model writes - Storage: deterministic reaction hash across web/native, Smaz double-decode, per-entry parsing, per-radio path history and regions, review-mode data isolation - UI: safe channel slot selection, byte-length name limits, double-send guard, mounted checks, localized hardcoded strings - Skip persisted-store reload on repeat SELF_INFO Features: - Radio default flood scope (firmware ver 11+) and explicit unscoped sends (ver 12+) - Scan for nearby nodes (#570) - Optional distinct first-hop repeater counting for channel resend (#589) - Optional region next to hop count (#580) Issues: - Message text follows system font size (#569) - Repeater/room password field accepts 20 chars (#576) - TCP auto-reconnect and keepalive (#571) - Order feeds by local receive time; flag future timestamps (#584) - Coding rate help text (#568), French "Favoris" (#575) - iOS/macOS app badge now clears Translations for all new strings in every locale.
This commit is contained in:
1 parent
a64a33d0c0
commit
25f197c979
120 files changed
+10424
-687
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import '../services/app_settings_service.dart';
|
||||
import '../services/storage_service.dart';
|
||||
import '../services/timeout_prediction_service.dart';
|
||||
import '../storage/legacy_key_migration.dart';
|
||||
import '../storage/prefs_manager.dart';
|
||||
import 'review_radio.dart';
|
||||
@@ -7,6 +9,11 @@ import 'review_radio.dart';
|
||||
/// interrupted session (crash, app killed) is still undone on the next launch.
|
||||
const _savedMutedChannelsKey = 'review_mode_saved_muted_channels';
|
||||
|
||||
/// Prefix for snapshots of app-wide repeater keys (saved passwords, clock sync
|
||||
/// toggles) taken when review mode starts. An empty snapshot means the key did
|
||||
/// not exist.
|
||||
const _savedGlobalKeyPrefix = 'review_mode_saved_global_';
|
||||
|
||||
/// Deletes every persisted per-radio preference written while review mode was
|
||||
/// active. All per-radio stores (contacts, channels, messages, unread counts,
|
||||
/// channel/contact settings, regions, discovery cache, path history, ...) embed
|
||||
@@ -26,11 +33,19 @@ Future<void> clearReviewModeData() async {
|
||||
/// The simulated radio's scope never adopts legacy unscoped keys, so real
|
||||
/// radio data cannot be pulled into it. Channel mutes are app-wide and keyed
|
||||
/// by channel name (muting the simulated "Public" would mute the real one),
|
||||
/// so the current mutes are saved for [endReviewModeSession] to put back.
|
||||
/// so the current mutes are saved for [endReviewModeSession] to put back, as
|
||||
/// are the app-wide repeater keys. Delivery timing is not recorded meanwhile.
|
||||
Future<void> beginReviewModeSession(AppSettingsService? settings) async {
|
||||
scopesWithoutLegacyMigration.add(ReviewRadio.storagePrefix);
|
||||
TimeoutPredictionService.recordingSuspended = true;
|
||||
await clearReviewModeData();
|
||||
final prefs = PrefsManager.instance;
|
||||
for (final key in StorageService.globalRepeaterKeys) {
|
||||
final savedKey = '$_savedGlobalKeyPrefix$key';
|
||||
// An earlier interrupted session's snapshot holds the real state.
|
||||
if (prefs.containsKey(savedKey)) continue;
|
||||
await prefs.setString(savedKey, prefs.getString(key) ?? '');
|
||||
}
|
||||
// An earlier interrupted session's record holds the real pre-review state.
|
||||
if (settings != null && !prefs.containsKey(_savedMutedChannelsKey)) {
|
||||
await prefs.setStringList(
|
||||
@@ -40,12 +55,24 @@ Future<void> beginReviewModeSession(AppSettingsService? settings) async {
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes the review session's data and restores the channel mutes saved by
|
||||
/// [beginReviewModeSession]. Also called at startup to finish a session that
|
||||
/// Deletes the review session's data and restores the channel mutes and
|
||||
/// repeater keys saved by [beginReviewModeSession]. Also called at startup to finish a session that
|
||||
/// was interrupted; it does nothing when no session was left behind.
|
||||
Future<void> endReviewModeSession(AppSettingsService? settings) async {
|
||||
TimeoutPredictionService.recordingSuspended = false;
|
||||
await clearReviewModeData();
|
||||
final prefs = PrefsManager.instance;
|
||||
for (final key in StorageService.globalRepeaterKeys) {
|
||||
final savedKey = '$_savedGlobalKeyPrefix$key';
|
||||
final saved = prefs.getString(savedKey);
|
||||
if (saved == null) continue;
|
||||
if (saved.isEmpty) {
|
||||
await prefs.remove(key);
|
||||
} else {
|
||||
await prefs.setString(key, saved);
|
||||
}
|
||||
await prefs.remove(savedKey);
|
||||
}
|
||||
final savedMutes = prefs.getStringList(_savedMutedChannelsKey);
|
||||
if (savedMutes == null || settings == null) return;
|
||||
await settings.updateSettings(
|
||||
|
||||
@@ -15,6 +15,7 @@ class ReviewRadio {
|
||||
this.scheduledMessageInterval = const Duration(seconds: 45),
|
||||
this.ackDelay = const Duration(milliseconds: 1500),
|
||||
this.replyDelay = const Duration(seconds: 4),
|
||||
this.firmwareVerCode = ReviewScript.firmwareVerCode,
|
||||
}) {
|
||||
_seedState();
|
||||
}
|
||||
@@ -30,6 +31,13 @@ class ReviewRadio {
|
||||
final Duration ackDelay;
|
||||
final Duration replyDelay;
|
||||
|
||||
/// FIRMWARE_VER_CODE reported in DEVICE_INFO (tests use older values to
|
||||
/// exercise version gates).
|
||||
final int firmwareVerCode;
|
||||
|
||||
// Default flood scope (CMD_SET/GET_DEFAULT_FLOOD_SCOPE): name field + key.
|
||||
Uint8List? _defaultFloodScope;
|
||||
|
||||
final StreamController<Uint8List> _controller =
|
||||
StreamController<Uint8List>.broadcast();
|
||||
final List<Uint8List> _outbox = [];
|
||||
@@ -174,7 +182,7 @@ class ReviewRadio {
|
||||
case cmdDeviceQuery:
|
||||
_emit([
|
||||
ReviewFrames.deviceInfo(
|
||||
firmwareVerCode: ReviewScript.firmwareVerCode,
|
||||
firmwareVerCode: firmwareVerCode,
|
||||
maxContacts: ReviewScript.maxContacts,
|
||||
maxChannels: ReviewScript.maxChannels,
|
||||
),
|
||||
@@ -247,6 +255,25 @@ class ReviewRadio {
|
||||
]),
|
||||
]);
|
||||
break;
|
||||
case cmdGetDefaultFloodScope when firmwareVerCode < 11:
|
||||
case cmdSetDefaultFloodScope when firmwareVerCode < 11:
|
||||
_emit([ReviewFrames.err()]);
|
||||
break;
|
||||
case cmdGetDefaultFloodScope:
|
||||
_emit([
|
||||
Uint8List.fromList([
|
||||
respCodeDefaultFloodScope,
|
||||
...?_defaultFloodScope,
|
||||
]),
|
||||
]);
|
||||
break;
|
||||
case cmdSetDefaultFloodScope:
|
||||
_defaultFloodScope =
|
||||
frame.length >= 1 + defaultFloodScopeNameSize + floodScopeKeySize
|
||||
? Uint8List.fromList(frame.sublist(1))
|
||||
: null;
|
||||
_emit([ReviewFrames.ok()]);
|
||||
break;
|
||||
case cmdGetStats:
|
||||
_emit([
|
||||
frame.length >= 2 && frame[1] == statsTypeRadio
|
||||
@@ -300,6 +327,10 @@ class ReviewRadio {
|
||||
case cmdSendAnonReq:
|
||||
_emit([ReviewFrames.err()]);
|
||||
break;
|
||||
case cmdSendControlData:
|
||||
_emit([ReviewFrames.ok()]);
|
||||
_handleNodeDiscover(frame);
|
||||
break;
|
||||
case cmdSendTelemetryReq:
|
||||
// The 4-byte "self" form is answered with a push the app does not
|
||||
// track; remote requests are answered with ERR.
|
||||
@@ -452,6 +483,44 @@ class ReviewRadio {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pushes [frame] to the app as if the radio had sent it.
|
||||
@visibleForTesting
|
||||
void emitForTest(Uint8List frame) => _emit([frame]);
|
||||
|
||||
/// Answers a DISCOVER_REQ the way firmware repeaters and sensors do: one
|
||||
/// zero-hop DISCOVER_RESP per matching node, echoing the request tag.
|
||||
void _handleNodeDiscover(Uint8List frame) {
|
||||
// [cmd][0x8<flags>][type mask][tag u32][since u32]
|
||||
if (frame.length < 7 || (frame[1] >> 4) != controlSubtypeDiscoverReq) {
|
||||
return;
|
||||
}
|
||||
final prefixOnly = (frame[1] & 0x01) != 0;
|
||||
final typeMask = frame[2];
|
||||
final tag = frame.sublist(3, 7);
|
||||
var snrQuarterDb = 40;
|
||||
for (final c in _contacts) {
|
||||
if (c.type != advTypeRepeater && c.type != advTypeSensor) continue;
|
||||
if ((typeMask & (1 << c.type)) == 0) continue;
|
||||
final key = prefixOnly ? c.publicKey.sublist(0, 8) : c.publicKey;
|
||||
final snr = snrQuarterDb;
|
||||
snrQuarterDb -= 12;
|
||||
_later(ackDelay, () {
|
||||
_emit([
|
||||
Uint8List.fromList([
|
||||
pushCodeControlData,
|
||||
snr & 0xFF,
|
||||
(-60) & 0xFF,
|
||||
0, // path_len: zero-hop
|
||||
(controlSubtypeDiscoverResp << 4) | c.type,
|
||||
(snr - 8) & 0xFF,
|
||||
...tag,
|
||||
...key,
|
||||
]),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _handleLogin(Uint8List frame) {
|
||||
// [cmd][pub_key x32][password...]
|
||||
_Contact? contact;
|
||||
|
||||
Reference in new issue
Block a user