Merge "[Settings] Prevent crash from abnormal behavior." into sc-dev
This commit is contained in:
@@ -88,6 +88,13 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
Telephony.Carriers.EDITED_STATUS,
|
Telephony.Carriers.EDITED_STATUS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Copied from {@code com.android.internal.telephony.TelephonyIntents} */
|
||||||
|
private static final String ACTION_SIM_STATE_CHANGED =
|
||||||
|
"android.intent.action.SIM_STATE_CHANGED";
|
||||||
|
/** Copied from {@code com.android.internal.telephony.IccCardConstants} */
|
||||||
|
public static final String INTENT_KEY_ICC_STATE = "ss";
|
||||||
|
public static final String INTENT_VALUE_ICC_ABSENT = "ABSENT";
|
||||||
|
|
||||||
private static final int ID_INDEX = 0;
|
private static final int ID_INDEX = 0;
|
||||||
private static final int NAME_INDEX = 1;
|
private static final int NAME_INDEX = 1;
|
||||||
private static final int APN_INDEX = 2;
|
private static final int APN_INDEX = 2;
|
||||||
@@ -151,7 +158,16 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.getAction().equals(
|
String action = intent.getAction();
|
||||||
|
if (ACTION_SIM_STATE_CHANGED.equals(action)
|
||||||
|
&& intent.getStringExtra(INTENT_KEY_ICC_STATE)
|
||||||
|
.equals(INTENT_VALUE_ICC_ABSENT)) {
|
||||||
|
final SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
|
||||||
|
if (sm != null && !sm.isActiveSubscriptionId(mSubId)) {
|
||||||
|
Log.d(TAG, "Due to SIM absent, closes APN settings page");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else if (intent.getAction().equals(
|
||||||
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) {
|
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) {
|
||||||
if (mRestoreDefaultApnMode) {
|
if (mRestoreDefaultApnMode) {
|
||||||
return;
|
return;
|
||||||
@@ -201,8 +217,9 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
mSubId = activity.getIntent().getIntExtra(SUB_ID,
|
mSubId = activity.getIntent().getIntExtra(SUB_ID,
|
||||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||||
mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId);
|
mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId);
|
||||||
mIntentFilter = new IntentFilter(
|
mIntentFilter = new IntentFilter();
|
||||||
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
|
mIntentFilter.addAction(TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
|
||||||
|
mIntentFilter.addAction(ACTION_SIM_STATE_CHANGED);
|
||||||
|
|
||||||
setIfOnlyAvailableForAdmins(true);
|
setIfOnlyAvailableForAdmins(true);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user