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

Commit 6f6af2a2 authored by Lucas Silva's avatar Lucas Silva Committed by Automerger Merge Worker
Browse files

Merge "Avoid callback leak in ComplicationHostViewController" into tm-qpr-dev...

Merge "Avoid callback leak in ComplicationHostViewController" into tm-qpr-dev am: 0348c776 am: db5c344b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21907979



Change-Id: I2126c2ade7826e51d33a815d6001307050334e7e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 11d17bba db5c344b
Loading
Loading
Loading
Loading
+2 −12
Original line number Original line Diff line number Diff line
@@ -61,9 +61,6 @@ public class ComplicationHostViewController extends ViewController<ConstraintLay
    @VisibleForTesting
    @VisibleForTesting
    boolean mIsAnimationEnabled;
    boolean mIsAnimationEnabled;


    // Whether dream entry animations are finished.
    private boolean mEntryAnimationsFinished = false;

    @Inject
    @Inject
    protected ComplicationHostViewController(
    protected ComplicationHostViewController(
            @Named(SCOPED_COMPLICATIONS_LAYOUT) ConstraintLayout view,
            @Named(SCOPED_COMPLICATIONS_LAYOUT) ConstraintLayout view,
@@ -78,14 +75,6 @@ public class ComplicationHostViewController extends ViewController<ConstraintLay
        mComplicationCollectionViewModel = viewModel;
        mComplicationCollectionViewModel = viewModel;
        mDreamOverlayStateController = dreamOverlayStateController;
        mDreamOverlayStateController = dreamOverlayStateController;


        mDreamOverlayStateController.addCallback(new DreamOverlayStateController.Callback() {
            @Override
            public void onStateChanged() {
                mEntryAnimationsFinished =
                        mDreamOverlayStateController.areEntryAnimationsFinished();
            }
        });

        // Whether animations are enabled.
        // Whether animations are enabled.
        mIsAnimationEnabled = secureSettings.getFloatForUser(
        mIsAnimationEnabled = secureSettings.getFloatForUser(
                Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f, UserHandle.USER_CURRENT) != 0.0f;
                Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f, UserHandle.USER_CURRENT) != 0.0f;
@@ -159,7 +148,8 @@ public class ComplicationHostViewController extends ViewController<ConstraintLay


                    // Complications to be added before dream entry animations are finished are set
                    // Complications to be added before dream entry animations are finished are set
                    // to invisible and are animated in.
                    // to invisible and are animated in.
                    if (!mEntryAnimationsFinished && mIsAnimationEnabled) {
                    if (!mDreamOverlayStateController.areEntryAnimationsFinished()
                            && mIsAnimationEnabled) {
                        view.setVisibility(View.INVISIBLE);
                        view.setVisibility(View.INVISIBLE);
                    }
                    }
                    mComplications.put(id, viewHolder);
                    mComplications.put(id, viewHolder);
+0 −10
Original line number Original line Diff line number Diff line
@@ -92,9 +92,6 @@ public class ComplicationHostViewControllerTest extends SysuiTestCase {
    @Captor
    @Captor
    private ArgumentCaptor<Observer<Collection<ComplicationViewModel>>> mObserverCaptor;
    private ArgumentCaptor<Observer<Collection<ComplicationViewModel>>> mObserverCaptor;


    @Captor
    private ArgumentCaptor<DreamOverlayStateController.Callback> mCallbackCaptor;

    @Complication.Category
    @Complication.Category
    static final int COMPLICATION_CATEGORY = Complication.CATEGORY_SYSTEM;
    static final int COMPLICATION_CATEGORY = Complication.CATEGORY_SYSTEM;


@@ -189,8 +186,6 @@ public class ComplicationHostViewControllerTest extends SysuiTestCase {


        // Dream entry animations finished.
        // Dream entry animations finished.
        when(mDreamOverlayStateController.areEntryAnimationsFinished()).thenReturn(true);
        when(mDreamOverlayStateController.areEntryAnimationsFinished()).thenReturn(true);
        final DreamOverlayStateController.Callback stateCallback = captureOverlayStateCallback();
        stateCallback.onStateChanged();


        // Add a complication after entry animations are finished.
        // Add a complication after entry animations are finished.
        final HashSet<ComplicationViewModel> complications = new HashSet<>(
        final HashSet<ComplicationViewModel> complications = new HashSet<>(
@@ -223,9 +218,4 @@ public class ComplicationHostViewControllerTest extends SysuiTestCase {
                mObserverCaptor.capture());
                mObserverCaptor.capture());
        return mObserverCaptor.getValue();
        return mObserverCaptor.getValue();
    }
    }

    private DreamOverlayStateController.Callback captureOverlayStateCallback() {
        verify(mDreamOverlayStateController).addCallback(mCallbackCaptor.capture());
        return mCallbackCaptor.getValue();
    }
}
}