Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/gradle/com.github.tfcporciuncul…
Browse files Browse the repository at this point in the history
…a-flow-preferences-1.4.0
  • Loading branch information
kodiakhq[bot] authored Nov 27, 2023
2 parents b572a4b + 77f69c6 commit 33c2b48
Show file tree
Hide file tree
Showing 59 changed files with 1,200 additions and 807 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Cache Grade dependencies
uses: actions/cache@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ For the views material components were preferred whenever possible.
## Development

The project should build and run out-of-the-box with Android Studio 4+.
The minimum Android OS version supported is Android 5 (Lollipop, API 21).
The minimum Android OS version supported is Android 6 (Marshmallow, API 23).

### Run Android lint

Expand Down
89 changes: 57 additions & 32 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ buildscript {
}
dependencies {
classpath 'com.github.triplet.gradle:play-publisher:3.4.0'
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.7.0.0"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.8.2.1"
}
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.github.triplet.play'
Expand All @@ -28,13 +27,13 @@ repositories {
}

android {
compileSdkVersion 32
compileSdk 33
ndkVersion '21.3.6528147'

defaultConfig {
applicationId "tech.relaycorp.courier"
minSdkVersion 21
targetSdkVersion 32
minSdk 23
targetSdk 33
versionCode 1
versionName project.findProperty("versionName") ?: "0.1"

Expand Down Expand Up @@ -74,22 +73,24 @@ android {
}
}
}
buildFeatures {
viewBinding true
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
jvmTarget = JavaVersion.VERSION_17
}
packagingOptions {
exclude 'META-INF/*'
}
lintOptions {
checkAllWarnings true
warningsAsErrors true
abortOnError true
lintConfig file('lint.xml')
jniLibs {
excludes += ['META-INF/*']
}
resources {
excludes += ['META-INF/*']
}
}
sourceSets {
androidTest {
Expand All @@ -101,6 +102,13 @@ android {
resources.srcDirs += "src/sharedTest/resources"
}
}
lint {
abortOnError true
checkAllWarnings true
lintConfig file('lint.xml')
warningsAsErrors true
}
namespace 'tech.relaycorp.courier'
}

dependencies {
Expand All @@ -112,22 +120,23 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"

// Android
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'

// Dependency Injection
api 'com.google.dagger:dagger:2.42'
kapt 'com.google.dagger:dagger-compiler:2.42'
api 'com.google.dagger:dagger:2.43.2'
kapt 'com.google.dagger:dagger-compiler:2.43.2'

// Awala
implementation 'tech.relaycorp:awala:1.65.0'
implementation 'tech.relaycorp:cogrpc:1.1.27'
implementation 'tech.relaycorp:cogrpc-okhttp:1.1.15'
implementation 'tech.relaycorp:doh:1.0.10'
implementation 'tech.relaycorp:awala:1.66.4'
implementation 'tech.relaycorp:cogrpc:1.1.30'
implementation 'tech.relaycorp:cogrpc-okhttp:1.1.18'
implementation 'tech.relaycorp:doh:1.0.21'
testImplementation "tech.relaycorp:awala-testing:1.5.10"

// ORM
implementation "androidx.room:room-runtime:$roomVersion"
Expand Down Expand Up @@ -155,7 +164,7 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesVersion"
testImplementation 'org.mockito:mockito-inline:4.6.0'
testImplementation 'org.mockito:mockito-inline:4.7.0'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
testImplementation "io.grpc:grpc-testing:$grpcVersion"

Expand All @@ -164,11 +173,27 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesVersion"
androidTestImplementation "io.grpc:grpc-testing:$grpcVersion"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation('com.adevinta.android:barista:4.2.0') {
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1') {
exclude group: 'com.google.protobuf'
}
androidTestImplementation('com.adevinta.android:barista:4.3.0') {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'com.google.protobuf'
}
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.43.2'
}

