Skip to content

Commit 1698d45

Browse files
committed
Fix null ptr exception in getReadingLevelScale()
Handle the case where WebView settings might be null. Bug: 5472493 Change-Id: I6b1c2e5e5e56a517910a330ae9d40a4adc99d75a
1 parent 9a7e4ce commit 1698d45

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/java/android/webkit/ZoomManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,10 @@ public final float getDefaultScale() {
314314
* Returns the zoom scale used for reading text on a double-tap.
315315
*/
316316
public final float getReadingLevelScale() {
317-
return mDisplayDensity * mWebView.getSettings().getDoubleTapZoom() / 100.0f;
317+
WebSettings settings = mWebView.getSettings();
318+
final float doubleTapZoomFactor = settings != null
319+
? settings.getDoubleTapZoom() / 100.f : 1.0f;
320+
return mDisplayDensity * doubleTapZoomFactor;
318321
}
319322

320323
public final float getInvDefaultScale() {

0 commit comments

Comments
 (0)