Bug 1626979 - Add GeckoView API for appending app notes to crash report. r=geckoview-reviewers,snorp,droeh

Differential Revision: https://phabricator.services.mozilla.com/D69662

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Randall E. Barker 2020-04-07 23:42:42 +00:00
Родитель f805480ab5
Коммит 1dde134b0f
6 изменённых файлов: 40 добавлений и 19 удалений

Просмотреть файл

@ -460,6 +460,7 @@ package org.mozilla.geckoview {
}
public final class GeckoRuntime implements Parcelable {
method @AnyThread public void appendAppNotesToCrashReport(@NonNull String);
method @UiThread public void attachTo(@NonNull Context);
method @UiThread public void configurationChanged(@NonNull Configuration);
method @UiThread @NonNull public static GeckoRuntime create(@NonNull Context);

Просмотреть файл

@ -250,6 +250,11 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
extras.putString("Android_ProcessName", getProcessName());
extras.putString("Android_PackageName", pkgName);
final String notes = GeckoAppShell.getAppNotes();
if (notes != null) {
extras.putString("Notes", notes);
}
if (context != null) {
final PackageManager pkgMgr = context.getPackageManager();
try {

Просмотреть файл

@ -114,24 +114,6 @@ public class GeckoAppShell {
return getApplicationContext();
}
@Override
protected Bundle getCrashExtras(final Thread thread, final Throwable exc) {
final Bundle extras = super.getCrashExtras(thread, exc);
extras.putString("ProductName", BuildConfig.MOZ_APP_BASENAME);
extras.putString("ProductID", BuildConfig.MOZ_APP_ID);
extras.putString("Version", BuildConfig.MOZ_APP_VERSION);
extras.putString("BuildID", BuildConfig.MOZ_APP_BUILDID);
extras.putString("Vendor", BuildConfig.MOZ_APP_VENDOR);
extras.putString("ReleaseChannel", BuildConfig.MOZ_UPDATE_CHANNEL);
final String appNotes = getAppNotes();
if (appNotes != null) {
extras.putString("Notes", appNotes);
}
return extras;
}
@Override
public boolean reportException(final Thread thread, final Throwable exc) {
try {
@ -259,6 +241,9 @@ public class GeckoAppShell {
@WrapForJNI(stubName = "NotifyObservers", dispatchTo = "gecko")
private static native void nativeNotifyObservers(String topic, String data);
@WrapForJNI(stubName = "AppendAppNotesToCrashReport", dispatchTo = "gecko")
public static native void nativeAppendAppNotesToCrashReport(final String notes);
@RobocopTarget
public static void notifyObservers(final String topic, final String data) {
notifyObservers(topic, data, GeckoThread.State.RUNNING);

Просмотреть файл

@ -815,6 +815,23 @@ public final class GeckoRuntime implements Parcelable {
return mPushController;
}
/**
* Appends notes to crash report.
* @param notes The application notes to append to the crash report.
*/
@AnyThread
public void appendAppNotesToCrashReport(@NonNull final String notes) {
final String notesWithNewLine = notes + "\n";
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
GeckoAppShell.nativeAppendAppNotesToCrashReport(notesWithNewLine);
} else {
GeckoThread.queueNativeCallUntil(GeckoThread.State.PROFILE_READY, GeckoAppShell.class,
"nativeAppendAppNotesToCrashReport", String.class, notesWithNewLine);
}
// This function already adds a newline
GeckoAppShell.appendAppNotesToCrashReport(notes);
}
@Override // Parcelable
@AnyThread
public int describeContents() {

Просмотреть файл

@ -13,6 +13,12 @@ exclude: true
⚠️ breaking change
## v77
- Added [`GeckoRuntime.appendAppNotesToCrashReport`][77.1] For adding app notes to the crash report.
([bug 1626979]({{bugzilla}}1626979))
[77.1]: {{javadoc_uri}}/GeckoRuntime.html#appendAppNotesToCrashReport-java.lang.String-
## v76
- Added [`GeckoSession.PermissionDelegate.PERMISSION_MEDIA_KEY_SYSTEM_ACCESS`][76.1] to control EME media key access.
- [`RuntimeTelemetry#getSnapshots`][68.10] is deprecated and will be removed
@ -667,4 +673,4 @@ exclude: true
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
[65.25]: {{javadoc_uri}}/GeckoResult.html
[api-version]: d1e459d9f40b32fed4859a0bc3a848e2908b50c1
[api-version]: 266a352d20a71acc3052a2a9184e5a95a183145b

Просмотреть файл

@ -9,6 +9,7 @@
#include "base/message_loop.h"
#include "base/task.h"
#include "mozilla/Hal.h"
#include "nsExceptionHandler.h"
#include "nsIScreen.h"
#include "nsWindow.h"
#include "nsThreadUtils.h"
@ -258,6 +259,12 @@ class GeckoAppShellSupport final
aData ? aData->ToString().get() : nullptr);
}
static void AppendAppNotesToCrashReport(jni::String::Param aNotes) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aNotes);
CrashReporter::AppendAppNotesToCrashReport(aNotes->ToCString());
}
static void OnSensorChanged(int32_t aType, float aX, float aY, float aZ,
float aW, int64_t aTime) {
AutoTArray<float, 4> values;