From bae6a107de82699b21dca950402df1b279dc9e0a Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Thu, 3 Oct 2024 17:35:00 -0700 Subject: [PATCH] Rename to ObjectSandbox. Flag: TEST_ONLY Bug: 369504330 Test: go/testedequals Change-Id: Iacfdc62270aa6f23e7c9b79205d967272e0a7a66 --- .../launcher3/util/MainThreadInitializedObject.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/util/MainThreadInitializedObject.java b/src/com/android/launcher3/util/MainThreadInitializedObject.java index a7d5c130f3..9a70298a5b 100644 --- a/src/com/android/launcher3/util/MainThreadInitializedObject.java +++ b/src/com/android/launcher3/util/MainThreadInitializedObject.java @@ -50,7 +50,7 @@ public class MainThreadInitializedObject { public T get(Context context) { Context app = context.getApplicationContext(); - if (app instanceof SandboxApplication sc) { + if (app instanceof ObjectSandbox sc) { return sc.getObject(this); } @@ -100,7 +100,8 @@ public class MainThreadInitializedObject { T get(Context context); } - public interface SandboxApplication { + /** Sandbox for isolating {@link MainThreadInitializedObject} instances from Launcher. */ + public interface ObjectSandbox { /** * Find a cached object from mObjectMap if we have already created one. If not, generate @@ -116,7 +117,7 @@ public class MainThreadInitializedObject { void putObject(MainThreadInitializedObject object, T value); /** - * Returns whether this context should cleanup all objects when its destroyed or leave it + * Returns whether this sandbox should cleanup all objects when its destroyed or leave it * to the GC. * These objects can have listeners attached to the system server and mey not be able to get * GCed themselves when running on a device. @@ -137,7 +138,7 @@ public class MainThreadInitializedObject { * Abstract Context which allows custom implementations for * {@link MainThreadInitializedObject} providers */ - public static class SandboxContext extends LauncherApplication implements SandboxApplication { + public static class SandboxContext extends LauncherApplication implements ObjectSandbox { private static final String TAG = "SandboxContext"; @@ -159,8 +160,8 @@ public class MainThreadInitializedObject { @Override public boolean shouldCleanUpOnDestroy() { - return (getBaseContext().getApplicationContext() instanceof SandboxApplication sa) - ? sa.shouldCleanUpOnDestroy() : true; + return (getBaseContext().getApplicationContext() instanceof ObjectSandbox os) + ? os.shouldCleanUpOnDestroy() : true; } public void onDestroy() {