Lint
This commit is contained in:
parent
558d34c6cf
commit
11dbfcd6e9
|
@ -10,14 +10,17 @@ object AppCompanion {
|
|||
* to avoid testing buffered responses on boot.
|
||||
*/
|
||||
val booting = AtomicBoolean(false)
|
||||
|
||||
/**
|
||||
* Check if we have internet access.
|
||||
* The initial value is true, because the first time we check it is before
|
||||
* [RestartNetworkCallback] is registered.
|
||||
*/
|
||||
val hasInternet = AtomicBoolean(true)
|
||||
|
||||
/** Have we received the start event ? To check the reverse proxy timeout is high enough */
|
||||
val started = AtomicBoolean(false)
|
||||
|
||||
/** Have we received the ping event ? To check the reverse proxy timeout is high enough */
|
||||
val pinged = AtomicBoolean(false)
|
||||
val bufferedResponseChecked = AtomicBoolean(false)
|
||||
|
|
|
@ -10,7 +10,7 @@ import android.util.Log
|
|||
class WakeLock(context: Context) {
|
||||
private var wakeLock: PowerManager.WakeLock =
|
||||
(context.getSystemService(Context.POWER_SERVICE) as PowerManager)
|
||||
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK_TAG)
|
||||
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK_TAG)
|
||||
|
||||
/**
|
||||
* Acquire the [WakeLock][PowerManager.WakeLock] with 10 seconds timeout.
|
||||
|
@ -46,7 +46,7 @@ class WakeLock(context: Context) {
|
|||
fun new(context: Context): WakeLock {
|
||||
Log.d(TAG, "Generating a new instance")
|
||||
instance?.release()
|
||||
return WakeLock(context).also {
|
||||
return WakeLock(context).also {
|
||||
instance = it
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.os.Bundle
|
|||
import android.util.Log
|
||||
import org.unifiedpush.distributor.nextpush.distributor.EXTRA_PI
|
||||
|
||||
class LinkActivity: Activity() {
|
||||
class LinkActivity : Activity() {
|
||||
private val TAG = LinkActivity::class.simpleName
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
|
@ -6,8 +6,10 @@ package org.unifiedpush.distributor.nextpush.distributor
|
|||
enum class ConnectorTokenValidity {
|
||||
/** This is a new token. */
|
||||
TOKEN_NEW,
|
||||
|
||||
/** This is a known token, which match the provided application. */
|
||||
TOKEN_REGISTERED_OK,
|
||||
|
||||
/** This is a known token, but it doesn't match the application. */
|
||||
TOKEN_NOK,
|
||||
TOKEN_NOK
|
||||
}
|
|
@ -4,18 +4,20 @@ package org.unifiedpush.distributor.nextpush.distributor
|
|||
* A registration request may fail for different reasons.
|
||||
*/
|
||||
enum class FailedReason {
|
||||
/**
|
||||
* This is a generic error type, you can try to register again directly.
|
||||
*/
|
||||
/**
|
||||
* This is a generic error type, you can try to register again directly.
|
||||
*/
|
||||
INTERNAL_ERROR,
|
||||
/**
|
||||
* The registration failed because of missing network connection, try again when network is back.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The registration failed because of missing network connection, try again when network is back.
|
||||
*/
|
||||
NETWORK,
|
||||
/**
|
||||
* The distributor requires a user action to work. For instance, the distributor may be log out of the push server and requires the user to log in. The user must interact with the distributor or sending a new registration will fail again.
|
||||
*/
|
||||
ACTION_REQUIRED,
|
||||
|
||||
/**
|
||||
* The distributor requires a user action to work. For instance, the distributor may be log out of the push server and requires the user to log in. The user must interact with the distributor or sending a new registration will fail again.
|
||||
*/
|
||||
ACTION_REQUIRED
|
||||
/*
|
||||
* The distributor requires a VAPID key and the app didn't provide one during registration.
|
||||
VAPID_REQUIRED,
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.concurrent.Executors
|
|||
import java.util.concurrent.ScheduledFuture
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RaiseAppToForeground(private val context: Context, private val app: String, private val onUnbound: () -> Unit): ServiceConnection, Runnable {
|
||||
class RaiseAppToForeground(private val context: Context, private val app: String, private val onUnbound: () -> Unit) : ServiceConnection, Runnable {
|
||||
|
||||
/**
|
||||
* Is the service bound ? This is a per service connection
|
||||
|
@ -23,7 +23,7 @@ class RaiseAppToForeground(private val context: Context, private val app: String
|
|||
|
||||
private val foregroundImportance = listOf(
|
||||
RunningAppProcessInfo.IMPORTANCE_FOREGROUND,
|
||||
RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE,
|
||||
RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -64,7 +64,6 @@ class RaiseAppToForeground(private val context: Context, private val app: String
|
|||
`package` = app
|
||||
action = ACTION
|
||||
}
|
||||
//val sConnection = RaiseAppToForeground(context, app)
|
||||
/** Bind to the target raise to the foreground service */
|
||||
context.bindService(intent, this, Context.BIND_AUTO_CREATE)
|
||||
/** Call [run] (unbind) in 5 seconds */
|
||||
|
@ -121,6 +120,7 @@ class RaiseAppToForeground(private val context: Context, private val app: String
|
|||
private const val TAG = "RaiseAppToForeground"
|
||||
private const val TARGET_CLASS = "org.unifiedpush.android.connector.RaiseToForegroundService"
|
||||
private const val ACTION = "org.unifiedpush.android.distributor.RAISE_TO_FOREGROUND"
|
||||
|
||||
/** Executor to unbind 5 seconds later */
|
||||
private val unbindExecutor = Executors.newSingleThreadScheduledExecutor()
|
||||
}
|
||||
|
|
|
@ -45,8 +45,11 @@ class RegisterBroadcastReceiver : BroadcastReceiver() {
|
|||
* Get application package name following AND_3 specifications.
|
||||
*/
|
||||
private fun getApplicationAnd3(context: Context, intent: Intent): String? {
|
||||
return if (Build.VERSION.SDK_INT >= 34) getApplicationAnd3SharedId(context, intent)
|
||||
else getApplicationAnd3PendingIntent(intent)
|
||||
return if (Build.VERSION.SDK_INT >= 34) {
|
||||
getApplicationAnd3SharedId(context, intent)
|
||||
} else {
|
||||
getApplicationAnd3PendingIntent(intent)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,7 +131,7 @@ class RegisterBroadcastReceiver : BroadcastReceiver() {
|
|||
when (checkToken(context, connectorToken, application)) {
|
||||
ConnectorTokenValidity.TOKEN_REGISTERED_OK -> onRegisterKnownToken(context, connectorToken)
|
||||
ConnectorTokenValidity.TOKEN_NOK -> onRegisterNokToken(context, connectorToken, application)
|
||||
ConnectorTokenValidity.TOKEN_NEW ->onRegisterNewToken(context, connectorToken, application)
|
||||
ConnectorTokenValidity.TOKEN_NEW -> onRegisterNewToken(context, connectorToken, application)
|
||||
}
|
||||
AppCompanion.createQueue.removeToken(connectorToken)
|
||||
} else {
|
||||
|
@ -179,9 +182,9 @@ class RegisterBroadcastReceiver : BroadcastReceiver() {
|
|||
)
|
||||
|
||||
else -> createApp(
|
||||
context,
|
||||
application,
|
||||
connectorToken
|
||||
context,
|
||||
application,
|
||||
connectorToken
|
||||
) { success ->
|
||||
when (success) {
|
||||
true -> {
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import org.unifiedpush.distributor.nextpush.AppCompanion
|
||||
import org.unifiedpush.distributor.nextpush.WakeLock
|
||||
|
|
Loading…
Reference in New Issue