Package org.robolectric.shadows
Class ShadowCrossProfileApps
- java.lang.Object
-
- org.robolectric.shadows.ShadowCrossProfileApps
-
@Implements(value=android.content.pm.CrossProfileApps.class, minSdk=28) public class ShadowCrossProfileApps extends java.lang.ObjectRobolectric implementation ofCrossProfileApps.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowCrossProfileApps.StartedActivityContainer object to hold parameters passed tostartMainActivity(ComponentName, UserHandle)orstartActivity(ComponentName, UserHandle).static classShadowCrossProfileApps.StartedMainActivityDeprecated.UsepeekNextStartedActivity()andShadowCrossProfileApps.StartedActivityinstead.
-
Constructor Summary
Constructors Constructor Description ShadowCrossProfileApps()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void__constructor__(android.content.Context context, android.content.pm.ICrossProfileApps service)voidaddTargetUserProfile(android.os.UserHandle userHandle)AddsuserHandleto the list of accessible handles.voidclearNextStartedActivities()Clears all records ofShadowCrossProfileApps.StartedActivitys from calls toCrossProfileApps.startActivity(ComponentName, UserHandle)orCrossProfileApps.startMainActivity(ComponentName, UserHandle).voidclearTargetUserProfiles()Clears the list of accessible handles.ShadowCrossProfileApps.StartedActivitygetNextStartedActivity()Consumes the most recentComponentName,UserHandlepair started byCrossProfileApps.startMainActivity(ComponentName, UserHandle)orCrossProfileApps.startActivity(ComponentName, UserHandle), and returns it wrapped inShadowCrossProfileApps.StartedActivity.protected android.graphics.drawable.DrawablegetProfileSwitchingIconDrawable(android.os.UserHandle userHandle)Returns aDrawablethat 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 java.lang.CharSequencegetProfileSwitchingLabel(android.os.UserHandle userHandle)Returns aCharSequencethat 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 java.util.List<android.os.UserHandle>getTargetUserProfiles()Returns a list ofUserHandles currently accessible.ShadowCrossProfileApps.StartedActivitypeekNextStartedActivity()Returns the most recentComponentName,UserHandlepair started byCrossProfileApps.startMainActivity(ComponentName, UserHandle)orCrossProfileApps.startActivity(ComponentName, UserHandle), wrapped inShadowCrossProfileApps.StartedActivity.ShadowCrossProfileApps.StartedMainActivitypeekNextStartedMainActivity()Deprecated.UsepeekNextStartedActivity()instead.voidremoveTargetUserProfile(android.os.UserHandle userHandle)RemovesuserHandlefrom the list of accessible handles, if present.protected voidstartActivity(android.content.ComponentName componentName, android.os.UserHandle targetUser)Simulates starting the activity specified in the specified profile, performing the same security checks done by the realCrossProfileApps.protected voidstartMainActivity(android.content.ComponentName componentName, android.os.UserHandle targetUser)Simulates starting the main activity specified in the specified profile, performing the same security checks done by the realCrossProfileApps.protected voidverifyHasInteractAcrossProfilesPermission()Ensure the current package has the permission to interact across profiles.
-
-
-
Method Detail
-
__constructor__
@Implementation protected void __constructor__(android.content.Context context, android.content.pm.ICrossProfileApps service)
-
getTargetUserProfiles
@Implementation protected java.util.List<android.os.UserHandle> getTargetUserProfiles()
Returns a list ofUserHandles currently accessible. This list is populated from calls toaddTargetUserProfile(UserHandle).
-
getProfileSwitchingIconDrawable
@Implementation protected android.graphics.drawable.Drawable getProfileSwitchingIconDrawable(android.os.UserHandle userHandle)
Returns aDrawablethat can be shown for profile switching, which is guaranteed to always be the same for a particular user and to be distinct between users.
-
getProfileSwitchingLabel
@Implementation protected java.lang.CharSequence getProfileSwitchingLabel(android.os.UserHandle userHandle)
Returns aCharSequencethat 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.
-
startMainActivity
@Implementation protected void startMainActivity(android.content.ComponentName componentName, android.os.UserHandle targetUser)Simulates starting the main activity specified in the specified profile, performing the same security checks done by the realCrossProfileApps.The most recent main activity started can be queried by
peekNextStartedActivity()()}.
-
startActivity
@Implementation(minSdk=29) protected void startActivity(android.content.ComponentName componentName, android.os.UserHandle targetUser)Simulates starting the activity specified in the specified profile, performing the same security checks done by the realCrossProfileApps.The most recent main activity started can be queried by
peekNextStartedActivity()()}.
-
addTargetUserProfile
public void addTargetUserProfile(android.os.UserHandle userHandle)
AddsuserHandleto the list of accessible handles.
-
removeTargetUserProfile
public void removeTargetUserProfile(android.os.UserHandle userHandle)
RemovesuserHandlefrom the list of accessible handles, if present.
-
clearTargetUserProfiles
public void clearTargetUserProfiles()
Clears the list of accessible handles.
-
peekNextStartedMainActivity
@Nullable @Deprecated public ShadowCrossProfileApps.StartedMainActivity peekNextStartedMainActivity()
Deprecated.UsepeekNextStartedActivity()instead.Returns the most recentComponentName,UserHandlepair started byCrossProfileApps.startMainActivity(ComponentName, UserHandle), wrapped inShadowCrossProfileApps.StartedMainActivity.
-
peekNextStartedActivity
@Nullable public ShadowCrossProfileApps.StartedActivity peekNextStartedActivity()
Returns the most recentComponentName,UserHandlepair started byCrossProfileApps.startMainActivity(ComponentName, UserHandle)orCrossProfileApps.startActivity(ComponentName, UserHandle), wrapped inShadowCrossProfileApps.StartedActivity.
-
getNextStartedActivity
@Nullable public ShadowCrossProfileApps.StartedActivity getNextStartedActivity()
Consumes the most recentComponentName,UserHandlepair started byCrossProfileApps.startMainActivity(ComponentName, UserHandle)orCrossProfileApps.startActivity(ComponentName, UserHandle), and returns it wrapped inShadowCrossProfileApps.StartedActivity.
-
clearNextStartedActivities
public void clearNextStartedActivities()
Clears all records ofShadowCrossProfileApps.StartedActivitys from calls toCrossProfileApps.startActivity(ComponentName, UserHandle)orCrossProfileApps.startMainActivity(ComponentName, UserHandle).
-
verifyHasInteractAcrossProfilesPermission
protected void verifyHasInteractAcrossProfilesPermission()
Ensure the current package has the permission to interact across profiles.
-
-