Push: improve Push history screen, log and stored data (#4601)
* Add adb tools to help with doze mode and app standby * Add info about the device state when an error occurs in push. * Keep more events in the DB. * Push history: add confirmation dialog when resetting the data * Push history: add a filter to see only the errors * Update screenshots * Push history: print out invalid/ignored data received. * Increase log level for push, to make such log more visible. It also appears that sometimes Timber.d are not present in the rageshakes. * Log priority * Do not include device state for invalid/ignored event. * Fix tests. * Fix format issue. * Fix mistake in code blocks and do not filter when not necessary. * Improve formatting and add missing unit test. * Reduce nesting of blocks. --------- Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
@@ -46,13 +46,14 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
|
||||
* @param instance connection, for multi-account
|
||||
*/
|
||||
override fun onMessage(context: Context, message: ByteArray, instance: String) {
|
||||
Timber.tag(loggerTag.value).d("New message")
|
||||
Timber.tag(loggerTag.value).w("New message")
|
||||
coroutineScope.launch {
|
||||
val pushData = pushParser.parse(message, instance)
|
||||
if (pushData == null) {
|
||||
Timber.tag(loggerTag.value).w("Invalid data received from UnifiedPush")
|
||||
pushHandler.handleInvalid(
|
||||
providerInfo = "${UnifiedPushConfig.NAME} - $instance",
|
||||
data = String(message),
|
||||
)
|
||||
} else {
|
||||
pushHandler.handle(
|
||||
@@ -68,7 +69,7 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
|
||||
* You should send the endpoint to your application server and sync for missing notifications.
|
||||
*/
|
||||
override fun onNewEndpoint(context: Context, endpoint: String, instance: String) {
|
||||
Timber.tag(loggerTag.value).i("onNewEndpoint: $endpoint")
|
||||
Timber.tag(loggerTag.value).w("onNewEndpoint: $endpoint")
|
||||
coroutineScope.launch {
|
||||
val gateway = unifiedPushGatewayResolver.getGateway(endpoint)
|
||||
.let { gatewayResult ->
|
||||
@@ -109,7 +110,7 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
|
||||
* Called when this application is unregistered from receiving push messages.
|
||||
*/
|
||||
override fun onUnregistered(context: Context, instance: String) {
|
||||
Timber.tag(loggerTag.value).d("Unifiedpush: Unregistered")
|
||||
Timber.tag(loggerTag.value).w("Unifiedpush: Unregistered")
|
||||
/*
|
||||
val mode = BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_FOR_REALTIME
|
||||
pushDataStore.setFdroidSyncBackgroundMode(mode)
|
||||
|
||||
@@ -90,7 +90,7 @@ class VectorUnifiedPushMessagingReceiverTest {
|
||||
@Test
|
||||
fun `onMessage invalid invokes the push handler invalid method`() = runTest {
|
||||
val context = InstrumentationRegistry.getInstrumentation().context
|
||||
val handleInvalidResult = lambdaRecorder<String, Unit> { }
|
||||
val handleInvalidResult = lambdaRecorder<String, String, Unit> { _, _ -> }
|
||||
val vectorUnifiedPushMessagingReceiver = createVectorUnifiedPushMessagingReceiver(
|
||||
pushHandler = FakePushHandler(
|
||||
handleInvalidResult = handleInvalidResult,
|
||||
|
||||
Reference in New Issue
Block a user