Lint
This commit is contained in:
parent
f328fcc13f
commit
f4eaba00a5
|
@ -96,7 +96,8 @@ class SSEListener(val context: Context) : EventSourceListener() {
|
|||
"deleteApp" -> {
|
||||
val message = Gson().fromJson(data, SSEResponse::class.java)
|
||||
if (Database.getDb(context).getPackageName(message.token) != null &&
|
||||
!AppCompanion.delQueue.containsTokenElseAdd(message.token)) {
|
||||
!AppCompanion.delQueue.containsTokenElseAdd(message.token)
|
||||
) {
|
||||
deleteAppFromSSE(context, message.token)
|
||||
AppCompanion.delQueue.removeToken(message.token)
|
||||
}
|
||||
|
|
|
@ -15,20 +15,20 @@ object RegistrationCountCache {
|
|||
}
|
||||
}
|
||||
|
||||
fun refresh(context: Context) = synchronized(this) {
|
||||
nRegistrations = null
|
||||
val count = getCount(context)
|
||||
Log.d(TAG, "Refreshing nRegistrations to $count")
|
||||
// if n == 1: start the SSE (The fg service starts on boot, but doesn't connect without reg)
|
||||
// if n == 0: We keep the foreground service but stop the SSE/RestarWorker
|
||||
// The Runner will starts StartService, which will disconnect the SSE
|
||||
if (count in intArrayOf(0,1)) {
|
||||
RestartWorker.run(context, delay = 0, force = true)
|
||||
}
|
||||
ForegroundNotification(context).update()
|
||||
}
|
||||
fun refresh(context: Context) = synchronized(this) {
|
||||
nRegistrations = null
|
||||
val count = getCount(context)
|
||||
Log.d(TAG, "Refreshing nRegistrations to $count")
|
||||
// if n == 1: start the SSE (The fg service starts on boot, but doesn't connect without reg)
|
||||
// if n == 0: We keep the foreground service but stop the SSE/RestarWorker
|
||||
// The Runner will starts StartService, which will disconnect the SSE
|
||||
if (count in intArrayOf(0, 1)) {
|
||||
RestartWorker.run(context, delay = 0, force = true)
|
||||
}
|
||||
ForegroundNotification(context).update()
|
||||
}
|
||||
|
||||
fun oneOrMore(context: Context): Boolean = synchronized(this) {
|
||||
return getCount(context) > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,10 @@ class StartService : Service() {
|
|||
if (isServiceStarted &&
|
||||
!FailureHandler.hasFailed() &&
|
||||
// If there is no registration, this is a request to stop the SSE
|
||||
RegistrationCountCache.oneOrMore(context)) return
|
||||
RegistrationCountCache.oneOrMore(context)
|
||||
) {
|
||||
return
|
||||
}
|
||||
Log.d(TAG, "Starting the Listener")
|
||||
Log.d(TAG, "Service is started: $isServiceStarted")
|
||||
Log.d(TAG, "nFails: ${FailureHandler.nFails()}")
|
||||
|
|
|
@ -44,7 +44,7 @@ open class AppNotification(
|
|||
private val shown: AtomicBoolean,
|
||||
private val notificationId: Int,
|
||||
private val notificationData: NotificationData,
|
||||
private val channelData: ChannelData,
|
||||
private val channelData: ChannelData
|
||||
) {
|
||||
internal fun createNotificationChannel() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
@ -221,7 +221,7 @@ class NoServerAppNotification(val context: Context) : AppNotification(
|
|||
),
|
||||
context.warningChannelData
|
||||
) {
|
||||
override fun create(bigText: Boolean): Notification{
|
||||
override fun create(bigText: Boolean): Notification {
|
||||
createNotificationChannel()
|
||||
|
||||
val notificationIntent = Intent(Intent.ACTION_VIEW)
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.util.Log
|
|||
import java.util.Timer
|
||||
import kotlin.concurrent.schedule
|
||||
|
||||
|
||||
fun MutableList<String>.containsTokenElseAdd(connectorToken: String): Boolean {
|
||||
return synchronized(this) {
|
||||
if (connectorToken !in this) {
|
||||
|
@ -28,4 +27,4 @@ private fun delayRemove(list: MutableList<String>, token: String) {
|
|||
Timer().schedule(1_000L /* 1sec */) {
|
||||
list.removeToken(token)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue