Commit 5a8a58fa authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Speculative fix for nullptr crash in calculateSignalLevel

The crash only happens on certain devices in certain countries.
The crash trace seems to indicate that the context could be null
in some cases.

Change-Id: I0ad8bdd4c79e66f7eebaf269154b9852e48e787f
Bug: 1019974
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1892062Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711414}
parent c78dbc72
......@@ -255,6 +255,14 @@ class AndroidNetworkLibrary {
*/
@CalledByNative
public static int getWifiSignalLevel(int countBuckets) {
// Some devices unexpectedly have a null context. See https://crbug.com/1019974.
if (ContextUtils.getApplicationContext() == null) {
return -1;
}
if (ContextUtils.getApplicationContext().getContentResolver() == null) {
return -1;
}
Intent intent = null;
try {
intent = ContextUtils.getApplicationContext().registerReceiver(
......
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