Prevent crash on SIM Lock settings while rotating
Prevent crash when getContext() returns null.
Fix: 316244109
Test: manual - rotating on SIM Lock settings
Change-Id: Iae17585cb52ea74e92129df2a1ced25454678d9a
diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java
index 4628221..422610a 100644
--- a/src/com/android/settings/IccLockSettings.java
+++ b/src/com/android/settings/IccLockSettings.java
@@ -52,6 +52,7 @@
import android.widget.TextView;
import android.widget.Toast;
+import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;
@@ -716,13 +717,18 @@
return slotId;
}
+ @Nullable
private SubscriptionInfo getVisibleSubscriptionInfoForSimSlotIndex(int slotId) {
final List<SubscriptionInfo> subInfoList =
mProxySubscriptionMgr.getActiveSubscriptionsInfo();
if (subInfoList == null) {
return null;
}
- final CarrierConfigManager carrierConfigManager = getContext().getSystemService(
+ Context context = getContext();
+ if (context == null) {
+ return null;
+ }
+ final CarrierConfigManager carrierConfigManager = context.getSystemService(
CarrierConfigManager.class);
for (SubscriptionInfo subInfo : subInfoList) {
if ((isSubscriptionVisible(carrierConfigManager, subInfo)