Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
emil-wire authored Mar 15, 2024
2 parents 8a24958 + e1581cc commit 164c862
Show file tree
Hide file tree
Showing 193 changed files with 5,027 additions and 1,746 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle-run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2

- name: AVD cache
uses: buildjet/cache@v3
uses: buildjet/cache@v4
id: avd-cache
with:
path: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ lint/tmp/
# Autogenerated file with git hash information.
app/src/main/assets/version.txt
/intellij.gdsl

# Editor temporary files
*~
\#*#
10 changes: 10 additions & 0 deletions AR-builder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ pipeline {
}
}
}

stage('Keep builds forever if important') {
steps {
script {
if (params.SOURCE_BRANCH.startsWith("release/") || params.SOURCE_BRANCH == "develop" || params.SOURCE_BRANCH == "main" || params.SOURCE_BRANCH == "prod") {
currentBuild.keepLog = true
}
}
}
}
}
}

Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,29 @@ To do so, you will find instructions there, but you can do the following:
1. Create a [Crowdin account](https://crowdin.com/).
2. Request access to add translations in our [project](https://crowdin.com/project/wire-android-reloaded).
3. Translate away.

# App flavours

We have a few different app flavours with different intended usages. Each app flavour has a different icon background colour to enable easier distinction.
To see how they are customised in details, check [the flavour configuration file](./default.json).

| Name | Icon background colour | Description / Intended Usage | Logging Enabled | Default Backend |
|----------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|-----------------|
| Dev | 🔴 | For developing new features. Bleeding edge. Unstable. Staging Backend. Eats experimental features for breakfast and drinks developers tears as dessert. || Wire Staging |
| Staging | 🟡 | Mainly for QA to test a release-like app with a staging backend. Imitates the Production/Release application, having features flags following the Prod/White app below, but with extra dev tools. || Wire Staging |
| Internal | 🟢 | Currently unused (?). It was used in the past and _probably_ should be deleted any time soon. || Wire Prod |
| Beta | 🔵 | Used by internal users within the company as dogfood. Some features that are not yet ready for the general public might be tested here first. || Wire Prod |
| Prod || The production app available to the general public. | ✖️ | Wire Prod |
| F-Droid || Also a production app available to the general public. Published on the F-Droid store, but without any closed-source software. | ✖️ | Wire Prod |

## Logging
> [!IMPORTANT]
> Logs on all builds except Prod and F-Droid will be uploaded to a third party service for developer analysis.
>
> Logs on Prod and F-Droid can be enabled within the application, but they are **NOT** uploaded anywhere. Users can export and read the log files manually from the application.
>
> We do not log sensitive content (such as content of messages, encryption keys, etc.) in any way whatsoever. And things like unique identifiers are obfuscated.
## Build Types

The apps can be built for release or debugging. Debug versions might have extra debugging tools, are not minified, and can be profiled if needed. In general, debug builds _run slower_ due to the lack of minimisation.
21 changes: 21 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,29 @@ android {
jniLibs.pickFirsts.add("**/libsodium.so")
}
android.buildFeatures.buildConfig = true

var fdroidBuild = gradle.startParameter.taskRequests.toString().lowercase().contains("fdroid")
sourceSets {
// Add the "foss" sourceSets for the fdroid flavor
if(fdroidBuild) {
getByName("main") {
java.srcDirs("src/foss/kotlin", "src/prod/kotlin")
resources.srcDirs("src/prod/res")
println("Building with FOSS sourceSets")
}
// For all other flavors use the "nonfree" sourceSets
} else {
getByName("main") {
java.srcDirs("src/main/kotlin", "src/nonfree/kotlin")
println("Building with non-free sourceSets")
}
}
}
}




dependencies {
implementation("com.wire.kalium:kalium-logic")
implementation("com.wire.kalium:kalium-util")
Expand Down
16 changes: 9 additions & 7 deletions app/src/beta/kotlin/com/wire/android/util/DataDogLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ object DataDogLogger : LogWriter() {
.build()

override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
val attributes = KaliumLogger.UserClientData.getFromTag(tag)?.let { userClientData ->
mapOf(
"userId" to userClientData.userId,
"clientId" to userClientData.clientId,
)
} ?: emptyMap<String, Any?>()

val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag)
val userAccountData = mapOf(
"userId" to logInfo.userClientData?.userId,
"clientId" to logInfo.userClientData?.clientId,
)
val attributes = mapOf(
"wireAccount" to userAccountData,
"tag" to logInfo.textTag
)
when (severity) {
Severity.Debug -> logger.d(message, throwable, attributes)
Severity.Info -> logger.i(message, throwable, attributes)
Expand Down
16 changes: 9 additions & 7 deletions app/src/dev/kotlin/com/wire/android/util/DataDogLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ object DataDogLogger : LogWriter() {
.build()

override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
val attributes = KaliumLogger.UserClientData.getFromTag(tag)?.let { userClientData ->
mapOf(
"userId" to userClientData.userId,
"clientId" to userClientData.clientId,
)
} ?: emptyMap<String, Any?>()

val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag)
val userAccountData = mapOf(
"userId" to logInfo.userClientData?.userId,
"clientId" to logInfo.userClientData?.clientId,
)
val attributes = mapOf(
"wireAccount" to userAccountData,
"tag" to logInfo.textTag
)
when (severity) {
Severity.Debug -> logger.d(message, throwable, attributes)
Severity.Info -> logger.i(message, throwable, attributes)
Expand Down
39 changes: 39 additions & 0 deletions app/src/fdroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
Wire
Copyright (C) 2018 Wire Swiss GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.wire.android"
android:sharedUserId="${sharedUserId}">
<application>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
tools:node="remove" />
<meta-data
android:name="com.google.android.gms.version"
tools:node="remove" />
<service
android:name=".services.WireFirebaseMessagingService"
tools:node="remove" />
<meta-data
android:name="com.wire.android.initializer.FirebaseInitializer"
tools:node="remove" />

</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.home.messagecomposer.location

import android.content.Context
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class LocationPickerHelperFlavor @Inject constructor(context: Context) : LocationPickerHelper(context) {
suspend fun getLocation(onSuccess: (GeoLocatedAddress) -> Unit, onError: () -> Unit) {
getLocationWithoutGms(
onSuccess = onSuccess,
onError = onError
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*
*/

package com.wire.android.util.extension

import android.content.Context

fun Context.isGoogleServicesAvailable(): Boolean {
val returnValue: Boolean = false
return returnValue
}

fun Context.initGoogleFirebase() { /* Stub for compatibility */ }
16 changes: 9 additions & 7 deletions app/src/internal/kotlin/com/wire/android/util/DataDogLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ object DataDogLogger : LogWriter() {
.build()

override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
val attributes = KaliumLogger.UserClientData.getFromTag(tag)?.let { userClientData ->
mapOf(
"userId" to userClientData.userId,
"clientId" to userClientData.clientId,
)
} ?: emptyMap<String, Any?>()

val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag)
val userAccountData = mapOf(
"userId" to logInfo.userClientData?.userId,
"clientId" to logInfo.userClientData?.clientId,
)
val attributes = mapOf(
"wireAccount" to userAccountData,
"tag" to logInfo.textTag
)
when (severity) {
Severity.Debug -> logger.d(message, throwable, attributes)
Severity.Info -> logger.i(message, throwable, attributes)
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.wire.android"
android:sharedUserId="${sharedUserId}">
android:sharedUserId="${sharedUserId}"
android:installLocation="internalOnly"
>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -39,6 +41,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Expand Down Expand Up @@ -320,8 +323,7 @@
<service
android:name=".services.OngoingCallService"
android:exported="false"
android:foregroundServiceType="phoneCall" />

android:foregroundServiceType="phoneCall|microphone" />
</application>

</manifest>
37 changes: 37 additions & 0 deletions app/src/main/kotlin/com/wire/android/AppLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,53 @@ package com.wire.android

import com.wire.kalium.logger.KaliumLogLevel
import com.wire.kalium.logger.KaliumLogger
import com.wire.kalium.util.serialization.toJsonElement

private var appLoggerConfig = KaliumLogger.Config.disabled()

// App wide global logger, carefully initialized when our application is "onCreate"
internal var appLogger = KaliumLogger.disabled()

object AppLogger {
fun init(config: KaliumLogger.Config) {
appLoggerConfig = config
appLogger = KaliumLogger(config = config, tag = "WireAppLogger")
}

fun setLogLevel(level: KaliumLogLevel) {
appLoggerConfig.setLogLevel(level)
}
}

object AppJsonStyledLogger {
/**
* Log a structured JSON message, in the following format:
*
* Example:
* ```
* leadingMessage: {map of key-value pairs represented as JSON}
* ```
* @param level the severity of the log message
* @param error optional - the throwable error to be logged
* @param leadingMessage the leading message useful for later grok parsing
* @param jsonStringKeyValues the map of key-value pairs to be logged in a valid JSON format
*/
fun log(
level: KaliumLogLevel,
error: Throwable? = null,
leadingMessage: String,
jsonStringKeyValues: Map<String, Any?>
) = with(appLogger) {
val logJson = jsonStringKeyValues.toJsonElement()
val sanitizedLeadingMessage = if (leadingMessage.endsWith(":")) leadingMessage else "$leadingMessage:"
val logMessage = "$sanitizedLeadingMessage $logJson"
when (level) {
KaliumLogLevel.DEBUG -> d(logMessage)
KaliumLogLevel.INFO -> i(logMessage)
KaliumLogLevel.WARN -> w(logMessage)
KaliumLogLevel.ERROR -> e(logMessage, throwable = error)
KaliumLogLevel.VERBOSE -> v(logMessage)
KaliumLogLevel.DISABLED -> Unit
}
}
}
1 change: 1 addition & 0 deletions app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class WireApplication : Application(), Configuration.Provider {
override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setWorkerFactory(wireWorkerFactory.get())
.setMinimumLoggingLevel(android.util.Log.DEBUG)
.build()
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ class UseCaseModule {
fun provideIsMLSEnabledUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).isMLSEnabled

@ViewModelScoped
@Provides
fun provideGetDefaultProtocol(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).getDefaultProtocol

@ViewModelScoped
@Provides
fun provideIsE2EIEnabledUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
Expand Down Expand Up @@ -460,4 +465,9 @@ class UseCaseModule {
@Provides
fun provideObserveLegalHoldForUserUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).observeLegalHoldStateForUser

@ViewModelScoped
@Provides
fun provideMembersHavingLegalHoldClientUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).membersHavingLegalHoldClient
}
Loading

0 comments on commit 164c862

Please sign in to comment.