Package org.robolectric.shadows
Class ShadowLauncherApps
java.lang.Object
org.robolectric.shadows.ShadowLauncherApps
@Implements(value=android.content.pm.LauncherApps.class,
minSdk=21)
public class ShadowLauncherApps
extends Object
Shadow of
LauncherApps
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addActivity
(UserHandle userHandle, LauncherActivityInfo activityInfo) Adds aLauncherActivityInfo
to be retrieved bygetActivityList(String, UserHandle)
.void
addApplicationInfo
(UserHandle userHandle, String packageName, ApplicationInfo applicationInfo) Adds aApplicationInfo
to be retrieved bygetApplicationInfo(String, int, UserHandle)
.void
addDynamicShortcut
(ShortcutInfo shortcutInfo) Adds a dynamic shortcut to be returned bygetShortcuts(ShortcutQuery, UserHandle)
.void
addEnabledPackage
(UserHandle userHandle, String packageName) Adds an enabled package to be checked byisPackageEnabled(String, UserHandle)
.void
addShortcutConfigActivity
(UserHandle userHandle, LauncherActivityInfo activityInfo) Adds aLauncherActivityInfo
to be retrieved bygetShortcutConfigActivityList(String, UserHandle)
.void
addSuspendedPackageLauncherExtras
(UserHandle userHandle, String packageName, Bundle bundle) Adds aBundle
to be retrieved bygetSuspendedPackageLauncherExtras(String, UserHandle)
.protected List<LauncherActivityInfo>
getActivityList
(String packageName, UserHandle user) protected List<PackageInstaller.SessionInfo>
protected ApplicationInfo
getApplicationInfo
(String packageName, int flags, UserHandle user) protected IntentSender
protected List<LauncherActivityInfo>
getShortcutConfigActivityList
(String packageName, UserHandle user) protected List<ShortcutInfo>
getShortcuts
(LauncherApps.ShortcutQuery query, UserHandle user) This method is an incomplete implementation of this API that only supports querying for pinned dynamic shortcuts.protected Bundle
getSuspendedPackageLauncherExtras
(String packageName, UserHandle user) protected boolean
protected boolean
isActivityEnabled
(ComponentName component, UserHandle user) protected boolean
isPackageEnabled
(String packageName, UserHandle user) void
notifyPackageAdded
(String packageName) FiresLauncherApps.Callback.onPackageAdded(String, UserHandle)
on all of the registered callbacks, with the provided packageName.void
notifyPackageRemoved
(String packageName) FiresLauncherApps.Callback.onPackageRemoved(String, UserHandle)
on all of the registered callbacks, with the provided packageName.protected void
pinShortcuts
(String packageName, List<String> shortcutIds, UserHandle user) protected void
registerCallback
(LauncherApps.Callback callback) protected void
registerCallback
(LauncherApps.Callback callback, Handler handler) protected void
registerPackageInstallerSessionCallback
(Executor executor, PackageInstaller.SessionCallback callback) void
setActivityEnabled
(UserHandle userHandle, ComponentName componentName) Sets an activity referenced by ComponentName as enabled, to be checked byisActivityEnabled(ComponentName, UserHandle)
.void
setHasShortcutHostPermission
(boolean permission) Sets the return value ofhasShortcutHostPermission()
.protected boolean
shouldHideFromSuggestions
(String packageName, UserHandle user) protected void
startAppDetailsActivity
(ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts) protected void
startPackageInstallerSessionDetailsActivity
(PackageInstaller.SessionInfo sessionInfo, Rect sourceBounds, Bundle opts) protected void
startShortcut
(ShortcutInfo shortcut, Rect sourceBounds, Bundle startActivityOptions) protected void
startShortcut
(String packageName, String shortcutId, Rect sourceBounds, Bundle startActivityOptions, UserHandle user) protected void
unregisterCallback
(LauncherApps.Callback callback) protected void
-
Constructor Details
-
ShadowLauncherApps
public ShadowLauncherApps()
-
-
Method Details
-
addDynamicShortcut
Adds a dynamic shortcut to be returned bygetShortcuts(ShortcutQuery, UserHandle)
.- Parameters:
shortcutInfo
- the shortcut to add.
-
notifyPackageAdded
FiresLauncherApps.Callback.onPackageAdded(String, UserHandle)
on all of the registered callbacks, with the provided packageName.- Parameters:
packageName
- the package the was added.
-
addEnabledPackage
Adds an enabled package to be checked byisPackageEnabled(String, UserHandle)
.- Parameters:
userHandle
- the user handle to be added.packageName
- the package name to be added.
-
setActivityEnabled
Sets an activity referenced by ComponentName as enabled, to be checked byisActivityEnabled(ComponentName, UserHandle)
.- Parameters:
userHandle
- the user handle to be set.componentName
- the component name of the activity to be enabled.
-
addShortcutConfigActivity
Adds aLauncherActivityInfo
to be retrieved bygetShortcutConfigActivityList(String, UserHandle)
.- Parameters:
userHandle
- the user handle to be added.activityInfo
- theLauncherActivityInfo
to be added.
-
addActivity
Adds aLauncherActivityInfo
to be retrieved bygetActivityList(String, UserHandle)
.- Parameters:
userHandle
- the user handle to be added.activityInfo
- theLauncherActivityInfo
to be added.
-
notifyPackageRemoved
FiresLauncherApps.Callback.onPackageRemoved(String, UserHandle)
on all of the registered callbacks, with the provided packageName.- Parameters:
packageName
- the package the was removed.
-
addApplicationInfo
public void addApplicationInfo(UserHandle userHandle, String packageName, ApplicationInfo applicationInfo) Adds aApplicationInfo
to be retrieved bygetApplicationInfo(String, int, UserHandle)
.- Parameters:
userHandle
- the user handle to be added.packageName
- the package name to be added.applicationInfo
- the application info to be added.
-
startPackageInstallerSessionDetailsActivity
@Implementation(minSdk=29) protected void startPackageInstallerSessionDetailsActivity(@NonNull PackageInstaller.SessionInfo sessionInfo, @Nullable Rect sourceBounds, @Nullable Bundle opts) -
startAppDetailsActivity
@Implementation protected void startAppDetailsActivity(ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts) -
getShortcutConfigActivityList
@Implementation(minSdk=26) protected List<LauncherActivityInfo> getShortcutConfigActivityList(@Nullable String packageName, @NonNull UserHandle user) -
getShortcutConfigActivityIntent
@Implementation(minSdk=26) @Nullable protected IntentSender getShortcutConfigActivityIntent(@NonNull LauncherActivityInfo info) -
isPackageEnabled
-
getActivityList
@Implementation(minSdk=21) protected List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user) -
getApplicationInfo
@Implementation(minSdk=26) protected ApplicationInfo getApplicationInfo(@NonNull String packageName, int flags, @NonNull UserHandle user) throws PackageManager.NameNotFoundException -
addSuspendedPackageLauncherExtras
public void addSuspendedPackageLauncherExtras(UserHandle userHandle, String packageName, Bundle bundle) Adds aBundle
to be retrieved bygetSuspendedPackageLauncherExtras(String, UserHandle)
.- Parameters:
userHandle
- the user handle to be added.packageName
- the package name to be added.bundle
- the bundle for the extras.
-
getSuspendedPackageLauncherExtras
@Implementation(minSdk=28) @Nullable protected Bundle getSuspendedPackageLauncherExtras(String packageName, UserHandle user) throws PackageManager.NameNotFoundException -
shouldHideFromSuggestions
@Implementation(minSdk=29) protected boolean shouldHideFromSuggestions(@NonNull String packageName, @NonNull UserHandle user) -
isActivityEnabled
@Implementation(minSdk=21) protected boolean isActivityEnabled(ComponentName component, UserHandle user) -
setHasShortcutHostPermission
public void setHasShortcutHostPermission(boolean permission) Sets the return value ofhasShortcutHostPermission()
. If this isn't explicitly set,hasShortcutHostPermission()
defaults to returning false.- Parameters:
permission
- boolean to be returned
-
hasShortcutHostPermission
-
getShortcuts
@Implementation(minSdk=25) @Nullable protected List<ShortcutInfo> getShortcuts(@NonNull LauncherApps.ShortcutQuery query, @NonNull UserHandle user) This method is an incomplete implementation of this API that only supports querying for pinned dynamic shortcuts. It also doesn't not supportLauncherApps.ShortcutQuery.setChangedSince(long)
. -
pinShortcuts
@Implementation(minSdk=25) protected void pinShortcuts(@NonNull String packageName, @NonNull List<String> shortcutIds, @NonNull UserHandle user) -
startShortcut
@Implementation(minSdk=25) protected void startShortcut(@NonNull String packageName, @NonNull String shortcutId, @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions, @NonNull UserHandle user) -
startShortcut
@Implementation(minSdk=25) protected void startShortcut(@NonNull ShortcutInfo shortcut, @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions) -
registerCallback
-
registerCallback
-
unregisterCallback
-
registerPackageInstallerSessionCallback
@Implementation(minSdk=29) protected void registerPackageInstallerSessionCallback(@NonNull Executor executor, @NonNull PackageInstaller.SessionCallback callback) -
unregisterPackageInstallerSessionCallback
@Implementation(minSdk=29) protected void unregisterPackageInstallerSessionCallback(@NonNull PackageInstaller.SessionCallback callback) -
getAllPackageInstallerSessions
@Implementation(minSdk=29) @NonNull protected List<PackageInstaller.SessionInfo> getAllPackageInstallerSessions()
-