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

Commit 5744ab14 authored by cretin45's avatar cretin45
Browse files

SystemUI: Avoid NPEs during status bar recreation for MSIM

PS2:
   * Clear the subs views on recreation
   * Unregister receivers on recreation

Change-Id: Id131ffac497f46a753a97b479823e51fda7c412c
parent 27742ae7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3445,6 +3445,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private void recreateStatusBar() {
        mRecreating = true;

        if (mMSimNetworkController != null) {
            mMSimNetworkController.clearSubsLabelView();
            mContext.unregisterReceiver(mMSimNetworkController);
        } else if (mNetworkController != null) {
            mContext.unregisterReceiver(mNetworkController);
        }

        removeHeadsUpView();

        mStatusBarContainer.removeAllViews();
+13 −3
Original line number Diff line number Diff line
@@ -341,6 +341,10 @@ public class MSimNetworkController extends NetworkController {
        mSubsLabelViews.add(v);
    }

    public void clearSubsLabelView() {
        mSubsLabelViews.clear();
    }

    private void updateCarrierText(int sub) {
        int textResId = 0;
        if (mAirplaneMode) {
@@ -388,15 +392,21 @@ public class MSimNetworkController extends NetworkController {
        for (int i = 0; i < mSubsLabelViews.size(); i++) {
            View v = mSubsLabelViews.get(i);
            TextView label1 = (TextView)v.findViewById(R.id.sub1_label);
            if (label1 != null) {
                label1.setText(mCarrierTextSub[MSimConstants.SUB1]);
            }
            TextView label2 = (TextView)v.findViewById(R.id.sub2_label);
            if (label2 != null) {
                label2.setText(mCarrierTextSub[MSimConstants.SUB2]);
            }
            if (mSimSlotCount == 3) {
                TextView label3 = (TextView)v.findViewById(R.id.sub3_label);
                if (label3 != null) {
                    label3.setText(mCarrierTextSub[MSimConstants.SUB3]);
                }
            }
        }
    }


    // ===== Telephony ==============================================================