configurations.all {
resolutionStrategy.eachDependency { details ->
/*
* Our TLS certificates are being rejected with OPENSSL_internal:NOT_ENOUGH_DATA
* on Netty 4.1.79.Final, so we're locking its version to 4.1.78.Final until we're able to fix the
* underlying issue
*/
if (details.requested.group == 'io.netty') {
details.useVersion nettyVersion
}
}
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.42'
}

spotless {
Expand All @@ -180,9 +205,9 @@ spotless {

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.freeCompilerArgs += [
'-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi',
'-Xuse-experimental=kotlinx.coroutines.FlowPreview',
'-Xuse-experimental=kotlin.time.ExperimentalTime'
'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
'-opt-in=kotlinx.coroutines.FlowPreview',
'-opt-in=kotlin.time.ExperimentalTime'
]
}

Expand Down
10 changes: 8 additions & 2 deletions app/firebase-test-lab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ spec:
test: app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
timeout: 30m
device:
# Nexus 5X (virtual)
- model: Nexus5X
# Nexus 5 (virtual)
- model: Nexus5
version: 23 # Android 6.0
locale: en
orientation: portrait

# Nexus 6 (virtual)
- model: Nexus6
version: 24 # Android 7.0
locale: en
orientation: portrait
Expand Down
6 changes: 3 additions & 3 deletions app/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ task jacocoAndroidTestReport(type: JacocoReport) {
}

reports {
html.enabled true
html.required = true
html.destination file("${buildDir}/reports/coverage")
xml.enabled true
xml.required = true
xml.destination file("${buildDir}/reports/coverage.xml")
csv.enabled false
csv.required = false
}

doLast {
Expand Down
4 changes: 4 additions & 0 deletions app/lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<issue id="LockedOrientationActivity" severity="ignore"/>
<issue id="ConvertToWebp" severity="ignore"/>
<issue id="CheckResult" severity="informational"/>
<issue id="MonochromeLauncherIcon" severity="informational"/>
<issue id="InvalidPackage">
<!-- Ignore errors about BC importing javax.naming because we don't use those modules -->
<ignore path="**/bcpkix-*.jar" />
Expand All @@ -15,8 +16,11 @@
<ignore path="**/grpc-core/**" />
<!-- Ignore errors about jacoco importing javax.management because we don’t use those modules -->
<ignore path="**/org.jacoco/**" />
<!-- io.ktor.util.debug.IntellijIdeaDebugDetector is not used in production -->
<ignore path="**/io.ktor/ktor-utils-jvm/**" />
</issue>
<issue id="TrustAllX509TrustManager">
<ignore path="org/bouncycastle/est/jcajce/*.class" />
<ignore regexp="bcpkix-jdk15on" />
</issue>
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"entities": [
{
"tableName": "Message",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`recipientAddress` TEXT NOT NULL, `recipientType` TEXT NOT NULL, `senderAddress` TEXT NOT NULL, `messageId` TEXT NOT NULL, `messageType` TEXT NOT NULL, `creationTimeUtc` INTEGER NOT NULL, `expirationTimeUtc` INTEGER NOT NULL, `storagePath` TEXT NOT NULL, `size` INTEGER NOT NULL, PRIMARY KEY(`senderAddress`, `messageId`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`recipientAddress` TEXT NOT NULL, `recipientType` TEXT NOT NULL, `senderId` TEXT NOT NULL, `messageId` TEXT NOT NULL, `messageType` TEXT NOT NULL, `creationTimeUtc` INTEGER NOT NULL, `expirationTimeUtc` INTEGER NOT NULL, `storagePath` TEXT NOT NULL, `size` INTEGER NOT NULL, PRIMARY KEY(`senderId`, `messageId`))",
"fields": [
{
"fieldPath": "recipientAddress",
Expand All @@ -21,8 +21,8 @@
"notNull": true
},
{
"fieldPath": "senderAddress",
"columnName": "senderAddress",
"fieldPath": "senderId",
"columnName": "senderId",
"affinity": "TEXT",
"notNull": true
},
Expand Down Expand Up @@ -65,7 +65,7 @@
],
"primaryKey": {
"columnNames": [
"senderAddress",
"senderId",
"messageId"
],
"autoGenerate": false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package tech.relaycorp.courier.domain

import android.os.Build
import io.grpc.internal.testing.StreamRecorder
import io.grpc.stub.MetadataUtils
import junit.framework.TestCase.assertNull
import junit.framework.TestCase.assertTrue
import kotlinx.coroutines.runBlocking
import org.junit.Assume.assumeTrue
import org.junit.Before
import org.junit.Test
import tech.relaycorp.cogrpc.okhttp.OkHTTPChannelBuilderProvider
Expand All @@ -30,6 +32,12 @@ class PrivateSyncTest {

@Test
fun privateSync() {
// Related issue: https://github.com/relaycorp/relaynet-courier-android/issues/584
assumeTrue(
"Test is currently failing on API 23 and lower due to a grpc internal issue",
Build.VERSION.SDK_INT >= 24
)

Networking.androidGatewaySubnetPrefix = null
runBlocking { privateSync.startSync() }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package tech.relaycorp.courier.ui.settings

import androidx.test.espresso.Espresso.onIdle
import com.google.android.material.slider.Slider
import com.adevinta.android.barista.assertion.BaristaEnabledAssertions.assertDisabled
import com.adevinta.android.barista.assertion.BaristaEnabledAssertions.assertEnabled
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertContains
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -51,11 +55,11 @@ class SettingsActivityTest {
}

@Test
fun clearButtonDisabledWithData() {
runBlocking {
storedMessageDao.insert(StoredMessageFactory.build())
}
fun clearButtonDisabledWithData() = runTest(StandardTestDispatcher()) {
storedMessageDao.insert(StoredMessageFactory.build())
advanceUntilIdle()
testRule.start()
onIdle()
assertEnabled(R.id.deleteData)
}

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="tech.relaycorp.courier">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
16 changes: 6 additions & 10 deletions app/src/main/java/tech/relaycorp/cogrpc/server/CogRPCServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import java.net.InetSocketAddress
import java.security.Security
import java.util.concurrent.TimeUnit
import java.util.logging.Level
import kotlin.math.roundToLong
import kotlin.time.minutes
import kotlin.time.seconds
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds

class CogRPCServer
internal constructor(
Expand Down Expand Up @@ -54,12 +53,9 @@ internal constructor(
.maxInboundMessageSize(MAX_MESSAGE_SIZE)
.maxInboundMetadataSize(MAX_METADATA_SIZE)
.maxConcurrentCallsPerConnection(MAX_CONCURRENT_CALLS_PER_CONNECTION)
.maxConnectionAge(MAX_CONNECTION_AGE.inSeconds.roundToLong(), TimeUnit.SECONDS)
.maxConnectionAgeGrace(
MAX_CONNECTION_AGE_GRACE.inSeconds.roundToLong(),
TimeUnit.SECONDS
)
.maxConnectionIdle(MAX_CONNECTION_IDLE.inSeconds.roundToLong(), TimeUnit.SECONDS)
.maxConnectionAge(MAX_CONNECTION_AGE.inWholeSeconds, TimeUnit.SECONDS)
.maxConnectionAgeGrace(MAX_CONNECTION_AGE_GRACE.inWholeSeconds, TimeUnit.SECONDS)
.maxConnectionIdle(MAX_CONNECTION_IDLE.inWholeSeconds, TimeUnit.SECONDS)
.useTransportSecurity(
certGenerator.exportCertificate().inputStream(),
certGenerator.exportPrivateKey().inputStream()
Expand All @@ -83,7 +79,7 @@ internal constructor(
fun stop() {
server
?.shutdown()
?.awaitTermination(TERMINATION_TIMEOUT.inSeconds.toLong(), TimeUnit.SECONDS)
?.awaitTermination(TERMINATION_TIMEOUT.inWholeSeconds, TimeUnit.SECONDS)
server = null

job.cancel()
Expand Down
Loading

0 comments on commit 33c2b48

Please sign in to comment.