Merge "Removing unnecessary SafeClosable requirement from DaggerSingletonObject" into main
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user