Commit f3e2f0b3 authored by Mikhail Khokhlov's avatar Mikhail Khokhlov Committed by Commit Bot

Catch SecurityException in RadioUtils.getCellSignalLevel

It appears that on some devices the SignalStrength.getLevel method
requires the READ_PHONE_STATE permission that Chrome doesn't have.
This CL catches the exception to avoid crash in this case.

Bug: 1150536
Change-Id: I1fcbdbbe36d62cc48357e01f66654ca1c1fe5291
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2549967Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Cr-Commit-Position: refs/heads/master@{#829654}
parent 40ecc106
......@@ -97,8 +97,16 @@ public class RadioUtils {
TelephonyManager telephonyManager =
(TelephonyManager) ContextUtils.getApplicationContext().getSystemService(
Context.TELEPHONY_SERVICE);
SignalStrength signalStrength = telephonyManager.getSignalStrength();
if (signalStrength == null) return -1;
return signalStrength.getLevel();
int level = -1;
try {
SignalStrength signalStrength = telephonyManager.getSignalStrength();
if (signalStrength != null) {
level = signalStrength.getLevel();
}
} catch (java.lang.SecurityException e) {
// Sometimes SignalStrength.getLevel() requires extra permissions
// that Chrome doesn't have. See crbug.com/1150536.
}
return level;
}
}
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