Settings: Fix exception in about phone during SIM swap
In about phone SIM status dialog fragment does not correctly remove the subscription change listener and broadcast receiver during SIM swap, which results in IllegalStateException force close and memroy leak. Make sure to remove sub change listener and un-register broadcast receiver in SIM swap case. Bug: 159410236 Change-Id: I7867852c58b2b38e0afc73422b7d616aa305199c
This commit is contained in:
@@ -148,6 +148,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
||||
private final Context mContext;
|
||||
|
||||
private boolean mShowLatestAreaInfo;
|
||||
private boolean mIsRegisteredListener = false;
|
||||
|
||||
private final BroadcastReceiver mAreaInfoReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -277,11 +278,22 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
||||
mContext.registerReceiver(mAreaInfoReceiver,
|
||||
new IntentFilter(CellBroadcastIntents.ACTION_AREA_INFO_UPDATED));
|
||||
}
|
||||
|
||||
mIsRegisteredListener = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mSubscriptionInfo == null) {
|
||||
if (mIsRegisteredListener) {
|
||||
mSubscriptionManager.removeOnSubscriptionsChangedListener(
|
||||
mOnSubscriptionsChangedListener);
|
||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
||||
if (mShowLatestAreaInfo) {
|
||||
mContext.unregisterReceiver(mAreaInfoReceiver);
|
||||
}
|
||||
mIsRegisteredListener = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user