This commit is contained in:
sim 2024-11-02 12:39:21 +00:00
parent 558d34c6cf
commit 11dbfcd6e9
9 changed files with 38 additions and 29 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -8,14 +8,16 @@ enum class FailedReason {
* 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.
*/
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,
ACTION_REQUIRED
/*
* The distributor requires a VAPID key and the app didn't provide one during registration.
VAPID_REQUIRED,

View File

@ -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()
}

View File

@ -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)
}
}
/**

View File

@ -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