From 67851334055dd8ef884f44c986caeb38698de295 Mon Sep 17 00:00:00 2001 From: Nadav Bar Date: Fri, 21 Jan 2022 21:48:36 +0200 Subject: [PATCH] CaptioningManager: handle a case where caption calls enabled resource is not defined Change-Id: I9a54aef7f3cdbf7fa8e0d894b9c4c0223ff85605 Bug: 215444065. Test: CaptioningManagerTest#testIsCallCaptioningEnabled --- .../android/view/accessibility/CaptioningManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/accessibility/CaptioningManager.java b/core/java/android/view/accessibility/CaptioningManager.java index 05c74f2d01111..4f9781b6b6af3 100644 --- a/core/java/android/view/accessibility/CaptioningManager.java +++ b/core/java/android/view/accessibility/CaptioningManager.java @@ -254,7 +254,13 @@ public class CaptioningManager { * Returns true if system wide call captioning is enabled for this device. */ public boolean isCallCaptioningEnabled() { - return mResources.getBoolean(R.bool.config_systemCaptionsServiceCallsEnabled); + try { + return mResources.getBoolean( + R.bool.config_systemCaptionsServiceCallsEnabled); + } catch (Resources.NotFoundException e) { + // The resource may not be defined, return false in that case + return false; + } } private void notifyEnabledChanged() {