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:
Sunny Goyal committed 2024-04-22 17:04:33 -07:00
1 parent 1f40fa0e7f
commit 10fa016352
35 files changed
+233 -245

No files matched your search

@@ -48,11 +48,11 @@ public class LauncherProvider extends ContentProvider {
*/
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
if (appState == null || !appState.getModel().isModelLoaded()) {
return;
}
appState.getModel().dumpState("", fd, writer, args);
LauncherAppState.INSTANCE.executeIfCreated(appState -> {
if (appState.getModel().isModelLoaded()) {
appState.getModel().dumpState("", fd, writer, args);
}
});
}
@Override