public class

ProfileManager

extends Object
java.lang.Object
   ↳ lineageos.app.ProfileManager

Class Overview

The ProfileManager allows you to create Profiles and ProfileGroups to create specific behavior states depending on triggers from hardware devices changing states, such as:

     WiFi being enabled
     WiFi connecting to a certain AP
     Bluetooth connecting to a certain device
     Bluetooth disconnecting to a certain device
     NFC tag being scanned
 

Depending on these triggers, you can override connection settings, lockscreen modes, media stream volumes and various other settings.

To get the instance of this class, utilize ProfileManager#getInstance(Context context)

This manager requires the MODIFY_PROFILES permission.

See also:

Summary

Constants
String ACTION_PROFILE_PICKER Activity Action: Shows a profile picker.
String EXTRA_LAST_PROFILE_NAME Extra for INTENT_ACTION_PROFILE_SELECTED: The name of the previously active profile
String EXTRA_LAST_PROFILE_UUID Extra for INTENT_ACTION_PROFILE_SELECTED: The string representation of the UUID of the previously active profile
String EXTRA_PROFILES_STATE The lookup key for an int that indicates whether Profiles are enabled or disabled.
String EXTRA_PROFILE_DIALOG_THEME Set the resource id theme to use for the dialog picker activity.
String EXTRA_PROFILE_EXISTING_UUID Given to the profile picker as a UUID string representation.
String EXTRA_PROFILE_NAME Extra for INTENT_ACTION_PROFILE_SELECTED and INTENT_ACTION_PROFILE_UPDATED: The name of the newly activated or updated profile
String EXTRA_PROFILE_PICKED_UUID Returned from the profile picker as a UUID string representation.
String EXTRA_PROFILE_SHOW_NONE Given to the profile picker as a boolean.
String EXTRA_PROFILE_TITLE Given to the profile picker as a CharSequence.
String EXTRA_PROFILE_UUID Extra for INTENT_ACTION_PROFILE_SELECTED and INTENT_ACTION_PROFILE_UPDATED: The string representation of the UUID of the newly activated or updated profile
String INTENT_ACTION_PROFILE_SELECTED

Broadcast Action: A new profile has been selected.

String INTENT_ACTION_PROFILE_UPDATED

Broadcast Action: Current profile has been updated.

String PROFILES_STATE_CHANGED_ACTION Broadcast intent action indicating that Profiles has been enabled or disabled.
int PROFILES_STATE_DISABLED Profiles are disabled.
int PROFILES_STATE_ENABLED Profiles are enabled.
Fields
public static final UUID NO_PROFILE Constant for NO_PROFILE
Public Methods
void addProfile(Profile profile)
Add a Profile that can be selected by the user
Profile getActiveProfile()
Get the active Profile
static ProfileManager getInstance(Context context)
Get or create an instance of the ProfileManager
Profile getProfile(UUID profileUuid)
Get a Profile via UUID
Profile getProfile(String profileName)
This method was deprecated in API level 2. No replacement.
String[] getProfileNames()
Get the profile names currently available to the user
Profile[] getProfiles()
Get the Profiles currently available to the user
boolean isProfilesEnabled()
Check if profiles are currently activated in the system
boolean profileExists(UUID profileUuid)
Check if a Profile exists via its UUID
boolean profileExists(String profileName)
Check if a Profile exists via its literal name
void removeProfile(Profile profile)
Remove a Profile from user selection
void resetAll()
Reset all profiles, groups, and notification groups to default state
void setActiveProfile(UUID profileUuid)
Set the active Profile by UUID
void setActiveProfile(String profileName)
This method was deprecated in API level 2. No replacement.
void updateProfile(Profile profile)
Update a Profile object
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_PROFILE_PICKER

added in API level 2

Activity Action: Shows a profile picker.

Input: EXTRA_PROFILE_EXISTING_UUID, EXTRA_PROFILE_SHOW_NONE, EXTRA_PROFILE_TITLE.

Output: EXTRA_PROFILE_PICKED_UUID.

Constant Value: "lineageos.platform.intent.action.PROFILE_PICKER"

public static final String EXTRA_LAST_PROFILE_NAME

added in API level 2

Extra for INTENT_ACTION_PROFILE_SELECTED: The name of the previously active profile

Constant Value: "lastName"

public static final String EXTRA_LAST_PROFILE_UUID

added in API level 2

Extra for INTENT_ACTION_PROFILE_SELECTED: The string representation of the UUID of the previously active profile

Constant Value: "lastUuid"

public static final String EXTRA_PROFILES_STATE

added in API level 2

The lookup key for an int that indicates whether Profiles are enabled or disabled. Retrieve it with getIntExtra(String, int).

Constant Value: "profile_state"

public static final String EXTRA_PROFILE_DIALOG_THEME

added in API level 2

Set the resource id theme to use for the dialog picker activity.
The default theme is com.android.internal.R.Theme_Holo_Dialog_Alert.

Constant Value: "lineageos.platform.intent.extra.profile.DIALOG_THEME"

public static final String EXTRA_PROFILE_EXISTING_UUID

added in API level 2

Given to the profile picker as a UUID string representation. The UUID representation of the current profile, which will be used to show a checkmark next to the item for this UUID. If the item is NO_PROFILE then "None" item is selected if EXTRA_PROFILE_SHOW_NONE is enabled. Otherwise, the current profile is selected.

