From 3d66e6b6fe06d75282e43ae2bc78baa23cf6fdf9 Mon Sep 17 00:00:00 2001 From: yomna Date: Wed, 26 Feb 2025 21:48:51 +0000 Subject: [PATCH] Handle failing calls to TelephonyManager If the phone process has died, Settings cannot make calls to TelephonyManager. Update the handling of this case to new best practices. Bug: b/394077023 Test: m & atest CellularSecurityPreferenceController Flag: EXEMPT bugfix Change-Id: I64ecb143d0830873b590ce4a397c398d8b41943f --- .../network/CellularSecurityPreferenceController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/network/CellularSecurityPreferenceController.java b/src/com/android/settings/network/CellularSecurityPreferenceController.java index 6ab32e31729..f8699cbe77c 100644 --- a/src/com/android/settings/network/CellularSecurityPreferenceController.java +++ b/src/com/android/settings/network/CellularSecurityPreferenceController.java @@ -77,7 +77,7 @@ public class CellularSecurityPreferenceController extends BasePreferenceControll } if (mTelephonyManager == null) { Log.w(LOG_TAG, "Telephony manager not yet initialized"); - mTelephonyManager = mContext.getSystemService(TelephonyManager.class); + return CONDITIONALLY_UNAVAILABLE; } // Check there are valid SIM cards which can be displayed to the user, otherwise this @@ -186,7 +186,7 @@ public class CellularSecurityPreferenceController extends BasePreferenceControll protected boolean areNotificationsEnabled() { if (mTelephonyManager == null) { Log.w(LOG_TAG, "Telephony manager not yet initialized"); - mTelephonyManager = mContext.getSystemService(TelephonyManager.class); + return false; } return mTelephonyManager.isNullCipherNotificationsEnabled()