use of android.os.Build.VERSION_CODES.N_MR1 in project robolectric by robolectric.
the class ShadowLauncherApps method getShortcuts.
/**
* This method is an incomplete implementation of this API that only supports querying for pinned
* dynamic shortcuts. It also doesn't not support {@link ShortcutQuery#setChangedSince(long)}.
*/
@Implementation(minSdk = N_MR1)
@Nullable
protected List<ShortcutInfo> getShortcuts(@NonNull ShortcutQuery query, @NonNull UserHandle user) {
if (reflector(ReflectorShortcutQuery.class, query).getChangedSince() != 0) {
throw new UnsupportedOperationException("Robolectric does not currently support ShortcutQueries that filter on time since" + " change.");
}
int flags = reflector(ReflectorShortcutQuery.class, query).getQueryFlags();
if ((flags & ShortcutQuery.FLAG_MATCH_PINNED) == 0 || (flags & ShortcutQuery.FLAG_MATCH_DYNAMIC) == 0) {
throw new UnsupportedOperationException("Robolectric does not currently support ShortcutQueries that match non-dynamic" + " Shortcuts.");
}
Iterable<ShortcutInfo> shortcutsItr = shortcuts;
List<String> ids = reflector(ReflectorShortcutQuery.class, query).getShortcutIds();
if (ids != null) {
shortcutsItr = Iterables.filter(shortcutsItr, shortcut -> ids.contains(shortcut.getId()));
}
ComponentName activity = reflector(ReflectorShortcutQuery.class, query).getActivity();
if (activity != null) {
shortcutsItr = Iterables.filter(shortcutsItr, shortcut -> shortcut.getActivity().equals(activity));
}
String packageName = reflector(ReflectorShortcutQuery.class, query).getPackage();
if (packageName != null && !packageName.isEmpty()) {
shortcutsItr = Iterables.filter(shortcutsItr, shortcut -> shortcut.getPackage().equals(packageName));
}
return Lists.newArrayList(shortcutsItr);
}
Aggregations