mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 08:05:22 +00:00
use singleton
This commit is contained in:
@@ -41,7 +41,6 @@ class BluetoothMeshService(private val context: Context) {
|
|||||||
|
|
||||||
// Core components - each handling specific responsibilities
|
// Core components - each handling specific responsibilities
|
||||||
private val encryptionService = EncryptionService(context)
|
private val encryptionService = EncryptionService(context)
|
||||||
private val noiseEncryptionService = com.bitchat.android.noise.NoiseEncryptionService(context)
|
|
||||||
private val peerManager = PeerManager()
|
private val peerManager = PeerManager()
|
||||||
private val fragmentManager = FragmentManager()
|
private val fragmentManager = FragmentManager()
|
||||||
private val securityManager = SecurityManager(encryptionService, myPeerID)
|
private val securityManager = SecurityManager(encryptionService, myPeerID)
|
||||||
@@ -208,13 +207,13 @@ class BluetoothMeshService(private val context: Context) {
|
|||||||
|
|
||||||
// Noise protocol operations
|
// Noise protocol operations
|
||||||
override fun hasNoiseSession(peerID: String): Boolean {
|
override fun hasNoiseSession(peerID: String): Boolean {
|
||||||
return noiseEncryptionService.hasEstablishedSession(peerID)
|
return encryptionService.hasEstablishedSession(peerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initiateNoiseHandshake(peerID: String) {
|
override fun initiateNoiseHandshake(peerID: String) {
|
||||||
try {
|
try {
|
||||||
// Initiate proper Noise handshake with specific peer
|
// Initiate proper Noise handshake with specific peer
|
||||||
val handshakeData = noiseEncryptionService.initiateHandshake(peerID)
|
val handshakeData = encryptionService.initiateHandshake(peerID)
|
||||||
|
|
||||||
if (handshakeData != null) {
|
if (handshakeData != null) {
|
||||||
val packet = BitchatPacket(
|
val packet = BitchatPacket(
|
||||||
@@ -568,7 +567,7 @@ class BluetoothMeshService(private val context: Context) {
|
|||||||
private fun sendKeyExchangeToDevice() {
|
private fun sendKeyExchangeToDevice() {
|
||||||
// For discovery, broadcast our static identity key (32 bytes) so peers can identify us
|
// For discovery, broadcast our static identity key (32 bytes) so peers can identify us
|
||||||
// This is not a handshake initiation, but identity announcement
|
// This is not a handshake initiation, but identity announcement
|
||||||
val identityData = noiseEncryptionService.getStaticPublicKeyData()
|
val identityData = encryptionService.getCombinedPublicKeyData()
|
||||||
|
|
||||||
val packet = BitchatPacket(
|
val packet = BitchatPacket(
|
||||||
version = 1u,
|
version = 1u,
|
||||||
@@ -613,28 +612,28 @@ class BluetoothMeshService(private val context: Context) {
|
|||||||
* Check if we have an established Noise session with a peer
|
* Check if we have an established Noise session with a peer
|
||||||
*/
|
*/
|
||||||
fun hasEstablishedSession(peerID: String): Boolean {
|
fun hasEstablishedSession(peerID: String): Boolean {
|
||||||
return noiseEncryptionService.hasEstablishedSession(peerID) // FIXED: Use same service as delegate
|
return encryptionService.hasEstablishedSession(peerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get peer fingerprint for identity management
|
* Get peer fingerprint for identity management
|
||||||
*/
|
*/
|
||||||
fun getPeerFingerprint(peerID: String): String? {
|
fun getPeerFingerprint(peerID: String): String? {
|
||||||
return noiseEncryptionService.getPeerFingerprint(peerID) // FIXED: Use same service as delegate
|
return encryptionService.getPeerFingerprint(peerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get our identity fingerprint
|
* Get our identity fingerprint
|
||||||
*/
|
*/
|
||||||
fun getIdentityFingerprint(): String {
|
fun getIdentityFingerprint(): String {
|
||||||
return noiseEncryptionService.getIdentityFingerprint() // FIXED: Use same service as delegate
|
return encryptionService.getIdentityFingerprint()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if encryption icon should be shown for a peer
|
* Check if encryption icon should be shown for a peer
|
||||||
*/
|
*/
|
||||||
fun shouldShowEncryptionIcon(peerID: String): Boolean {
|
fun shouldShowEncryptionIcon(peerID: String): Boolean {
|
||||||
return noiseEncryptionService.hasEstablishedSession(peerID) // FIXED: Use same service as delegate
|
return encryptionService.hasEstablishedSession(peerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user