Constant Value: "lineageos.platform.extra.profile.EXISTING_UUID"

public static final String EXTRA_PROFILE_NAME

added in API level 2

Extra for INTENT_ACTION_PROFILE_SELECTED and INTENT_ACTION_PROFILE_UPDATED: The name of the newly activated or updated profile

Constant Value: "name"

public static final String EXTRA_PROFILE_PICKED_UUID

added in API level 2

Returned from the profile picker as a UUID string representation.

It will be one of:

  • the picked profile,
  • null if the "None" item was picked.

    Constant Value: "lineageos.platform.intent.extra.profile.PICKED_UUID"
  • public static final String EXTRA_PROFILE_SHOW_NONE

    added in API level 2

    Given to the profile picker as a boolean. Whether to show an item for deselect the profile. If the "None" item is picked, EXTRA_PROFILE_PICKED_UUID will be NO_PROFILE.

    Constant Value: "lineageos.platform.intent.extra.profile.SHOW_NONE"

    public static final String EXTRA_PROFILE_TITLE

    added in API level 2

    Given to the profile picker as a CharSequence. The title to show for the profile picker. This has a default value that is suitable in most cases.

    Constant Value: "lineageos.platform.intent.extra.profile.TITLE"

    public static final String EXTRA_PROFILE_UUID

    added in API level 2

    Extra for INTENT_ACTION_PROFILE_SELECTED and INTENT_ACTION_PROFILE_UPDATED: The string representation of the UUID of the newly activated or updated profile

    Constant Value: "uuid"

    public static final String INTENT_ACTION_PROFILE_SELECTED

    added in API level 2

    Broadcast Action: A new profile has been selected. This can be triggered by the user or by calls to the ProfileManagerService / Profile.

    Constant Value: "lineageos.platform.intent.action.PROFILE_SELECTED"

    public static final String INTENT_ACTION_PROFILE_UPDATED

    added in API level 2

    Broadcast Action: Current profile has been updated. This is triggered every time the currently active profile is updated, instead of selected.

    For instance, this includes profile updates caused by a locale change, which doesn't trigger a profile selection, but causes its name to change.

    Constant Value: "lineageos.platform.intent.action.PROFILE_UPDATED"

    public static final String PROFILES_STATE_CHANGED_ACTION

    added in API level 2

    Broadcast intent action indicating that Profiles has been enabled or disabled. One extra provides this state as an int.

    Constant Value: "lineageos.platform.app.profiles.PROFILES_STATE_CHANGED"

    public static final int PROFILES_STATE_DISABLED

    added in API level 2

    Profiles are disabled.

    Constant Value: 0 (0x00000000)

    public static final int PROFILES_STATE_ENABLED

    added in API level 2

    Profiles are enabled.

    Constant Value: 1 (0x00000001)

    Fields

    public static final UUID NO_PROFILE

    added in API level 2

    Constant for NO_PROFILE

    Public Methods

    public void addProfile (Profile profile)

    added in API level 2

    Add a Profile that can be selected by the user

    Parameters
    profile Profile: a Profile object

    public Profile getActiveProfile ()

    added in API level 2

    Get the active Profile

    Returns
    Profile active Profile

    public static ProfileManager getInstance (Context context)

    added in API level 2

    Get or create an instance of the ProfileManager

    Returns
    ProfileManager ProfileManager

    public Profile getProfile (UUID profileUuid)

    added in API level 2

    Get a Profile via UUID

    Parameters
    profileUuid UUID: UUID associated with the profile
    Returns
    Profile Profile

    public Profile getProfile (String profileName)

    added in API level 2

    This method was deprecated in API level 2.
    No replacement.

    Get the Profile object by its literal name

    Parameters
    profileName String: name associated with the profile
    Returns
    Profile profile a Profile object

    public String[] getProfileNames ()

    added in API level 2

    Get the profile names currently available to the user

    Returns
    String[] ERROR(/String[]) of profile names

    public Profile[] getProfiles ()

    added in API level 2

    Get the Profiles currently available to the user

    Returns
    Profile[] ERROR(/Profile[])

    public boolean isProfilesEnabled ()

    added in API level 4

    Check if profiles are currently activated in the system

    Returns
    boolean whether profiles are enabled

    public boolean profileExists (UUID profileUuid)

    added in API level 2

    Check if a Profile exists via its UUID

    Parameters
    profileUuid UUID: the profiles UUID
    Returns
    boolean whether or not the profile exists

    public boolean profileExists (String profileName)

    added in API level 2

    Check if a Profile exists via its literal name

    Parameters
    profileName String: a profile name
    Returns
    boolean whether or not the profile exists

    public void removeProfile (Profile profile)

    added in API level 2

    Remove a Profile from user selection

    Parameters
    profile Profile: a Profile object

    public void resetAll ()

    added in API level 2

    Reset all profiles, groups, and notification groups to default state

    public void setActiveProfile (UUID profileUuid)

    added in API level 2

    Set the active Profile by UUID

    Parameters
    profileUuid UUID: the UUID associated with the profile

    public void setActiveProfile (String profileName)

    added in API level 2

    This method was deprecated in API level 2.
    No replacement.

    Parameters
    profileName String

    public void updateProfile (Profile profile)

    added in API level 2

    Update a Profile object

    Parameters
    profile Profile: a Profile object