Search in sources :

Example 1 with N_MR1

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);
}
Also used : Rect(android.graphics.Rect) Iterables(com.google.common.collect.Iterables) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Pair(android.util.Pair) Multimap(com.google.common.collect.Multimap) Process(android.os.Process) LOLLIPOP(android.os.Build.VERSION_CODES.LOLLIPOP) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) ArrayList(java.util.ArrayList) Implements(org.robolectric.annotation.Implements) IntentSender(android.content.IntentSender) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) Accessor(org.robolectric.util.reflector.Accessor) ForType(org.robolectric.util.reflector.ForType) Handler(android.os.Handler) Looper(android.os.Looper) UserHandle(android.os.UserHandle) L(android.os.Build.VERSION_CODES.L) O(android.os.Build.VERSION_CODES.O) N(android.os.Build.VERSION_CODES.N) Executor(java.util.concurrent.Executor) Q(android.os.Build.VERSION_CODES.Q) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) Predicate(java.util.function.Predicate) P(android.os.Build.VERSION_CODES.P) Collectors(java.util.stream.Collectors) Implementation(org.robolectric.annotation.Implementation) SessionCallback(android.content.pm.PackageInstaller.SessionCallback) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) Nullable(androidx.annotation.Nullable) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Reflector.reflector(org.robolectric.util.reflector.Reflector.reflector) ShortcutQuery(android.content.pm.LauncherApps.ShortcutQuery) N_MR1(android.os.Build.VERSION_CODES.N_MR1) ShortcutInfo(android.content.pm.ShortcutInfo) ComponentName(android.content.ComponentName) Implementation(org.robolectric.annotation.Implementation) Nullable(androidx.annotation.Nullable)

Aggregations

ComponentName (android.content.ComponentName)1 IntentSender (android.content.IntentSender)1 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)1 LauncherApps (android.content.pm.LauncherApps)1 ShortcutQuery (android.content.pm.LauncherApps.ShortcutQuery)1 SessionCallback (android.content.pm.PackageInstaller.SessionCallback)1 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)1 ShortcutInfo (android.content.pm.ShortcutInfo)1 Rect (android.graphics.Rect)1 L (android.os.Build.VERSION_CODES.L)1 LOLLIPOP (android.os.Build.VERSION_CODES.LOLLIPOP)1 N (android.os.Build.VERSION_CODES.N)1 N_MR1 (android.os.Build.VERSION_CODES.N_MR1)1 O (android.os.Build.VERSION_CODES.O)1 P (android.os.Build.VERSION_CODES.P)1 Q (android.os.Build.VERSION_CODES.Q)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Process (android.os.Process)1