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

Commit 41fe1734 authored by Lars Greiss's avatar Lars Greiss Committed by Jorge Ruesga
Browse files

Frameworks: fix possible NPE + and missing expandable panel

Steps to reproduce for NPE:
- go into volume style settings
- switch to disabled
- switch to expanded
- NPE and hotreboot

Fix:
Check if mStreamControls is initialized and if not lock it and do it.

Steps for expandable error:
- go into volume style settings
- switch to disable
- press one time the volume button
- change to expandable
- change the volume and press the expanded icon
- result is it does not expand and is empty due of the missing volume panels.

Fix:
- if it was changed from disabled to expanded be sure that the additional volume panels
are recreated.

PS:
- fix another exception

Change-Id: I58d63d34f831b6a6f60f6eddb3a07fc916d464f3
parent 9e5e556b
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -415,20 +415,26 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
                mMoreButton.setVisibility(View.GONE);
                mDivider.setVisibility(View.GONE);
                mShowCombinedVolumes = false;
                if (mCurrentOverlayStyle != -1) {
                    reorderSliders(mActiveStreamType);
                }
                mCurrentOverlayStyle = VOLUME_OVERLAY_SINGLE;
                break;
            case VOLUME_OVERLAY_EXPANDABLE :
                mMoreButton.setVisibility(View.VISIBLE);
                mDivider.setVisibility(View.VISIBLE);
                mShowCombinedVolumes = true;
                if (mCurrentOverlayStyle != -1) {
                    reorderSliders(mActiveStreamType);
                }
                mCurrentOverlayStyle = VOLUME_OVERLAY_EXPANDABLE;
                break;
            case VOLUME_OVERLAY_EXPANDED :
                mMoreButton.setVisibility(View.GONE);
                mDivider.setVisibility(View.GONE);
                mShowCombinedVolumes = true;
                if (mCurrentOverlayStyle == VOLUME_OVERLAY_NONE) {
                    addOtherVolumes();
                if (mCurrentOverlayStyle != -1) {
                    reorderSliders(mActiveStreamType);
                    expand();
                }
                mCurrentOverlayStyle = VOLUME_OVERLAY_EXPANDED;
@@ -510,6 +516,11 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
    }

    private void reorderSliders(int activeStreamType) {
        synchronized (this) {
            if (mStreamControls == null) {
                createSliders();
            }
        }
        mSliderGroup.removeAllViews();

        StreamControl active = mStreamControls.get(activeStreamType);