Commit Graph

4738 Commits

Author SHA1 Message Date
Maciej Surmacz de20977ea1 Triggers a ping worker from the event loop on any IOException
Other error can be indications of the BE being blocked, not just
the ConnectException. We might end up in a state when the event
loop always fails in the background without trying to unblock the
network communication.

MAILAND-2980
2022-09-14 11:47:12 +02:00
Maciej Surmacz 548f5d61db Closes the response body before the retry
In some situations, not closing the body before retrying would crash
the application.

MAILAND-2980
2022-09-14 11:47:12 +02:00
Maciej Surmacz 99d188994a Ignores canceled exceptions when deciding if server reachable
The canceled exception happens when a flow is cancelled while the
network call is being made. As such, it should not be an indication
of the server not being reachable, nor should we retry the call
when it happens.

MAILAND-2980
2022-09-14 11:47:12 +02:00
Maciej Surmacz e5e7ff4091 Informs the job manager as soon as the server reachable status changes
This way the jobs that require network will run as soon as we determine
that the server is indeed reachable.

Additionally, changes a name of a flow to a more meaningful one.

Finally, fixes synchronisation of the hasConn function- before it was
synchronised on a boolean, which is a mistake. On top of that, the read
and the write functions were being synchronised in different ways,
using different objects as locks.

MAILAND-2980
2022-09-14 11:47:11 +02:00
Maciej Surmacz 7ed2a8d2e2 Starts observing counters only once in the mailbox view model
Previously, we would restart observing the counters every time
user id, location, label or refresh flow emitted. This would result
in the counters network call being started multiple times in a sequence,
the old calls being immediately cancelled. This would throw an
IOException, which in turn was interpreted as server not reachable.

Now we only start observing the counters once, which eliminates the
behaviour described above.

MAILAND-2980
2022-09-14 11:45:44 +02:00
Maciej Surmacz acee0c2a92 Merge branch 'fix/2981_try-switching-away-from-proxy-more-frequently' into 'develop'
Switches away from proxy as soon as main BE is available

See merge request android/mail/proton-mail-android!1167
2022-09-14 09:36:14 +00:00
Maciej Surmacz cd36ddcd4e Adds the retry interceptor missing after merging network call retry
MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz a7dec66ca2 Adds a log to check how long before we switch back to the main BE
Additionally removes some unused code that could've potentially be
misused.

MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz 8eb5f3e132 Fixes network configurator test
MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz bf59959deb Renames the switch class
Additionally, introduces a result class to be more explicit about the
possible outcomes.

The ping worker also updates the connectivity status in the app
accordingly when the switch succeeded.

MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz 131f0c8cbb Adds a class to try to switch to the main backend only when on proxy
This class is used by the ping worker- this way, when switched to
a proxy, we will try to ping the main BE with each ping worker
execution, and switch to the main BE as soon as it's available.

MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz c8e03b3050 Adds a class to try to switch to the main backend if it is available
This is used now at the start of the process of finding an alternative
routing. Before, the ping was executed against the current endpoint,
which would be a proxy when we were on a proxy, and thus not doing
what we wanted it to do.

MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz f3494edfe1 Removes the auto-retry code that was no longer used
Clean up to reduce some noise

MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz 3c8768b431 Refactors NetworkSwitcher class and adds tests
MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz 54a8d2978e Injects the main backend api into the api manager class
In order to check if the main backend is available even when we are
switch to a proxy, we need to always have access to the main backend.
This is achieved by injecting two instances of api to the api manager
class: one that can be reset when we switch to a proxy, and the other
one always pointing to the main BE. The main BE one is only used to
execute the ping call.

MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz 695dadba72 Synchronizes the call to rebuild api when switching to a proxy
This call is triggered from the okhttp interceptors, which are executed
on background threads, potentially concurrently. This might result
in the cache being inconsistent and holding wrong api instance for
a given URL.

