Skip to content

Commit 73b36e8

Browse files
authored
Merge branch 'master' into fix/add-retry-defensive-check
2 parents f868ded + a8cdab9 commit 73b36e8

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

app/src/main/java/to/bitkit/androidServices/LightningNodeService.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import android.app.Notification
44
import android.app.PendingIntent
55
import android.app.Service
66
import android.content.Intent
7+
import android.os.Build
78
import android.os.IBinder
9+
import androidx.annotation.RequiresApi
810
import androidx.core.app.NotificationCompat
11+
import androidx.core.content.ContextCompat
912
import dagger.hilt.android.AndroidEntryPoint
1013
import kotlinx.coroutines.CoroutineDispatcher
1114
import kotlinx.coroutines.CoroutineScope
@@ -65,9 +68,6 @@ class LightningNodeService : Service() {
6568
handlePaymentReceived(event)
6669
}
6770
).onSuccess {
68-
val notification = createNotification()
69-
startForeground(ID_NOTIFICATION_NODE, notification)
70-
7171
walletRepo.setWalletExistsState()
7272
walletRepo.refreshBip21()
7373
walletRepo.syncBalances()
@@ -116,8 +116,10 @@ class LightningNodeService : Service() {
116116
return NotificationCompat.Builder(this, CHANNEL_ID_NODE)
117117
.setContentTitle(getString(R.string.app_name))
118118
.setContentText(contentText)
119-
.setSmallIcon(R.drawable.ic_launcher_fg_regtest)
119+
.setSmallIcon(R.drawable.ic_bitkit_outlined)
120+
.setColor(ContextCompat.getColor(this, R.color.brand))
120121
.setContentIntent(pendingIntent)
122+
.setOngoing(true)
121123
.addAction(
122124
R.drawable.ic_x,
123125
getString(R.string.notification__service__stop),
@@ -151,6 +153,16 @@ class LightningNodeService : Service() {
151153
super.onDestroy()
152154
}
153155

156+
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
157+
override fun onTimeout(startId: Int, fgsType: Int) {
158+
Logger.warn("Foreground service timeout reached", context = TAG)
159+
serviceScope.launch {
160+
lightningRepo.stop()
161+
stopSelf()
162+
}
163+
super.onTimeout(startId, fgsType)
164+
}
165+
154166
override fun onBind(intent: Intent?): IBinder? = null
155167

156168
companion object {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="600dp"
3+
android:height="600dp"
4+
android:viewportWidth="600"
5+
android:viewportHeight="600">
6+
<group>
7+
<clip-path
8+
android:pathData="M0,0h600v600h-600z"/>
9+
<path
10+
android:pathData="M377.4,496.6C338.39,543.97 279.29,574.17 213.13,574.17C95.66,574.17 0.43,478.94 0.43,361.47C0.43,244 95.66,148.77 213.13,148.77C214,148.77 214.86,148.78 215.73,148.79L249.12,25H453.95C530.29,25 599.4,83.19 599.4,162.18C599.4,191.47 594,222.8 577,249.89C575.09,252.93 573.07,255.87 570.93,258.7C573.27,262 575.47,265.44 577.51,269.04C593.91,297.9 597.33,330.73 594.22,362.36C590.75,397.6 576.5,431.81 549.28,457.38C521.72,483.26 484.78,496.6 443.08,496.6H377.4ZM213.13,200.37C209.29,200.37 205.48,200.51 201.71,200.77C118.06,206.63 52.03,276.34 52.03,361.47C52.03,450.45 124.16,522.57 213.13,522.57C262.51,522.57 306.7,500.36 336.25,465.38C344.9,455.14 352.29,443.81 358.2,431.62C368.47,410.41 374.23,386.62 374.23,361.47C374.23,287.67 324.61,225.47 256.91,206.39C342.83,226.91 402.58,297.92 402.58,392.7C402.58,393.74 402.58,394.77 402.56,395.8C402.27,413.25 399.57,430.15 394.75,446.2H443.08C444.4,446.2 445.72,446.18 447.02,446.14C505.86,444.53 539.09,406.65 543.92,357.44C546.49,331.33 542.93,309.2 532.4,291.95C530.71,289.16 528.83,286.5 526.76,283.98C517.11,272.16 503.41,263.2 485.33,257.49L485.32,257.48C485.15,257.43 484.99,257.38 484.83,257.33L484.63,257.27C484.41,257.25 484.25,257.07 484.25,256.86C484.25,256.74 484.29,256.64 484.36,256.57C484.43,256.5 484.52,256.45 484.63,256.44L484.71,256.42L484.79,256.41L484.9,256.38C503.74,252.1 517.85,243.51 527.95,231.64C529.96,229.28 531.81,226.79 533.51,224.17C544.23,207.68 548.87,186.35 548.87,162.18C548.87,114.85 506.37,75.4 453.95,75.4H287.85L252.82,205.3C240.12,202.08 226.82,200.37 213.13,200.37Z"
11+
android:fillColor="#ffffff"
12+
android:fillType="evenOdd"/>
13+
</group>
14+
</vector>

0 commit comments

Comments
 (0)