Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e717f5d authored by hoffc's avatar hoffc Committed by Michael Bestas
Browse files

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
parent 6bb4a0c5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -152,6 +152,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
@@ -282,11 +283,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;
        }