-
Notifications
You must be signed in to change notification settings - Fork 473
For #3439 - Add "report" action to crash notification #4087
Conversation
if (skipPrompt) { | ||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) | ||
as NotificationManager | ||
notificationManager.cancelAll() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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? 🤔
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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,
b66a29e
to
a83d17b
Compare
There was a problem hiding this 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 :)
...nents/lib/crash/src/main/java/mozilla/components/lib/crash/notification/CrashNotification.kt
Show resolved
Hide resolved
} else { | ||
PendingIntent.getService( | ||
context, REPORT_REQUEST_CODE, CrashPrompt.createReportIntent(context, crash), 0 | ||
) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
components/lib/crash/src/main/java/mozilla/components/lib/crash/prompt/CrashPrompt.kt
Outdated
Show resolved
Hide resolved
...nents/lib/crash/src/main/java/mozilla/components/lib/crash/service/SendCrashReportService.kt
Outdated
Show resolved
Hide resolved
...nents/lib/crash/src/main/java/mozilla/components/lib/crash/service/SendCrashReportService.kt
Show resolved
Hide resolved
...nents/lib/crash/src/main/java/mozilla/components/lib/crash/service/SendCrashReportService.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Yes, something went wrong when I reorder git history on my branch. Let me take a look. Thanks, |
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
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]>
Build succeeded |
Pull Request checklist
After merge