mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Fixing MainThreadInitializedObject
> Making SafeCloseable implementation mandatory, to prevent leaks during test and preview > Removing getNoCreate method and defining executeIfCreated to avoid null pointer exceptions > Fixing sandbox value leaking into main, by Checking sandbox against App context > Converting sanbox to an interface instead a class Bug: 335280439 Test: Presubmit Flag: None Change-Id: I951dcde871898e745ff6490a1c4f8fd1512888f5
This commit is contained in:
@@ -59,6 +59,7 @@ import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.LockedUserState;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.Partner;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
import com.android.launcher3.util.WindowBounds;
|
||||
import com.android.launcher3.util.window.WindowManagerProxy;
|
||||
|
||||
@@ -75,7 +76,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InvariantDeviceProfile {
|
||||
public class InvariantDeviceProfile implements SafeCloseable {
|
||||
|
||||
public static final String TAG = "IDP";
|
||||
// We do not need any synchronization for this variable as its only written on UI thread.
|
||||
@@ -229,9 +230,8 @@ public class InvariantDeviceProfile {
|
||||
if (!newGridName.equals(gridName)) {
|
||||
LauncherPrefs.get(context).put(GRID_NAME, newGridName);
|
||||
}
|
||||
LockedUserState.get(context).runOnUserUnlocked(() -> {
|
||||
new DeviceGridState(this).writeToPrefs(context);
|
||||
});
|
||||
LockedUserState.get(context).runOnUserUnlocked(() ->
|
||||
new DeviceGridState(this).writeToPrefs(context));
|
||||
|
||||
DisplayController.INSTANCE.get(context).setPriorityListener(
|
||||
(displayContext, info, flags) -> {
|
||||
@@ -295,6 +295,11 @@ public class InvariantDeviceProfile {
|
||||
initGrid(context, myInfo, result, deviceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
DisplayController.INSTANCE.executeIfCreated(dc -> dc.setPriorityListener(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinitialize the current grid after a restore, where some grids might now be disabled.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user