MAILAND-2981
2022-09-14 07:46:49 +00:00
Maciej Surmacz 1b113226f7 Merge branch 'fix/2990_catch-network-errors-when-froce-fetching-events' into 'develop'
Catches the network exceptions when force-fetching events throws

See merge request android/mail/proton-mail-android!1171
2022-09-13 12:19:36 +00:00
Maciej Surmacz 9f4633ae14 Catches the network exceptions when force-fetching events throws
MAILAND-2990
2022-09-12 12:42:40 +02:00
Maciej Surmacz 4d2a469632 Merge branch 'feat/2980_add-retry-mechanism-to-network-calls' into 'develop'
Introduces a retry mechanism to all network calls

See merge request android/mail/proton-mail-android!1161
2022-09-06 08:38:46 +00:00
Maciej Surmacz 39127aa5d5 Adds the RetryInterceptor to the okhttp chain
This interceptor is last in the chain. This mean it will be the last one
to process a request (without modifying it any further) and the first
one to process a response (retry the request if needed).

MAILAND-2980
2022-09-06 07:39:35 +00:00
Maciej Surmacz ce4801ef5f Introduces a RetryRequestInterceptor class
This interceptor uses the TryWithExponentialBackoff class to
retry the network calls, if the call result (error or a response)
is retryable. If all the retries have failed, the result is propagated
to the next interceptor in the chain.

This commit also includes definitions of which errors and responses
are considered retryabale.

MAILAND-2980
2022-09-06 07:39:35 +00:00
Maciej Surmacz 75a2c97d09 Introduces a TryWithExponentialBackoff class
This class uses TryWithRetry and waits before each retry using the
exponential backoff mechanism.

MAILAND-2980
2022-09-06 07:39:35 +00:00
Maciej Surmacz ddf6a3dc98 Extends the tryWithRetry class with extra functionality
The class now takes three blocks:
- to determine if the error is retryable,
- to determine if the result is retryable,
- to execute before each retry.

MAILAND-2980
2022-09-06 07:39:35 +00:00
Zorica Stojchevska 8570f9b578 Merge branch 'chore/translations-2022-08-29_062709' into 'develop'
i18n: Upgrade translations from crowdin (eb53182d).

See merge request android/mail/proton-mail-android!1162
2022-09-02 08:03:00 +00:00
proton-ci 3ea146a2c5 i18n: Upgrade translations from crowdin (eb53182d). 2022-09-02 07:03:05 +00:00
Zorica Stojchevska 7bdef95d0c Merge branch 'fix/contact_robot_test_fix' into 'develop'
Remove delay on ContactRobot

See merge request android/mail/proton-mail-android!1168
2022-09-01 14:47:12 +00:00
Zorica Stojchevska 446846a52b Remove delay on ContactRobot 2022-09-01 15:47:16 +02:00
Zorica Stojchevska 0591ad96f6 Merge branch 'fix/appetize' into 'develop'
Use core appetize

See merge request android/mail/proton-mail-android!1165
2022-09-01 10:51:54 +00:00
Zorica Stojchevska f9504ed7b4 Use core appetize 2022-09-01 12:22:05 +02:00
Zorica Stojchevska eb53182da1 Changed build version
#comment Just changed the version for a new release
Affected: nothing
2022-08-24 11:07:46 +02:00
Zorica Stojchevska 6b0097a986 Merge branch 'fix/sending_failed_invalid_sender' into 'develop'
Notify the user properly when sending fails because of `Invalid Sender`

See merge request android/mail/proton-mail-android!1159
2022-08-24 08:56:40 +00:00
Zorica Stojchevska aa806e8475 Notify the user in composer when saving draft fails with `Invalid
Sender`
2022-08-24 09:52:32 +02:00
Zorica Stojchevska 903be26468 Notify the user properly when sending fails because of `Invalid Sender` 2022-08-23 19:43:31 +00:00
Zorica Stojchevska e6834feecd Changed build version
#comment Just changed the version for a new release
Affected: nothing
2022-08-23 20:07:55 +02:00
Zorica Stojchevska 1c520fd79d Merge branch 'chore/translations-2022-08-22_062425' into 'develop'
i18n: Upgrade translations from crowdin (5ba03980).

