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

Commit 8dae83ee authored by Pinyao Ting's avatar Pinyao Ting
Browse files

Fix launcher crash after restore with some specific widgets.

The internal implementation of PendingAppWidgetHostView#getDefaultViews
uses the same view across updates which causes the exception in
AppWidgetHostView#applyContent when it tries to call addView() because
the view has already been added to its parent view in previous iteration.

Bug: 151901506
Test: manual
Change-Id: Ieccec814ac514e592d0d4f196b60ba89aec0d661
parent 4527d2db
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView
    private static final float MIN_SATUNATION = 0.7f;

    private final Rect mRect = new Rect();
    private View mDefaultView;
    private OnClickListener mClickListener;
    private final LauncherAppWidgetInfo mInfo;
    private final int mStartState;
@@ -111,12 +110,11 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView

    @Override
    protected View getDefaultView() {
        if (mDefaultView == null) {
            mDefaultView = mInflater.inflate(R.layout.appwidget_not_ready, this, false);
            mDefaultView.setOnClickListener(this);
        View defaultView = mInflater.inflate(R.layout.appwidget_not_ready, this, false);
        defaultView.setOnClickListener(this);
        applyState();
        }
        return mDefaultView;
        invalidate();
        return defaultView;
    }

    @Override