Merge "Fix some QSFragment leaks" into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
176cef8731
@@ -130,6 +130,11 @@ public class QSIconViewImpl extends QSIconView {
|
|||||||
d.setLayoutDirection(getLayoutDirection());
|
d.setLayoutDirection(getLayoutDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Drawable lastDrawable = iv.getDrawable();
|
||||||
|
if (lastDrawable instanceof Animatable2) {
|
||||||
|
((Animatable2) lastDrawable).clearAnimationCallbacks();
|
||||||
|
}
|
||||||
|
|
||||||
if (iv instanceof SlashImageView) {
|
if (iv instanceof SlashImageView) {
|
||||||
((SlashImageView) iv).setAnimationEnabled(shouldAnimate);
|
((SlashImageView) iv).setAnimationEnabled(shouldAnimate);
|
||||||
((SlashImageView) iv).setState(null, d);
|
((SlashImageView) iv).setState(null, d);
|
||||||
|
|||||||
@@ -172,7 +172,8 @@ public class InternetDialogController implements AccessPointController.AccessPoi
|
|||||||
private Executor mExecutor;
|
private Executor mExecutor;
|
||||||
private AccessPointController mAccessPointController;
|
private AccessPointController mAccessPointController;
|
||||||
private IntentFilter mConnectionStateFilter;
|
private IntentFilter mConnectionStateFilter;
|
||||||
private InternetDialogCallback mCallback;
|
@VisibleForTesting
|
||||||
|
InternetDialogCallback mCallback;
|
||||||
private UiEventLogger mUiEventLogger;
|
private UiEventLogger mUiEventLogger;
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
@@ -215,13 +216,17 @@ public class InternetDialogController implements AccessPointController.AccessPoi
|
|||||||
new KeyguardUpdateMonitorCallback() {
|
new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefreshCarrierInfo() {
|
public void onRefreshCarrierInfo() {
|
||||||
|
if (mCallback != null) {
|
||||||
mCallback.onRefreshCarrierInfo();
|
mCallback.onRefreshCarrierInfo();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSimStateChanged(int subId, int slotId, int simState) {
|
public void onSimStateChanged(int subId, int slotId, int simState) {
|
||||||
|
if (mCallback != null) {
|
||||||
mCallback.onSimStateChanged();
|
mCallback.onSimStateChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected List<SubscriptionInfo> getSubscriptionInfo() {
|
protected List<SubscriptionInfo> getSubscriptionInfo() {
|
||||||
@@ -331,6 +336,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi
|
|||||||
mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateCallback);
|
mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateCallback);
|
||||||
mConnectivityManager.unregisterNetworkCallback(mConnectivityManagerNetworkCallback);
|
mConnectivityManager.unregisterNetworkCallback(mConnectivityManagerNetworkCallback);
|
||||||
mConnectedWifiInternetMonitor.unregisterCallback();
|
mConnectedWifiInternetMonitor.unregisterCallback();
|
||||||
|
mCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -155,6 +155,28 @@ public class QSIconViewImplTest extends SysuiTestCase {
|
|||||||
inOrder.verify(d).stop();
|
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) {
|
private static Drawable.ConstantState fakeConstantState(Drawable otherDrawable) {
|
||||||
return new Drawable.ConstantState() {
|
return new Drawable.ConstantState() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -968,6 +968,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
assertThat(mInternetDialogController.mSubIdTelephonyManagerMap.get(SUB_ID)).isEqualTo(
|
assertThat(mInternetDialogController.mSubIdTelephonyManagerMap.get(SUB_ID)).isEqualTo(
|
||||||
mTelephonyManager);
|
mTelephonyManager);
|
||||||
assertThat(mInternetDialogController.mSubIdTelephonyCallbackMap.get(SUB_ID)).isNotNull();
|
assertThat(mInternetDialogController.mSubIdTelephonyCallbackMap.get(SUB_ID)).isNotNull();
|
||||||
|
assertThat(mInternetDialogController.mCallback).isNotNull();
|
||||||
|
|
||||||
mInternetDialogController.onStop();
|
mInternetDialogController.onStop();
|
||||||
|
|
||||||
@@ -980,6 +981,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
verify(mAccessPointController).removeAccessPointCallback(mInternetDialogController);
|
verify(mAccessPointController).removeAccessPointCallback(mInternetDialogController);
|
||||||
verify(mConnectivityManager).unregisterNetworkCallback(
|
verify(mConnectivityManager).unregisterNetworkCallback(
|
||||||
any(ConnectivityManager.NetworkCallback.class));
|
any(ConnectivityManager.NetworkCallback.class));
|
||||||
|
assertThat(mInternetDialogController.mCallback).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getResourcesString(String name) {
|
private String getResourcesString(String name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user