Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

For #3439 - Add "report" action to crash notification #4087

Merged
merged 1 commit into from
Aug 15, 2019

Conversation

rocketsroger
Copy link
Contributor

@rocketsroger rocketsroger commented Aug 9, 2019

Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or does not need one
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues closed by this pull request are added to the milestone of the version currently in development.
  • Breaking Changes: If this is a breaking change, please push a draft PR on Reference Browser to address the breaking issues.

@rocketsroger rocketsroger marked this pull request as ready for review August 9, 2019 21:54
@rocketsroger rocketsroger requested a review from a team as a code owner August 9, 2019 21:54
@pocmo pocmo added the 🕵️‍♀️ needs review PRs that need to be reviewed label Aug 12, 2019
@pocmo pocmo self-assigned this Aug 12, 2019
if (skipPrompt) {
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE)
as NotificationManager
notificationManager.cancelAll()
Copy link
Contributor

Choose a reason for hiding this comment

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

Cancelling all notification is a bit aggressive here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look into if I can just cancel the crash notification. Thanks,

val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE)
as NotificationManager
notificationManager.cancelAll()
sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for this broadcast here? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the report button is clicked, it retracts the notification drawer. I will agree if you think this is not needed.

@@ -29,10 +31,18 @@ class CrashHandlerService : IntentService(WORKER_THREAD_NAME) {

intent.extras?.let { extras ->
val crash = Crash.NativeCodeCrash.fromBundle(extras)
val skipPrompt = extras.getBoolean(Crash.INTENT_EXTRA_SKIP_PROMPT, false)

if (skipPrompt) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned about reusing the CrashHandlerService class here: It's main purpose is to receive crashes from GeckoView (hence the Crash.NativeCodeCrash.fromBundle() above) and forward it to the CrashReporter instance.

With this patch it also receives crashes from the notification (which may not be Crash.NativeCodeCrash!). Since we kill this process immediately I wonder if we'd even be able to report any crashes (which may happen asynchronously).

We may want to consider using CrashReporter.submitReport() (like CrashReporterActivity does) and wait for it to completely. Not sure from where though? Maybe a foreground service? Or a workmanager worker (which would still need a service to schedule it?)? A workmanager worker would have the benefit that we could fix some of our other lib-crash issues (e.g. CrashReporterActivity blocking, CrashReporterActivity trying only once, ..). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I've misunderstood the role of CrashHandlerService then. I'll look into both the foreground service and the worker idea. Thanks,

@rocketsroger rocketsroger force-pushed the AC_3439 branch 2 times, most recently from b66a29e to a83d17b Compare August 12, 2019 22:58
Copy link
Contributor

@pocmo pocmo left a comment

Choose a reason for hiding this comment

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

This looks already pretty great :)

components/lib/crash/src/main/AndroidManifest.xml Outdated Show resolved Hide resolved
} else {
PendingIntent.getService(
context, REPORT_REQUEST_CODE, CrashPrompt.createReportIntent(context, crash), 0
)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could consider moving the creation of such a pending intent behind a helper. Maybe even in support-utils.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had some issues moving this to support-util. Couldn't find a clean way because of the Crash class dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opened #4113 to track this.

Copy link
Contributor

@pocmo pocmo left a comment

Choose a reason for hiding this comment

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

Looks great! :)

internal class CrashNotification(
private val context: Context,
private val crash: Crash,
private val configuration: CrashReporter.PromptConfiguration
) {
fun show() {
val pendingIntent = PendingIntent.getActivity(
context, 0, CrashPrompt.createIntent(context, crash), 0
context, 0, CrashPrompt.createIntent(context, crash), 0
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change that in the commit. But this indentation seems to come from the default AS formatting that is a bit different than what ktlint does.

You can get Android Studio to follow ktlint (on Mac) like this:

brew install ktlint
ktlint --apply-to-idea-project --android

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After applying and restarting android studio. It still wants to do double intent for this line. I'll look into why. Thanks for the ktlint apply commands.

Copy link
Contributor

@pocmo pocmo left a comment

Choose a reason for hiding this comment

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

Something looks not right here. There are now 29 commits in this PR.

@rocketsroger
Copy link
Contributor Author

Something looks not right here. There are now 29 commits in this PR.

Yes, something went wrong when I reorder git history on my branch. Let me take a look. Thanks,

@Dexterp37 Dexterp37 removed the request for review from a team August 14, 2019 15:07
@rocketsroger rocketsroger requested a review from pocmo August 14, 2019 15:19
@pocmo
Copy link
Contributor

pocmo commented Aug 14, 2019

Looks good now. Can you re-force-push your branch (or rebase) so that we do not get all those merge commits merged in? I just disabled the "update branch" button so that it's now gone :D

@pocmo pocmo closed this Aug 14, 2019
@pocmo pocmo reopened this Aug 14, 2019
@rocketsroger
Copy link
Contributor Author

Looks good now. Can you re-force-push your branch (or rebase) so that we do not get all those merge commits merged in? I just disabled the "update branch" button so that it's now gone :D

Done. Only 1 commit now for this change. Please let me know if its not clean. Thanks,

Copy link
Contributor

@pocmo pocmo left a comment

Choose a reason for hiding this comment

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

bors r+

bors bot pushed a commit that referenced this pull request Aug 15, 2019
4087: For #3439 - Add "report" action to crash notification r=pocmo a=rocketsroger


### Pull Request checklist
<!-- Before submitting the PR, please address each item -->
- [x] **Quality**: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
- [x] **Tests**: This PR includes thorough tests or an explanation of why it does not
- [x] **Changelog**: This PR includes [a changelog entry](https://github.com/mozilla-mobile/android-components/blob/master/docs/changelog.md) or does not need one
- [x] **Accessibility**: The code in this PR follows [accessibility best practices](https://github.com/mozilla-mobile/shared-docs/blob/master/android/accessibility_guide.md) or does not include any user facing features

### After merge
- [ ] **Milestone**: Make sure issues closed by this pull request are added to the [milestone](https://github.com/mozilla-mobile/android-components/milestones) of the version currently in development.
- [ ] **Breaking Changes**: If this is a breaking change, please push a draft PR on [Reference Browser](https://github.com/mozilla-mobile/reference-browser) to address the breaking issues.

Co-authored-by: Roger Yang <[email protected]>
@bors
Copy link

bors bot commented Aug 15, 2019

Build succeeded

@bors bors bot merged commit 3908909 into mozilla-mobile:master Aug 15, 2019
@rocketsroger rocketsroger deleted the AC_3439 branch August 15, 2019 17:12
@rocketsroger rocketsroger added this to the 9.0.0 📷 milestone Aug 15, 2019
@rocketsroger rocketsroger removed the 🕵️‍♀️ needs review PRs that need to be reviewed label Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants