Skip to content

ANR when asking to select the notification method #7675

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 16 commits into from
Dec 5, 2022

Conversation

mnaturel
Copy link
Contributor

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Refactoring most of the logic for registration of push notification distributor. Adding unit tests on the new code.

The previous code was a mix of UI and domain layer which lead to non necessary complexity and some bugs like ANR, crash or unexpected behavior.

Motivation and context

Closes #7653

Screenshots / GIFs

Tests

Both FDroid and Gplay version should be tested.

  • Install Ntfy app
  • Login to Element
  • Check the distributor choice is asked when landing the first time in the home screen
  • Check the notifications are well received in the different choices (background sync, Google services, Ntfy)
  • Go to Settings -> Notifications
  • Disable Notifications for the device
  • Check the notifications are no more received
  • Enable the notifications in settings
  • Check distributor is asked
  • Change the notification method in Settings -> Notifications
  • Check notifications are still received after change of the method

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 11

Checklist

@mnaturel mnaturel marked this pull request as ready for review November 30, 2022 16:38
@mnaturel mnaturel requested a review from bmarty November 30, 2022 16:38
import im.vector.app.test.fakes.FakePushersManager
import im.vector.app.test.fakes.FakeUnifiedPushHelper
import im.vector.app.test.fixtures.PusherFixture
import io.mockk.verify

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 Unused import

@mnaturel mnaturel force-pushed the fix/mna/unified-push-selection branch from e146b84 to b30dda7 Compare December 1, 2022 09:40
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rework! I have done some tests and did not see any issue.

// 'app should always check the device for a compatible Google Play services APK before accessing Google Play services features'
if (checkPlayServices(activity)) {
if (checkPlayServices(context)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think checkPlayServices can display a dialog, and so needs an Activity. I will try running your code on an emulator without the PlayServices.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understood, we only use the checking method GoogleApiAvailability.isGooglePlayServicesAvailable(context). This method only requires a Context. In case of error, we display a toast which only requires a Context as well.

}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for extracting logic from the Activity to the ViewModel. Maybe creating a new dedicated ViewModel may have been better, but it can be done later.

@@ -23,5 +23,4 @@ import org.matrix.android.sdk.api.session.sync.SyncRequestState
data class HomeActivityViewState(
val syncRequestState: SyncRequestState = SyncRequestState.Idle,
val authenticationDescription: AuthenticationDescription? = null,
val areNotificationsSilenced: Boolean = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is (or will be) handled elsewhere?

Copy link
Contributor Author

@mnaturel mnaturel Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to look into that, I am not sure it is needed. What is sure is that it should not have been added in the ViewState as it was not used for rendering UI but for domain logic. There will be 2 successive PRs following that current PR which will fix issues with both remote and local notifications toggling for the session.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks!

@mnaturel
Copy link
Contributor Author

mnaturel commented Dec 2, 2022

I will wait for approval of the successive PR #7630 and #7692 to merge this PR.

@mnaturel mnaturel force-pushed the fix/mna/unified-push-selection branch from b30dda7 to f8c59f6 Compare December 5, 2022 08:47
@ElementBot
Copy link

Warnings
⚠️ Please add a reviewer to your PR.

Generated by 🚫 dangerJS against f8c59f6

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

64.4% 64.4% Coverage
0.0% 0.0% Duplication

@mnaturel mnaturel merged commit a2f8fed into develop Dec 5, 2022
@mnaturel mnaturel deleted the fix/mna/unified-push-selection branch December 5, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ANR when asking to select the notification method
3 participants