public final class

MAMPolicyManager

extends Object
java.lang.Object
   ↳ com.microsoft.intune.mam.client.identity.MAMPolicyManager

Class Overview

Allows multi-identity apps to specify the current identity, which will determine the active policy. Allows all apps to retrieve the active policy, or the policy for a specific identity.

Summary

Public Methods
static void bypassConditionalLaunchChecks(Activity activity)
Allow the given Activity to bypass conditional launch checks.
static String getCurrentIdentity(Context context)
Computes the current effective identity that will be used for policy.
static String getCurrentThreadIdentity()
Get the current thread identity.
static AppPolicy getCurrentThreadPolicy()
Get the current app policy.
static boolean getIsIdentityManaged(String identity)
static AppPolicy getPolicy(Context context)
Get the current app policy.
static AppPolicy getPolicy()
Deprecated alias for getCurrentThreadPolicy.
static AppPolicy getPolicyForIdentity(String identity)
Get the applicable app policy for a given identity.
static String getProcessIdentity()
Get the process-wide identity.
static String getUIPolicyIdentity(Context context)
Get the current UI identity.
static MAMIdentitySwitchResult setCurrentThreadIdentity(String identity)
Set the current thread identity.
static MAMIdentitySwitchResult setProcessIdentity(String identity)
Set the process-wide identity.
static void setUIPolicyIdentity(Context context, String identity, MAMSetUIIdentityCallback mamSetUIIdentityCallback)
Set the associated identity with the Context.
static void setUIPolicyIdentity(Context context, String identity, MAMSetUIIdentityCallback mamSetUIIdentityCallback, EnumSet<IdentitySwitchOption> options)
Set the associated identity with the Context.
static void showDiagnostics(Context context)
Display the Intune Diagnostics screen.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void bypassConditionalLaunchChecks (Activity activity)

Allow the given Activity to bypass conditional launch checks. This must be called before onMAMCreate, e.g. from the Activity's constructor or attachBaseContext() override. Because this method allows the bypass of conditional launch policy checks, it should only be used after consulting with Microsoft to confirm there is no other supported way to achieve your app’s desired behavior.

Parameters
activity The activity to exempt from the launch checks.

public static String getCurrentIdentity (Context context)

Computes the current effective identity that will be used for policy. The following identity sources are considered in order 1. Thread 2. Context (UI identity) 3. Process 4. Default (empty string for multi-identity apps or apps with no policy, managed user for single-identity apps)

Parameters
context context to check identity on for (2) above
Returns
  • effective identity

public static String getCurrentThreadIdentity ()

Get the current thread identity.

Returns
  • Current thread identity.

public static AppPolicy getCurrentThreadPolicy ()

Get the current app policy. This does NOT take the UI (Context) identity into account. To take UI identity into account, use the override which takes a Context.

Returns
  • Policy for the current identity.

public static boolean getIsIdentityManaged (String identity)

Parameters
identity identity
Returns
  • true if the identity has policy

public static AppPolicy getPolicy (Context context)

Get the current app policy.

Parameters
context for which the policy will be applicable. This is used to retrieve the UI identity.
Returns
  • Policy for the current identity.

public static AppPolicy getPolicy ()

Deprecated alias for getCurrentThreadPolicy.

Returns
  • see getCurrentThreadPolicy

public static AppPolicy getPolicyForIdentity (String identity)

Get the applicable app policy for a given identity.

Parameters
identity Identity to get policy for.
Returns
  • Policy for the identity.

public static String getProcessIdentity ()

Get the process-wide identity.

Returns
  • Current process-wide identity.

public static String getUIPolicyIdentity (Context context)

Get the current UI identity.

Parameters
context Context to get the identity from.
Returns
  • Current UI identity.

public static MAMIdentitySwitchResult setCurrentThreadIdentity (String identity)

Set the current thread identity.

Parameters
identity Identity to set. If null, the current thread identity is cleared.
Returns
  • SUCCEEDED after thread identity is set correctly. FAILED if the app is not MI-enabled.

public static MAMIdentitySwitchResult setProcessIdentity (String identity)

Set the process-wide identity.

Parameters
identity New process-wide identity. If null, the process identity is cleared.
Returns
  • SUCCEEDED after process identity is set correctly. FAILED if the app is not MI-enabled.

public static void setUIPolicyIdentity (Context context, String identity, MAMSetUIIdentityCallback mamSetUIIdentityCallback)

Set the associated identity with the Context.

Parameters
context Context to set the identity in.
identity New identity to set. If null, the Context identity is cleared.
mamSetUIIdentityCallback callback to notify the application the identity switch result. May be null.

public static void setUIPolicyIdentity (Context context, String identity, MAMSetUIIdentityCallback mamSetUIIdentityCallback, EnumSet<IdentitySwitchOption> options)

Set the associated identity with the Context.

Parameters
context Context to set the identity in.
identity New identity to set. If null, the Context identity is cleared.
mamSetUIIdentityCallback callback to notify the application the identity switch result. May be null.
options Identity switch options.

public static void showDiagnostics (Context context)

Display the Intune Diagnostics screen.

Parameters
context App's context.