diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt
index 3682768911..6a35b652ec 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt
@@ -221,6 +221,22 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
}
)
+ clickPref(
+ title = DSLSettingsText.from("Delete UnifiedPush ping"),
+ summary = DSLSettingsText.from("Make as Molly never received the ping from MollySocket. Will cause UnifiedPush to stop and Websocket to restart."),
+ onClick = {
+ MaterialAlertDialogBuilder(requireContext())
+ .setTitle("Delete UnifiedPush ping?")
+ .setMessage("Are you sure?")
+ .setPositiveButton(android.R.string.ok) { _, _ ->
+ SignalStore.unifiedpush.pinged = false
+ Toast.makeText(requireContext(), "UnifiedPush ping deleted!", Toast.LENGTH_SHORT).show()
+ }
+ .setNegativeButton(android.R.string.cancel, null)
+ .show()
+ }
+ )
+
dividerPref()
sectionHeaderPref(DSLSettingsText.from("Logging"))
diff --git a/app/src/main/res/values/strings2.xml b/app/src/main/res/values/strings2.xml
index 1d84ce99a6..dc21d43769 100644
--- a/app/src/main/res/values/strings2.xml
+++ b/app/src/main/res/values/strings2.xml
@@ -146,6 +146,8 @@
OK: Air Gapped
MollySocket url missing
Pending
+ Waiting for test notification
+ Air Gapped, waiting for test notification
MollySocket server not found
An internal Error occurred, please try again
The account ID is refused by the server
diff --git a/app/src/unifiedpush/java/im/molly/unifiedpush/components/settings/app/notifications/UnifiedPushSettingsFragment.kt b/app/src/unifiedpush/java/im/molly/unifiedpush/components/settings/app/notifications/UnifiedPushSettingsFragment.kt
index 0daf53d95e..ecc24fa3a9 100644
--- a/app/src/unifiedpush/java/im/molly/unifiedpush/components/settings/app/notifications/UnifiedPushSettingsFragment.kt
+++ b/app/src/unifiedpush/java/im/molly/unifiedpush/components/settings/app/notifications/UnifiedPushSettingsFragment.kt
@@ -154,6 +154,8 @@ class UnifiedPushSettingsFragment : DSLSettingsFragment(R.string.NotificationsSe
UnifiedPushStatus.FORBIDDEN_ENDPOINT -> getString(R.string.UnifiedPushSettingsFragment__status_summary_forbidden_endpoint)
UnifiedPushStatus.NO_DISTRIBUTOR -> getString(R.string.UnifiedPushSettingsFragment__status_summary_no_distributor)
UnifiedPushStatus.PENDING -> getString(R.string.UnifiedPushSettingsFragment__status_summary_pending)
+ UnifiedPushStatus.AIR_GAPED_NOT_PINGED -> getString(R.string.UnifiedPushSettingsFragment__status_summary_air_gaped_not_pinged)
+ UnifiedPushStatus.NOT_PINGED -> getString(R.string.UnifiedPushSettingsFragment__status_summary_not_pinged)
UnifiedPushStatus.OK -> getString(R.string.UnifiedPushSettingsFragment__ok)
UnifiedPushStatus.INTERNAL_ERROR -> getString(R.string.UnifiedPushSettingsFragment__status_summary_internal_error)
UnifiedPushStatus.UNKNOWN -> getString(R.string.UnifiedPushSettingsFragment__status_summary_unknown_error)
diff --git a/app/src/unifiedpush/java/im/molly/unifiedpush/device/MollySocketLinkedDevice.kt b/app/src/unifiedpush/java/im/molly/unifiedpush/device/MollySocketLinkedDevice.kt
index 5645a944be..cd05a78377 100644
--- a/app/src/unifiedpush/java/im/molly/unifiedpush/device/MollySocketLinkedDevice.kt
+++ b/app/src/unifiedpush/java/im/molly/unifiedpush/device/MollySocketLinkedDevice.kt
@@ -38,6 +38,7 @@ class MollySocketLinkedDevice(val context: Context) {
}
device = SignalStore.unifiedpush.device
?: run {
+ SignalStore.unifiedpush.pinged = false
newDevice()
SignalStore.unifiedpush.device
}
diff --git a/app/src/unifiedpush/java/im/molly/unifiedpush/jobs/UnifiedPushRefreshJob.kt b/app/src/unifiedpush/java/im/molly/unifiedpush/jobs/UnifiedPushRefreshJob.kt
index 3d2fc1894a..c79c554858 100644
--- a/app/src/unifiedpush/java/im/molly/unifiedpush/jobs/UnifiedPushRefreshJob.kt
+++ b/app/src/unifiedpush/java/im/molly/unifiedpush/jobs/UnifiedPushRefreshJob.kt
@@ -69,6 +69,7 @@ class UnifiedPushRefreshJob private constructor(parameters: Parameters) : BaseJo
UnifiedPushStatus.MISSING_ENDPOINT,
UnifiedPushStatus.NO_DISTRIBUTOR,
UnifiedPushStatus.LINK_DEVICE_ERROR,
+ UnifiedPushStatus.AIR_GAPED_NOT_PINGED,
UnifiedPushStatus.SERVER_NOT_FOUND_AT_URL-> {
Log.i(TAG, "UnifiedPush enabled, but this is currently unavailable. Status=$status.")
reInitializeNotificationServices()
@@ -81,6 +82,7 @@ class UnifiedPushRefreshJob private constructor(parameters: Parameters) : BaseJo
// We try to register to MollySocket server,
// Then re-init the services
UnifiedPushStatus.PENDING,
+ UnifiedPushStatus.NOT_PINGED,
UnifiedPushStatus.FORBIDDEN_UUID,
UnifiedPushStatus.FORBIDDEN_ENDPOINT,
UnifiedPushStatus.INTERNAL_ERROR -> {
diff --git a/app/src/unifiedpush/java/im/molly/unifiedpush/model/UnifiedPushStatus.kt b/app/src/unifiedpush/java/im/molly/unifiedpush/model/UnifiedPushStatus.kt
index fe488def75..97feb01e4f 100644
--- a/app/src/unifiedpush/java/im/molly/unifiedpush/model/UnifiedPushStatus.kt
+++ b/app/src/unifiedpush/java/im/molly/unifiedpush/model/UnifiedPushStatus.kt
@@ -10,6 +10,8 @@ enum class UnifiedPushStatus {
NO_DISTRIBUTOR,
PENDING,
LINK_DEVICE_ERROR,
+ AIR_GAPED_NOT_PINGED,
+ NOT_PINGED,
OK,
INTERNAL_ERROR,
UNKNOWN,
diff --git a/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt b/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt
index c4db35fa82..53e7f430d5 100644
--- a/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt
+++ b/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt
@@ -45,7 +45,9 @@ class UnifiedPushReceiver : MessagingReceiver() {
val msg = message.toString(Charsets.UTF_8)
if (msg.contains("\"test\":true")) {
Log.d(TAG, "Test message received.")
+ SignalStore.unifiedpush.pinged = true
UnifiedPushNotificationBuilder(context).setNotificationTest()
+ AppDependencies.jobManager.add(UnifiedPushRefreshJob())
return
}
if (KeyCachingService.isLocked()) {
diff --git a/app/src/unifiedpush/java/org/thoughtcrime/securesms/keyvalue/UnifiedPushValues.kt b/app/src/unifiedpush/java/org/thoughtcrime/securesms/keyvalue/UnifiedPushValues.kt
index 0643d6934a..43b5e07e24 100644
--- a/app/src/unifiedpush/java/org/thoughtcrime/securesms/keyvalue/UnifiedPushValues.kt
+++ b/app/src/unifiedpush/java/org/thoughtcrime/securesms/keyvalue/UnifiedPushValues.kt
@@ -18,6 +18,7 @@ class UnifiedPushValues(store: KeyValueStore) : SignalStoreValues(store) {
private const val UNIFIEDPUSH_ENABLED = "unifiedpush.enabled"
private const val UNIFIEDPUSH_PENDING = "unifiedpush.pending"
private const val UNIFIEDPUSH_AIR_GAPED = "unifiedpush.air_gaped"
+ private const val UNIFIEDPUSH_PINGED = "unifiedpush.pinged"
}
override fun onFirstEverAppLaunch() = Unit
@@ -50,6 +51,11 @@ class UnifiedPushValues(store: KeyValueStore) : SignalStoreValues(store) {
var airGaped: Boolean by booleanValue(UNIFIEDPUSH_AIR_GAPED, false)
+ // This is set to true by default to avoid warning previous users,
+ // It is set to false when registering a new device in
+ // im.molly.unifiedpush.device.MollySocketLinkedDevice
+ var pinged: Boolean by booleanValue(UNIFIEDPUSH_PINGED, true)
+
var mollySocketUrl: String? by stringValue(MOLLYSOCKET_URL, null)
var mollySocketFound: Boolean by booleanValue(MOLLYSOCKET_OK, false)
@@ -66,12 +72,15 @@ class UnifiedPushValues(store: KeyValueStore) : SignalStoreValues(store) {
SignalStore.unifiedpush.pending -> UnifiedPushStatus.PENDING
SignalStore.unifiedpush.device == null -> UnifiedPushStatus.LINK_DEVICE_ERROR
SignalStore.unifiedpush.endpoint == null -> UnifiedPushStatus.MISSING_ENDPOINT
+ SignalStore.unifiedpush.airGaped &&
+ !SignalStore.unifiedpush.pinged -> UnifiedPushStatus.AIR_GAPED_NOT_PINGED
SignalStore.unifiedpush.airGaped -> UnifiedPushStatus.AIR_GAPED
SignalStore.unifiedpush.mollySocketUrl.isNullOrBlank() ||
!SignalStore.unifiedpush.mollySocketFound -> UnifiedPushStatus.SERVER_NOT_FOUND_AT_URL
SignalStore.unifiedpush.mollySocketInternalError -> UnifiedPushStatus.INTERNAL_ERROR
SignalStore.unifiedpush.forbiddenUuid -> UnifiedPushStatus.FORBIDDEN_UUID
SignalStore.unifiedpush.forbiddenEndpoint -> UnifiedPushStatus.FORBIDDEN_ENDPOINT
+ !SignalStore.unifiedpush.pinged -> UnifiedPushStatus.NOT_PINGED
else -> UnifiedPushStatus.OK
}
}