Package org.robolectric.shadows
Class ShadowLauncherApps
java.lang.Object
org.robolectric.shadows.ShadowLauncherApps
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) static void
reset()
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
-
reset
-
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(PackageInstaller.SessionInfo sessionInfo, Rect sourceBounds, Bundle opts) -
startAppDetailsActivity
@Implementation protected void startAppDetailsActivity(ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts) -
getShortcutConfigActivityList
@Implementation(minSdk=26) protected List<LauncherActivityInfo> getShortcutConfigActivityList(String packageName, UserHandle user) -
getShortcutConfigActivityIntent
@Implementation(minSdk=26) protected IntentSender getShortcutConfigActivityIntent(LauncherActivityInfo info) -
isPackageEnabled
-
getActivityList
@Implementation(minSdk=21) protected List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user) -
getApplicationInfo
@Implementation(minSdk=26) protected ApplicationInfo getApplicationInfo(String packageName, int flags, 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) protected Bundle getSuspendedPackageLauncherExtras(String packageName, UserHandle user) throws PackageManager.NameNotFoundException -
shouldHideFromSuggestions
@Implementation(minSdk=29) protected boolean shouldHideFromSuggestions(String packageName, 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) 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. It also doesn't not supportLauncherApps.ShortcutQuery.setChangedSince(long)
. -
pinShortcuts
@Implementation(minSdk=25) protected void pinShortcuts(String packageName, List<String> shortcutIds, UserHandle user) -
startShortcut
@Implementation(minSdk=25) protected void startShortcut(String packageName, String shortcutId, Rect sourceBounds, Bundle startActivityOptions, UserHandle user) -
startShortcut
@Implementation(minSdk=25) protected void startShortcut(ShortcutInfo shortcut, Rect sourceBounds, Bundle startActivityOptions) -
registerCallback
-
registerCallback
-
unregisterCallback
-
registerPackageInstallerSessionCallback
@Implementation(minSdk=29) protected void registerPackageInstallerSessionCallback(Executor executor, PackageInstaller.SessionCallback callback) -
unregisterPackageInstallerSessionCallback
@Implementation(minSdk=29) protected void unregisterPackageInstallerSessionCallback(PackageInstaller.SessionCallback callback) -
getAllPackageInstallerSessions
@Implementation(minSdk=29) protected List<PackageInstaller.SessionInfo> getAllPackageInstallerSessions()
-