Profiles API
Overview
A Profile is a device state which can be created, modified, or activated for a user based off of an environmental trigger. When you tell the system to create a profile, it will be populated within the system settings application’s Profile viewer. This hub can both be controlled by the Settings application and by a 3rd party application.
Creating a Profile
You must specify the UI information, actions, and optional environmental triggers for a Profile utilizing the methods available within the Profile
object.
To add your created Profile to the system, invoke a call to ProfileManager.addProfile(Profile)
Required Profile contents
A Profile object must contain the following:
- An identifying name, set by
setName(String)
- A
Profile.Type
, set bysetProfileType(Int)
To use these Profiles API, your application must first declare the write settings permission in AndroidManifest.xml.
Creating and adding a simple Profile
The snippet below details how to create a Profile
object that overrides the devices ring mode settings to be muted.
Kotlin
Java
To set the profile to be the primary active profile, you can trigger this by calling setActiveProfile(UUID)
by passing the UUID of the created Profile object.
Kotlin
Java
Leveraging a ProfileTrigger
For the instances where you want to trigger a Profile based off of an environment change as defined by Profile.TriggerType
you can set a specific Profile.ProfileTrigger
on your Profile.
To create a ProfileTrigger you’ll need to populate 4 parameters, for something like a trigger based off of a WiFi access point, you can follow the model below:
Kotlin
Java
As you can see we set the TriggerType as WiFI, set the SSID as the triggerId (for tracking), set the title of the access point as the triggerName, and then finally declare that we want to be “triggered” when an ON_CONNECT is given for the access point.
Get assistance
If you have any questions or get stuck on any of the steps, feel free to ask on our subreddit or in #OkcarOS on Libera.Chat.
You can also find more information in the LineageSDK javadoc.