Fixed DisplayCutout flaky test

The root cause is that only the top cutout spec was cached.

Now cache the full spec string.

Bug: 145983914
Test: atest android.view.DisplayCutoutTest#fromSpec_setsSafeInsets_top_and_bottom, android.view.DisplayCutoutTest#fromSpec_setsSafeInsets_top -- --abi x86
Test: atest DisplayCutouTest, ScreenDecorationTest
Change-Id: I21ef26e5453412ec659b1d05798b61f04c3d660b
Merged-In: I1d5663ebd8588021387b7ae5296851769954f996
This commit is contained in:
shawnlin
2020-03-06 17:19:42 +08:00
parent 9838205a67
commit a62e449f6b

View File

@@ -638,7 +638,8 @@ public final class DisplayCutout {
return sCachedCutout;
}
}
spec = spec.trim();
final String specToCache = spec.trim();
spec = specToCache;
final float offsetX;
if (spec.endsWith(RIGHT_MARKER)) {
offsetX = displayWidth;
@@ -709,7 +710,7 @@ public final class DisplayCutout {
final Pair<Path, DisplayCutout> result = new Pair<>(p, cutout);
synchronized (CACHE_LOCK) {
sCachedSpec = spec;
sCachedSpec = specToCache;
sCachedDisplayWidth = displayWidth;
sCachedDisplayHeight = displayHeight;
sCachedDensity = density;