If the CarrierConfigManager is still null, return that the preference is

not available.

Test: atest -c VideoCallingPreferenceControllerTest
Bug: 186594185
Change-Id: I4650d9f77f6a4a0cb84d6e20f02e4ab1d1841131
This commit is contained in:
Jeremy Goldman
2021-05-03 16:16:21 +08:00
parent 9c69df3b82
commit 050f7a7657

View File

@@ -19,7 +19,6 @@ package com.android.settings.network.telephony;
import android.content.Context; import android.content.Context;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager; import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyCallback; import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
@@ -143,6 +142,16 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
return false; return false;
} }
// When called within Settings Search, this variable may still be null.
if (mCarrierConfigManager == null) {
Log.e(TAG, "CarrierConfigManager set to null.");
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
if (mCarrierConfigManager == null) {
Log.e(TAG, "Unable to reinitialize CarrierConfigManager.");
return false;
}
}
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId); final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
if (carrierConfig == null) { if (carrierConfig == null) {
return false; return false;