Merge "Prevents a ConcurrentModificationException in Widget" into sc-dev am: 3a37543fb9

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15001812

Change-Id: I6aa3f859df6a706716081d4258200eafeafcada3
This commit is contained in:
TreeHugger Robot
2021-06-17 01:09:54 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 5 deletions
@@ -36,6 +36,10 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public final class LauncherAppWidgetProviderInfoTest {
@@ -234,10 +238,11 @@ public final class LauncherAppWidgetProviderInfoTest {
Mockito.when(profile.getCellSize()).thenReturn(new Point(CELL_SIZE, CELL_SIZE));
InvariantDeviceProfile idp = new InvariantDeviceProfile();
idp.supportedProfiles.add(profile);
List<DeviceProfile> supportedProfiles = new ArrayList<>(idp.supportedProfiles);
supportedProfiles.add(profile);
idp.supportedProfiles = Collections.unmodifiableList(supportedProfiles);
idp.numColumns = NUM_OF_COLS;
idp.numRows = NUM_OF_ROWS;
return idp;
}
}
@@ -138,7 +138,10 @@ public class InvariantDeviceProfile {
public int defaultLayoutId;
int demoModeLayoutId;
public final List<DeviceProfile> supportedProfiles = new ArrayList<>();
/**
* An immutable list of supported profiles.
*/
public List<DeviceProfile> supportedProfiles = Collections.EMPTY_LIST;
@Nullable public DevicePaddings devicePaddings;
@@ -313,10 +316,10 @@ public class InvariantDeviceProfile {
// Supported overrides: numRows, numColumns, iconSize
applyPartnerDeviceProfileOverrides(context, metrics);
supportedProfiles.clear();
final List<DeviceProfile> localSupportedProfiles = new ArrayList<>();
defaultWallpaperSize = new Point(displayInfo.currentSize);
for (WindowBounds bounds : displayInfo.supportedBounds) {
supportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo)
localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo)
.setUseTwoPanels(isSplitDisplay)
.setWindowBounds(bounds).build());
@@ -334,6 +337,7 @@ public class InvariantDeviceProfile {
defaultWallpaperSize.x =
Math.max(defaultWallpaperSize.x, Math.round(parallaxFactor * displayWidth));
}
supportedProfiles = Collections.unmodifiableList(localSupportedProfiles);
ComponentName cn = new ComponentName(context.getPackageName(), getClass().getName());
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);