Class MAMPolicyManager

  • All Implemented Interfaces:

    
    public final class MAMPolicyManager
    
                        

    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.

    • Constructor Detail

    • Method Detail

      • setUIPolicyIdentity

        @Deprecated() static void setUIPolicyIdentity(@NonNull() Context context, @Nullable() String identity, @Nullable() MAMSetUIIdentityCallback mamSetUIIdentityCallback)

        Set the associated identity with the Context.

        Parameters:
        context - Context to set the identity in.
        identity - UPN of new identity to set.
        mamSetUIIdentityCallback - callback to notify the application the identity switch result.
      • setUIPolicyIdentity

        @Deprecated() static void setUIPolicyIdentity(@NonNull() Context context, @Nullable() String identity, @Nullable() MAMSetUIIdentityCallback mamSetUIIdentityCallback, @NonNull() EnumSet<IdentitySwitchOption> options)

        Set the associated identity with the Context.

        Parameters:
        context - Context to set the identity in.
        identity - UPN of new identity to set.
        mamSetUIIdentityCallback - callback to notify the application the identity switch result.
        options - Identity switch options.
      • setUIPolicyIdentityOID

         static void setUIPolicyIdentityOID(@NonNull() Context context, @Nullable() String oid, @Nullable() MAMSetUIIdentityCallback mamSetUIIdentityCallback)

        Set the associated identity with the Context.

        Parameters:
        context - Context to set the identity in.
        oid - AAD OID of new identity to set.
        mamSetUIIdentityCallback - callback to notify the application the identity switch result.
      • setUIPolicyIdentityOID

         static void setUIPolicyIdentityOID(@NonNull() Context context, @Nullable() String oid, @Nullable() MAMSetUIIdentityCallback mamSetUIIdentityCallback, @NonNull() EnumSet<IdentitySwitchOption> options)

        Set the associated identity with the Context.

        Parameters:
        context - Context to set the identity in.
        oid - AAD OID of new identity to set.
        mamSetUIIdentityCallback - callback to notify the application the identity switch result.
        options - Identity switch options.
      • setUIPolicyIdentityOIDs

         static void setUIPolicyIdentityOIDs(@NonNull() Activity activity, @NonNull() List<String> oids, @NonNull() MAMSetUIIdentityCallback mamSetUIIdentityCallback)

        Sets identities for an activity.

        If a single identity is provided, the activity is a segmented view (an activity with one managed account) and behaves like setUIPolicyIdentityOID. If multiple identities are provided, the activity is a mixed view.

        Before calling this API, register a MAMBlockAccountCallback via registerBlockedAccountCallback. This method should be called in Activity.onCreate() or later in the activity lifecycle.

        Parameters:
        activity - The Activity for which to set the identities.
        oids - The list of OIDs representing the list of identities to set for the activity.
        mamSetUIIdentityCallback - Callback to receive the result of the identity switch:
        • SUCCEEDED: At least one OID is allowed (not blocked); app may use data for allowed accounts only.
        • FAILED: All OIDs are blocked; app should not display data for any and should implement a fallback (e.g., switch identities or finish the activity).
      • setUIPolicyIdentityOIDs

         static void setUIPolicyIdentityOIDs(@NonNull() Activity activity, @NonNull() List<String> oids, @NonNull() MAMSetUIIdentityCallback mamSetUIIdentityCallback, @NonNull() EnumSet<IdentitySwitchOption> options)

        Sets identities for an activity.

        If a single identity is provided, the activity is a segmented view (an activity with one managed account) and behaves like setUIPolicyIdentityOID. If multiple identities are provided, the activity is a mixed view.

        Before calling this API, register a MAMBlockAccountCallback via registerBlockedAccountCallback. This method should be called in Activity.onCreate() or later in the activity lifecycle.

        Parameters:
        activity - The Activity for which to set the identities.
        oids - The list of OIDs representing the list of identities to set for the activity.
        mamSetUIIdentityCallback - Callback to receive the result of the identity switch:
        • SUCCEEDED: At least one OID is allowed (not blocked); app may use data for allowed accounts only.
        • FAILED: All OIDs are blocked; app should not display data for any and should implement a fallback (e.g., switch identities or finish the activity).
        options - Identity switch options.
      • getUIPolicyIdentity

        @Deprecated()@Nullable() static String getUIPolicyIdentity(@NonNull() Context context)

        Get the UPN of the current UI identity.

        Parameters:
        context - Context to get the identity from.
        Returns:

        Current UI identity UPN.

      • getUIPolicyIdentityOID

        @Nullable() static String getUIPolicyIdentityOID(@NonNull() Context context)

        Get the AAD OID of the current UI identity.

        Parameters:
        context - Context to get the identity from.
        Returns:

        Current UI identity OID.

      • getUIPolicyIdentityOIDs

        @NonNull() static List<String> getUIPolicyIdentityOIDs(@NonNull() Activity activity)

        Get the OIDs of identities associated with the Activity, if any.

        Parameters:
        activity - Activity to get the identities from.
        Returns:

        Current UI identities OIDs.

      • setProcessIdentity

        @Deprecated() static MAMIdentitySwitchResult setProcessIdentity(@Nullable() String identity)

        Set the process-wide identity.

        Parameters:
        identity - UPN of new process-wide identity.
        Returns:

        SUCCEEDED after process identity is set correctly. FAILED if the app is not MI-enabled.

      • setProcessIdentityOID

         static MAMIdentitySwitchResult setProcessIdentityOID(@Nullable() String oid)

        Set the process-wide identity.

        Parameters:
        oid - AAD OID of new process-wide identity.
        Returns:

        SUCCEEDED after process identity is set correctly. FAILED if the app is not MI-enabled.

      • getProcessIdentityOID

        @Nullable() static String getProcessIdentityOID()

        Get the AAD OID of the process-wide identity.

        Returns:

        Current process-wide identity OID.

      • setCurrentThreadIdentityOID

         static MAMIdentitySwitchResult setCurrentThreadIdentityOID(@Nullable() String oid)

        Set the current thread identity.

        Parameters:
        oid - AAD OID of identity to set.
        Returns:

        SUCCEEDED after thread identity is set correctly. FAILED if the app is not MI-enabled.

      • getCurrentThreadIdentityOID

        @Nullable() static String getCurrentThreadIdentityOID()

        Get the AAD OID of the current thread identity.

        Returns:

        Current thread identity OID.

      • getCurrentIdentity

        @Deprecated()@NonNull() static String getCurrentIdentity(@Nullable() Context context)

        Computes the current effective identity that will be used for policy and returns its UPN. 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's UPN.

      • getCurrentIdentityOID

        @NonNull() static String getCurrentIdentityOID(@Nullable() Context context)

        Computes the current effective identity that will be used for policy and returns its AAD OID. 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's OID.

      • getCurrentThreadPolicy

        @NonNull() 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.

      • getPolicy

        @NonNull()@Deprecated() static AppPolicy getPolicy()

        Deprecated alias for getCurrentThreadPolicy.

        Returns:

        see getCurrentThreadPolicy

      • getPolicy

        @NonNull() static AppPolicy getPolicy(@NonNull() Context context)

        Get the current app policy.

        Parameters:
        context - for which the policy will be applicable.
        Returns:

        Policy for the current identity.

      • getPolicyForIdentity

        @Deprecated()@NonNull() static AppPolicy getPolicyForIdentity(@Nullable() String identity)

        Get the applicable app policy for a given identity.

        Parameters:
        identity - Identity to get policy for.
        Returns:

        Policy for the identity.

      • getPolicyForIdentityOID

        @NonNull() static AppPolicy getPolicyForIdentityOID(@Nullable() String oid)

        Get the applicable app policy for a given identity.

        Parameters:
        oid - AAD OID of the identity to get policy for.
        Returns:

        Policy for the identity.

      • getIsIdentityOIDManaged

         static boolean getIsIdentityOIDManaged(@Nullable() String oid)
        Parameters:
        oid - AAD OID of the identity.
        Returns:

        true if the identity has policy

      • showDiagnostics

         static void showDiagnostics(Context context)

        Display the Intune Diagnostics screen.

        Parameters:
        context - App's context.
      • bypassConditionalLaunchChecks

         static void bypassConditionalLaunchChecks(@NonNull() 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.
      • registerBlockedAccountCallback

         static void registerBlockedAccountCallback(@NonNull() Activity activity, @NonNull() MAMBlockAccountCallback callback)

        Registers a MAMBlockAccountCallback for a mixed view activity. This callback is invoked by the MAM SDK when one or more accounts are blocked for the mixed view activity. Implement the callback interface to handle blocked accounts appropriately, such as by hiding data associated with those accounts.

        You must register the MAMBlockAccountCallback before calling setUIPolicyIdentityOIDs.

        Parameters:
        activity - The activity for which to register the callback.
        callback - The MAMBlockAccountCallback to be notified when an account is blocked.