Commit d78c1a6e authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Ignore DelayedScreenLockIntentHandler exceptions

Not really a good fix, but better than crashing for now.

Bug: 1099819
Change-Id: I50616008ba19a168ad9b1976552dc8e47991dcbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315351
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792046}
parent 9fe250f6
......@@ -56,6 +56,19 @@ public class JavaExceptionReporter implements Thread.UncaughtExceptionHandler {
PiiElider.sanitizeStacktrace(stackTrace));
}
/**
* Report and upload the stack trace as if it was a crash. This is very expensive and should
* be called rarely and only on the UI thread to avoid corrupting other crash uploads. Ideally
* only called in idle handlers.
*
* @param exception The exception to report.
*/
@UiThread
public static void reportException(Throwable exception) {
assert ThreadUtils.runningOnUiThread();
JavaExceptionReporterJni.get().reportJavaException(false, exception);
}
@CalledByNative
private static void installHandler(boolean crashAfterReport) {
Thread.setDefaultUncaughtExceptionHandler(new JavaExceptionReporter(
......
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
......@@ -12,6 +13,7 @@ import android.content.IntentFilter;
import android.os.Handler;
import org.chromium.base.ContextUtils;
import org.chromium.base.JavaExceptionReporter;
import java.lang.ref.WeakReference;
......@@ -44,7 +46,12 @@ public class DelayedScreenLockIntentHandler extends BroadcastReceiver {
if (Intent.ACTION_USER_PRESENT.equals(intent.getAction()) && mDeferredIntent != null) {
Activity activity = mActivity.get();
if (activity != null) {
activity.startActivity(mDeferredIntent);
try {
activity.startActivity(mDeferredIntent);
} catch (ActivityNotFoundException e) {
// TODO(crbug.com/1099819): Figure out why this happens and fix properly.
JavaExceptionReporter.reportException(e);
}
}
// Prevent the broadcast receiver from firing intent unexpectedly.
updateDeferredIntent(null);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment