-
Notifications
You must be signed in to change notification settings - Fork 857
Align Autorageshake with web implementation #5639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7e93047
Align with web implementation
langleyd 531b62f
Make properties private
langleyd f38bf25
lint
langleyd 4fe8650
Add changelog
langleyd b488562
Keep live event/pagination listeners.
langleyd 3ae4303
Fix changelog wording
langleyd 363afd0
Update naming to InitialSyncProgressing for clarity.
langleyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Align auto-reporting of decryption errors implementation with web client. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Include original event in live decryption listeners and update sync status naming to InitialSyncProgressing for clarity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,11 @@ | |
| package im.vector.app | ||
|
|
||
| import android.content.SharedPreferences | ||
| import androidx.lifecycle.asFlow | ||
| import im.vector.app.core.di.ActiveSessionHolder | ||
| import im.vector.app.features.rageshake.BugReporter | ||
| import im.vector.app.features.rageshake.ReportType | ||
| import im.vector.app.features.session.coroutineScope | ||
| import im.vector.app.features.settings.VectorPreferences | ||
| import kotlinx.coroutines.CoroutineScope | ||
| import kotlinx.coroutines.Dispatchers | ||
|
|
@@ -34,6 +36,7 @@ import kotlinx.coroutines.launch | |
| import org.matrix.android.sdk.api.session.Session | ||
| import org.matrix.android.sdk.api.session.events.model.Event | ||
| import org.matrix.android.sdk.api.session.events.model.toContent | ||
| import org.matrix.android.sdk.api.session.initsync.SyncStatusService | ||
| import timber.log.Timber | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
|
|
@@ -62,10 +65,11 @@ class AutoRageShaker @Inject constructor( | |
|
|
||
| private val e2eDetectedFlow = MutableSharedFlow<E2EMessageDetected>(replay = 0) | ||
| private val matchingRSRequestFlow = MutableSharedFlow<Event>(replay = 0) | ||
|
|
||
| private var hasSynced = false | ||
| private var preferenceEnabled = false | ||
| fun initialize() { | ||
| observeActiveSession() | ||
| enable(vectorPreferences.labsAutoReportUISI()) | ||
| preferenceEnabled = vectorPreferences.labsAutoReportUISI() | ||
| // It's a singleton... | ||
| vectorPreferences.subscribeToChanges(this) | ||
|
|
||
|
|
@@ -74,7 +78,7 @@ class AutoRageShaker @Inject constructor( | |
| e2eDetectedFlow | ||
| .onEach { | ||
| sendRageShake(it) | ||
| delay(2_000) | ||
| delay(60_000) | ||
| } | ||
| .catch { cause -> | ||
| Timber.w(cause, "Failed to RS") | ||
|
|
@@ -84,7 +88,7 @@ class AutoRageShaker @Inject constructor( | |
| matchingRSRequestFlow | ||
| .onEach { | ||
| sendMatchingRageShake(it) | ||
| delay(2_000) | ||
| delay(60_000) | ||
| } | ||
| .catch { cause -> | ||
| Timber.w(cause, "Failed to send matching rageshake") | ||
|
|
@@ -93,14 +97,7 @@ class AutoRageShaker @Inject constructor( | |
| } | ||
|
|
||
| override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { | ||
| enable(vectorPreferences.labsAutoReportUISI()) | ||
| } | ||
|
|
||
| var _enabled = false | ||
| fun enable(enabled: Boolean) { | ||
| if (enabled == _enabled) return | ||
| _enabled = enabled | ||
| detector.enabled = enabled | ||
| preferenceEnabled = vectorPreferences.labsAutoReportUISI() | ||
| } | ||
|
|
||
| private fun observeActiveSession() { | ||
|
|
@@ -115,7 +112,6 @@ class AutoRageShaker @Inject constructor( | |
| } | ||
|
|
||
| fun decryptionErrorDetected(target: E2EMessageDetected) { | ||
| if (target.source == UISIEventSource.INITIAL_SYNC) return | ||
| if (activeSessionHolder.getSafeActiveSession()?.sessionId != currentActiveSessionId) return | ||
| val shouldSendRS = synchronized(alreadyReportedUisi) { | ||
| val reportInfo = ReportInfo(target.roomId, target.sessionId) | ||
|
|
@@ -148,7 +144,6 @@ class AutoRageShaker @Inject constructor( | |
| append("\"room_id\": \"${target.roomId}\",") | ||
| append("\"sender_key\": \"${target.senderKey}\",") | ||
| append("\"device_id\": \"${target.senderDeviceId}\",") | ||
| append("\"source\": \"${target.source}\",") | ||
| append("\"user_id\": \"${target.senderUserId}\",") | ||
| append("\"session_id\": \"${target.sessionId}\"") | ||
| append("}") | ||
|
|
@@ -245,6 +240,9 @@ class AutoRageShaker @Inject constructor( | |
| override val reciprocateToDeviceEventType: String | ||
| get() = AUTO_RS_REQUEST | ||
|
|
||
| override val enabled: Boolean | ||
| get() = [email protected] && [email protected] | ||
|
|
||
| override fun uisiDetected(source: E2EMessageDetected) { | ||
| decryptionErrorDetected(source) | ||
| } | ||
|
|
@@ -261,7 +259,14 @@ class AutoRageShaker @Inject constructor( | |
| return | ||
| } | ||
| this.currentActiveSessionId = sessionId | ||
| this.detector.enabled = _enabled | ||
|
|
||
| hasSynced = session.hasAlreadySynced() | ||
| session.getSyncStatusLive() | ||
| .asFlow() | ||
| .onEach { | ||
| hasSynced = it !is SyncStatusService.Status.InitialSyncProgressing | ||
| } | ||
| .launchIn(session.coroutineScope) | ||
| activeSessionIds.add(sessionId) | ||
| session.addListener(this) | ||
| session.addEventStreamListener(detector) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.