@Implements(value=android.content.pm.CrossProfileApps.class, minSdk=28) public class ShadowCrossProfileApps extends Object
Robolectric implementation of CrossProfileApps
.
Modifier and Type | Class and Description |
---|---|
static class |
ShadowCrossProfileApps.StartedMainActivity
Container object to hold parameters passed to
startMainActivity(ComponentName,
UserHandle) . |
Constructor and Description |
---|
ShadowCrossProfileApps() |
Modifier and Type | Method and Description |
---|---|
protected void |
__constructor__(Context context,
ICrossProfileApps service) |
void |
addTargetUserProfile(UserHandle userHandle)
Adds
userHandle to the list of accessible handles. |
void |
clearTargetUserProfiles()
Clears the list of accessible handles.
|
protected Drawable |
getProfileSwitchingIconDrawable(UserHandle userHandle)
Returns a
Drawable that can be shown for profile switching, which is guaranteed to always be the same for a particular user and to be distinct between users. |
protected CharSequence |
getProfileSwitchingLabel(UserHandle userHandle)
Returns a
CharSequence that can be shown as a label for profile switching, which is guaranteed to always be the same for a particular user and to be distinct between users. |
protected List<UserHandle> |
getTargetUserProfiles()
Returns a list of
UserHandle s currently accessible. |
ShadowCrossProfileApps.StartedMainActivity |
peekNextStartedMainActivity()
Returns the most recent
ComponentName , UserHandle pair started by CrossProfileApps.startMainActivity(ComponentName, UserHandle) , wrapped in ShadowCrossProfileApps.StartedMainActivity . |
void |
removeTargetUserProfile(UserHandle userHandle)
Removes
userHandle from the list of accessible handles, if present. |
protected void |
startMainActivity(ComponentName componentName,
UserHandle targetUser)
Simulates starting the main activity specified in the specified profile, performing the same security checks done by the real
CrossProfileApps . |
@Implementation protected void __constructor__(Context context, ICrossProfileApps service)
@Implementation protected List<UserHandle> getTargetUserProfiles()
Returns a list of UserHandle
s currently accessible. This list is populated from calls to addTargetUserProfile(UserHandle)
.
@Implementation protected Drawable getProfileSwitchingIconDrawable(UserHandle userHandle)
Returns a Drawable
that can be shown for profile switching, which is guaranteed to always be the same for a particular user and to be distinct between users.
@Implementation protected CharSequence getProfileSwitchingLabel(UserHandle userHandle)
Returns a CharSequence
that can be shown as a label for profile switching, which is guaranteed to always be the same for a particular user and to be distinct between users.
@Implementation protected void startMainActivity(ComponentName componentName, UserHandle targetUser)
Simulates starting the main activity specified in the specified profile, performing the same security checks done by the real CrossProfileApps
.
The most recent main activity started can be queried by peekNextStartedMainActivity()
.
public void addTargetUserProfile(UserHandle userHandle)
Adds userHandle
to the list of accessible handles.
public void removeTargetUserProfile(UserHandle userHandle)
Removes userHandle
from the list of accessible handles, if present.
public void clearTargetUserProfiles()
Clears the list of accessible handles.
public ShadowCrossProfileApps.StartedMainActivity peekNextStartedMainActivity()
Returns the most recent ComponentName
, UserHandle
pair started by CrossProfileApps.startMainActivity(ComponentName, UserHandle)
, wrapped in ShadowCrossProfileApps.StartedMainActivity
.