Skip to content

Commit

Permalink
Merge branch 'release/tchap_v1.99.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Renaud committed Feb 9, 2022
2 parents 997d758 + 81d2c51 commit a12f2b4
Show file tree
Hide file tree
Showing 67 changed files with 281 additions and 271 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [ GplayBtchapWithoutvoipWithpinning, FdroidBtchapWithoutvoipWithoutpinning ]
target: [ GplayPreprodWithoutvoipWithoutpinning, FdroidPreprodWithoutvoipWithoutpinning ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
Expand All @@ -46,7 +46,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [ GplayBtchapWithoutvoipWithpinning, GplayTchapWithoutvoipWithpinning, FdroidBtchapWithoutvoipWithoutpinning, FdroidTchapWithoutvoipWithoutpinning ]
target: [ GplayPreprodWithoutvoipWithoutpinning, GplayAgentWithoutvoipWithpinning, FdroidPreprodWithoutvoipWithoutpinning, FdroidAgentWithoutvoipWithoutpinning ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [ GplayBtchapWithoutvoipWithpinning, FdroidBtchapWithoutvoipWithoutpinning ]
target: [ GplayPreprodWithoutvoipWithoutpinning, FdroidPreprodWithoutvoipWithoutpinning ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [ GplayBtchapWithoutvoipWithpinning, FdroidBtchapWithoutvoipWithoutpinning ]
target: [ GplayPreprodWithoutvoipWithoutpinning, FdroidPreprodWithoutvoipWithoutpinning ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sanity_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
touch emulator.log
chmod 777 emulator.log
adb logcat >> emulator.log &
./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedGplayBtchapWithoutvoipWithpinningDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest || adb pull storage/emulated/0/Pictures/failure_screenshots && exit 1
./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedGplayPreprodWithoutvoipWithoutpinningDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest || adb pull storage/emulated/0/Pictures/failure_screenshots && exit 1
- name: Upload Failing Test Report Log
uses: actions/upload-artifact@v2
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Run unit tests
run: ./gradlew clean TestGplayBtchapWithoutvoipWithpinningDebugUnitTest $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false --stacktrace
run: ./gradlew clean TestGplayPreprodWithoutvoipWithoutpinningDebugUnitTest $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false --stacktrace
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always() &&
Expand Down
21 changes: 14 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ If an issue does not exist yet, it may be relevant to open a new issue and let u

This project is full Kotlin. Please do not write Java classes.

### TCHAP_CHANGES.md
### Tchap changes

Please add a comment upon each Tchap specific change compared to the Element codebase. The comment must be prefixed by `Tchap: ` to help developers
identifying this kind of changes and simplifying conflict resolution during the rebase against Element.
Also, add an explanation about why the changes are necessary for Tchap or why the behaviour is different from Element.

Please consider staying aligned as much as possible with the Element codebase, if a change or an improvement can be relevant for Element, prefer to add a
contribution in the Element repository.

Please add a line to the top of the file `TCHAP_CHANGES.md` describing your change.
### Changelog

Please create at least one file under ./changelog.d containing details about your change. Towncrier will be used when preparing the release.
Expand All @@ -49,10 +55,11 @@ Towncrier says to use the PR number for the filename, but the issue number is al

Supported filename extensions are:

- ``.feature``: Signifying a new feature in Element Android or in the Matrix SDK.
- ``.feature``: Signifying a new feature in Tchap Android.
- ``.improvements``: Signifying a feature improvement in Tchap Android.
- ``.bugfix``: Signifying a bug fix.
- ``.wip``: Signifying a work in progress change, typically a component of a larger feature which will be enabled once all tasks are complete.
- ``.doc``: Signifying a documentation improvement.
- ``.removal``: Signifying a deprecation or removal of public API. Can be used to notifying about API change in the Matrix SDK
- ``.misc``: Any other changes.

See https://github.com/twisted/towncrier#news-fragments if you need more details.
Expand Down Expand Up @@ -84,16 +91,16 @@ For ktlint to fix some detected errors for you (you still have to check and comm
#### lint

<pre>
./gradlew lintGplayBtchapWithoutvoipWithpinningRelease
./gradlew lintFdroidBtchapWithoutvoipWithoutpinningRelease
./gradlew lintGplayPreprodWithoutvoipWithoutpinningRelease
./gradlew lintFdroidPreprodWithoutvoipWithoutpinningRelease
</pre>

### Unit tests

Make sure the following commands execute without any error:

<pre>
./gradlew testGplayBtchapWithoutvoipWithpinningReleaseUnitTest
./gradlew testGplayPreprodWithoutvoipWithoutpinningReleaseUnitTest
</pre>

### Tests
Expand Down
16 changes: 16 additions & 0 deletions TCHAP_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
Changes in Tchap 1.99.5 (2022-02-09)
====================================

Improvements 🙌
--------------
- [Login] Handle correctly M_LIMIT_EXCEEDED error code ([#322](https://github.com/tchapgouv/tchap-android-v2/issues/322))
- [Workaround] Hide the text input in a DM left by the other member ([#405](https://github.com/tchapgouv/tchap-android-v2/issues/405))

Bugfixes 🐛
----------
- Fix potential missing rooms caused by the use of Spaces or low priority tags ([#389](https://github.com/tchapgouv/tchap-android-v2/issues/389))
- [Invitation by email] Handle correctly Id server consent ([#392](https://github.com/tchapgouv/tchap-android-v2/issues/392))
- [Workaround] Do not select a DM left by the other user ([#401](https://github.com/tchapgouv/tchap-android-v2/issues/401))
- Fix the push notifications which were not working for some devices ([#402](https://github.com/tchapgouv/tchap-android-v2/issues/402))


Changes in Tchap 1.99.4 (2022-01-26)
====================================

Expand Down
2 changes: 1 addition & 1 deletion docs/ui-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Click on the green arrow in front of each test. Clicking on the arrow in front o
### From command line

````shell script
./gradlew vector:connectedGplayBtchapWithoutvoipWithpinningDebugAndroidTest
./gradlew vector:connectedGplayPreprodWithoutvoipWithoutpinningDebugAndroidTest
````

To run all the tests from the `vector` module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ internal class TchapRoomGetter @Inject constructor(
// 1. join-join
// 2. invite-join
// 3. join-invite
// 4. join-left (or invite-left)
// The case left-x isn't possible because we ignore for the moment the left rooms.
// If other member user id is an email, we take the oldest room.

return directRoomMemberships.firstOrNull { it.first == Membership.JOIN && it.second == Membership.JOIN }?.roomId // join - join
?: directRoomMemberships.firstOrNull { it.first == Membership.INVITE && it.second == Membership.JOIN }?.roomId // invite - join
?: directRoomMemberships.firstOrNull { it.first == Membership.JOIN && it.second == Membership.INVITE }?.roomId // join - invite
?: directRoomMemberships.firstOrNull { it.first?.isActive() == true && it.second == Membership.LEAVE }?.roomId // join or invite - left
?: directRoomMemberships // otherUserId is an email
.takeIf { Patterns.EMAIL_ADDRESS.matcher(otherUserId).matches() }
?.firstOrNull { it.first == Membership.JOIN }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ fun Throwable.is401() =
fun Throwable.isTokenError() =
this is Failure.ServerError &&
(error.code == MatrixError.M_UNKNOWN_TOKEN ||
error.code == MatrixError.M_MISSING_TOKEN ||
error.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT)
error.code == MatrixError.M_MISSING_TOKEN ||
error.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT)

fun Throwable.isLimitExceededError() =
this is Failure.ServerError &&
httpCode == 429 &&
error.code == MatrixError.M_LIMIT_EXCEEDED

fun Throwable.shouldBeRetried(): Boolean {
return this is Failure.NetworkConnection ||
this is IOException ||
(this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
this.isLimitExceededError()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package org.matrix.android.sdk.internal.network
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.delay
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.failure.GlobalError
import org.matrix.android.sdk.api.failure.getRetryDelay
import org.matrix.android.sdk.api.failure.isLimitExceededError
import org.matrix.android.sdk.api.failure.shouldBeRetried
import org.matrix.android.sdk.internal.network.ssl.CertUtil
import retrofit2.HttpException
Expand All @@ -33,7 +34,8 @@ import java.io.IOException
*
* @param globalErrorReceiver will be use to notify error such as invalid token error. See [GlobalError]
* @param canRetry if set to true, the request will be executed again in case of error, after a delay
* @param maxDelayBeforeRetry the max delay to wait before a retry
* @param maxDelayBeforeRetry the max delay to wait before a retry. Note that in the case of a 429, if the provided delay exceeds this value, the error will
* be propagated as it does not make sense to retry it with a shorter delay.
* @param maxRetriesCount the max number of retries
* @param requestBlock a suspend lambda to perform the network request
*/
Expand Down Expand Up @@ -74,23 +76,26 @@ internal suspend inline fun <DATA> executeRequest(globalErrorReceiver: GlobalErr

currentRetryCount++

if (exception is Failure.ServerError &&
exception.httpCode == 429 &&
exception.error.code == MatrixError.M_LIMIT_EXCEEDED &&
currentRetryCount < maxRetriesCount) {
if (exception.isLimitExceededError() && currentRetryCount < maxRetriesCount) {
// 429, we can retry
delay(exception.getRetryDelay(1_000))
val retryDelay = exception.getRetryDelay(1_000)
if (retryDelay <= maxDelayBeforeRetry) {
delay(retryDelay)
} else {
// delay is too high to be retried, propagate the exception
throw exception
}
} else if (canRetry && currentRetryCount < maxRetriesCount && exception.shouldBeRetried()) {
delay(currentDelay)
currentDelay = currentDelay.times(2L).coerceAtMost(maxDelayBeforeRetry)
// Try again (loop)
} else {
throw when (exception) {
is IOException -> Failure.NetworkConnection(exception)
is IOException -> Failure.NetworkConnection(exception)
is Failure.ServerError,
is Failure.OtherServerError,
is CancellationException -> exception
else -> Failure.Unknown(exception)
is CancellationException -> exception
else -> Failure.Unknown(exception)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.failure.getRetryDelay
import org.matrix.android.sdk.api.failure.isLimitExceededError
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.CryptoService
import org.matrix.android.sdk.api.session.events.model.Event
Expand Down Expand Up @@ -145,17 +145,17 @@ internal class EventSenderProcessorCoroutine @Inject constructor(
task.execute()
} catch (exception: Throwable) {
when {
exception is IOException || exception is Failure.NetworkConnection -> {
exception is IOException || exception is Failure.NetworkConnection -> {
canReachServer.set(false)
task.markAsFailedOrRetry(exception, 0)
}
(exception is Failure.ServerError && exception.error.code == MatrixError.M_LIMIT_EXCEEDED) -> {
(exception.isLimitExceededError()) -> {
task.markAsFailedOrRetry(exception, exception.getRetryDelay(3_000))
}
exception is CancellationException -> {
exception is CancellationException -> {
Timber.v("## $task has been cancelled, try next task")
}
else -> {
else -> {
Timber.v("## un-retryable error for $task, try next task")
// this task is in error, check next one?
task.onTaskFailed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.auth.data.sessionId
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.failure.isLimitExceededError
import org.matrix.android.sdk.api.failure.isTokenError
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.CryptoService
Expand Down Expand Up @@ -171,7 +171,7 @@ internal class EventSenderProcessorThread @Inject constructor(
break@retryLoop
} catch (exception: Throwable) {
when {
exception is IOException || exception is Failure.NetworkConnection -> {
exception is IOException || exception is Failure.NetworkConnection -> {
canReachServer = false
if (task.retryCount.getAndIncrement() >= 3) task.onTaskFailed()
while (!canReachServer) {
Expand All @@ -180,25 +180,25 @@ internal class EventSenderProcessorThread @Inject constructor(
waitForNetwork()
}
}
(exception is Failure.ServerError && exception.error.code == MatrixError.M_LIMIT_EXCEEDED) -> {
(exception.isLimitExceededError()) -> {
if (task.retryCount.getAndIncrement() >= 3) task.onTaskFailed()
Timber.v("## SendThread retryLoop retryable error for $task reason: ${exception.localizedMessage}")
// wait a bit
// Todo if its a quota exception can we get timout?
sleep(3_000)
continue@retryLoop
}
exception.isTokenError() -> {
exception.isTokenError() -> {
Timber.v("## SendThread retryLoop retryable TOKEN error, interrupt")
// we can exit the loop
task.onTaskFailed()
throw InterruptedException()
}
exception is CancellationException -> {
exception is CancellationException -> {
Timber.v("## SendThread task has been cancelled")
break@retryLoop
}
else -> {
else -> {
Timber.v("## SendThread retryLoop Un-Retryable error, try next task")
// this task is in error, check next one?
task.onTaskFailed()
Expand Down
2 changes: 1 addition & 1 deletion tools/check/forbidden_strings_in_code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Formatter\.formatShortFileSize===1
# android\.text\.TextUtils

### This is not a rule, but a warning: the number of "enum class" has changed. For Json classes, it is mandatory that they have `@JsonClass(generateAdapter = false)`. If the enum is not used as a Json class, change the value in file forbidden_strings_in_code.txt
enum class===116
enum class===117

### Do not import temporary legacy classes
import org.matrix.android.sdk.internal.legacy.riot===3
Expand Down
47 changes: 47 additions & 0 deletions tools/release/sign_all_apks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

set -e

if [ "$#" -ne 2 ]
then
echo "Usage: ./sign_all_apks \$KEY \$FOLDER"
exit 1
fi

# Get the command line parameters
PARAM_KEYSTORE_PATH=$1
PARAM_DIRECTORY=$2
CHECKSUM_FILE="checksum.txt"

apkFiles=$(ls "$PARAM_DIRECTORY"/*.apk)
if [ "${#apkFiles[@]}" -eq 0 ]
then
echo "The directory doesn't contain apk files."
exit 1
fi

# Sign all the apks in the directory PARAM_DIRECTORY
for file in ${PARAM_DIRECTORY}/*.apk
do
echo "Signing.... ${file}"
sh ./sign_apk.sh "${PARAM_KEYSTORE_PATH}" "${file}"
done

# Rename and Hash all the apks in the directory PARAM_DIRECTORY
for file in ${PARAM_DIRECTORY}/*.apk
do
# Rename Apk: remove unsigned by signed
apkName="$(echo ${file} | sed -e 's/\-unsigned/-signed/')" ;
mv "${file}" "${apkName}" ;

# Hash application with SHA 256
echo "Hash SHA 256 on file... ${apkName}"
result="$(shasum "-a" "256" ${apkName})"

# Save hash in file: Checksum.txt
resultSplit=(${result})
newName="$(echo ${resultSplit[1]} | sed 's/.*\///')"
echo "SHA256(${newName})=${resultSplit[0]}" > ${PARAM_DIRECTORY}/${CHECKSUM_FILE}
done

echo "done !! :)"
2 changes: 1 addition & 1 deletion towncrier.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.towncrier]
version = "1.99.4"
version = "1.99.5"
directory = "changelog.d"
filename = "TCHAP_CHANGES.md"
name = "Changes in Tchap"
Expand Down
Loading

0 comments on commit a12f2b4

Please sign in to comment.