See merge request android/mail/proton-mail-android!1160
2022-08-23 08:13:37 +00:00
proton-ci ed3e596cce i18n: Upgrade translations from crowdin (5ba03980). 2022-08-22 06:24:25 +00:00
Maciej Surmacz 5ba03980e0 Merge branch 'fix/continue-observing-counters-when-network-call-fails' into 'develop'
Fixes the counters flow stopping after a network error

See merge request android/mail/proton-mail-android!1156
2022-08-17 15:35:47 +00:00
Maciej Surmacz f6eeec9fe7 Fixes the counters flow stopping when network error happened
If an error happened while trying to fetch the counters from the BE,
the flow would stop emitting. This means the counter in the mailbox
would stop updating automatically at this point.

Fixed by catching the exception on the inner flow, otherwise, if the
exception was caught on the outer flow, the inner flow would get
cancelled and stop emitting.
2022-08-17 14:43:36 +00:00
Denys Zelenchuk 037c835f2a Merge branch 'test/fusion-migration' into 'develop'
Migrate to fusion test framework.

See merge request android/mail/proton-mail-android!1158
2022-08-17 10:50:54 +00:00
Denys Zelenchuk 32ef96d97d Fixed MRs commits - updated onboarding flag in BaseTest, increased test case toast timeout, cleaned up unnecessary commented code. 2022-08-17 11:41:11 +02:00
Denys Zelenchuk 37abad58fc Migrate to fusion test framework. 2022-08-17 11:41:11 +02:00
Maciej Surmacz 9b2f37be14 Merge branch 'fix/stop-mailbox-state-emitters-when-mailbox-in-bg' into 'develop'
Stops mailbox emissions from the viewmodel when the activity is in bg

See merge request android/mail/proton-mail-android!1155
2022-08-17 07:53:23 +00:00
Maciej Surmacz f1e1447f41 Stops observing the mailbox counters when screen in bg
This is mostly a fix for excessive counter calls we make, even when
the app is in bg. Currently two calls to fetch counters are made
every 30s, even if the app is in the bg. This is quite wasteful and
puts strain on the BE (we were already made aware of the excessive
calls we make to those endpoints).
2022-08-17 07:03:19 +00:00
Zorica Stojchevska a29c857b84 Merge branch 'chore/translations-2022-08-15_062811' into 'develop'
i18n: Upgrade translations from crowdin (4fa4164f).

See merge request android/mail/proton-mail-android!1157
2022-08-16 11:52:46 +00:00
proton-ci a0bc73631b i18n: Upgrade translations from crowdin (4fa4164f). 2022-08-15 06:28:12 +00:00
Zorica Stojchevska 4fa4164faa Revert HV to version 2 2022-08-12 09:53:38 +02:00
Zorica Stojchevska 39a8136c95 Merge branch 'fix/fixes_some_crashes' into 'develop'
Fixes crashes when clicking on a link can't open the link in another app

See merge request android/mail/proton-mail-android!1151
2022-08-10 17:16:56 +00:00
Zorica Stojchevska 7118edc500 Fixes crashes when clicking on a link can't open the link in another app 2022-08-09 09:28:41 +00:00
Maciej Surmacz 6f87358568 Merge branch 'chore/sentry-fixes' into 'develop'
Uses the SentryAndroid class to init sentry and re-enables the sentry plugin

See merge request android/mail/proton-mail-android!1153
2022-08-08 10:40:54 +00:00
Maciej Surmacz 99ec9ab88f Reintroduces the sentry plugin and updates the sentry version
The timber and okhttp breadcrumb integrations are disabled.

MAILAND-2972
2022-08-08 07:29:22 +00:00