Skip to content

Remove dead name-based dedup code after PR #630#633

Merged
torlando-tech merged 1 commit intomainfrom
cleanup/remove-dead-name-dedup-code
Mar 9, 2026
Merged

Remove dead name-based dedup code after PR #630#633
torlando-tech merged 1 commit intomainfrom
cleanup/remove-dead-name-dedup-code

Conversation

@torlando-tech
Copy link
Copy Markdown
Owner

Summary

  • Removes shouldSkipDiscoveredDevice() and all supporting infrastructure (recentlyDeduplicatedIdentities, deduplicationCooldownMs, IDENTITY_BYTES_IN_ADVERTISED_NAME) — dead since PR fix: stop changing phone's Bluetooth device name during BLE advertising #630 stopped advertising device names
  • Removes BleAdvertiser.setTransportIdentity() and its callers in KotlinBLEBridge and BleConnectionManager — advertiser no longer needs identity for name computation
  • Simplifies scanner callback to invoke Python directly without the always-false skip check
  • Removes 15 dead tests and 6 dead test helpers; keeps 5 live tests (3 pendingCentralConnections + 2 onAddressChanged)
  • Updates docs/ble-architecture.md and detekt baseline

No behavioral change — the GATT-layer identity dedup in handleIdentityReceived() remains fully intact and handles all deduplication correctly.

Test plan

  • :reticulum:compileDebugKotlin passes
  • :reticulum:testDebugUnitTest --tests "*.KotlinBLEBridgeDeduplicationTest" — 5 remaining tests pass
  • :app:compileNoSentryDebugKotlin passes
  • grep for all removed symbols returns zero matches

🤖 Generated with Claude Code

PR #630 stopped advertising device names in BLE scan responses.
This made shouldSkipDiscoveredDevice() always return false since
it relied on matching "RNS-"/"Reticulum-" prefixes in advertised
names. The GATT-layer identity dedup remains intact.

Removed:
- shouldSkipDiscoveredDevice() and its scanner callback wrapper
- recentlyDeduplicatedIdentities map + deduplicationCooldownMs
- BleAdvertiser.setTransportIdentity() + transportIdentityHash
- IDENTITY_BYTES_IN_ADVERTISED_NAME constant
- 15 dead tests and 6 dead test helpers
- Stale detekt baseline entry and docs references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 9, 2026

Greptile Summary

This PR is a clean dead-code removal pass following PR #630, which stopped advertising identity-based device names. Because devices no longer advertise an RNS-{hex} name, shouldSkipDiscoveredDevice() was already always returning false (it short-circuits on a null name), the recentlyDeduplicatedIdentities cooldown map was never populated via the scanner path, and BleAdvertiser.setTransportIdentity() was setting state that was never read. Removing all of it is correct and introduces no behavioral change.

Key changes:

  • KotlinBLEBridge.kt: Removes shouldSkipDiscoveredDevice(), recentlyDeduplicatedIdentities, deduplicationCooldownMs, the advertiser?.setTransportIdentity() call, and all four recentlyDeduplicatedIdentities.clear() / .remove() sites.
  • BleAdvertiser.kt: Removes transportIdentityHash volatile field and setTransportIdentity() method; device name is now set directly without any identity-based computation.
  • BleConnectionManager.kt: Removes advertiser.setTransportIdentity() call; also expression-bodies three trivial private functions.
  • BleConstants.kt: Removes IDENTITY_BYTES_IN_ADVERTISED_NAME.
  • KotlinBLEBridgeDeduplicationTest.kt: Deletes 15 tests and 6 helpers that exercised the now-deleted code; retains the 5 live tests covering pendingCentralConnections and onAddressChanged.
  • docs/ble-architecture.md / detekt-baseline-debug.xml: Updated to match the removed symbols.

Confidence Score: 5/5

Important Files Changed

Filename Overview
reticulum/src/main/java/com/lxmf/messenger/reticulum/ble/bridge/KotlinBLEBridge.kt Correctly removes recentlyDeduplicatedIdentities, deduplicationCooldownMs, shouldSkipDiscoveredDevice(), advertiser.setTransportIdentity() call, and all cleanup site references. Scanner callback simplified to call Python directly. No live logic is affected.
reticulum/src/main/java/com/lxmf/messenger/reticulum/ble/server/BleAdvertiser.kt Removes transportIdentityHash volatile field, setTransportIdentity() method, and identity-based name computation. Device name is now set directly from the passed argument. Logging simplified accordingly.
reticulum/src/main/java/com/lxmf/messenger/reticulum/ble/service/BleConnectionManager.kt Removes advertiser.setTransportIdentity() call and updates comment/log. Also converts three single-expression functions to expression-body style (style-only).
reticulum/src/main/java/com/lxmf/messenger/reticulum/ble/model/BleConstants.kt Removes IDENTITY_BYTES_IN_ADVERTISED_NAME constant. Consistent with the advertiser no longer computing an identity-based device name.
reticulum/src/test/java/com/lxmf/messenger/reticulum/ble/bridge/KotlinBLEBridgeDeduplicationTest.kt Removes 15 dead tests and 6 dead helpers tied to shouldSkipDiscoveredDevice / recentlyDeduplicatedIdentities. Retains 5 live tests: 3 for pendingCentralConnections and 2 for onAddressChanged.
docs/ble-architecture.md Removes references to recentlyDeduplicatedIdentities and deduplicationCooldownMs from data-structures and timing-constants tables. Scan Response description updated to show no device name is advertised. Leaves a minor double-blank-line cosmetic artifact.
reticulum/detekt-baseline-debug.xml Removes the MaxLineLength baseline suppression that covered the now-deleted identity-name computation in BleAdvertiser. Leaves one blank line placeholder in the XML.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[BLE Scanner discovers device] --> B[onDeviceDiscovered callback]
    B --> C["Log: Device discovered (address, name, RSSI)"]
    C --> D[Build serviceUuidsArray]
    D --> E[onDeviceDiscovered.callAttr to Python]

    subgraph REMOVED ["❌ Removed (dead since PR #630)"]
        R1["shouldSkipDiscoveredDevice(device.name)"]
        R2["recentlyDeduplicatedIdentities map"]
        R3["deduplicationCooldownMs = 60,000ms"]
        R4["BleAdvertiser.setTransportIdentity()"]
        R5["IDENTITY_BYTES_IN_ADVERTISED_NAME = 3"]
    end

    subgraph REMAINS ["✅ Remains — GATT-layer dedup"]
        G1[handleIdentityReceived]
        G2{Dual connection?}
        G3[DedupeAction.CLOSE_CENTRAL]
        G4[DedupeAction.CLOSE_PERIPHERAL]
        G1 --> G2
        G2 -- yes --> G3
        G2 -- yes --> G4
    end

    E --> REMAINS
Loading

Last reviewed commit: eb0c3e1

@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@torlando-tech torlando-tech merged commit 118c091 into main Mar 9, 2026
14 checks passed
@torlando-tech torlando-tech deleted the cleanup/remove-dead-name-dedup-code branch March 9, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant