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

Commit d423a8b8 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Changing DeepShortcutManager to have a singleton contructor instead of...

Merge "Changing DeepShortcutManager to have a singleton contructor instead of getting it from LauncherAppState" into ub-launcher3-master
parents 0993a378 dde4fd97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2594,7 +2594,7 @@ public class Launcher extends Activity
                if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
                    String id = ((ShortcutInfo) info).getDeepShortcutId();
                    String packageName = intent.getPackage();
                    LauncherAppState.getInstance().getShortcutManager().startShortcut(
                    DeepShortcutManager.getInstance(this).startShortcut(
                            packageName, id, intent.getSourceBounds(), optsBundle, info.user);
                } else {
                    // Could be launching some bookkeeping activity
+1 −9
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dynamicui.ExtractionUtils;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutCache;
import com.android.launcher3.util.ConfigMonitor;
import com.android.launcher3.util.TestingUtils;
import com.android.launcher3.util.Thunk;
@@ -44,7 +42,6 @@ public class LauncherAppState {
    @Thunk final LauncherModel mModel;
    private final IconCache mIconCache;
    private final WidgetPreviewLoader mWidgetCache;
    private final DeepShortcutManager mDeepShortcutManager;

    @Thunk boolean mWallpaperChangedSinceLastCheck;

@@ -98,10 +95,9 @@ public class LauncherAppState {
        mInvariantDeviceProfile = new InvariantDeviceProfile(sContext);
        mIconCache = new IconCache(sContext, mInvariantDeviceProfile);
        mWidgetCache = new WidgetPreviewLoader(sContext, mIconCache);
        mDeepShortcutManager = new DeepShortcutManager(sContext, new ShortcutCache());

        mAppFilter = AppFilter.loadByName(sContext.getString(R.string.app_filter_class));
        mModel = new LauncherModel(this, mIconCache, mAppFilter, mDeepShortcutManager);
        mModel = new LauncherModel(this, mIconCache, mAppFilter);

        LauncherAppsCompat.getInstance(sContext).addOnAppsChangedCallback(mModel);

@@ -173,10 +169,6 @@ public class LauncherAppState {
        return mWidgetCache;
    }

    public DeepShortcutManager getShortcutManager() {
        return mDeepShortcutManager;
    }

    public boolean hasWallpaperChangedSinceLastCheck() {
        boolean result = mWallpaperChangedSinceLastCheck;
        mWallpaperChangedSinceLastCheck = false;
+11 −11
Original line number Diff line number Diff line
@@ -156,7 +156,8 @@ public class LauncherModel extends BroadcastReceiver
        @Override
        public void run() {
            if (mDeepShortcutsLoaded) {
                boolean hasShortcutHostPermission = mDeepShortcutManager.hasHostPermission();
                boolean hasShortcutHostPermission =
                        DeepShortcutManager.getInstance(mApp.getContext()).hasHostPermission();
                if (hasShortcutHostPermission != mHasShortcutHostPermission) {
                    mApp.reloadWorkspace();
                }
@@ -173,7 +174,6 @@ public class LauncherModel extends BroadcastReceiver
    // </ only access in worker thread >

    private final IconCache mIconCache;
    private final DeepShortcutManager mDeepShortcutManager;

    private final LauncherAppsCompat mLauncherApps;
    private final UserManagerCompat mUserManager;
@@ -210,14 +210,12 @@ public class LauncherModel extends BroadcastReceiver
        public void bindDeepShortcutMap(MultiHashMap<ComponentKey, String> deepShortcutMap);
    }

    LauncherModel(LauncherAppState app, IconCache iconCache, AppFilter appFilter,
            DeepShortcutManager deepShortcutManager) {
    LauncherModel(LauncherAppState app, IconCache iconCache, AppFilter appFilter) {
        Context context = app.getContext();
        mApp = app;
        mBgAllAppsList = new AllAppsList(iconCache, appFilter);
        mBgWidgetsModel = new WidgetsModel(iconCache, appFilter);
        mIconCache = iconCache;
        mDeepShortcutManager = deepShortcutManager;

        mLauncherApps = LauncherAppsCompat.getInstance(context);
        mUserManager = UserManagerCompat.getInstance(context);
@@ -1191,6 +1189,7 @@ public class LauncherModel extends BroadcastReceiver
            final PackageManager manager = context.getPackageManager();
            final boolean isSafeMode = manager.isSafeMode();
            final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
            final DeepShortcutManager shortcutManager = DeepShortcutManager.getInstance(context);
            final boolean isSdCardReady = Utilities.isBootCompleted();
            final MultiHashMap<UserHandleCompat, String> pendingPackages = new MultiHashMap<>();

@@ -1288,8 +1287,8 @@ public class LauncherModel extends BroadcastReceiver
                        // We can only query for shortcuts when the user is unlocked.
                        if (userUnlocked) {
                            List<ShortcutInfoCompat> pinnedShortcuts =
                                    mDeepShortcutManager.queryForPinnedShortcuts(null, user);
                            if (mDeepShortcutManager.wasLastCallSuccess()) {
                                    shortcutManager.queryForPinnedShortcuts(null, user);
                            if (shortcutManager.wasLastCallSuccess()) {
                                for (ShortcutInfoCompat shortcut : pinnedShortcuts) {
                                    shortcutKeyToPinnedShortcuts.put(ShortcutKey.fromInfo(shortcut),
                                            shortcut);
@@ -1773,7 +1772,7 @@ public class LauncherModel extends BroadcastReceiver
                    MutableInt numTimesPinned = sBgDataModel.pinnedShortcutCounts.get(key);
                    if (numTimesPinned == null || numTimesPinned.value == 0) {
                        // Shortcut is pinned but doesn't exist on the workspace; unpin it.
                        mDeepShortcutManager.unpinShortcut(key);
                        shortcutManager.unpinShortcut(key);
                    }
                }

@@ -2326,12 +2325,13 @@ public class LauncherModel extends BroadcastReceiver
            }
            if (!mDeepShortcutsLoaded) {
                sBgDataModel.deepShortcutMap.clear();
                mHasShortcutHostPermission = mDeepShortcutManager.hasHostPermission();
                DeepShortcutManager shortcutManager = DeepShortcutManager.getInstance(mContext);
                mHasShortcutHostPermission = shortcutManager.hasHostPermission();
                if (mHasShortcutHostPermission) {
                    for (UserHandleCompat user : mUserManager.getUserProfiles()) {
                        if (mUserManager.isUserUnlocked(user)) {
                            List<ShortcutInfoCompat> shortcuts = mDeepShortcutManager
                                    .queryForAllShortcuts(user);
                            List<ShortcutInfoCompat> shortcuts =
                                    shortcutManager.queryForAllShortcuts(user);
                            sBgDataModel.updateDeepShortcutMap(null, user, shortcuts);
                        }
                    }
+2 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.util.ContentWriter;

@@ -295,7 +296,7 @@ public class ShortcutInfo extends ItemInfo {

        // TODO: Use cache for this
        LauncherAppState launcherAppState = LauncherAppState.getInstance();
        Drawable unbadgedDrawable = launcherAppState.getShortcutManager()
        Drawable unbadgedDrawable = DeepShortcutManager.getInstance(context)
                .getShortcutIconDrawable(shortcutInfo,
                        launcherAppState.getInvariantDeviceProfile().fillResIconDpi);

+4 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.util.ComponentKey;
@@ -123,8 +124,8 @@ public class BgDataModel {
                    ShortcutKey pinnedShortcut = ShortcutKey.fromShortcutInfo((ShortcutInfo) item);
                    MutableInt count = pinnedShortcutCounts.get(pinnedShortcut);
                    if (count == null || --count.value == 0) {
                        LauncherAppState.getInstance()
                                .getShortcutManager().unpinShortcut(pinnedShortcut);
                        DeepShortcutManager.getInstance(LauncherAppState.getInstance().getContext())
                                .unpinShortcut(pinnedShortcut);
                    }
                    // Fall through.
                }
@@ -161,7 +162,7 @@ public class BgDataModel {

                // Since this is a new item, pin the shortcut in the system server.
                if (newItem && count.value == 1) {
                    LauncherAppState.getInstance().getShortcutManager()
                    DeepShortcutManager.getInstance(LauncherAppState.getInstance().getContext())
                            .pinShortcut(pinnedShortcut);
                }
                // Fall through
Loading