diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2019-07-17 14:30:04 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2019-07-17 15:16:33 -0700 |
commit | 31ab19f71db752b54861719cedb5c23737bfdeb4 (patch) | |
tree | 1f04bbbb064ff67b20732c20fad38ecbb014154f /go | |
parent | 273c079761a6fd289a317d43a493924cb78ca0dc (diff) | |
download | packages_apps_Trebuchet-31ab19f71db752b54861719cedb5c23737bfdeb4.tar.gz packages_apps_Trebuchet-31ab19f71db752b54861719cedb5c23737bfdeb4.tar.bz2 packages_apps_Trebuchet-31ab19f71db752b54861719cedb5c23737bfdeb4.zip |
Removing global state from DeepShortcutManager
This makes DeepShortcutManager thread-safe and avoids any locks
Change-Id: If4593b3541da6259591ff7a607efa58158006481
Diffstat (limited to 'go')
-rw-r--r-- | go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java index 1e449108d..c20ed129c 100644 --- a/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java +++ b/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java @@ -26,57 +26,46 @@ import android.os.UserHandle; import com.android.launcher3.ItemInfo; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; /** * Performs operations related to deep shortcuts, such as querying for them, pinning them, etc. */ public class DeepShortcutManager { - private static DeepShortcutManager sInstance; - private static final Object sInstanceLock = new Object(); + + private static final DeepShortcutManager sInstance = new DeepShortcutManager(); public static DeepShortcutManager getInstance(Context context) { - synchronized (sInstanceLock) { - if (sInstance == null) { - sInstance = new DeepShortcutManager(context.getApplicationContext()); - } - return sInstance; - } + return sInstance; } - private DeepShortcutManager(Context context) { - } + private final QueryResult mFailure = new QueryResult(); - public static boolean supportsShortcuts(ItemInfo info) { - return false; - } + private DeepShortcutManager() { } - public boolean wasLastCallSuccess() { + public static boolean supportsShortcuts(ItemInfo info) { return false; } - public void onShortcutsChanged(List<ShortcutInfo> shortcuts) { - } - /** * Queries for the shortcuts with the package name and provided ids. * * This method is intended to get the full details for shortcuts when they are added or updated, * because we only get "key" fields in onShortcutsChanged(). */ - public List<ShortcutInfo> queryForFullDetails(String packageName, + public QueryResult queryForFullDetails(String packageName, List<String> shortcutIds, UserHandle user) { - return Collections.emptyList(); + return mFailure; } /** * Gets all the manifest and dynamic shortcuts associated with the given package and user, * to be displayed in the shortcuts container on long press. */ - public List<ShortcutInfo> queryForShortcutsContainer(ComponentName activity, + public QueryResult queryForShortcutsContainer(ComponentName activity, UserHandle user) { - return Collections.emptyList(); + return mFailure; } /** @@ -106,20 +95,28 @@ public class DeepShortcutManager { * * If packageName is null, returns all pinned shortcuts regardless of package. */ - public List<ShortcutInfo> queryForPinnedShortcuts(String packageName, UserHandle user) { - return Collections.emptyList(); + public QueryResult queryForPinnedShortcuts(String packageName, UserHandle user) { + return mFailure; } - public List<ShortcutInfo> queryForPinnedShortcuts(String packageName, + public QueryResult queryForPinnedShortcuts(String packageName, List<String> shortcutIds, UserHandle user) { - return Collections.emptyList(); + return mFailure; } - public List<ShortcutInfo> queryForAllShortcuts(UserHandle user) { - return Collections.emptyList(); + public QueryResult queryForAllShortcuts(UserHandle user) { + return mFailure; } public boolean hasHostPermission() { return false; } + + + public static class QueryResult extends ArrayList<ShortcutInfo> { + + public boolean wasSuccess() { + return true; + } + } } |