Merge "Convert ItemInstallQueue to use Dagger" into main

This commit is contained in:
Treehugger Robot
2024-11-06 16:59:57 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 10 deletions
@@ -20,6 +20,7 @@ import android.content.Context;
import com.android.launcher3.contextualeducation.ContextualEduStatsManager;
import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.model.ItemInstallQueue;
import com.android.launcher3.pm.InstallSessionHelper;
import com.android.launcher3.util.ApiWrapper;
import com.android.launcher3.util.DaggerSingletonTracker;
@@ -48,6 +49,7 @@ public interface LauncherBaseAppComponent {
CustomWidgetManager getCustomWidgetManager();
IconShape getIconShape();
InstallSessionHelper getInstallSessionHelper();
ItemInstallQueue getItemInstallQueue();
RefreshRateTracker getRefreshRateTracker();
ScreenOnTracker getScreenOnTracker();
SettingsCache getSettingsCache();
@@ -45,16 +45,18 @@ import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.dagger.ApplicationContext;
import com.android.launcher3.dagger.LauncherAppSingleton;
import com.android.launcher3.dagger.LauncherBaseAppComponent;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.DaggerSingletonObject;
import com.android.launcher3.util.PersistedItemArray;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
import java.util.HashSet;
@@ -62,10 +64,13 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
/**
* Class to maintain a queue of pending items to be added to the workspace.
*/
public class ItemInstallQueue implements SafeCloseable {
@LauncherAppSingleton
public class ItemInstallQueue {
private static final String LOG = "ItemInstallQueue";
@@ -81,9 +86,8 @@ public class ItemInstallQueue implements SafeCloseable {
public static final int NEW_SHORTCUT_BOUNCE_DURATION = 450;
public static final int NEW_SHORTCUT_STAGGER_DELAY = 85;
public static MainThreadInitializedObject<ItemInstallQueue> INSTANCE =
new MainThreadInitializedObject<>(ItemInstallQueue::new);
public static DaggerSingletonObject<ItemInstallQueue> INSTANCE =
new DaggerSingletonObject<>(LauncherBaseAppComponent::getItemInstallQueue);
private final PersistedItemArray<PendingInstallShortcutInfo> mStorage =
new PersistedItemArray<>(APPS_PENDING_INSTALL);
private final Context mContext;
@@ -95,13 +99,11 @@ public class ItemInstallQueue implements SafeCloseable {
// Only accessed on worker thread
private List<PendingInstallShortcutInfo> mItems;
private ItemInstallQueue(Context context) {
@Inject
public ItemInstallQueue(@ApplicationContext Context context) {
mContext = context;
}
@Override
public void close() {}
@WorkerThread
private void ensureQueueLoaded() {
Preconditions.assertWorkerThread();