From bf9d047b534c47d2233a76732e98bfc2c91f7cb5 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 11 Oct 2024 13:04:18 -0700 Subject: [PATCH] Removing unnecessary SafeClosable requirement from DaggerSingletonObject Test: presubmit Bug: 361850561 Flag: EXEMPT dagger Change-Id: I453159be83e92eee92f5a18cfe0d3ea9a3123f47 --- .../android/launcher3/pm/InstallSessionHelper.java | 12 ++---------- .../launcher3/util/DaggerSingletonObject.java | 2 +- .../android/launcher3/pm/InstallSessionHelperTest.kt | 4 +--- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/com/android/launcher3/pm/InstallSessionHelper.java b/src/com/android/launcher3/pm/InstallSessionHelper.java index f36f595545..afc5117a63 100644 --- a/src/com/android/launcher3/pm/InstallSessionHelper.java +++ b/src/com/android/launcher3/pm/InstallSessionHelper.java @@ -38,13 +38,10 @@ import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.ItemInstallQueue; import com.android.launcher3.util.ApplicationInfoWrapper; import com.android.launcher3.util.DaggerSingletonObject; -import com.android.launcher3.util.DaggerSingletonTracker; -import com.android.launcher3.util.ExecutorUtil; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.Preconditions; -import com.android.launcher3.util.SafeCloseable; import java.util.ArrayList; import java.util.HashMap; @@ -59,7 +56,7 @@ import javax.inject.Inject; */ @SuppressWarnings("NewApi") @LauncherAppSingleton -public class InstallSessionHelper implements SafeCloseable { +public class InstallSessionHelper { @NonNull private static final String LOG = "InstallSessionHelper"; @@ -91,17 +88,12 @@ public class InstallSessionHelper implements SafeCloseable { private IntSet mPromiseIconIds; @Inject - public InstallSessionHelper(@NonNull @ApplicationContext final Context context, - DaggerSingletonTracker tracker) { + public InstallSessionHelper(@NonNull @ApplicationContext final Context context) { mInstaller = context.getPackageManager().getPackageInstaller(); mAppContext = context.getApplicationContext(); mLauncherApps = context.getSystemService(LauncherApps.class); - ExecutorUtil.executeSyncOnMainOrFail(() -> tracker.addCloseable(this)); } - @Override - public void close() { } - @WorkerThread @NonNull private IntSet getPromiseIconIds() { diff --git a/src/com/android/launcher3/util/DaggerSingletonObject.java b/src/com/android/launcher3/util/DaggerSingletonObject.java index b8cf2ae77a..febe6af2d4 100644 --- a/src/com/android/launcher3/util/DaggerSingletonObject.java +++ b/src/com/android/launcher3/util/DaggerSingletonObject.java @@ -29,7 +29,7 @@ import java.util.function.Function; * We should delete this class at the end and use @Inject to get dagger provided singletons. */ -public class DaggerSingletonObject { +public class DaggerSingletonObject { private final Function mFunction; public DaggerSingletonObject(Function function) { diff --git a/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt b/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt index a991981362..ca2ef42124 100644 --- a/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt +++ b/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt @@ -28,7 +28,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.launcher3.LauncherPrefs import com.android.launcher3.LauncherPrefs.Companion.PROMISE_ICON_IDS -import com.android.launcher3.util.DaggerSingletonTracker import com.android.launcher3.util.Executors.MODEL_EXECUTOR import com.android.launcher3.util.IntArray import com.android.launcher3.util.LauncherModelHelper @@ -54,7 +53,6 @@ class InstallSessionHelperTest { private val expectedAppPackage = "expectedAppPackage" private val expectedInstallerPackage = "expectedInstallerPackage" private val mockPackageInstaller: PackageInstaller = mock() - private val mTracker: DaggerSingletonTracker = mock() private lateinit var installSessionHelper: InstallSessionHelper private lateinit var launcherApps: LauncherApps @@ -64,7 +62,7 @@ class InstallSessionHelperTest { whenever(packageManager.packageInstaller).thenReturn(mockPackageInstaller) whenever(sandboxContext.packageName).thenReturn(expectedInstallerPackage) launcherApps = sandboxContext.spyService(LauncherApps::class.java) - installSessionHelper = InstallSessionHelper(sandboxContext, mTracker) + installSessionHelper = InstallSessionHelper(sandboxContext) } @Test