DimLayer: More release fixes.
DimState and DimAnimatable are sharing ownership of the Dim layer with either having the possibility to remove it. They aren't holding references to eachother so its not clear where to consolidate ownership. We take the easy way out and add some valid checks so they can safely share ownership. Bug: 130315011 Test: Existing tests pass Change-Id: Id473e40c58f1ca0f4a6a23284e220c6fd2ec36d2
This commit is contained in:
@@ -102,7 +102,9 @@ class Dimmer {
|
||||
}
|
||||
|
||||
void removeSurface() {
|
||||
getPendingTransaction().remove(mDimLayer);
|
||||
if (mDimLayer != null && mDimLayer.isValid()) {
|
||||
getPendingTransaction().remove(mDimLayer);
|
||||
}
|
||||
mDimLayer = null;
|
||||
}
|
||||
}
|
||||
@@ -305,7 +307,9 @@ class Dimmer {
|
||||
|
||||
if (!mDimState.mDimming) {
|
||||
if (!mDimState.mAnimateExit) {
|
||||
t.remove(mDimState.mDimLayer);
|
||||
if (mDimState.mDimLayer.isValid()) {
|
||||
t.remove(mDimState.mDimLayer);
|
||||
}
|
||||
} else {
|
||||
startDimExit(mLastRequestedDimContainer, mDimState.mSurfaceAnimator, t);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
@@ -78,7 +79,9 @@ public class DimmerTests extends WindowTestsBase {
|
||||
|
||||
@Override
|
||||
public SurfaceControl build() {
|
||||
return mock(SurfaceControl.class);
|
||||
SurfaceControl mSc = mock(SurfaceControl.class);
|
||||
when(mSc.isValid()).thenReturn(true);
|
||||
return mSc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user