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

Commit 176cef87 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Fix some QSFragment leaks" into udc-qpr-dev

parents 01c82157 bd04a016
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -130,6 +130,11 @@ public class QSIconViewImpl extends QSIconView {
                d.setLayoutDirection(getLayoutDirection());
            }

            final Drawable lastDrawable = iv.getDrawable();
            if (lastDrawable instanceof Animatable2) {
                ((Animatable2) lastDrawable).clearAnimationCallbacks();
            }

            if (iv instanceof SlashImageView) {
                ((SlashImageView) iv).setAnimationEnabled(shouldAnimate);
                ((SlashImageView) iv).setState(null, d);
+9 −3
Original line number Diff line number Diff line
@@ -172,7 +172,8 @@ public class InternetDialogController implements AccessPointController.AccessPoi
    private Executor mExecutor;
    private AccessPointController mAccessPointController;
    private IntentFilter mConnectionStateFilter;
    private InternetDialogCallback mCallback;
    @VisibleForTesting
    InternetDialogCallback mCallback;
    private UiEventLogger mUiEventLogger;
    private BroadcastDispatcher mBroadcastDispatcher;
    private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@@ -215,13 +216,17 @@ public class InternetDialogController implements AccessPointController.AccessPoi
            new KeyguardUpdateMonitorCallback() {
                @Override
                public void onRefreshCarrierInfo() {
                    if (mCallback != null) {
                        mCallback.onRefreshCarrierInfo();
                    }
                }

                @Override
                public void onSimStateChanged(int subId, int slotId, int simState) {
                    if (mCallback != null) {
                        mCallback.onSimStateChanged();
                    }
                }
            };

    protected List<SubscriptionInfo> getSubscriptionInfo() {
@@ -331,6 +336,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi
        mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateCallback);
        mConnectivityManager.unregisterNetworkCallback(mConnectivityManagerNetworkCallback);
        mConnectedWifiInternetMonitor.unregisterCallback();
        mCallback = null;
    }

    @VisibleForTesting
+22 −0
Original line number Diff line number Diff line
@@ -155,6 +155,28 @@ public class QSIconViewImplTest extends SysuiTestCase {
        inOrder.verify(d).stop();
    }

    @Test
    public void testAnimatorCallbackRemovedOnOldDrawable() {
        ImageView iv = new ImageView(mContext);
        AnimatedVectorDrawable d1 = mock(AnimatedVectorDrawable.class);
        when(d1.getConstantState()).thenReturn(fakeConstantState(d1));
        AnimatedVectorDrawable d2 = mock(AnimatedVectorDrawable.class);
        when(d2.getConstantState()).thenReturn(fakeConstantState(d2));
        State s = new State();
        s.isTransient = true;

        // When set Animatable2 d1
        s.icon = new QSTileImpl.DrawableIcon(d1);
        mIconView.updateIcon(iv, s, true);

        // And then set Animatable2 d2
        s.icon = new QSTileImpl.DrawableIcon(d2);
        mIconView.updateIcon(iv, s, true);

        // Then d1 has its callback cleared
        verify(d1).clearAnimationCallbacks();
    }

    private static Drawable.ConstantState fakeConstantState(Drawable otherDrawable) {
        return new Drawable.ConstantState() {
            @Override
+2 −0
Original line number Diff line number Diff line
@@ -968,6 +968,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
        assertThat(mInternetDialogController.mSubIdTelephonyManagerMap.get(SUB_ID)).isEqualTo(
                mTelephonyManager);
        assertThat(mInternetDialogController.mSubIdTelephonyCallbackMap.get(SUB_ID)).isNotNull();
        assertThat(mInternetDialogController.mCallback).isNotNull();

        mInternetDialogController.onStop();

@@ -980,6 +981,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
        verify(mAccessPointController).removeAccessPointCallback(mInternetDialogController);
        verify(mConnectivityManager).unregisterNetworkCallback(
                any(ConnectivityManager.NetworkCallback.class));
        assertThat(mInternetDialogController.mCallback).isNull();
    }

    private String getResourcesString(String name) {