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

Commit d3bdbc31 authored by Rajshekar Eashwarappa's avatar Rajshekar Eashwarappa Committed by Steve Kondik
Browse files

framework:Thread synchronization for UI update

Issue : Framework reboot was observed due to out of sync between
        two threads which inturn causes Null pointer exception
        while updating airplanemode.
Fix : Handled Null pointer exception and the crash is not observed.
CRs-Fixed: 570122

Change-Id: I2e969f6e7726ffcf8648b366ebb54cb2b0afc292
parent 585dcda2
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1138,8 +1138,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            if (!mHasTelephony) return;
            final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
            mAirplaneState = inAirplaneMode ? ToggleAction.State.On : ToggleAction.State.Off;
            mAirplaneModeOn.updateState(mAirplaneState);
            mAdapter.notifyDataSetChanged();
            mHandler.sendEmptyMessage(MESSAGE_REFRESH_AIRPLANEMODE);
        }
    };

@@ -1162,6 +1161,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
    private static final int MESSAGE_DISMISS = 0;
    private static final int MESSAGE_REFRESH = 1;
    private static final int MESSAGE_SHOW = 2;
    private static final int MESSAGE_REFRESH_AIRPLANEMODE = 3;
    private static final int DIALOG_DISMISS_DELAY = 300; // ms

    private Handler mHandler = new Handler() {
@@ -1179,6 +1179,10 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            case MESSAGE_SHOW:
                handleShow();
                break;
            case MESSAGE_REFRESH_AIRPLANEMODE:
                mAirplaneModeOn.updateState(mAirplaneState);
                mAdapter.notifyDataSetChanged();
                break;
            }
        }
    };