Skip to content

Commit

Permalink
Merge branch 'epic/new-sso-login-flow' into feat/newlogin-sso
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina authored Feb 24, 2025
2 parents 7ecb449 + 52262c4 commit 0634377
Show file tree
Hide file tree
Showing 279 changed files with 3,991 additions and 1,900 deletions.
54 changes: 54 additions & 0 deletions .github/actions/deploy-to-s3/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,57 @@ runs:
GITHUB_TOKEN: ${{ inputs.github-token }}
run: |
gh pr comment "${{ github.event.pull_request.number }}" --body "Built [wire-android-${{ inputs.build-flavour }}-${{ inputs.build-variant }}-pr-${{ github.event.pull_request.number }}.apk](${{ steps.upload.outputs.file-url }}) is available for download"
- name: Extract version and version code from APK filename
shell: bash
run: |
filename=${{ steps.path.outputs.apk_full_path }}
# Extract version name and version code
version=$(echo "$filename" | sed -E 's/.*-v([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
version_code=$(echo "$filename" | sed -E 's/.*-([0-9]+)-${{ inputs.build-flavour }}-${{ inputs.build-variant }}\.apk/\1/')
# Print the extracted version and version code
echo "Extracted version: v$version"
echo "Extracted version code: $version_code"
# set them as environment variables for later use
echo "VERSION=v$version" >> $GITHUB_ENV
echo "VERSION_CODE=$version_code" >> $GITHUB_ENV
- name: Rename mapping file
if: ${{ inputs.build-variant != 'debug' }}
shell: bash
id: mapping
run: |
capitalized_variant=$(echo "${{ inputs.build-variant }}" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')
echo "Capitalized Variant: $capitalized_variant"
mapping_full_path="app/build/outputs/mapping/${{ inputs.build-flavour }}${capitalized_variant}/mapping.txt"
new_mapping_file_name="mapping-${{ env.VERSION }}-${{ env.VERSION_CODE }}-${{ inputs.build-flavour }}-${{ inputs.build-variant }}.txt"
mv "$mapping_full_path" "$new_mapping_file_name"
# Set the new mapping file name as an environment variable
echo "new_mapping_file_name=$new_mapping_file_name" >> $GITHUB_ENV
- name: Upload mapping file to S3 from branch
if: ${{ github.event.pull_request.number == '' && inputs.build-variant != 'debug' }}
id: upload-mapping-from-branch
uses: hkusu/[email protected]
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: 'eu-central-1'
aws-bucket: ${{ inputs.aws-bucket }}
destination-dir: "megazord/android/reloaded/${{ inputs.build-flavour }}/${{ inputs.build-variant }}/"
file-path: ${{ env.new_mapping_file_name }}
output-file-url: 'false'
public: false
- name: Upload mapping file to S3 from PR
if: ${{ github.event.pull_request.number != '' && inputs.build-variant != 'debug' }}
id: upload-mapping-from-PR
uses: hkusu/[email protected]
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: 'eu-central-1'
aws-bucket: ${{ inputs.aws-bucket }}
destination-dir: "megazord/android/reloaded/${{ inputs.build-flavour }}/${{ inputs.build-variant }}/PR-${{ github.event.pull_request.number }}/"
file-path: ${{ env.new_mapping_file_name }}
output-file-url: 'false'
public: false
2 changes: 1 addition & 1 deletion .github/workflows/gradle-run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
merge-multiple: true

- name: Upload code coverage to codecov
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "app/build/reports/kover/report.xml"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/checkout@v4

- name: Download and Extract Artifacts
uses: dawidd6/action-download-artifact@v7
uses: dawidd6/action-download-artifact@v8
with:
run_id: ${{ github.event.workflow_run.id }}
path: artifacts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import com.wire.android.ui.WireActivity
import com.wire.android.util.DataDogLogger
import com.wire.kalium.logger.KaliumLogLevel
import com.wire.kalium.logger.KaliumLogger
import com.wire.kalium.logic.CoreLogger
import com.wire.kalium.common.logger.CoreLogger
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import kotlinx.coroutines.test.runTest
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<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" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

<!-- needed to switch between speaker/earpiece -->
<uses-permission android:name="android.permission.BLUETOOTH" />
Expand Down Expand Up @@ -313,6 +314,12 @@
<receiver
android:name=".notification.broadcastreceivers.EndOngoingCallReceiver"
android:exported="false" />
<receiver
android:name=".notification.broadcastreceivers.PlayPauseAudioMessageReceiver"
android:exported="false" />
<receiver
android:name=".notification.broadcastreceivers.StopAudioMessageReceiver"
android:exported="false" />

<service
android:name=".services.WireFirebaseMessagingService"
Expand Down Expand Up @@ -351,6 +358,11 @@
android:name=".services.CallService"
android:exported="false"
android:foregroundServiceType="phoneCall|microphone" />

<service
android:name=".services.PlayingAudioMessageService"
android:exported="false"
android:foregroundServiceType="mediaPlayback" />
</application>

</manifest>
17 changes: 13 additions & 4 deletions app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import com.wire.android.util.lifecycle.ConnectionPolicyManager
import com.wire.android.workmanager.WireWorkerFactory
import com.wire.kalium.logger.KaliumLogLevel
import com.wire.kalium.logger.KaliumLogger
import com.wire.kalium.logic.CoreLogger
import com.wire.kalium.common.logger.CoreLogger
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.feature.session.CurrentSessionResult
import dagger.Lazy
Expand Down Expand Up @@ -182,7 +182,7 @@ class WireApplication : BaseApp() {

private suspend fun initializeApplicationLoggingFrameworks() {
// 1. Datadog should be initialized first
ExternalLoggerManager.initDatadogLogger(applicationContext, globalDataStore.get())
ExternalLoggerManager.initDatadogLogger(applicationContext)
// 2. Initialize our internal logging framework
val isLoggingEnabled = globalDataStore.get().isLoggingEnabled().first()
val config = if (isLoggingEnabled) {
Expand All @@ -208,7 +208,7 @@ class WireApplication : BaseApp() {
private fun initializeAnonymousAnalytics() {
if (!BuildConfig.ANALYTICS_ENABLED) return

val anonymousAnalyticsRecorder = AnonymousAnalyticsRecorderImpl()
val anonymousAnalyticsRecorder = AnonymousAnalyticsRecorderImpl(BuildConfig.VERSION_NAME, BuildConfig.APP_NAME)
val analyticsSettings = AnalyticsSettings(
countlyAppKey = BuildConfig.ANALYTICS_APP_KEY,
countlyServerUrl = BuildConfig.ANALYTICS_SERVER_URL,
Expand Down Expand Up @@ -254,7 +254,16 @@ class WireApplication : BaseApp() {
.isAppVisibleFlow()
.filter { isVisible -> isVisible }
.collect {
AnonymousAnalyticsManagerImpl.sendEvent(AnalyticsEvent.AppOpen)
val currentSessionResult = coreLogic.get().getGlobalScope().session.currentSessionFlow().first()
val isTeamMember = if (currentSessionResult is CurrentSessionResult.Success) {
coreLogic.get().getSessionScope(currentSessionResult.accountInfo.userId).team.isSelfATeamMember()
} else {
null
}

AnonymousAnalyticsManagerImpl.sendEvent(
AnalyticsEvent.AppOpen(isTeamMember)
)
}
}
}
Expand Down
18 changes: 6 additions & 12 deletions app/src/main/kotlin/com/wire/android/datastore/GlobalDataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex
private val MIGRATION_COMPLETED = booleanPreferencesKey("migration_completed")
private val WELCOME_SCREEN_PRESENTED = booleanPreferencesKey("welcome_screen_presented")
private val IS_LOGGING_ENABLED = booleanPreferencesKey("is_logging_enabled")
private val IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED =
booleanPreferencesKey("is_encrypted_proteus_storage_enabled")
private val APP_LOCK_PASSCODE = stringPreferencesKey("app_lock_passcode")
private val APP_LOCK_SOURCE = intPreferencesKey("app_lock_source")
private val ENTER_TO_SENT = booleanPreferencesKey("enter_to_sent")

val APP_THEME_OPTION = stringPreferencesKey("app_theme_option")
val RECORD_AUDIO_EFFECTS_CHECKBOX = booleanPreferencesKey("record_audio_effects_checkbox")
Expand Down Expand Up @@ -104,16 +103,6 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex
context.dataStore.edit { it[RECORD_AUDIO_EFFECTS_CHECKBOX] = enabled }
}

fun isEncryptedProteusStorageEnabled(): Flow<Boolean> =
getBooleanPreference(
IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED,
BuildConfig.ENCRYPT_PROTEUS_STORAGE
)

suspend fun setEncryptedProteusStorageEnabled(enabled: Boolean) {
context.dataStore.edit { it[IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED] = enabled }
}

suspend fun setMigrationCompleted() {
context.dataStore.edit { it[MIGRATION_COMPLETED] = true }
}
Expand Down Expand Up @@ -244,4 +233,9 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex
fun selectedThemeOptionFlow(): Flow<ThemeOption> =
getStringPreference(APP_THEME_OPTION, ThemeOption.SYSTEM.toString())
.map { ThemeOption.valueOf(it) }

fun enterToSendFlow(): Flow<Boolean> = getBooleanPreference(ENTER_TO_SENT, false)
suspend fun setEnterToSend(enabled: Boolean) {
context.dataStore.edit { it[ENTER_TO_SENT] = enabled }
}
}
6 changes: 6 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.app.NotificationManager
import android.content.Context
import android.location.Geocoder
import android.media.AudioAttributes
import android.media.AudioManager
import android.media.MediaPlayer
import androidx.core.app.NotificationManagerCompat
import com.wire.android.BuildConfig
Expand All @@ -48,6 +49,7 @@ annotation class CurrentAppVersion

@Module
@InstallIn(SingletonComponent::class)
@Suppress("TooManyFunctions")
object AppModule {

@CurrentAppVersion
Expand Down Expand Up @@ -104,4 +106,8 @@ object AppModule {

@Provides
fun provideAnonymousAnalyticsManager(): AnonymousAnalyticsManager = AnonymousAnalyticsManagerImpl

@Provides
fun provideAudioManager(@ApplicationContext context: Context): AudioManager =
context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
}
15 changes: 0 additions & 15 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,6 @@ class UseCaseModule {
): ObserveSecurityClassificationLabelUseCase =
coreLogic.getSessionScope(currentAccount).observeSecurityClassificationLabel

@ViewModelScoped
@Provides
fun provideCreateBackupUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).backup.create

@ViewModelScoped
@Provides
fun provideVerifyBackupUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).backup.verify

@ViewModelScoped
@Provides
fun provideRestoreBackupUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).backup.restore

@ViewModelScoped
@Provides
fun provideUpdateApiVersionsScheduler(@KaliumCoreLogic coreLogic: CoreLogic) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,20 @@ package com.wire.android.di
import android.content.Context
import android.os.Build
import com.wire.android.BuildConfig
import com.wire.android.datastore.GlobalDataStore
import com.wire.android.util.isWebsocketEnabledByDefault
import com.wire.kalium.logic.featureFlags.BuildFileRestrictionState
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking

@Module
@InstallIn(SingletonComponent::class)
class KaliumConfigsModule {

@Provides
fun provideKaliumConfigs(globalDataStore: GlobalDataStore, context: Context): KaliumConfigs {
fun provideKaliumConfigs(context: Context): KaliumConfigs {
val fileRestriction: BuildFileRestrictionState = if (BuildConfig.FILE_RESTRICTION_ENABLED) {
BuildConfig.FILE_RESTRICTION_LIST.split(",").map { it.trim() }.let {
BuildFileRestrictionState.AllowSome(it)
Expand All @@ -55,7 +52,7 @@ class KaliumConfigsModule {
lowerKeyingMaterialsUpdateThreshold = BuildConfig.PRIVATE_BUILD,
developmentApiEnabled = BuildConfig.DEVELOPMENT_API_ENABLED,
ignoreSSLCertificatesForUnboundCalls = BuildConfig.IGNORE_SSL_CERTIFICATES,
encryptProteusStorage = runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() },
encryptProteusStorage = true,
guestRoomLink = BuildConfig.ENABLE_GUEST_ROOM_LINK,
selfDeletingMessages = BuildConfig.SELF_DELETING_MESSAGES,
wipeOnCookieInvalid = BuildConfig.WIPE_ON_COOKIE_INVALID,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Wire
* Copyright (C) 2025 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.di.accountScoped

import com.wire.android.di.CurrentAccount
import com.wire.android.di.KaliumCoreLogic
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.backup.BackupScope
import com.wire.kalium.util.DelicateKaliumApi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@Module
@InstallIn(ViewModelComponent::class)
class BackupModule {

@ViewModelScoped
@Provides
fun provideBackupScope(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId): BackupScope =
coreLogic.getSessionScope(currentAccount).backup

@ViewModelScoped
@Provides
fun provideCreateBackupUseCase(backupScope: BackupScope) =
backupScope.create

@ViewModelScoped
@Provides
fun provideVerifyBackupUseCase(backupScope: BackupScope) =
backupScope.verify

@ViewModelScoped
@Provides
fun provideRestoreBackupUseCase(backupScope: BackupScope) =
backupScope.restore

@OptIn(DelicateKaliumApi::class)
@ViewModelScoped
@Provides
fun provideOnboardingBackupUseCase(backupScope: BackupScope) =
backupScope.createUnEncryptedCopy
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.wire.kalium.logic.feature.call.usecase.EndCallOnConversationChangeUse
import com.wire.kalium.logic.feature.call.usecase.EndCallUseCase
import com.wire.kalium.logic.feature.call.usecase.FlipToBackCameraUseCase
import com.wire.kalium.logic.feature.call.usecase.FlipToFrontCameraUseCase
import com.wire.kalium.logic.feature.call.usecase.GetAllCallsWithSortedParticipantsUseCase
import com.wire.kalium.logic.feature.call.usecase.GetIncomingCallsUseCase
import com.wire.kalium.logic.feature.call.usecase.MuteCallUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveOutgoingCallUseCase
Expand Down Expand Up @@ -58,7 +58,7 @@ class CallsModule {

@ViewModelScoped
@Provides
fun provideGetIncomingCallsUseCase(callsScope: CallsScope) =
fun provideGetIncomingCallsUseCase(callsScope: CallsScope): GetIncomingCallsUseCase =
callsScope.getIncomingCalls

@ViewModelScoped
Expand Down Expand Up @@ -91,12 +91,6 @@ class CallsModule {
fun provideAcceptCallUseCase(callsScope: CallsScope) =
callsScope.answerCall

@ViewModelScoped
@Provides
fun provideObserveCallByConversationIdUseCase(
callsScope: CallsScope
): GetAllCallsWithSortedParticipantsUseCase = callsScope.allCallsWithSortedParticipants

@ViewModelScoped
@Provides
fun provideOnGoingCallUseCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import com.wire.kalium.logic.feature.conversation.ConversationScope
import com.wire.kalium.logic.feature.conversation.CreateGroupConversationUseCase
import com.wire.kalium.logic.feature.conversation.GetConversationProtocolInfoUseCase
import com.wire.kalium.logic.feature.conversation.GetConversationUnreadEventsCountUseCase
import com.wire.kalium.logic.feature.conversation.GetOneToOneConversationUseCase
import com.wire.kalium.logic.feature.conversation.GetOneToOneConversationDetailsUseCase
import com.wire.kalium.logic.feature.conversation.GetOrCreateOneToOneConversationUseCase
import com.wire.kalium.logic.feature.conversation.IsOneToOneConversationCreatedUseCase
import com.wire.kalium.logic.feature.conversation.JoinConversationViaCodeUseCase
Expand Down Expand Up @@ -95,7 +95,7 @@ class ConversationModule {

@ViewModelScoped
@Provides
fun provideObserveConversationUseCase(conversationScope: ConversationScope): GetOneToOneConversationUseCase =
fun provideObserveConversationUseCase(conversationScope: ConversationScope): GetOneToOneConversationDetailsUseCase =
conversationScope.getOneToOneConversation

@ViewModelScoped
Expand Down
Loading

0 comments on commit 0634377

Please sign in to comment.