Skip to content

Commit

Permalink
Disconnect Breez SDK on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed Jan 4, 2024
1 parent 987c548 commit fe5a96b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.cBreez.client.BreezNotificationHelper.Companion.notifyForegroundServi
import com.cBreez.client.BreezNotificationHelper.Companion.notifyPaymentReceived
import com.cBreez.client.BreezNotificationHelper.Companion.registerNotificationChannels
import com.cBreez.client.BreezSdkConnector.Companion.connectSDK
import com.cBreez.client.BreezSdkConnector.Companion.disconnectSDK
import com.cBreez.client.Constants.EXTRA_REMOTE_MESSAGE
import com.cBreez.client.Constants.NOTIFICATION_ID_FOREGROUND_SERVICE
import com.google.firebase.messaging.RemoteMessage
Expand Down Expand Up @@ -96,6 +97,7 @@ class BreezForegroundService : Service() {
private fun shutdown() {
Logger.tag(TAG).debug { "Shutting down Breez foreground service" }
stopForeground(STOP_FOREGROUND_REMOVE)
disconnectSDK()
stopSelf()
}

Expand Down
10 changes: 10 additions & 0 deletions android/app/src/main/java/com/cBreez/client/BreezSdkConnector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,15 @@ class BreezSdkConnector {
val result: ByteArray = storageCipher.decrypt(data)
return String(result, charset)
}

internal fun disconnectSDK() {
if(breezSDK != null){
// Connect to the Breez SDK make it ready for use
Logger.tag(TAG).debug { "Disconnecting Breez SDK" }
breezSDK!!.disconnect()
Logger.tag(TAG).debug { "Disconnected from Breez SDK" }
breezSDK = null
}
}
}
}

0 comments on commit fe5a96b

Please sign in to comment.