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
This commit is contained in:
yomna
2025-02-26 21:48:51 +00:00
parent d46bed9b13
commit 3d66e6b6fe

View File

@@ -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()