Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf9d047b authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing unnecessary SafeClosable requirement from DaggerSingletonObject

Test: presubmit
Bug: 361850561
Flag: EXEMPT dagger
Change-Id: I453159be83e92eee92f5a18cfe0d3ea9a3123f47
parent bb9300c7
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -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() {
+1 −1
Original line number Diff line number Diff line
@@ -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<T extends SafeCloseable> {
public class DaggerSingletonObject<T> {
    private final Function<LauncherAppComponent, T> mFunction;

    public DaggerSingletonObject(Function<LauncherAppComponent, T> function) {
+1 −3
Original line number Diff line number Diff line
@@ -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